/* ════════════════════════════════════════════════════════════════════════
   비용노트 — Hi-Fi Prototype Styles
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --bg:        #f6f6f4;
  --surface:   #ffffff;
  --surface-2: #fafaf8;
  --border:    #ececea;
  --border-strong: #d8d8d4;
  --divider:   #f0f0ed;
  /* Type */
  --ink:        #16161a;
  --ink-2:      #3a3a40;
  --ink-3:      #6a6a72;
  --ink-4:      #9a9aa2;
  --inverted:   #ffffff;
  /* Accent */
  --accent:     #5760c7;
  --accent-2:   #4751b8;
  --accent-soft:#eef0fb;
  --accent-ring:#c8cdee;
  /* Categories */
  --cat-ott:    #c46699;
  --cat-cloud:  #5071bf;
  --cat-saas:   #4fa678;
  --cat-other:  #b59558;
  --cat-ott-soft:   #f8edf3;
  --cat-cloud-soft: #ecf0f9;
  --cat-saas-soft:  #ecf6f0;
  --cat-other-soft: #f6f1e7;
  /* States */
  --warn:       #c97a3e;
  --warn-soft:  #fbf0e6;
  --good:       #4fa678;
  --bad:        #c95757;
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.04), 0 0 0 0.5px rgba(20, 20, 30, 0.04);
  --shadow-md: 0 4px 12px rgba(20, 20, 30, 0.06), 0 0 0 0.5px rgba(20, 20, 30, 0.04);
  --shadow-lg: 0 12px 32px rgba(20, 20, 30, 0.10), 0 0 0 0.5px rgba(20, 20, 30, 0.06);
  /* Radii */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px;
}

[data-theme="dark"] {
  --bg:        #0d0d10;
  --surface:   #16161a;
  --surface-2: #1a1a1f;
  --border:    #25252c;
  --border-strong: #34343c;
  --divider:   #1f1f25;
  --ink:        #efeff2;
  --ink-2:      #c8c8ce;
  --ink-3:      #909096;
  --ink-4:      #5a5a62;
  --inverted:   #16161a;
  --accent:     #8088dc;
  --accent-2:   #9aa2e8;
  --accent-soft:#1f213e;
  --accent-ring:#3c3f70;
  --cat-ott:    #de85b0;
  --cat-cloud:  #7591d5;
  --cat-saas:   #74c495;
  --cat-other:  #c9ab72;
  --cat-ott-soft:   #2a1f27;
  --cat-cloud-soft: #1c2230;
  --cat-saas-soft:  #1c2a23;
  --cat-other-soft: #2a261c;
  --warn:       #d99868;
  --warn-soft:  #2c241b;
  --good:       #74c495;
  --bad:        #db7e7e;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); transition: background 0.16s, color 0.16s; }
body {
  font-family: "Pretendard", system-ui, -apple-system, sans-serif;
  font-size: 13px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-feature-settings: "tnum"; }
.tnum { font-variant-numeric: tabular-nums; }
button { font-family: inherit; }

/* ── App shell ──────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 18px;
  font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--cat-ott));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 13px; font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.nav-section { padding: 12px 10px 4px; font-size: 10px; font-weight: 600; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 7px;
  color: var(--ink-2); font-size: 13px; font-weight: 450;
  cursor: pointer; transition: background 0.12s;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.active svg { color: var(--accent); }
.nav-item svg { color: var(--ink-3); width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .count {
  margin-left: auto; font-size: 11px; color: var(--ink-4);
  background: var(--surface-2); padding: 1px 6px; border-radius: 999px;
}
.nav-item.active .count { background: white; color: var(--accent); }
[data-theme="dark"] .nav-item.active .count { background: var(--surface); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0; }
.budget-card {
  padding: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); margin-bottom: 4px;
}
.budget-card .label { font-size: 11px; color: var(--ink-3); display: flex; justify-content: space-between; }
.budget-card .bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 8px 0 6px; display: block; flex-direction: unset; align-items: unset; gap: unset; }
.budget-card .bar > div { height: 100%; width: 0%; background: var(--accent); border-radius: 3px; display: block; }
.budget-card .figures { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.budget-card .fig-row { display: flex; justify-content: space-between; align-items: baseline; }
.budget-card .fig-label { font-size: 10px; color: var(--ink-4); letter-spacing: 0.02em; }
.budget-card .fig-val { font-size: 12px; color: var(--ink-2); }
.budget-card .fig-val.spent { color: var(--ink-3); }
.budget-card .fig-row strong.fig-val { font-size: 13px; color: var(--ink); }

/* ── Sidebar user / logout ─────────────────────────────────────────── */
.sidebar-user {
  padding: 12px 10px 10px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-name { font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 10px; color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 6px;
  color: var(--ink-3); display: flex; align-items: center; justify-content: center;
  text-decoration: none; transition: background 0.12s, color 0.12s;
}
.logout-btn:hover { background: var(--surface-2); color: var(--ink); }
.logout-btn svg { width: 15px; height: 15px; }

/* ── Main / screens ────────────────────────────────────────────────── */
.main { padding: 22px 32px 60px; max-width: 1480px; }
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 22px; gap: 12px; flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.topbar .sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Segmented */
.seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 2px;
}
.seg button {
  border: 0; background: transparent;
  padding: 5px 12px; font-size: 12px; font-weight: 500;
  color: var(--ink-3); border-radius: 6px; cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg button.on { background: var(--surface-2); border: 1px solid var(--border); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); border-radius: 7px;
  cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: white;
  box-shadow: 0 1px 2px rgba(87, 96, 199, 0.25);
}
.btn.primary:hover { background: var(--accent-2); }
.btn.icon { padding: 7px 8px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); border-color: color-mix(in oklab, var(--bad) 30%, var(--border)); }
.btn.danger:hover { background: color-mix(in oklab, var(--bad) 8%, var(--surface)); }

