/* Nexus 종합 대시보드 — 1차 (2026-11-28)
   디자인: ui-ux-pro-max 추천(Minimalism & Swiss, 다크 기본, 촘촘한 대시보드 배치).
   상태 표시 규칙은 관제판과 같다: 열림=초록 테두리, 원격=보라 점, 작업 중=초록 깜빡, 질문 대기=파랑 깜빡+배경 강조, 완료=주황. */
:root {
  --bg: #020617; --surface: #0b1222; --surface-2: #111a2e; --raised: #16213a;
  --line: #1f2b44; --line-strong: #334155;
  --text: #f1f5f9; --text-2: #cbd5e1; --muted: #8b9bb4;
  --accent: #22c55e; --accent-ink: #052e16;
  --open: #22c55e; --busy: #22c55e; --wait: #3b82f6; --done: #f59e0b; --rc: #a78bfa;
  --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --info: #60a5fa;
  --lead: #93c5fd; --wait-bg: rgba(59,130,246,.18);
  --focus: #e2e8f0;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
  --font: "Pretendard", "Segoe UI Variable Text", "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --mono: "Cascadia Mono", "Consolas", ui-monospace, monospace;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px -16px rgba(0,0,0,.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8fafc; --raised: #eef2f7;
    --line: #e2e8f0; --line-strong: #cbd5e1;
    --text: #0f172a; --text-2: #334155; --muted: #5b6b82;
    --open: #16a34a; --busy: #16a34a; --wait: #2563eb; --done: #d97706; --rc: #7c3aed;
    --ok: #15803d; --warn: #b45309; --bad: #dc2626; --info: #2563eb;
    --lead: #1d4ed8; --wait-bg: rgba(37,99,235,.10); --focus: #0f172a;
    --shadow: 0 1px 2px rgba(15,23,42,.06);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8fafc; --raised: #eef2f7;
  --line: #e2e8f0; --line-strong: #cbd5e1;
  --text: #0f172a; --text-2: #334155; --muted: #5b6b82;
  --open: #16a34a; --busy: #16a34a; --wait: #2563eb; --done: #d97706; --rc: #7c3aed;
  --ok: #15803d; --warn: #b45309; --bad: #dc2626; --info: #2563eb;
  --lead: #1d4ed8; --wait-bg: rgba(37,99,235,.10); --focus: #0f172a;
  --shadow: 0 1px 2px rgba(15,23,42,.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 상단 ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-5); height: 52px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 700; letter-spacing: .02em; }
