/* aiMSP 운영 콘솔 — 조용한 중립 팔레트, 단일 강조색, 표 중심의 밀도 */
:root {
  color-scheme: light;
  --bg: #f7f7f5; --panel: #ffffff; --side: #fbfbfa; --ink: #1c1d1f; --ink-2: #45474c; --muted: #7a7d84; --faint: #a9acb2;
  --line: #e7e6e3; --line-2: #efeeeb; --hover: #f3f2ef;
  --accent: #3b5bdb; --accent-ink: #2f4ac0; --accent-wash: #eef1fd;
  --ok: #2b8a3e; --warn: #c27c0e; --bad: #c92a2a; --info: #1971c2;
  --s1: #3b5bdb; --s2: #0c8599; --s3: #e8a33d; --s4: #d9480f; --s5: #7048e8; --s6: #5c940d; --s7: #c2255c; --s8: #868e96;
  --r: 8px;
  --font: "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111214; --panel: #17181b; --side: #141517; --ink: #e8e8ea; --ink-2: #c4c5c9; --muted: #8b8e95; --faint: #5e6168;
    --line: #26282c; --line-2: #1f2124; --hover: #1d1f22;
    --accent: #7c94ff; --accent-ink: #9aaeff; --accent-wash: #1c2340;
    --ok: #51cf66; --warn: #fcc419; --bad: #ff6b6b; --info: #4dabf7;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214; --panel: #17181b; --side: #141517; --ink: #e8e8ea; --ink-2: #c4c5c9; --muted: #8b8e95; --faint: #5e6168;
  --line: #26282c; --line-2: #1f2124; --hover: #1d1f22;
  --accent: #7c94ff; --accent-ink: #9aaeff; --accent-wash: #1c2340;
  --ok: #51cf66; --warn: #fcc419; --bad: #ff6b6b; --info: #4dabf7;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 13.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.01em; }

/* 레이아웃 */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--side); border-right: 1px solid var(--line); padding: 16px 12px; }
.mark { display: flex; gap: 10px; align-items: center; padding: 2px 8px 18px; }
.mark b { display: block; font-size: 15px; letter-spacing: -.01em; }
.mark small { display: block; color: var(--muted); font-size: 11.5px; }
.glyph { width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: conic-gradient(from 210deg, var(--accent), #5f7cff, var(--s2), var(--accent)); box-shadow: inset 0 0 0 5px var(--side); outline: 1px solid var(--line); }
.navgroup { font-size: 11px; color: var(--faint); letter-spacing: .04em; padding: 14px 10px 6px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; color: var(--ink-2); font-weight: 500; }
nav a svg { width: 15px; height: 15px; fill: currentColor; stroke: currentColor; opacity: .7; flex: none; }
nav a:hover { background: var(--hover); text-decoration: none; }
nav a.on { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
nav a.on svg { color: var(--accent); opacity: 1; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 8px 0; }
.who { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { display: flex; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.link { background: none; border: 0; padding: 0; color: var(--muted); font-size: 12px; cursor: pointer; }
.link:hover { color: var(--ink); }

.main { min-width: 0; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.crumbs { font-size: 12.5px; color: var(--muted); }
.crumbs b { color: var(--ink); font-weight: 600; }
.range { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); padding: 2px; }
.seg button { border: 0; background: none; padding: 3px 10px; border-radius: 5px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--panel); }
input, select, textarea { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 7px; padding: 5px 9px; font: inherit; font-size: 12.5px; }
input:focus, select:focus { outline: 2px solid var(--accent-wash); border-color: var(--accent); }
main { padding: 22px 28px 48px; max-width: 1560px; }

/* 머리말 */
.head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { font-size: 20px; letter-spacing: -.02em; margin: 0; font-weight: 650; }
.head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; color: var(--ink); }
.btn:hover { background: var(--hover); }
.loading { color: var(--muted); padding: 40px 0; }
.loading::after { content: " …"; }
.empty { color: var(--muted); padding: 14px 0; font-size: 12.5px; }
.card .body > .empty:only-child { padding: 6px 0; }
.err { color: var(--bad); padding: 14px 0; }

/* 지표 줄 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; overflow: hidden; }
.kpi { padding: 14px 16px 12px; box-shadow: 1px 0 0 var(--line-2); min-width: 0; }
.kpi .k { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 24px; font-weight: 650; letter-spacing: -.025em; margin-top: 4px; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 8px; }
.kpi .d { font-size: 11.5px; font-weight: 500; letter-spacing: 0; }
.kpi .d.up { color: var(--ok); } .kpi .d.down { color: var(--bad); } .kpi .d.flat { color: var(--faint); }
.kpi .s { color: var(--muted); font-size: 11.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi svg.spark { display: block; width: 100%; height: 26px; margin-top: 8px; }
.kpi.bad .v { color: var(--bad); } .kpi.warn .v { color: var(--warn); } .kpi.ok .v { color: var(--ok); }

/* 카드 */
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.card > header { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px 0; }
.card > header h2 { font-size: 13px; font-weight: 600; margin: 0; letter-spacing: -.005em; }
.card > header .meta { color: var(--muted); font-size: 12px; margin-left: auto; }
.card .body { padding: 10px 16px 14px; }
.card .body.flush { padding: 6px 0 4px; }
.section { margin-top: 14px; }

/* 표 */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; padding: 7px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
th[data-k] { cursor: pointer; }
th[data-k]:hover { color: var(--ink); }
td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.subj { max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .tbl-wrap th:first-child, .card .tbl-wrap td:first-child { padding-left: 16px; }
.card .tbl-wrap th:last-child, .card .tbl-wrap td:last-child { padding-right: 16px; }

/* 상태: 점 + 글자, 보조 표시는 옅은 태그 */
.st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--ink-2); }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.st.bad::before { background: var(--bad); } .st.warn::before { background: var(--warn); } .st.ok::before { background: var(--ok); }
.st.acc::before { background: var(--accent); }
.chip { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 11px; line-height: 18px; background: var(--hover); color: var(--ink-2); white-space: nowrap; margin: 1px 3px 1px 0; }
.chip.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.chip.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.chip.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.chip.acc { background: var(--accent-wash); color: var(--accent-ink); }
.sev { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.sev.SEV1 { color: var(--bad); } .sev.SEV2 { color: var(--s4); } .sev.SEV3 { color: var(--warn); } .sev.SEV4 { color: var(--faint); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters input[type=search] { min-width: 260px; }
.filters label { color: var(--ink-2); font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--line-2); }

/* 차트 */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--faint); font-size: 10.5px; font-family: var(--font); }
.chart .grid line { stroke: var(--line-2); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.mix { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line-2); margin: 4px 0 12px; gap: 2px; }
.mix > span { display: block; height: 100%; }
.mix-legend { display: grid; grid-template-columns: 1fr auto auto; gap: 5px 14px; font-size: 12.5px; }
.mix-legend .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; }
.mix-legend .num { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hbar { display: grid; grid-template-columns: minmax(96px, 168px) 1fr 64px; gap: 8px 12px; align-items: center; font-size: 12.5px; }
.hbar .bar { height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.hbar .bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.hbar .mono { text-align: right; color: var(--ink-2); }

/* 조치 필요 */
.attn { list-style: none; margin: 0; padding: 0; }
.attn li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 9px 16px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.attn li:hover { background: var(--hover); }
.attn li:last-child { border-bottom: 0; }
.attn .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn .m { grid-column: 2; color: var(--muted); font-size: 11.5px; }

/* 조직도 */
.org { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); border-top: 1px solid var(--line-2); }
.team { padding: 12px 16px; box-shadow: 1px 1px 0 var(--line-2); }
.team h3 { font-size: 11.5px; color: var(--muted); font-weight: 500; margin: 0 0 8px; letter-spacing: .02em; }
.role { display: grid; grid-template-columns: 8px 1fr auto; gap: 8px; align-items: center; padding: 3px 0; }
.role .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.role.agent .dot { background: var(--accent); } .role.code .dot { background: var(--s2); } .role.human .dot { background: var(--warn); }
.role .t { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role.lead .t { font-weight: 600; }
.role .n { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.role.idle .t { color: var(--muted); }
.key { display: inline-flex; gap: 14px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.key span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--faint); vertical-align: 1px; }
.key .a::before { background: var(--accent); } .key .c::before { background: var(--s2); } .key .h::before { background: var(--warn); }

/* 상세 */
.kv { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 8px 16px; font-size: 12.5px; }
.kv .k { color: var(--muted); }
.timeline { position: relative; margin: 0; padding: 0 0 0 20px; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 14px 6px; }
.timeline li::before { content: ""; position: absolute; left: -18px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--panel); box-shadow: 0 0 0 1.5px var(--accent); }
.timeline li.mail_out::before { box-shadow: 0 0 0 1.5px var(--ok); }
.timeline li.email::before, .timeline li.zendesk_update::before { box-shadow: 0 0 0 1.5px var(--s2); }
.timeline li.sla::before { box-shadow: 0 0 0 1.5px var(--bad); }
.timeline li.approval::before, .timeline li.execution::before, .timeline li.csat::before { box-shadow: 0 0 0 1.5px var(--s5); }
.timeline .when { font-size: 11.5px; color: var(--muted); }
.timeline .when b { color: var(--ink-2); font-weight: 600; margin-left: 4px; }
.timeline .what { white-space: pre-wrap; word-break: break-word; margin-top: 2px; color: var(--ink-2); }
.run { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.run:last-child { border-bottom: 0; }
.run .h { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.run .h b { font-size: 13px; }
.tools { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 3px; }
.tool { font-family: var(--mono); font-size: 10.5px; padding: 0 5px; line-height: 18px; border-radius: 3px; background: var(--hover); color: var(--ink-2); }
.tool.no { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; }
details.mail { border-top: 1px solid var(--line-2); padding: 10px 16px; }
details.mail:first-child { border-top: 0; }
details.mail > summary { color: var(--ink); font-size: 12.5px; }
details.mail pre, .pre { white-space: pre-wrap; font: 12px/1.6 var(--mono); background: var(--bg); border: 1px solid var(--line-2); padding: 12px; border-radius: 6px; max-height: 520px; overflow: auto; }
.back { display: inline-block; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.banner { padding: 10px 14px; border-radius: var(--r); margin-bottom: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 12.5px; }
.banner.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); color: var(--bad); }
.brief { margin: 0; padding-left: 18px; columns: 2 360px; column-gap: 32px; }
.brief li { margin-bottom: 8px; break-inside: avoid; }

@media (max-width: 1100px) { .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .mark { padding: 0 8px 0 0; }
  nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .navgroup { display: none; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .who { display: none; }
  .bar, main { padding-left: 16px; padding-right: 16px; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kv { grid-template-columns: 96px minmax(0, 1fr); }
  .filters input[type=search] { min-width: 0; flex: 1 1 180px; }
}
