:root{
  --ink:#0F1B2D; --ink-soft:#16263C;
  --teal:#1F6F63; --amber:#B9791F; --amber-bright:#E8A23D; --coral:#C4453A;
  /* 중요 금액 시그니처 (UI amber와 별개) */
  --amount-primary:#e0a94a;
  --amount-primary-strong:#f0bc5e;
  --amount-primary-muted:#c4923a;
  /* 의미 토큰 — 팔레트 위 한 층 (손익 / 흐름 / 상태). docs/AMOUNT_DISPLAY_RULES.md */
  --amt-gain:var(--teal);   --amt-loss:var(--coral);
  --flow-in:var(--teal);    --flow-out:var(--coral);
  --state-ok:var(--teal);   --state-warn:var(--amber);  --state-danger:var(--coral);
}
.amt-gain{ color:var(--amt-gain); }
.amt-loss{ color:var(--amt-loss); }
.flow-in{ color:var(--flow-in); }
.flow-out{ color:var(--flow-out); }
.amt-neg-strong{ font-weight:800; }
body[data-theme="dark"]{
  --bg:#0B1420; --panel:#131F30; --panel-2:#0F1B2D; --line:#233247; --text:#E7EAEE; --muted:#8B96A3;
  --input-bg:#0B1420; --amber-bg:#2A2010; --teal-bg:#0F211D; --coral-bg:#2A1512;
}
*{ box-sizing:border-box; margin:0; padding:0; }
body{ font-family:'Inter','Noto Sans KR',sans-serif; background:var(--bg); color:var(--text); font-size:14px; }
/* 언어별 대표 글꼴. html lang 은 applyLoginLang / index 부팅이 정규화값으로 맞춘다. */
html[lang="ja"] body{ font-family:'Inter','Noto Sans JP',sans-serif; }
html[lang^="zh"] body{ font-family:'Inter','Noto Sans SC',sans-serif; }
.mono{ font-family:'IBM Plex Mono', monospace; }
a{ text-decoration:none; color:inherit; }
button{ font-family:inherit; }

/* 중요 금액 — 인라인 color 금지, 이 클래스만 사용 */
.amount-primary{ color:var(--amount-primary); }
.amount-primary-strong{ color:var(--amount-primary-strong); font-weight:700; }
.amount-primary-muted{ color:var(--amount-primary-muted); }
.amount-pair{ display:inline-flex; min-width:128px; flex-direction:column; gap:2px; }
.amount-pair .amount-line{ display:flex; justify-content:space-between; gap:8px; white-space:nowrap; }
.amount-pair .amount-line.slot,
.amount-pair .amount-line.live{ color:var(--amount-primary-muted); }
.amount-pair .amount-line.total{
  color:var(--amount-primary-strong); font-weight:700;
  padding-top:2px; border-top:1px solid var(--line);
}
.amount-pair .amount-line small{ font-size:10px; color:inherit; opacity:.9; }

.login-screen{ min-height:100vh; display:flex; align-items:center; justify-content:center;
  background:
    radial-gradient(circle at 80% 15%, rgba(232,162,61,0.16), transparent 55%),
    radial-gradient(circle at 15% 85%, rgba(31,111,99,0.18), transparent 55%),
    var(--ink);
}
.login-card{ width:400px; max-width:90vw; background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:38px 36px 30px; box-shadow:0 24px 60px -20px rgba(0,0,0,0.5); }
.login-logo{ display:flex; align-items:center; gap:10px; font-family:'Fraunces', serif; font-weight:600; font-size:22px; margin-bottom:4px; }
.login-logo .mark{ width:22px; height:22px; border-radius:50%; background:conic-gradient(from 180deg, var(--amber-bright), var(--teal), var(--amber-bright)); }
.login-sub{ font-size:12px; color:var(--muted); margin-bottom:28px; }
.login-error{ font-size:12px; color:var(--coral); margin:-6px 0 12px; display:none; }
.login-error.show{ display:block; }
.login-demo-note{ margin-top:18px; padding-top:16px; border-top:1px solid var(--line); font-size:11px; color:var(--muted); line-height:1.6; }
.login-demo-note code{ background:var(--input-bg); padding:1px 5px; border-radius:4px; font-family:'IBM Plex Mono',monospace; font-size:10.5px; }