/* Search */
.search {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 7px;
  color: var(--ink-3); font-size: 12px; min-width: 220px;
}
.search svg { width: 14px; height: 14px; }
.search kbd {
  margin-left: auto; font-size: 10px; padding: 1px 5px; border-radius: 3px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-3);
  font-family: inherit;
}

/* Theme toggle + avatar */
.theme-toggle {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-2);
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle svg { width: 14px; height: 14px; }
.avatar {
  width: 28px; height: 28px; border-radius: 999px;
  background: linear-gradient(135deg, var(--cat-saas), var(--accent));
  color: white; font-weight: 600; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 8px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.card-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; font-weight: 400; }

/* ── KPI grid ─────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-3); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.kpi .val { margin-top: 8px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .val .unit { font-size: 14px; font-weight: 500; color: var(--ink-3); margin-left: 1px; }
.kpi .delta {
  margin-top: 6px; display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; padding: 2px 7px; border-radius: 999px;
}
.delta.up { color: var(--bad); background: color-mix(in oklab, var(--bad) 10%, transparent); }
.delta.down { color: var(--good); background: color-mix(in oklab, var(--good) 10%, transparent); }
.delta.flat { color: var(--ink-3); background: var(--surface-2); }
.delta.warn { color: var(--warn); background: var(--warn-soft); }
.kpi-spark { position: absolute; right: 12px; bottom: 12px; width: 88px; height: 30px; opacity: 0.9; }

/* ── Row layouts ──────────────────────────────────────────────────── */
.row { display: grid; gap: 12px; margin-bottom: 12px; }
.row.r1 { grid-template-columns: 1.7fr 1fr; }
.row.r2 { grid-template-columns: 1fr 1fr; }
.row.r3 { grid-template-columns: 2fr 1fr; }

