/* 앱 화면 — tokens.css(다골라 톤) 변수를 앱 이름으로 이어 쓴다 */
:root {
  --bg: var(--sheet);
  --surface: var(--paper);
  --muted: var(--ink-2);
  --line: var(--rule);
  --brand: var(--ink);
  --brand-soft: var(--hi-soft);
  --warn: var(--bad);
  --warn-soft: var(--bad-soft);
  --radius: 16px;
}

body { font-size: 15px; line-height: 1.5; background: var(--sheet); }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* layout */
.shell { min-height: 100dvh; padding-bottom: 76px; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 60px; padding: 0 16px; background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand .sub { color: var(--ink-3); font-weight: 600; font-size: 13px; letter-spacing: 0; margin-left: 2px; }
main { max-width: 1080px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; letter-spacing: -0.02em; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 0 8px; font-size: 12px; color: var(--muted); text-decoration: none;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--ink); font-weight: 750; }
.tabbar a.active svg { filter: drop-shadow(3px -3px 0 var(--hi)); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 200px 1fr; padding-bottom: 0; }
  .topbar { grid-column: 1 / -1; }
  .tabbar {
    position: sticky; top: 57px; align-self: start; height: calc(100dvh - 57px);
    display: flex; flex-direction: column; gap: 4px; padding: 16px 12px;
    border-top: 0; border-right: 1px solid var(--line); background: transparent;
  }
  .tabbar a { flex-direction: row; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
  .tabbar a.active { background: var(--paper); box-shadow: inset 3px 0 0 var(--hi); }
  main { padding: 24px; width: 100%; }
}

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid { display: grid; gap: 10px; }
.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* segmented control */
.seg { display: inline-flex; background: var(--rule); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgb(0 0 0 / 8%); }

/* buttons */
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.raise { background: var(--hi); border-color: var(--hi); color: #1c1700; }
.btn.raise:hover { background: #ffd92e; border-color: #ffd92e; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

input[type=text], input[type=email], input[type=password], input[type=number] {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface);
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* cap meter */
.meter { height: 10px; background: var(--sheet); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.meter > div { height: 100%; background: var(--ink); border-radius: 99px; }
.meter.over > div { background: var(--warn); }

/* banners */
.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { background: var(--bad-soft); color: var(--ink); }
.banner.info { background: var(--hi-soft); color: var(--ink); }

/* leak list */
.leak-total { font-size: 26px; font-weight: 800; color: var(--warn); letter-spacing: -0.02em; }
.leak { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.leak:first-of-type { border-top: 0; }
.leak .what { min-width: 0; flex: 1 1 200px; }
.leak .kw { font-weight: 700; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
th button { border: 0; background: none; padding: 0; color: inherit; font: inherit; cursor: pointer; }
th button.sorted { color: var(--ink); font-weight: 800; }
tr.leaky td { background: color-mix(in srgb, var(--bad-soft) 55%, var(--paper)); }
tr.leaky td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); margin-left: 6px; font-weight: 700; }
.off { color: var(--muted); }

/* toggle */
.switch { position: relative; width: 42px; height: 24px; border-radius: 99px; border: 0; background: var(--rule); cursor: pointer; padding: 0; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / 20%); }
.switch[aria-checked=true] { background: var(--ink); }
.switch[aria-checked=true]::after { transform: translateX(18px); background: var(--hi); }

/* bar chart */
.bars { width: 100%; }
.bars text { font-size: 12px; fill: var(--muted); font-family: inherit; }
.bars .val { fill: var(--ink); font-weight: 600; }
.bars rect { fill: var(--ink); }

/* modal + toast */
dialog { border: 0; border-radius: 16px; background: var(--paper); color: var(--ink); padding: 20px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgb(0 0 0 / 25%); }
dialog::backdrop { background: rgb(13 20 40 / 55%); }
dialog h3 { margin: 0 0 8px; font-size: 17px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: #16213e; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }

/* auth */
.auth { max-width: 400px; margin: 8vh auto; padding: 16px; }
.auth .hero { margin-bottom: 20px; }
.auth .hero h1 { font-size: 26px; margin-bottom: 6px; }
.steps { padding-left: 20px; margin: 8px 0 12px; }
.steps li { margin-bottom: 4px; }
.empty { text-align: center; padding: 28px 16px; }

/* profit-first home */
.card.slim { padding: 12px 16px; }
.hero-card .big { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin: 2px 0 4px; }
.pos { color: var(--ok); }
.neg { color: var(--warn); }
.mini { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.mini b { color: var(--ink); }
button.link { border: 0; background: none; padding: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font-size: 13px; }
.todos { display: grid; gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .todos { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.todo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.todo.bad { border-left: 4px solid var(--warn); }
.todo.good { border-left: 4px solid var(--hi); }
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.figures div { display: flex; flex-direction: column; }
.figures b { font-size: 15px; }
@media (max-width: 380px) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--sheet); color: var(--muted); white-space: nowrap; }
.badge.good { background: var(--hi); color: #2a2400; }
.badge.bad { background: var(--warn-soft); color: var(--warn); }
.btn.wide { width: 100%; padding: 11px 14px; }

/* 아낄 수 있는 돈 */
.save-card { background: var(--night); color: var(--on-night); border-color: var(--night); }
.save-card .muted, .save-card .small { color: var(--on-night-2); }
.save-card .big { color: #fff; }
.save-card .big .hl-n { background: linear-gradient(transparent 58%, rgba(255, 228, 92, .9) 58%, rgba(255, 228, 92, .9) 90%, transparent 90%); }
.save-card .btn.raise { margin-top: 14px; }
.save-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.save-list li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 8px 10px; border-radius: 9px; background: rgba(255, 255, 255, .05); border: 1px solid var(--night-line); }
.save-list li em { font-style: normal; font-weight: 800; color: #ff8c85; white-space: nowrap; }

/* 앱 바닥글 */
.app-foot { margin-top: 32px; padding: 20px 0 8px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.app-foot a { color: var(--ink-2); text-decoration: none; margin-right: 12px; }
.main-col { min-width: 0; }
.wrap-app { max-width: 1080px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
@media (min-width: 900px) { .wrap-app { padding-left: 24px; padding-right: 24px; } }

/* 리포트 */
.tabs-line { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 14px; scrollbar-width: none; }
.tabs-line button { border: 0; background: none; padding: 10px 12px; font-weight: 650; color: var(--muted); cursor: pointer; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs-line button.on { color: var(--ink); border-bottom-color: var(--hi); }
.trend { width: 100%; height: auto; margin-top: 12px; }
.trend rect { fill: var(--ink); opacity: .82; }
.trend rect.neg { fill: var(--bad); }
.trend rect.best { fill: var(--hi); opacity: 1; }
.trend text { font-size: 11px; fill: var(--ink-3); font-family: inherit; }
.trend .val { fill: var(--ink); font-weight: 700; font-size: 12px; }
.trend .axis { stroke: var(--rule); }
.media-cards { display: grid; gap: 10px; }
@media (min-width: 760px) { .media-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.media-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.chg { font-weight: 700; }
.chg.up { color: var(--ok); }
.chg.down { color: var(--bad); }

/* 매체 연결 */
.connect-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
@media (min-width: 760px) { .connect-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.connect { font: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px; padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); background: var(--surface); }
.connect:hover { border-color: var(--ink-3); }
.connect span { font-size: 12px; color: var(--muted); }
label.btn { cursor: pointer; }