.form-row{ margin-bottom:14px; }
.form-row label{ display:block; font-size:12px; font-weight:600; margin-bottom:6px; color:var(--muted); }
.form-row input{ width:100%; padding:10px 12px; border-radius:8px; border:1px solid var(--line); background:var(--input-bg); color:var(--text); font-size:13.5px; }
.form-row select{ width:100%; padding:10px 12px; border-radius:8px; border:1px solid var(--line); background:var(--input-bg); color:var(--text); font-size:13.5px; }
.form-row input:focus{ outline:none; border-color:var(--teal); }

.btn{ padding:10px 18px; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; border:1px solid transparent; display:inline-flex; align-items:center; gap:6px; }
.btn:hover{ filter:brightness(1.08); }
.btn:disabled{ opacity:.5; cursor:not-allowed; }
.btn-primary{ background:var(--amber-bright); color:#1B2430; }
.btn-ghost{ background:transparent; border-color:var(--line); color:var(--text); }
.btn-sm{ padding:6px 12px; font-size:12px; }
.btn-block{ width:100%; justify-content:center; }

.app{ display:flex; min-height:100vh; }
.sidebar{ width:240px; flex-shrink:0; background:var(--panel-2); border-right:1px solid var(--line); padding:20px 0; height:100vh; position:sticky; top:0; overflow-y:auto; }
.sidebar-logo{ display:flex; align-items:center; gap:9px; font-family:'Fraunces', serif; font-weight:600; font-size:18px; padding:0 22px 22px; }
.sidebar-logo .mark{ width:18px; height:18px; border-radius:50%; background:conic-gradient(from 180deg, var(--amber-bright), var(--teal), var(--amber-bright)); }
.sb-item{ display:flex; align-items:center; gap:11px; padding:11px 22px; font-size:13.5px; font-weight:500; color:var(--muted); cursor:pointer; border-left:3px solid transparent; }
.sb-item:hover{ color:var(--text); background:rgba(255,255,255,0.02); }
.sb-item.active{ color:var(--text); background:rgba(232,162,61,0.08); border-left-color:var(--amber-bright); font-weight:600; }
.sb-item .ic{ width:18px; text-align:center; }

.main{ flex:1; min-width:0; }
.topbar{ height:64px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; padding:0 28px; position:sticky; top:0; background:var(--bg); z-index:10; }
.tier-chip{ display:flex; align-items:center; gap:8px; font-size:12.5px; font-weight:600; padding:6px 12px; border:1px solid var(--line); border-radius:20px; background:var(--panel); }
.tier-chip .dot{ width:8px; height:8px; border-radius:50%; background:var(--amber-bright); }
.profile-chip{ display:flex; align-items:center; gap:9px; }
.profile-chip .avatar{ width:32px; height:32px; border-radius:50%; background:var(--teal); display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; }

.content{ padding:24px 28px 48px; width:100%; max-width:none; box-sizing:border-box; }
.page-title{ font-family:'Fraunces', serif; font-size:26px; font-weight:600; margin-bottom:4px; }
.page-sub{ font-size:13px; color:var(--muted); margin-bottom:24px; }

.kpi-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:24px; }
.kpi-grid-6{ grid-template-columns:repeat(3,1fr); }
@media (max-width:1100px){ .kpi-grid-6{ grid-template-columns:repeat(2,1fr); } }
@media (max-width:900px){ .kpi-grid{ grid-template-columns:repeat(2,1fr); } .app{ flex-direction:column; } .sidebar{ width:100%; height:auto; position:static; } }
.kpi-card{ background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:18px 20px; }
.kpi-card .label{ font-size:11.5px; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; margin-bottom:8px; }
.kpi-card .value{ font-family:'IBM Plex Mono', monospace; font-size:22px; font-weight:700; }
.kpi-card .kpi-sub{ font-size:11px; color:var(--muted); margin-top:6px; }

.dash-grid{ display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:16px; }
@media (max-width:900px){ .dash-grid{ grid-template-columns:1fr; } }

/* Full-width dense tables — fill the panel, distribute columns evenly */
table.compact{
  width:100%;
  table-layout:fixed;
  border-collapse:collapse;
}
table.compact th,
table.compact td{
  padding:9px 12px;
  font-size:13px;
  vertical-align:middle;
  overflow:hidden;
  text-overflow:ellipsis;
}
table.compact th:first-child,
table.compact td:first-child{
  width:34%;
  text-align:left;
  white-space:normal;
  word-break:keep-all;
}
table.compact thead th:not(:first-child),
table.compact tbody td:not(:first-child){ text-align:right; }
table.compact td.mono,
table.compact th.mono{ font-variant-numeric:tabular-nums; }
table.compact .tiny{ white-space:normal; display:block; margin-top:2px; }
/* action column (e.g. 복사) */
table.compact td:last-child .btn{ float:right; }