.logo { width: 22px; height: 22px; display: block; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs button { background: none; border: 0; padding: 0 var(--sp-3); color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.clock { color: var(--text-2); font-variant-numeric: tabular-nums; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text-2); }
.icon-btn:hover { border-color: var(--line-strong); color: var(--text); }

main { padding: var(--sp-4) var(--sp-5) var(--sp-5); max-width: 1440px; margin: 0 auto; }

/* ---------- 요약 카드 ---------- */
.stats { display: grid; grid-template-columns: 1.3fr 1fr 1.2fr; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow); min-height: 84px; }
.stat h3 { margin: 0 0 var(--sp-2); font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; display: flex; justify-content: space-between; align-items: center; }
.stat h3 .sub { font-weight: 400; letter-spacing: 0; }
.meters { display: grid; gap: 6px; }
.meter { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: var(--sp-2); font-size: 13px; }
.meter .lbl { color: var(--text-2); }
.bar { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--ok); transition: width .4s ease; }
.bar > i.warn { background: var(--warn); } .bar > i.bad { background: var(--bad); }
.meter .val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3ch; text-align: right; }
.meter .hint { color: var(--muted); font-size: 12px; margin-left: 6px; font-weight: 400; }
.big { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.pill.fixed { color: var(--rc); border-color: color-mix(in srgb, var(--rc) 45%, transparent); }
.muted { color: var(--muted); }
.small-btn { padding: 6px 12px; min-height: 32px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 12px; font-weight: 600; }
.small-btn:hover { border-color: var(--text-2); }

/* ---------- 조직도 ---------- */
.org { --gap: 14px; }
.hq { display: flex; justify-content: center; align-items: stretch; gap: 0; flex-wrap: wrap; }
.hq .link { align-self: center; width: 28px; border-top: 1px dashed var(--line-strong); }
.trunk { width: 1px; height: 18px; margin: 0 auto; background: var(--line-strong); }
.depts { position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: var(--gap); padding-top: 16px; align-items: start; }
.depts::before { content: ""; position: absolute; top: 0; left: var(--bar-l, 12%); right: var(--bar-r, 12%); border-top: 1px solid var(--line-strong); }
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-3); box-shadow: var(--shadow); }
.card.first-row::before { content: ""; position: absolute; top: -17px; left: 50%; width: 1px; height: 16px; background: var(--line-strong); }
.hq .card { min-width: 260px; }
.hq .card.main { border-color: var(--line-strong); background: var(--surface-2); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.card-head .nm { font-weight: 700; font-size: 13px; color: var(--lead); }
.card-head .cnt { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
button.card-head { width: 100%; background: none; border: 0; padding: 0; text-align: left; }
button.card-head:hover .nm { text-decoration: underline; text-underline-offset: 3px; }
.chev { display: inline-block; width: 1em; color: var(--muted); transition: transform .15s; }
.folded .chev { transform: rotate(-90deg); }
.grp { margin-top: var(--sp-2); font-size: 11px; color: var(--muted); letter-spacing: .04em; padding-left: var(--sp-2); border-left: 2px solid var(--line-strong); }
.members { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.summary { width: 100%; margin-top: var(--sp-2); padding: 6px var(--sp-2); border-radius: var(--r-sm); border: 1px dashed var(--line-strong); background: transparent; color: var(--muted); font-size: 12px; text-align: left; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.summary:hover { color: var(--text-2); border-color: var(--text-2); }

/* 창 버튼 */
.m { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 5px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); font-size: 13px; transition: border-color .15s, background .15s, color .15s; }
.m:hover { border-color: var(--line-strong); color: var(--text); background: var(--raised); }
.m.lead { font-weight: 700; color: var(--text); }
.m.on { border-color: var(--open); box-shadow: 0 0 0 1px var(--open) inset; color: var(--text); }
.m.wait { background: var(--wait-bg); }
.hq .m { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.rc { width: 7px; height: 7px; border-radius: 50%; background: var(--rc); flex: none; }
.st { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.st.busy { background: var(--busy); animation: blink 1.2s ease-in-out infinite; }
.st.wait { background: var(--wait); animation: blink .9s ease-in-out infinite; }
.st.done { background: var(--done); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 2px; }
.dot.busy { background: var(--busy); } .dot.wait { background: var(--wait); } .dot.done { background: var(--done); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) {
  .st.busy, .st.wait { animation: none; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }
  .st.busy { outline: 2px solid color-mix(in srgb, var(--busy) 45%, transparent); }
  .st.wait { outline: 2px solid color-mix(in srgb, var(--wait) 45%, transparent); }
  * { transition: none !important; }
}
/* 모델 말풍선 */
.m[data-tip]:hover::after, .m[data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  white-space: nowrap; padding: 3px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; background: var(--text); color: var(--bg); pointer-events: none; z-index: 5; }

/* ---------- 도구 ---------- */
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.tool { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-size: 13px; transition: border-color .15s, color .15s; }
.tool:hover { border-color: var(--line-strong); color: var(--text); }
.tool.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.tool.primary:hover { filter: brightness(1.08); }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.stamp { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- 알림 ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 560px); padding: 10px 16px; border-radius: var(--r-md); background: var(--text); color: var(--bg); font-size: 13px; font-weight: 600;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); color: #fff; }

dialog { border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--text); padding: var(--sp-4); width: min(92vw, 380px); }
dialog::backdrop { background: rgba(2,6,23,.6); }
dialog label { display: block; font-weight: 600; margin-bottom: var(--sp-2); }
dialog input { width: 100%; font: inherit; padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); }
dialog menu { display: flex; justify-content: flex-end; gap: var(--sp-2); margin: var(--sp-4) 0 0; padding: 0; }

/* ---------- 포트폴리오 ---------- */
.pf-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { background: var(--surface); border: 0; padding: 7px 14px; font-size: 13px; color: var(--text-2); min-height: 34px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); font-weight: 700; }
.badge { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: var(--sp-3); }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow); }
.chart-card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-2); flex-wrap: wrap; }
.chart-card h3 { margin: 0; font-size: 15px; }
.chart-card h3 .gid { color: var(--muted); font-weight: 600; margin-right: 6px; font-family: var(--mono); font-size: 12px; }
.chart-card .draft { margin-left: 6px; }
.latest { display: flex; gap: var(--sp-4); margin: var(--sp-2) 0 0; flex-wrap: wrap; }
.latest div { display: grid; }
.latest .k { font-size: 11px; color: var(--muted); }
.latest .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ranges { display: inline-flex; gap: 2px; }
.ranges button { border: 1px solid transparent; background: none; color: var(--muted); padding: 4px 8px; min-height: 30px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.ranges button[aria-pressed="true"] { color: var(--text); border-color: var(--line-strong); background: var(--raised); }
.chart { height: 280px; margin-top: var(--sp-2); }
.chart-foot { display: flex; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; }
.chart-foot .stale { color: var(--warn); font-weight: 600; }
.chart-err { padding: var(--sp-4); border: 1px dashed var(--bad); border-radius: var(--r-md); color: var(--bad); font-size: 13px; }
.disclaimer { margin: var(--sp-4) 0 0; font-size: 12px; color: var(--muted); }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 900px) { .stats { grid-template-columns: 1fr 1fr; } .stats .stat:first-child { grid-column: 1 / -1; } }
@media (max-width: 640px) {
  .topbar { padding: 0 var(--sp-4); gap: var(--sp-2); }
  .clock { display: none; }
  main { padding: var(--sp-3) var(--sp-4) var(--sp-5); }
  .stats { grid-template-columns: 1fr; }
  .hq { flex-direction: column; align-items: stretch; gap: var(--sp-2); }
  .hq .link { display: none; }
  .hq .card { min-width: 0; }
  .trunk, .depts::before, .card.first-row::before { display: none; }
  .depts { padding-top: var(--sp-3); grid-template-columns: 1fr; }
  .m { min-height: 40px; }
  .sep { display: none; }
  .stamp { width: 100%; margin-left: 0; }
  .chart { height: 240px; }
}
.empty { height: 220px; margin-top: var(--sp-2); border: 1px dashed var(--line-strong); border-radius: var(--r-md); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-2); text-align: center; padding: var(--sp-3); }
.empty svg { width: 32px; height: 32px; color: var(--muted); }
.empty .muted { font-size: 12px; font-family: var(--mono); word-break: break-all; }
.chart-foot .note { flex-basis: 100%; }
/* 좁은 화면에서 가로로 넘치지 않게 */
.stats > *, .depts > *, .hq > .card, .charts > * { min-width: 0; }
.meter { grid-template-columns: 44px minmax(0, 1fr) auto; }
.m { max-width: 100%; overflow-wrap: anywhere; text-align: left; }
@media (max-width: 640px) {
  .meter .val { text-align: right; }
  .meter .hint { display: block; margin-left: 0; font-size: 11px; }
  .hq .card { width: 100%; }
}
/* 상태 카드 (2026-11-28) */
.status-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-3); }
.status-cards:empty { display: none; }
.status-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow); min-width: 0; }
.status-card h3 { margin: 0; font-size: 15px; }
.sc-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); }
.sc-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-3); margin: var(--sp-2) 0; }
.sc-period { display: grid; gap: 4px; }
.sc-period .k { font-size: 12px; color: var(--muted); }
.sc-period .v { font-size: 24px; font-weight: 700; }
.sc-period .v small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip.on { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); font-weight: 700; }
.small { font-size: 12px; }
/* 데이터 갱신 줄·DXY 위젯 (2026-11-28) */
.update-line { margin-left: auto; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums; cursor: default; }
.update-line.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.update-line.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.update-line.bad { color: #fff; background: var(--bad); border-color: var(--bad); }
.dxy-card { margin-bottom: var(--sp-3); }
.dxy-frame { height: 200px; margin-top: var(--sp-2); border-radius: var(--r-md); overflow: hidden; }
.dxy-frame.full { height: 460px; }
.dxy-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.tv-link { font-size: 12px; font-weight: 600; color: var(--info); padding: 4px 8px; text-decoration: none; }
.tv-link:hover { text-decoration: underline; }
@media (max-width: 640px) { .update-line { margin-left: 0; } .pf-head { flex-wrap: wrap; } .dxy-frame.full { height: 360px; } }
.chip.edge { border-style: dashed; border-color: var(--warn); }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); font-weight: 700; }
/* ---------- 2차 (2026-11-28 밤): 넓은 그래프·값 줄·봇·NAS·기록·폰 ---------- */
.chart-card.wide { grid-column: span 2; }
.chart-card.wide .chart { height: 340px; }
@media (max-width: 1100px) { .chart-card.wide { grid-column: auto; } }
.sc-rows { display: grid; gap: 6px; margin: var(--sp-2) 0; }
.sc-row { display: grid; grid-template-columns: minmax(0, 1.4fr) auto auto; grid-template-areas: "nm v tag" "sub sub sub"; column-gap: var(--sp-3); row-gap: 0; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sc-row:last-child { border-bottom: 0; }
.sc-row .nm { grid-area: nm; font-weight: 600; color: var(--text-2); min-width: 0; }
.sc-row .v { grid-area: v; font-size: 17px; font-weight: 700; text-align: right; }
.sc-row .chip { grid-area: tag; justify-self: end; }
.sc-row .sub { grid-area: sub; }
.sc-row .gid { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.chip.edge { color: var(--warn); }
.signals .panel-card { max-width: 900px; }
.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow); min-width: 0; margin-bottom: var(--sp-3); }
.panel-card h3 { margin: 0 0 var(--sp-2); font-size: 15px; }
.panel-card .sc-head { margin-bottom: var(--sp-2); }
.panel-card .sc-head h3 { margin: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--sp-3); align-items: start; }
.two-col > .panel-card { margin-bottom: 0; }
.tbl { display: grid; margin-top: 4px; }
.tbl .tr { display: flex; align-items: baseline; gap: var(--sp-2); padding: 7px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; min-width: 0; }
.tbl .tr:last-child { border-bottom: 0; }
.tbl .nm { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; color: var(--text); text-decoration: none; }
.tbl a.nm:hover { text-decoration: underline; text-underline-offset: 3px; }
.st-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; align-self: center; background: var(--muted); }
.st-dot.ok { background: var(--ok); } .st-dot.warn { background: var(--warn); } .st-dot.bad { background: var(--bad); }
.warn-text { color: var(--warn) !important; font-weight: 600; }
.approve-bar { margin-bottom: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--wait); background: var(--wait-bg); color: var(--text); font-size: 13px; display: grid; gap: 4px; }
.approve-bar .code { font-family: var(--mono); font-size: 18px; font-weight: 700; letter-spacing: .12em; margin-left: 4px; }
.pc-line { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pc-line.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pc-line.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pc-line.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.m.ro { cursor: default; }
[data-mode="nas"] .pc-only { display: none !important; }
/* 폰: 탭을 화면 아래로(엄지로 누르기 쉽게), 글자 16px 이상 */
@media (max-width: 640px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(56px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); z-index: 20; justify-content: space-around; gap: 0; }
  .tabs button { flex: 1; border-bottom: 0; border-top: 2px solid transparent; font-size: 13px; min-height: 48px; padding: 0 2px; white-space: nowrap; letter-spacing: -0.02em; }
  .tabs button[aria-selected="true"] { border-top-color: var(--accent); border-bottom-color: transparent; }
  main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .sc-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "nm tag" "v v" "sub sub"; }
  .sc-row .v { text-align: left; }
  .pc-line { font-size: 11px; padding: 2px 8px; }
}
[hidden] { display: none !important; }
/* 폰: 상단 막대의 흐림 효과(backdrop-filter)가 고정 하단 탭을 가두므로 폰 폭에서는 끈다 */
@media (max-width: 640px) { .topbar { backdrop-filter: none; background: var(--bg); } }
/* 선 고르기 칩·카드 조작(↔ 확대, ⠿ 옮기기) — 2026-11-28 사용자 요청 */
.sel { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-2); }
.sel:empty { display: none; }
.sel-chip { display: inline-flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.sel-chip.off { opacity: .55; border-style: dashed; }
.sel-chip.off .sel-main { text-decoration: line-through; text-decoration-color: var(--muted); }
.sel-main { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 6px 4px 10px; min-height: 32px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.sel-main:hover { color: var(--text); }
.sel-only { border: 0; border-left: 1px solid var(--line); background: none; width: 30px; min-height: 32px; display: grid; place-items: center; color: var(--muted); }
.sel-only:hover { color: var(--text); background: var(--raised); }
.sel-only svg { width: 13px; height: 13px; }
.sw { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.sw.band { height: 10px; width: 10px; opacity: .7; border-radius: 3px; }
.sel-all { border: 1px solid var(--line-strong); border-radius: 999px; background: var(--raised); padding: 4px 12px; min-height: 32px; font-size: 12px; font-weight: 700; color: var(--text); }
.ctl { display: inline-flex; gap: 2px; margin-left: 4px; align-self: flex-start; }
.ctl-btn { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; border: 1px solid transparent; background: none; color: var(--muted); }
.ctl-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--raised); }
.ctl-btn.zoom[aria-pressed="true"] { color: var(--accent); }
.ctl-btn.grip { cursor: grab; touch-action: none; }
.dragging { opacity: .6; outline: 2px dashed var(--accent); outline-offset: 2px; }
.dragging .ctl-btn.grip { cursor: grabbing; }
.chart-card .head { align-items: flex-start; }
.chart-card .head > div:first-child { flex: 1 1 260px; min-width: 0; }
.status-card.wide { grid-column: span 2; }
.dxy-card { margin-bottom: 0; }
.chart-card.wide .chart { height: 360px; }
@media (max-width: 1100px) { .status-card.wide { grid-column: auto; } }
@media (max-width: 640px) { .ctl-btn.zoom { display: none; } .sel-main { min-height: 36px; } .sel-only { min-height: 36px; width: 34px; } }
/* 상단 새로고침 버튼: 불러오는 동안 돈다 */
#reloadBtn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #reloadBtn.spin svg { animation: none; opacity: .5; } }
.small-btn.danger { border-color: var(--bad); color: var(--bad); }
.tbl .tr .small-btn { margin-left: auto; }

/* ---------- 일정 탭: 캘린더 + 할 일 (2026-11-29) ---------- */
.cal-layout { display: grid; grid-template-columns: minmax(0, 2.5fr) minmax(300px, 1fr); gap: var(--sp-3); align-items: start; }
.cal-layout > .panel-card { margin-bottom: 0; }
@media (max-width: 1100px) { .cal-layout { grid-template-columns: 1fr; } }
.cal-srcs { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 2px 0 var(--sp-2); font-size: 12px; color: var(--muted); }
.cal-src { display: inline-flex; align-items: center; gap: 5px; }
.cal-src i { width: 8px; height: 8px; border-radius: 2px; }
.cal-src.bad { color: var(--warn); }
.cal-hint { font-size: 13px; padding: 8px 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); margin-bottom: var(--sp-2); color: var(--text-2); }
.mono { font-family: var(--mono); font-size: 12px; }
.agenda { display: grid; }
.ag-day { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: var(--sp-3); padding: 10px 0; border-top: 1px solid var(--line); }
.ag-day:first-child { border-top: 0; }
.ag-day.today { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%); border-radius: var(--r-sm); padding-left: 8px; }
.ag-date { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: 13px; color: var(--text-2); }
.ag-date.red b { color: var(--bad); } .ag-date.blue b { color: var(--info); }
.ag-items { display: grid; gap: 6px; min-width: 0; }
.ag-ev { display: flex; align-items: baseline; gap: 8px; font-size: 14px; min-width: 0; flex-wrap: wrap; }
.ag-ev .bar { width: 3px; align-self: stretch; border-radius: 2px; flex: none; min-height: 18px; }
.ag-ev .t { color: var(--muted); font-size: 12px; min-width: 86px; }
.ag-ev .nm { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.ag-ev.holiday .nm { color: var(--bad); font-weight: 600; }
.ag-ev .cal-name { white-space: nowrap; }
.ag-ev.todo-due .t { color: var(--text-2); font-weight: 600; }
.bar.pri-high, .td.pri-high { --p: var(--bad); } .bar.pri-mid, .td.pri-mid { --p: var(--warn); } .bar.pri-low, .td.pri-low { --p: var(--muted); }
.ag-ev .bar[class*="pri-"] { background: var(--p); }
@media (max-width: 640px) { .ag-day { grid-template-columns: 1fr; gap: 6px; } .ag-date { flex-direction: row; align-items: center; } .ag-ev .t { min-width: 0; } }
/* 할 일 */
.td-form { display: grid; gap: 8px; margin: var(--sp-2) 0 var(--sp-3); }
.td-form input#todoText { font: inherit; font-size: 15px; padding: 10px 12px; min-height: 44px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); width: 100%; }
.td-form input#todoText:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.td-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-btn { border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 4px 12px; min-height: 32px; font-size: 13px; font-weight: 600; }
.chip-btn.on { background: var(--raised); color: var(--text); border-color: var(--text-2); }
.pri-seg button { min-height: 32px; padding: 4px 12px; }
.pri-seg .p-high[aria-pressed="true"] { color: var(--bad); } .pri-seg .p-mid[aria-pressed="true"] { color: var(--warn); }
.td-date { display: inline-flex; align-items: center; gap: 6px; }
.td-date input { font: inherit; font-size: 13px; padding: 4px 8px; min-height: 32px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); color-scheme: inherit; }
.td-add { margin-left: auto; min-height: 36px; }
.td-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-2); }
.td-filter .chip-btn { min-height: 30px; font-size: 12px; padding: 3px 10px; }
.td-list { list-style: none; margin: 0; padding: 0; display: grid; }
.td { display: flex; align-items: flex-start; gap: 10px; padding: 8px 4px 8px 8px; border-bottom: 1px solid var(--line); border-left: 3px solid var(--p); }
.td:last-child { border-bottom: 0; }
.td-check { width: 26px; height: 26px; flex: none; border-radius: 7px; border: 1.5px solid var(--line-strong); background: var(--surface-2); display: grid; place-items: center; color: transparent; margin-top: 1px; }
.td-check:hover { border-color: var(--ok); }
.td-check[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #052e16; }
.td-check svg { width: 15px; height: 15px; stroke-width: 3; }
.td-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.td-text { overflow-wrap: anywhere; font-size: 14px; }
.td.done .td-text { color: var(--muted); text-decoration: line-through; }
.td-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.td-tag { border: 1px solid var(--line); background: none; color: var(--text-2); border-radius: 999px; padding: 1px 8px; font-size: 12px; min-height: 24px; }
.td-tag:hover { border-color: var(--line-strong); color: var(--text); }
.td-tag.pri { color: var(--p); border-color: color-mix(in srgb, var(--p) 45%, transparent); font-weight: 700; }
.td-due { color: var(--muted); font-weight: 600; } .td-due.warn { color: var(--warn); } .td-due.bad { color: var(--bad); }
.td-del { width: 30px; height: 30px; flex: none; border: 0; background: none; color: var(--muted); border-radius: 6px; display: grid; place-items: center; }
.td-del:hover { color: var(--bad); background: var(--raised); }
.td-del.armed { color: #fff; background: var(--bad); }
.td-done-toggle { margin-top: var(--sp-2); border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600; padding: 6px 0; min-height: 32px; }
.td-cats { display: grid; gap: 6px; margin-top: var(--sp-3); padding: var(--sp-3); border: 1px dashed var(--line-strong); border-radius: var(--r-md); }
.td-cats input { font: inherit; padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); }

/* ---------- 일정: 달력 보기 (2026-11-29 "캘린더 형식으로 큼직하게") ---------- */
.cal-head { flex-wrap: wrap; gap: 8px; }
.cal-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-title { font-size: 22px; font-weight: 800; margin: 0 4px; min-width: 7.2em; text-align: center; }
.cal-arrow { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font-size: 22px; line-height: 1; display: grid; place-items: center; }
.cal-arrow:hover { background: var(--raised); }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.mg-wd { padding: 8px; font-size: 14px; font-weight: 700; text-align: center; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.mg-wd.sun { color: var(--bad); } .mg-wd.sat { color: var(--info); }
.mg-cell { min-height: 132px; padding: 6px 6px 8px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: none; color: inherit; font: inherit; text-align: left; display: flex; flex-direction: column; gap: 3px; min-width: 0; cursor: pointer; }
.mgrid > :nth-child(7n) { border-right: 0; }
.mgrid > :nth-last-child(-n+7) { border-bottom: 0; }
.mg-cell:hover { background: color-mix(in srgb, var(--raised) 60%, transparent); }
.mg-cell:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.mg-cell.out { opacity: .42; }
.mg-cell.sel { box-shadow: inset 0 0 0 2px var(--focus); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.mg-top { display: flex; align-items: center; gap: 4px; min-width: 0; }
.mg-num { font-size: 16px; font-weight: 700; min-width: 30px; height: 30px; display: grid; place-items: center; border-radius: 999px; flex: none; }
.mg-cell.red .mg-num { color: var(--bad); } .mg-cell.blue .mg-num { color: var(--info); }
.mg-cell.today .mg-num { background: var(--accent); color: #fff; }
.mg-hol { font-size: 12px; font-weight: 700; color: var(--bad); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mg-ev { --c: var(--muted); display: block; font-size: 13px; line-height: 1.35; padding: 2px 6px; border-radius: 5px; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mg-ev .tm { color: var(--text-2); font-size: 12px; margin-right: 4px; }
.mg-ev.todo { --c: var(--p); }
.mg-ev.pri-high, .mg-dots i.pri-high { --p: var(--bad); } .mg-ev.pri-mid, .mg-dots i.pri-mid { --p: var(--warn); } .mg-ev.pri-low, .mg-dots i.pri-low { --p: var(--muted); }
.mg-more { font-size: 12px; color: var(--muted); font-weight: 600; padding-left: 4px; }
.mg-dots { display: none; }
.mg-detail { margin-top: var(--sp-3); }
.mg-detail .ag-day { border-top: 0; }
@media (min-width: 1600px) { .mg-cell { min-height: 150px; } }
@media (max-width: 640px) {
  .cal-title { font-size: 19px; min-width: 6.4em; }
  .mg-wd { padding: 6px 0; font-size: 13px; }
  .mg-cell { min-height: 62px; padding: 4px 1px 6px; align-items: center; gap: 4px; }
  .mg-num { font-size: 15px; min-width: 28px; height: 28px; }
  .mg-ev, .mg-hol, .mg-more { display: none; }
  .mg-dots { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; }
  .mg-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--p)); }
}

/* ---------- 캘린더 관리 창 (2026-11-29) ---------- */
.cal-mng { min-height: 36px; }
.cal-hint .small-btn { margin-left: 6px; }
dialog.cal-dlg { width: min(94vw, 560px); max-height: 88vh; overflow: auto; padding: var(--sp-4); }
.cd-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.cd-head h3 { margin: 0; font-size: 18px; }
.cd-list { list-style: none; margin: 0 0 var(--sp-4); padding: 0; display: grid; gap: 8px; }
.cd-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.cd-row input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); cursor: pointer; }
dialog .cd-row input.cd-name { min-height: 38px; }
.cd-st { white-space: nowrap; } .cd-st.bad, .cd-add .bad { color: var(--bad); } .cd-add .ok { color: var(--ok); font-weight: 600; }
.cd-rm.armed { background: var(--bad); color: #fff; border-color: var(--bad); }
.cd-rm-sp { width: 1px; }
.cd-add { display: grid; gap: 10px; padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.cd-add h4 { margin: 0; font-size: 15px; }
dialog .cd-add label { margin: 0; display: grid; gap: 4px; font-size: 13px; }
dialog .cd-add input { min-height: 42px; }
.cd-sw { display: flex; flex-wrap: wrap; gap: 8px; }
.cd-sw .sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; background: var(--c); box-shadow: inset 0 0 0 2px var(--surface); }
.cd-sw .sw[aria-pressed="true"] { border-color: var(--text); }
.cd-addrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cd-help { font-size: 13px; color: var(--text-2); }
.cd-help summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.cd-help ol { margin: 6px 0; padding-left: 20px; display: grid; gap: 3px; }
@media (max-width: 640px) { .cd-row { grid-template-columns: 44px minmax(0, 1fr) auto; } .cd-st { display: none; } }
