:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #eef3f8;
  --text: #16202a;
  --muted: #667381;
  --line: #d8e0ea;
  --primary: #f26b21;
  --primary-dark: #c54e10;
  --navy: #18324a;
  --green: #1b8f68;
  --danger: #c93232;
  --shadow: 0 16px 40px rgba(24, 50, 74, 0.12);
  font-family: "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.loading-screen,
.auth-screen,
.verify-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-card,
.verify-card {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-title {
  margin: 18px 0 8px;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px 13px;
  outline: 0;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(242, 107, 33, 0.14);
}

.button-row,
.toolbar-row,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
}

.button.primary {
  background: var(--primary);
}

.button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
}

.button.danger {
  background: var(--danger);
}

.button.small {
  min-height: 36px;
  padding: 8px 11px;
  font-size: 0.92rem;
}

.button.full {
  width: 100%;
}

.link-button {
  background: transparent;
  color: var(--primary-dark);
  font-weight: 800;
  padding: 4px 0;
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.94rem;
}

.status.error {
  color: var(--danger);
  font-weight: 700;
}

.app-layout {
  display: grid;
  min-height: 100vh;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  display: flex;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 14px 18px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-action {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.brand-action:focus-visible {
  border-radius: 8px;
  outline: 3px solid rgba(242, 107, 33, 0.28);
  outline-offset: 4px;
}

.brand h1 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.2;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px 18px 52px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.metric strong {
  display: block;
  font-size: 1.7rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.9rem;
}

.data-error {
  margin: 0 0 16px;
  border: 1px solid rgba(201, 50, 50, 0.28);
  border-radius: 8px;
  background: rgba(201, 50, 50, 0.08);
  color: var(--danger);
  padding: 12px 14px;
  font-weight: 700;
}

.workbench {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.filters,
.dictionary-panel,
.logs-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.filters {
  align-self: start;
  padding: 14px;
}

.filters h2,
.panel-title h2 {
  margin: 0;
  font-size: 1rem;
}

.filters .form-grid {
  margin-top: 14px;
}

.dictionary-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-title {
  display: flex;
  padding: 14px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.entry-list {
  display: grid;
  gap: 0;
}

.entry-card {
  display: grid;
  grid-template-columns: minmax(86px, 130px) 1fr auto;
  gap: 14px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
}

.entry-card:last-child {
  border-bottom: 0;
}

.acronym {
  color: var(--navy);
  font-size: 1.35rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.entry-main h3 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.entry-main p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.chip {
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--navy);
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 800;
}

.entry-actions {
  display: flex;
  gap: 8px;
  align-items: start;
}

.empty-state {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

.logs-panel {
  margin-top: 16px;
  overflow: hidden;
}

.log-list {
  display: grid;
}

.log-item {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.log-item strong {
  color: var(--text);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 29, 43, 0.5);
}

.modal {
  width: min(100%, 620px);
  max-height: min(90vh, 760px);
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  padding: 18px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-body {
  padding: 18px;
}

.hidden {
  display: none !important;
}

.external-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.panel-title.compact {
  margin-bottom: 12px;
}

.external-actions,
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-note {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.source-note.error {
  color: var(--danger);
}

.data-error.small {
  margin-top: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
}

.external-empty {
  margin-top: 10px;
}

.external-list {
  margin-top: 12px;
}

.external-card {
  background: #fbfcff;
}

@media (max-width: 860px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
  }
}

@media (max-width: 620px) {
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-inner .button-row {
    width: 100%;
  }

  .topbar-inner .button {
    flex: 1;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  .entry-card {
    grid-template-columns: 1fr;
  }

  .entry-actions {
    width: 100%;
  }

  .entry-actions .button {
    flex: 1;
  }

  .auth-card,
  .verify-card {
    padding: 22px;
  }
}