.insight-split{
  display:grid;
  grid-template-columns:minmax(0, 1.2fr) minmax(0, 1fr);
  gap:16px 28px;
  align-items:start;
  margin:0;
  width:100%;
}
@media (max-width:900px){ .insight-split{ grid-template-columns:1fr; } }
.insight-split .spark-label{ margin-bottom:8px; }
.insight-split > div{ min-width:0; width:100%; }

.panel-note{ font-size:12px; color:var(--muted); margin-top:10px; }
.empty-hint{ color:var(--muted); font-size:12.5px; padding:8px 0; }
.tiny{ font-size:11px; }
.muted{ color:var(--muted); }
.spark-block{ margin-bottom:14px; }
.spark-label{ font-size:11px; color:var(--muted); margin-bottom:6px; }
.spark{ display:flex; align-items:flex-end; gap:4px; height:56px; width:100%; }
.spark span{ flex:1; background:linear-gradient(180deg, var(--amber-bright), var(--teal)); border-radius:3px 3px 1px 1px; min-width:0; opacity:.85; }
.spark-legend{ font-size:11px; color:var(--muted); margin-top:4px; }
.quick-actions{ display:flex; gap:10px; flex-wrap:wrap; margin-top:8px; margin-bottom:20px; }
.hint-list{ margin:0; padding-left:18px; color:var(--muted); font-size:13px; line-height:1.7; }
.hint-list b{ color:var(--text); font-weight:600; }

.hour-bars{
  display:flex; align-items:flex-end; gap:3px; height:80px;
  width:100%; padding-bottom:2px;
}
.hour-col{ flex:1; min-width:0; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; gap:4px; }
.hour-bar{
  width:72%;
  min-width:4px;
  background:linear-gradient(180deg, var(--amber-bright), var(--teal));
  border-radius:3px 3px 1px 1px; opacity:.9;
}
.hour-lab{ font-size:9px; color:var(--muted); font-family:'IBM Plex Mono', monospace; }

.msg-card{ border:1px solid var(--line); border-radius:10px; margin-bottom:10px; overflow:hidden; }
.msg-card > summary.msg-card-head{
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  padding:12px 14px; cursor:pointer; background:var(--input-bg, transparent);
  list-style:none;
}
.msg-card > summary.msg-card-head::-webkit-details-marker{ display:none; }
.msg-card > summary.msg-card-head::after{
  content:'▾'; color:var(--muted); font-size:12px; margin-left:4px; flex-shrink:0;
}
.msg-card[open] > summary.msg-card-head::after{ content:'▴'; }
.msg-card-head{
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  padding:12px 14px; cursor:pointer; background:var(--input-bg, transparent);
}
.msg-card-body{ padding:0 14px 14px; border-top:1px solid var(--line); }
.msg-bubble{
  margin-top:12px; padding:12px; border-radius:8px;
  background:var(--input-bg, rgba(255,255,255,.04));
  font-size:13px; line-height:1.55; white-space:pre-wrap;
}
.msg-bubble.reply{ border-left:3px solid var(--teal); }
.msg-reply{ margin-top:8px; }

.modal-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.55);
  display:none; align-items:center; justify-content:center;
  z-index:300; padding:20px;
}
.modal-overlay.show{ display:flex; }
.modal-box{
  width:min(480px, 100%); background:var(--panel); border:1px solid var(--line);
  border-radius:14px; padding:20px 22px; box-shadow:0 20px 50px rgba(0,0,0,.35);
}
.modal-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; gap:10px; }
.modal-head h3{ font-size:16px; margin:0; }
.form-row{ margin-bottom:12px; }
.form-row label{ display:block; font-size:12px; color:var(--muted); margin-bottom:6px; }
.form-row input, .form-row textarea{
  width:100%; box-sizing:border-box; padding:10px 12px; border-radius:8px;
  border:1px solid var(--line); background:var(--input-bg, rgba(0,0,0,.2));
  color:var(--text); font:inherit;
}
.btn-block{ width:100%; margin-top:4px; }

.panel{ background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:16px 18px; margin-bottom:14px; }
.panel-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; gap:12px; flex-wrap:wrap; }
.panel-head h3{ font-size:15px; font-weight:700; }
.panel-head span{ font-size:12px; color:var(--muted); }

table{ width:100%; border-collapse:collapse; font-size:13px; }
th{ text-align:left; font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; padding:9px 10px; border-bottom:1px solid var(--line); }
td{ padding:10px 10px; border-bottom:1px solid var(--line); vertical-align:top; }
tr:last-child td{ border-bottom:none; }