/* ── Trend chart (dashboard + monthly) ────────────────────────────── */
.trend-summary { display: flex; gap: 24px; margin-bottom: 6px; }
.trend-summary .item .v { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.trend-summary .item .k { font-size: 11px; color: var(--ink-3); }
.trend-svg { width: 100%; height: 220px; display: block; }
.trend-legend { display: flex; gap: 16px; font-size: 11px; color: var(--ink-3); padding-top: 4px; }
.trend-legend span { display: inline-flex; align-items: center; gap: 6px; }
.trend-legend i { width: 14px; height: 2px; background: var(--accent); display: inline-block; }
.trend-legend i.dashed { background: transparent; border-top: 1.5px dashed var(--ink-4); height: 0; }

/* ── Donut ────────────────────────────────────────────────────────── */
.donut-wrap { display: flex; gap: 18px; align-items: center; }
.donut-svg { flex-shrink: 0; }
.donut-center { fill: var(--ink); font-weight: 700; font-size: 18px; font-family: "Pretendard"; letter-spacing: -0.01em; }
.donut-center-sub { fill: var(--ink-3); font-size: 10px; font-weight: 500; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.donut-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.donut-row .swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.donut-row .name { flex: 1; font-weight: 500; }
.donut-row .amt { font-weight: 600; }
.donut-row .pct { color: var(--ink-3); font-size: 11px; min-width: 36px; text-align: right; }

/* ── Logo tiles + tags + chips ─────────────────────────────────────── */
.logo-tile {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--cat-cloud-soft); color: var(--cat-cloud);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  border: 1px solid color-mix(in oklab, var(--cat-cloud) 18%, transparent);
  flex-shrink: 0;
}
.logo-tile.s { width: 26px; height: 26px; font-size: 11px; border-radius: 6px; }
.logo-tile.l { width: 40px; height: 40px; font-size: 16px; border-radius: 10px; }
.logo-tile.ott   { background: var(--cat-ott-soft);   color: var(--cat-ott);   border-color: color-mix(in oklab, var(--cat-ott) 18%, transparent); }
.logo-tile.cloud { background: var(--cat-cloud-soft); color: var(--cat-cloud); border-color: color-mix(in oklab, var(--cat-cloud) 18%, transparent); }
.logo-tile.saas  { background: var(--cat-saas-soft);  color: var(--cat-saas);  border-color: color-mix(in oklab, var(--cat-saas) 18%, transparent); }
.logo-tile.other { background: var(--cat-other-soft); color: var(--cat-other); border-color: color-mix(in oklab, var(--cat-other) 18%, transparent); }
.logo-tile.has-img { padding: 0; overflow: hidden; background: #fff; border-color: transparent; }
.logo-tile.has-img img { width: 80%; height: 80%; object-fit: contain; display: block; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
  background: var(--accent-soft); color: var(--accent);
  text-transform: uppercase;
}
.tag.ott   { background: var(--cat-ott-soft);   color: var(--cat-ott); }
.tag.cloud { background: var(--cat-cloud-soft); color: var(--cat-cloud); }
.tag.saas  { background: var(--cat-saas-soft);  color: var(--cat-saas); }
.tag.other { background: var(--cat-other-soft); color: var(--cat-other); }
.tag.warn  { background: var(--warn-soft);      color: var(--warn); }
.tag.muted { background: var(--surface-2);      color: var(--ink-3); }
.tag.good  { background: color-mix(in oklab, var(--good) 12%, transparent); color: var(--good); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; font-size: 11px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--ink-2); border-radius: 999px; cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--ink); color: white; border-color: var(--ink); }
[data-theme="dark"] .chip.on { background: var(--accent); border-color: var(--accent); color: white; }
.chip .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--ink-3); }

/* ── MTD card ─────────────────────────────────────────────────────── */
.mtd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mtd-card { padding: 18px; position: relative; }
.mtd-card .head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.mtd-card .ico { display: flex; align-items: center; gap: 10px; }
.mtd-card .ico .name { font-weight: 600; font-size: 14px; }
.mtd-card .ico .meta { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.mtd-card .figs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mtd-card .figs .k { font-size: 11px; color: var(--ink-3); }
.mtd-card .figs .v { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin-top: 3px; }
.mtd-card .figs .v .unit { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-left: 1px; }
.mtd-card .compare { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.mtd-bar {
  margin-top: 16px; height: 6px; background: var(--surface-2);
  border-radius: 3px; overflow: hidden; position: relative;
  border: 1px solid var(--border);
}
.mtd-bar .fill { height: 100%; background: var(--cat-cloud); border-radius: 3px; }
.mtd-bar .marker { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--cat-cloud); border-radius: 1px; }
.mtd-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10px; color: var(--ink-3); }

