:root {
  --page: #f3f6f8;
  --panel: #ffffff;
  --ink: #16263a;
  --muted: #64748b;
  --line: #dce4ea;
  --navy: #173a5e;
  --navy-2: #244f78;
  --green: #a6c842;
  --green-soft: #f1f7df;
  --teal: #008c7a;
  --teal-soft: #e5f6f2;
  --pink: #eb8297;
  --blue: #2979b8;
  --amber: #d98c18;
  --red: #ce4b46;
  --shadow: 0 8px 26px rgba(23, 58, 94, 0.07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(41, 121, 184, .12);
}

label {
  display: grid;
  gap: 6px;
  color: #405169;
  font-size: .82rem;
  font-weight: 800;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #eef3f5;
  padding: 24px;
}

.login-panel {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 34px;
}

.login-panel h1 {
  margin: 7px 0 10px;
  color: var(--navy);
  font-size: 1.9rem;
  line-height: 1.25;
}

.login-description {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.65;
}

.login-panel label + label { margin-top: 13px; }
.login-message { min-height: 21px; margin: 10px 0 0; color: var(--red); font-size: .83rem; font-weight: 800; }

.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-lockup strong { display: block; color: var(--navy); font-size: 1.12rem; }
.brand-lockup small { display: block; color: var(--muted); font-size: .73rem; }
.brand-logo-image {
  width: 30px;
  height: 32px;
  flex: 0 0 30px;
  object-fit: contain;
}

.eyebrow {
  margin: 22px 0 0;
  color: var(--teal);
  font-size: .73rem;
  font-weight: 900;
  text-transform: uppercase;
}

.primary-btn, .secondary-btn, .danger-btn, .small-btn, .icon-btn, .text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border-radius: 6px;
  padding: 8px 13px;
  font-weight: 900;
}