.tag-pill{ display:inline-block; padding:3px 9px; border-radius:20px; font-size:11px; font-weight:700; }
.tag-pill.low{ background:var(--teal-bg); color:var(--teal); }
.tag-pill.mid{ background:var(--amber-bg); color:var(--amber-bright); }
.tag-pill.high{ background:var(--coral-bg); color:var(--coral); }
th.col-status, td.col-status{ text-align:center !important; vertical-align:middle; }
table.compact th.col-status,
table.compact td.col-status{ text-align:center !important; }

.join-url{ font-size:12px; word-break:break-all; color:var(--muted); max-width:420px; }

.toast{ position:fixed; bottom:24px; right:24px; background:var(--ink); color:#fff; padding:13px 20px; border-radius:10px; font-size:13px; box-shadow:0 12px 28px rgba(0,0,0,0.3); transform:translateY(20px); opacity:0; pointer-events:none; transition:all .25s; z-index:200; max-width:320px; }
.toast.show{ transform:translateY(0); opacity:1; }
/* 토스트 톤 — console(ops.css) 과 동일 구조. 상태축(--state-*) 파생색만 쓴다.
   톤 클래스가 없으면 중립 모양 그대로. 규칙: docs/UI_FEEDBACK_RULES.md */
.toast.tone-ok,
.toast.tone-warn,
.toast.tone-danger{ border-left:4px solid transparent; padding-left:16px; }
.toast.tone-ok{
  border-left-color:color-mix(in srgb, var(--state-ok) 60%, #fff);
  background:color-mix(in srgb, var(--state-ok) 14%, var(--ink));
}
.toast.tone-warn{
  border-left-color:color-mix(in srgb, var(--state-warn) 60%, #fff);
  background:color-mix(in srgb, var(--state-warn) 14%, var(--ink));
}
.toast.tone-danger{
  border-left-color:color-mix(in srgb, var(--state-danger) 60%, #fff);
  background:color-mix(in srgb, var(--state-danger) 14%, var(--ink));
}

/* ===== 결과 안내 패널 — console 과 같은 구조 (docs/UI_FEEDBACK_RULES.md) ===== */
.result-note{
  border:1px solid var(--line); border-left:4px solid var(--line); border-radius:10px;
  padding:14px 16px; font-size:13px; line-height:1.65;
}
.result-note .rn-title{ font-weight:700; margin-bottom:6px; }
.result-note ul{ margin:8px 0 0; padding-left:18px; }
.result-note li{ margin-bottom:4px; }
.result-note li:last-child{ margin-bottom:0; }
.result-note.tone-ok{
  border-left-color:var(--state-ok);
  background:color-mix(in srgb, var(--state-ok) 8%, transparent);
}
.result-note.tone-warn{
  border-left-color:var(--state-warn);
  background:color-mix(in srgb, var(--state-warn) 8%, transparent);
}

/* S5 정산 내역 — 확정 / 잠정 구분 */
.settle-badge{
  display:inline-block; padding:2px 8px; border-radius:4px; font-size:11px; font-weight:700;
  letter-spacing:.02em; vertical-align:middle;
}
.settle-badge.confirmed{ background:var(--teal-bg); color:var(--teal); border:1px solid color-mix(in srgb, var(--teal) 35%, transparent); }
.settle-badge.provisional{ background:var(--amber-bg); color:var(--amber-bright); border:1px solid color-mix(in srgb, var(--amber-bright) 35%, transparent); }
.settle-badge.carry{ background:rgba(255,255,255,.04); color:var(--muted); border:1px solid var(--line); }
.panel.settle-provisional{
  border-color:color-mix(in srgb, var(--amber-bright) 45%, var(--line));
  background:color-mix(in srgb, var(--amber-bg) 35%, var(--panel));
}
.panel.settle-confirmed{
  border-color:color-mix(in srgb, var(--teal) 35%, var(--line));
}
.carry-neg-note{
  margin:0 0 12px; padding:10px 12px; border-radius:8px;
  background:var(--amber-bg); border:1px solid color-mix(in srgb, var(--amber-bright) 30%, var(--line));
  font-size:13px; line-height:1.55; color:var(--text);
}
.carry-neg-note .amt{ color:var(--amber-bright); font-weight:700; font-variant-numeric:tabular-nums; }
.tiny{ font-size:11px; line-height:1.4; }
.muted{ color:var(--muted); }