/* AWS 리소스별 비용 breakdown */
.aws-breakdown { margin: 14px 0 12px; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.aws-breakdown-title { font-size: 10px; font-weight: 600; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; padding: 7px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.aws-breakdown-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--divider); font-size: 12px; }
.aws-breakdown-row:last-child { border-bottom: none; }
.aws-breakdown-name { color: var(--ink-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 8px; }
.aws-breakdown-amt { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex-shrink: 0; }
.aws-breakdown-amt .tnum { font-size: 12px; color: var(--ink); }
.aws-breakdown-krw { font-size: 10px; color: var(--ink-3); }
.aws-breakdown-total { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; background: var(--surface-2); border-top: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.aws-breakdown-total .aws-breakdown-amt .tnum { color: var(--cat-cloud); }
.aws-breakdown-empty { margin: 14px 0 12px; padding: 12px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--r-sm); font-size: 11px; color: var(--ink-4); text-align: center; line-height: 1.7; }
.aws-breakdown-empty span { font-size: 10px; color: var(--ink-4); }

/* 크레딧 KPI progress bar */
.credit-bar-wrap { height: 6px; background: var(--border); border-radius: 3px; margin: 10px 0 2px; overflow: hidden; }
.credit-bar-fill { height: 100%; background: var(--cat-cloud); border-radius: 3px; transition: width 0.4s ease; }

/* 크레딧 KPI 내 리소스 breakdown */
.credit-breakdown { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.credit-row { display: flex; justify-content: space-between; align-items: center; font-size: 11px; }
.credit-svc { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; padding-right: 6px; }
.credit-usd { color: var(--ink-2); flex-shrink: 0; font-size: 11px; }
.credit-breakdown-empty { margin-top: 8px; font-size: 10px; color: var(--ink-4); }

/* ── Upcoming list ────────────────────────────────────────────────── */
.up-row {
  display: grid; grid-template-columns: 36px 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.up-row:last-child { border-bottom: 0; }
.up-row .info .name { font-weight: 500; font-size: 13px; }
.up-row .info .meta { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.up-row .date { text-align: right; }
.up-row .date .d { font-weight: 600; font-size: 13px; }
.up-row .date .when {
  display: inline-block; margin-top: 1px;
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-3); font-weight: 500;
}
.up-row .date .when.soon { background: var(--warn-soft); color: var(--warn); }
.up-row .amt { font-weight: 700; font-size: 14px; text-align: right; min-width: 88px; }

/* ── Bar chart ────────────────────────────────────────────────────── */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 18px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bar .col {
  width: 100%; max-width: 36px; background: var(--surface-2);
  border-radius: 4px 4px 0 0; position: relative;
  border: 1px solid var(--border); border-bottom: 0;
  margin-top: auto;
}
.bar.hl .col { background: var(--accent); border-color: var(--accent); }
.bar .col .v {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 600; color: var(--ink); white-space: nowrap;
}
.bar.hl .col .v { color: var(--accent); }
.bar .lbl { font-size: 10px; color: var(--ink-3); }

/* Tall bar chart (24h hourly) */
.bar-chart.tall { height: 180px; gap: 4px; }
.bar-chart.tall .col { max-width: 28px; }

/* Daily bar (31개 막대) — bar-chart에 .daily 클래스 추가 시 gap 조정 */
.bar-chart.daily { gap: 3px; padding-top: 28px; }
.bar.day-bar { flex: none; width: calc((100% - 30 * 3px) / 31); min-width: 4px; gap: 3px; }
.bar.day-bar .col { max-width: unset; border-radius: 2px 2px 0 0; }
.bar.day-bar .col .v { font-size: 9px; font-weight: 600; white-space: nowrap; }
.bar.day-bar .lbl { font-size: 9px; min-height: 12px; }

/* ── Tables (subscription / monthly) ──────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left; padding: 10px 14px; font-size: 10px; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.tbl tbody td { padding: 12px 14px; border-bottom: 1px solid var(--divider); font-size: 13px; vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; transition: background 0.1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.selected { background: var(--accent-soft); }
.tbl .cell-name { display: flex; align-items: center; gap: 10px; }
.tbl .cell-name .name { font-weight: 500; }
.tbl .cell-name .sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.tbl tr.paused td { opacity: 0.55; }

/* ── Calendar ─────────────────────────────────────────────────────── */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 0; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden;
  background: var(--border);
}
.cal-hd {
  padding: 10px 12px; background: var(--surface-2); font-size: 11px; font-weight: 600;
  color: var(--ink-3); text-align: center;
}
.cal-cell {
  background: var(--surface); padding: 8px; min-height: 110px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative;
}
.cal-cell.off { background: var(--surface-2); }
.cal-cell:not(.off) { cursor: pointer; }
.cal-cell:not(.off):hover { background: var(--surface); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); z-index: 1; }
.cal-cell.selected { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); z-index: 2; }
.cal-cell .day { font-size: 11px; font-weight: 600; color: var(--ink-2); }
.cal-cell.off .day { color: var(--ink-4); font-weight: 400; }
.cal-cell.today .day { color: var(--accent); }
.cal-cell.selected .day { color: var(--accent); }
.cal-week-day { cursor: pointer; transition: background 0.1s; }
.cal-week-day:not(.off):hover { background: var(--surface) !important; }
.cal-week-day.today { box-shadow: 0 0 0 2px var(--accent); }
.cal-week-day.selected { background: var(--accent-soft) !important; box-shadow: 0 0 0 2px var(--accent); }
.cal-event {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 6px; border-radius: 5px;
  font-size: 10px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-event .dot { width: 5px; height: 5px; border-radius: 999px; flex-shrink: 0; }
.cal-event.ott   { background: var(--cat-ott-soft);   border-color: color-mix(in oklab, var(--cat-ott) 25%, transparent); color: var(--cat-ott); }
.cal-event.ott   .dot { background: var(--cat-ott); }
.cal-event.cloud { background: var(--cat-cloud-soft); border-color: color-mix(in oklab, var(--cat-cloud) 25%, transparent); color: var(--cat-cloud); }
.cal-event.cloud .dot { background: var(--cat-cloud); }
.cal-event.saas  { background: var(--cat-saas-soft);  border-color: color-mix(in oklab, var(--cat-saas) 25%, transparent); color: var(--cat-saas); }
.cal-event.saas  .dot { background: var(--cat-saas); }

/* ── Subscription detail panel ────────────────────────────────────── */
.sub-layout { display: grid; grid-template-columns: 1fr 380px; gap: 12px; }
.detail-panel { padding: 20px; position: sticky; top: 22px; align-self: start; }
.detail-panel .empty {
  height: 320px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-4); font-size: 12px; text-align: center; padding: 24px;
}
.detail-panel .empty svg { display: block; margin: 0 auto 8px; opacity: 0.6; }
.field { margin-bottom: 14px; }
.field-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-bottom: 5px; font-weight: 500; }
.field-input {
  display: block; width: 100%;
  padding: 8px 10px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--ink); font-family: inherit;
}
.field-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Toggle switch */
.switch { width: 32px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background 0.16s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 999px; background: white; box-shadow: 0 1px 2px rgba(0,0,0,0.12); transition: left 0.16s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 16px; }