.primary-btn { border: 1px solid var(--navy); background: var(--navy); color: #fff; }
.primary-btn:hover { background: var(--navy-2); }
.secondary-btn, .small-btn { border: 1px solid var(--line); background: #fff; color: var(--navy); }
.secondary-btn:hover, .small-btn:hover { background: #f7fafb; }
.danger-btn { border: 1px solid #f0cfcd; background: #fff4f3; color: var(--red); }
.text-btn { border: 0; background: transparent; color: var(--muted); }
.full { width: 100%; margin-top: 10px; }
.login-panel .primary-btn { margin-top: 18px; }

.icon-btn {
  width: 40px;
  min-width: 40px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
}

.icon-btn svg, .text-btn svg, .nav-list svg, .quarter-link svg, button svg { width: 17px; height: 17px; stroke-width: 2; }

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 20px 16px;
}

.sidebar-brand { min-height: 52px; padding: 0 7px; margin-bottom: 18px; }
.nav-list { display: grid; align-content: start; gap: 4px; flex: 1; overflow-y: auto; }

.nav-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #44566d;
  padding: 10px 11px;
  text-align: left;
  font-weight: 800;
}

.nav-list button:hover { background: #f4f7f8; }
.nav-list button.active { background: var(--green-soft); color: var(--navy); }

.sidebar-footer { display: grid; gap: 10px; }
.quarter-link {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--navy);
  padding: 9px 11px;
  font-size: .82rem;
  font-weight: 800;
  text-decoration: none;
}

.user-box { border-top: 1px solid var(--line); padding: 13px 7px 0; }
.user-box strong, .user-box > span { display: block; }
.user-box > span { margin-top: 2px; color: var(--muted); font-size: .75rem; }
.user-box .text-btn { justify-content: flex-start; margin-top: 5px; padding: 5px 0; font-size: .78rem; }

.main { min-width: 0; padding: 22px 26px 48px; }
.system-switch-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 15px;
  border: 1px solid #d8e5b4;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: #f6faeb;
  color: var(--navy);
  padding: 13px 16px;
  text-decoration: none;
  transition: border-color 160ms ease, background 160ms ease;
}
.system-switch-banner:hover { border-color: #b9cf74; background: #f0f7dc; }
.system-switch-copy { display: grid; gap: 2px; min-width: 0; }
.system-switch-copy small { color: var(--teal); font-size: .68rem; font-weight: 900; }
.system-switch-copy strong { font-size: 1rem; }
.system-switch-copy > span { color: var(--muted); font-size: .78rem; }
.system-switch-action { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; color: var(--navy); font-size: .82rem; font-weight: 900; }
.system-switch-action svg { width: 17px; height: 17px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.topbar .eyebrow { margin: 0 0 4px; }
.topbar h1 { margin: 0; color: var(--navy); font-size: 1.72rem; }
.period-toolbar { display: flex; align-items: flex-end; gap: 9px; }
.period-toolbar label { min-width: 130px; }
.period-toolbar label:nth-child(2) { min-width: 145px; }
.server-status { min-height: 0; margin-bottom: 10px; color: var(--muted); font-size: .78rem; }
.server-status.is-warning { color: var(--amber); }

.view { display: grid; gap: 16px; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.metric-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-top: 3px solid var(--navy);
  border-radius: 6px;
  background: var(--panel);
  padding: 16px;
}
.metric-card:nth-child(2) { border-top-color: var(--teal); }
.metric-card:nth-child(3) { border-top-color: var(--green); }
.metric-card:nth-child(4) { border-top-color: var(--pink); }
.metric-card:nth-child(5) { border-top-color: var(--amber); }
.metric-card span { display: block; color: var(--muted); font-size: .77rem; font-weight: 800; }
.metric-card strong { display: block; margin-top: 8px; font-size: 1.55rem; line-height: 1.2; }
.metric-card small { display: block; min-height: 18px; margin-top: 6px; color: var(--muted); font-size: .76rem; }
.delta-up { color: var(--teal) !important; }
.delta-down { color: var(--red) !important; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, .65fr); gap: 16px; }

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.panel-head h2 { margin: 0; color: var(--navy); font-size: 1rem; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: .76rem; }
.panel-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.hint { margin: 8px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.empty { display: grid; min-height: 210px; place-items: center; color: var(--muted); text-align: center; }

.chart-box { position: relative; width: 100%; height: 300px; }
.chart-box.compact { height: 250px; }
.chart-box.tall { height: 350px; }
.chart-fallback { display: grid; height: 100%; place-items: center; color: var(--muted); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 9px; text-align: left; white-space: nowrap; }
th { background: #f7f9fa; color: #53657a; font-size: .73rem; }
tbody tr:hover { background: #fafcfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rank-cell { color: var(--navy); font-weight: 900; }
.employee-link { border: 0; background: transparent; color: var(--blue); padding: 0; font-weight: 900; }
.score-pill, .status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: .72rem;
  font-weight: 900;
}
.status-pill.review { background: #fff4dc; color: #9b6105; }
.status-pill.done { background: var(--green-soft); color: #587413; }

.channel-list { display: grid; gap: 10px; }
.channel-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 44px; align-items: center; gap: 10px; }
.channel-row span { color: var(--muted); font-size: .77rem; font-weight: 800; }
.channel-row strong { text-align: right; font-size: .82rem; }
.bar-track { height: 9px; border-radius: 999px; background: #edf1f3; overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.channel-row:nth-child(2) i { background: var(--teal); }
.channel-row:nth-child(3) i { background: var(--pink); }
.channel-row:nth-child(4) i { background: var(--amber); }
.channel-row:nth-child(5) i { background: var(--green); }

.upload-layout { display: grid; grid-template-columns: minmax(340px, .8fr) minmax(560px, 1.2fr); gap: 16px; }
.drop-zone {
  display: grid;
  min-height: 310px;
  place-items: center;
  border: 2px dashed #b9c8d3;
  border-radius: 6px;
  background: #f8fafb;
  color: var(--muted);
  padding: 20px;
  text-align: center;
}
.drop-zone.dragging { border-color: var(--teal); background: var(--teal-soft); }
.drop-zone input { display: none; }
.drop-zone button { margin-top: 12px; }
.drop-zone svg { width: 40px; height: 40px; color: var(--navy); }
.drop-preview { width: 100%; }
.drop-preview img { display: block; width: 100%; max-height: 480px; object-fit: contain; border: 1px solid var(--line); background: #fff; }
.drop-preview p { margin: 10px 0 0; font-size: .78rem; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.summary-cell { border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: #fafcfc; }
.summary-cell span { display: block; color: var(--muted); font-size: .68rem; }
.summary-cell strong { display: block; margin-top: 4px; font-size: 1rem; }
.analysis-state { display: flex; align-items: center; gap: 9px; min-height: 34px; color: var(--muted); font-size: .79rem; }
.spinner { width: 17px; height: 17px; border: 2px solid #dce5e9; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.editable-table th,
.editable-table th.num { padding-inline: 18px; text-align: left; }
.editable-table input, .editable-table select { min-width: 76px; padding: 7px 8px; }
.editable-table .name-input { min-width: 100px; }
.editable-table .icon-btn { width: 32px; min-width: 32px; min-height: 32px; }
.validation-note { margin: 10px 0 0; color: var(--amber); font-size: .77rem; }

.employee-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.team-filter { display: flex; flex-wrap: wrap; gap: 7px; }
.team-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.team-summary-card {
  border: 1px solid var(--line);
  border-top: 3px solid var(--team-color);
  border-radius: 6px;
  background: #fff;
  padding: 14px;
}
.team-summary-card.selected { background: #f8fbef; border-color: var(--team-color); }
.team-summary-card > span { color: var(--muted); font-size: .78rem; font-weight: 900; }
.team-summary-card > strong { display: block; margin-top: 7px; color: var(--navy); font-size: 1.45rem; }
.team-summary-card > small { display: block; min-height: 18px; margin-top: 4px; color: var(--muted); font-size: .74rem; }
.team-summary-card > button { margin-top: 11px; border: 0; background: transparent; color: var(--navy); padding: 0; font-size: .78rem; font-weight: 900; }
.team-detail-grid { align-items: center; margin: 16px 0; }
.team-channel-list { padding: 12px 6px; }
.team-metric-grid { margin-top: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.monitoring-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.monitoring-wide { grid-column: span 2; }
.monitoring-full { grid-column: 1 / -1; }
.monitoring-filters { display: flex; align-items: end; gap: 10px; margin-bottom: 14px; }
.monitoring-filters label { width: min(210px, 100%); }
.monitoring-table th { vertical-align: bottom; }
.monitoring-table td { vertical-align: top; white-space: normal; }
.monitoring-table td > strong, .monitoring-table td > small { display: block; }
.monitoring-table td > small { margin-top: 4px; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.monitoring-text { min-width: 230px; line-height: 1.55; }
.monitoring-response { min-width: 260px; min-height: 92px; resize: vertical; line-height: 1.5; }
.recording-link { display: inline-block; margin-top: 6px; color: var(--blue); font-size: .75rem; font-weight: 900; text-decoration: none; }
.recording-link:hover { text-decoration: underline; }
.priority-tag {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: .7rem;
  font-weight: 900;
}
.priority-tag.normal { background: #edf3f6; color: #486174; }
.priority-tag.notice { background: #fff4dc; color: #9b6105; }
.priority-tag.urgent { background: #fff0ef; color: var(--red); }
.employee-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #496077;
  padding: 7px 11px;
  font-size: .79rem;
  font-weight: 800;
}
.employee-chip.selected { border-color: var(--teal); background: var(--teal-soft); color: var(--teal); }
.employee-chip:disabled { opacity: .45; }

.profile-summary { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: center; }
.profile-name { border-right: 1px solid var(--line); padding-right: 20px; }
.profile-name strong { display: block; color: var(--navy); font-size: 1.55rem; }
.profile-name span { display: block; margin-top: 5px; color: var(--muted); font-size: .82rem; }
.profile-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.profile-metrics div span { display: block; color: var(--muted); font-size: .72rem; }
.profile-metrics div strong { display: block; margin-top: 4px; font-size: 1.15rem; }

.insight-box { border-left: 4px solid var(--green); background: #f8fbef; padding: 14px 15px; line-height: 1.65; font-size: .86rem; }
.insight-box strong { color: var(--navy); }

.history-filters, .employee-toolbar, .settings-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.employee-toolbar { grid-template-columns: minmax(200px, 1fr) 160px auto; align-items: end; }
.weight-total { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; font-weight: 900; }
.weight-total.bad { color: var(--red); }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 50; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 380px; border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 6px; background: #fff; box-shadow: var(--shadow); padding: 12px 14px; font-size: .82rem; font-weight: 800; }
.toast.error { border-left-color: var(--red); }

@media (max-width: 1360px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .team-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monitoring-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-layout { grid-template-columns: 1fr; }
  .grid-main { grid-template-columns: 1fr; }
}

@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .main { padding: 20px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .profile-summary { grid-template-columns: 1fr; }
  .profile-name { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 14px; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 13px; }
  .sidebar-brand, .sidebar-footer { display: none; }
  .nav-list { display: flex; overflow-x: auto; padding-bottom: 2px; }
  .nav-list button { width: auto; white-space: nowrap; }
  .main { padding: 16px 12px 36px; }
  .system-switch-banner { align-items: flex-start; gap: 12px; padding: 12px; }
  .system-switch-copy > span { line-height: 1.45; }
  .system-switch-action { padding-top: 2px; }
  .period-toolbar { width: 100%; align-items: stretch; flex-wrap: wrap; }
  .period-toolbar label { flex: 1 1 140px; }
  .metric-grid, .profile-metrics, .summary-strip, .settings-grid, .history-filters, .team-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-row { grid-template-columns: 1fr; }
  .monitoring-filters { align-items: stretch; flex-direction: column; }
  .monitoring-filters label { width: 100%; }
  .panel { padding: 14px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .chart-box { height: 260px; }
}

@media (max-width: 440px) {
  .login-panel { padding: 26px 22px; }
  .metric-grid, .profile-metrics, .summary-strip, .settings-grid, .history-filters, .team-summary-grid, .team-metric-grid { grid-template-columns: 1fr; }
  .monitoring-form { grid-template-columns: 1fr; }
  .monitoring-wide, .monitoring-full { grid-column: auto; }
}