/* Alert rule row */
.alert-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--divider); gap: 14px; }
.alert-row:last-child { border-bottom: 0; }
.alert-row .meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8,8,12,0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-backdrop[data-open="true"] { display: flex; animation: fadeIn 0.16s; }
.modal {
  width: min(620px, calc(100% - 32px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 24px;
  box-shadow: var(--shadow-lg);
  max-height: 88vh; overflow: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.modal-close {
  width: 28px; height: 28px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-3);
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--divider); }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 16px; }
.preset {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); cursor: pointer; transition: background 0.1s, border-color 0.1s;
  font-size: 11px; font-weight: 500; color: var(--ink-2);
}
.preset:hover { background: var(--surface); border-color: var(--border-strong); }
.preset.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ── Misc ─────────────────────────────────────────────────────────── */
.divider-h { height: 1px; background: var(--divider); margin: 14px 0; }
.link { color: var(--accent); font-size: 11px; font-weight: 500; cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.stat-strip { display: flex; gap: 24px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 14px; flex-wrap: wrap; }
.stat-strip .stat .k { font-size: 11px; color: var(--ink-3); }
.stat-strip .stat .v { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin-top: 2px; }
.stat-strip .stat .v small { font-size: 11px; font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.stat-strip .div { width: 1px; background: var(--divider); }

/* ── Inline mini progress ─────────────────────────────────────────── */
.mini-bar { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; min-width: 60px; }
.mini-bar > div { height: 100%; background: var(--accent); border-radius: 2px; }

/* ── 14-day strip ─────────────────────────────────────────────────── */
.day-strip { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; }
.day-strip .day-c {
  display: flex; flex-direction: column; align-items: center;
  border-radius: 8px; padding: 8px 4px; cursor: pointer;
  background: var(--surface-2); border: 1px solid transparent;
  transition: background 0.1s;
}
.day-strip .day-c:hover { background: var(--surface); border-color: var(--border); }
.day-strip .day-c.today { background: var(--accent-soft); border-color: var(--accent-ring); }
.day-strip .day-c .dnum { font-size: 13px; font-weight: 600; }
.day-strip .day-c.today .dnum { color: var(--accent); }
.day-strip .day-c .dval { font-size: 9px; color: var(--ink-3); margin-top: 1px; }
.day-strip .day-c .dbar { height: 32px; width: 100%; margin-top: 6px; display: flex; align-items: flex-end; justify-content: center; }
.day-strip .day-c .dbar > i { width: 60%; background: var(--ink-4); border-radius: 2px 2px 0 0; display: block; }
.day-strip .day-c.today .dbar > i { background: var(--accent); }

/* ════════════════════════════════════════════════════════════════════════
   모바일 하단 탭바 (데스크탑에서는 숨김)
   ════════════════════════════════════════════════════════════════════════ */
.mobile-nav { display: none; }

/* ════════════════════════════════════════════════════════════════════════
   반응형 — 768px 이하 (모바일)
   ════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── 앱 레이아웃 ─────────────────────────────────────────────────── */
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px 14px 80px; width: 100%; box-sizing: border-box; overflow-x: hidden; }

  /* ── 하단 탭바 ───────────────────────────────────────────────────── */
  .mobile-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    height: 60px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  }
  .mobile-nav .nav-item {
    flex: 1; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 6px 4px;
    font-size: 10px; font-weight: 500;
    border-radius: 0;
  }
  .mobile-nav .nav-item svg { width: 20px; height: 20px; }
  .mobile-nav .nav-item span { display: block; }
  .mobile-nav .nav-item.active {
    background: transparent;
    color: var(--accent);
  }
  .mobile-nav .nav-item.active svg { color: var(--accent); }

  /* ── 상단바 ─────────────────────────────────────────────────────── */
  .topbar {
    flex-direction: column; align-items: flex-start;
    padding-bottom: 16px; gap: 10px;
  }
  .topbar h1 { font-size: 18px; }
  .topbar-actions { width: 100%; flex-wrap: wrap; gap: 6px; }

  /* ── KPI 그리드: 5열 → 2열 (3+2 wrap) ──────────────────────────── */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi .val { font-size: 20px; }

  /* ── 행 레이아웃: 모두 1열 ─────────────────────────────────────── */
  .row.r1, .row.r2, .row.r3 { grid-template-columns: 1fr; }

  /* ── 카드 ───────────────────────────────────────────────────────── */
  .card { padding: 14px; }

  /* ── 구독 화면 ──────────────────────────────────────────────────── */
  .sub-layout { grid-template-columns: 1fr; }
  .detail-panel { position: static; top: auto; }

  /* ── 테이블: 가로 스크롤 ────────────────────────────────────────── */
  .tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 520px; }
  .tbl thead th, .tbl tbody td { padding: 10px 10px; }

  /* ── MTD 카드 그리드 ────────────────────────────────────────────── */
  .mtd-grid { grid-template-columns: 1fr; }

  /* ── 막대 차트 ──────────────────────────────────────────────────── */
  .bar-chart { gap: 4px; height: 120px; }
  .bar .col .v { font-size: 9px; }

  /* ── 14일 스트립: 가로 스크롤 ──────────────────────────────────── */
  .day-strip { grid-template-columns: repeat(14, minmax(40px, 1fr)); overflow-x: auto; }

  /* ── 캘린더 ─────────────────────────────────────────────────────── */
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-cell .day { font-size: 10px; }
  .cal-event { font-size: 9px; padding: 2px 3px; }
  .cal-hd { padding: 6px 4px; font-size: 10px; }

  /* ── 모달 ───────────────────────────────────────────────────────── */
  .modal { padding: 18px; border-radius: var(--r-lg); }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }

  /* ── 다음 청구 리스트 ───────────────────────────────────────────── */
  .up-row { grid-template-columns: 28px 1fr auto; gap: 8px; }
  .up-row .amt { min-width: 70px; font-size: 13px; }

  /* ── stat-strip 세로 정렬 ───────────────────────────────────────── */
  .stat-strip { gap: 16px; padding: 12px 14px; }
  .stat-strip .div { display: none; }

  /* ── 트렌드 요약 ────────────────────────────────────────────────── */
  .trend-summary { flex-wrap: wrap; gap: 12px; }

  /* ── 검색창 최소 너비 해제 ──────────────────────────────────────── */
  .search { min-width: 0; flex: 1; }
}
