:root {
  --bg: #08090e;
  --bg-elev: #0e1017;
  --text: #f3f5f8;
  --text-2: #c5cbd6;
  --muted: #9aa3b4;
  --line: rgba(255,255,255,.08);
  --line-2: rgba(255,255,255,.06);
  --fill: rgba(255,255,255,.035);
  --fill-2: rgba(255,255,255,.05);
  --violet: #8b7cf6;
  --cyan: #22d3ee;
  --green: #3ddc97;
  --green-text: #4ae3a4;
  --red: #f97171;
  --red-text: #ff8d8d;
  --amber: #f5c16c;
  --radius: 14px;
  --gap: 16px;
  --header-h: 64px;
  --shadow-cta: 0 8px 24px rgba(99, 72, 200, 0.32);
  /* Type scale — the only font-size values in this file */
  --fs-caption: 12px;
  --fs-body: 14px;
  --fs-body-lg: 16px;
  --fs-h4: 16px;
  --fs-h3: 20px;
  --fs-h2: 24px;
  --fs-h1: 32px;
  --fs-display: 48px;
  --fs-stat: 32px;
  --fs-stat-sm: 28px;
  --lh-body: 1.55;
  --lh-heading: 1.25;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 200;
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px;
  font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
.skip-link:focus, .skip-link:focus-visible { top: 12px; outline: 2px solid #a394f7; outline-offset: 2px; }
:focus { outline: none; }
:focus-visible {
  outline: 2px solid #a394f7;
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: rgba(139,124,246,.7);
  outline: 2px solid rgba(163,148,247,.85);
  outline-offset: 1px;
}
html { color-scheme: dark; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans TC", "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei", "Source Han Sans TC", sans-serif;
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100%;
}
h1 { font-size: var(--fs-h1); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.03em; }
h2 { font-size: var(--fs-h2); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.03em; }
h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.02em; }
h4 { font-size: var(--fs-h4); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.02em; }
.display { font-size: var(--fs-display); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.04em; }
.stat-num { font-size: var(--fs-stat); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.03em; }
.stat-num.sm { font-size: var(--fs-stat-sm); }
.stat-num .unit { font-size: var(--fs-body-lg); font-weight: var(--fw-medium); color: var(--muted); margin-left: 6px; letter-spacing: -0.01em; }
.metric-val .unit { font-size: var(--fs-caption); font-weight: var(--fw-medium); color: var(--muted); margin-left: 5px; }
.hero-val.tight, .stat-num.tight, .metric-val.tight { margin-top: 8px; }
.fw-semibold { font-weight: var(--fw-semibold); }
.metric-val { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.02em; }
body { overflow-x: hidden; }
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
a { color: #b4aafc; text-decoration: none; }
a:hover { color: #d0c9ff; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.ambient {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(900px 520px at 50% -10%, rgba(92, 74, 180, 0.14), transparent 70%);
}

/* Header */
header.app-header {
  height: var(--header-h);
  background: rgba(8,9,14,.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 36px;
  position: sticky; top: 0; z-index: 50; isolation: isolate;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 28px; color: inherit; flex-shrink: 0; }
.logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #22d3ee 0%, #7c6cf6 100%);
  display: grid; place-items: center;
}
.wordmark { font-weight: var(--fw-semibold); font-size: var(--fs-body-lg); letter-spacing: -0.03em; }
nav.main { display: flex; align-items: stretch; height: var(--header-h); gap: 1px; flex-wrap: nowrap; }
nav.main a {
  color: var(--muted); font-size: var(--fs-body); font-weight: var(--fw-medium);
  padding: 0 12px; display: flex; align-items: center; position: relative; white-space: nowrap;
}
nav.main a:hover { color: var(--text-2); }
nav.main a.active { color: var(--text); font-weight: var(--fw-semibold); }
nav.main a.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 0;
  height: 2px; background: var(--violet); border-radius: 2px 2px 0 0;
}
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; flex-shrink: 0; }
.lang {
  display: flex; background: var(--fill); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px; flex-shrink: 0; white-space: nowrap;
}
.lang button {
  background: transparent; border: 0; color: var(--muted);
  padding: 5px 8px; font-size: var(--fs-caption); font-weight: var(--fw-medium); border-radius: 999px;
  white-space: nowrap; flex-shrink: 0;
}
.lang button.on { background: var(--fill-2); color: var(--text); font-weight: var(--fw-semibold); }
.icon-btn {
  position: relative; width: 36px; height: 36px; display: grid; place-items: center;
  color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 10px;
}
.icon-btn:hover { color: var(--text); background: var(--fill); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px; width: 6px; height: 6px;
  background: var(--violet); border-radius: 50%;
}
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 3px 10px 3px 3px;
  border: 1px solid var(--line); border-radius: 999px; color: inherit; background: transparent;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #1c1f2c; color: var(--text-2);
  display: grid; place-items: center; font-size: var(--fs-caption); font-weight: var(--fw-semibold); flex-shrink: 0;
}
.user-meta { line-height: 1.25; padding-right: 4px; text-align: left; }
.user-meta .name { font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--text); }
.user-meta .mail { font-size: var(--fs-caption); color: var(--muted); }
.header-cta { display: flex; gap: 8px; align-items: center; }
.btn-menu { display: none; }
.mobile-nav {
  display: none; position: fixed; top: var(--header-h); left: 0; right: 0;
  background: rgba(10,11,18,.96); border-bottom: 1px solid var(--line);
  padding: 8px 16px 16px; z-index: 39; backdrop-filter: blur(16px);
}
.mobile-nav.open { display: flex; flex-direction: column; }
.mobile-nav a {
  color: var(--text-2); padding: 12px 8px; border-bottom: 1px solid var(--line-2); font-weight: var(--fw-medium);
}
.mobile-nav a.active { color: var(--text); }

/* Dropdowns */
.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 360px;
  background: #12141d; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.4); overflow: hidden; z-index: 2;
}
.dropdown-panel h3 {
  font-size: var(--fs-h4); font-weight: var(--fw-semibold); line-height: var(--lh-heading); padding: 14px 16px 10px; border-bottom: 1px solid var(--line);
}
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.notif-item:last-child { border-bottom: 0; }
.notif-item .t { font-size: var(--fs-body); color: var(--text); line-height: 1.4; }
.notif-item .s { font-size: var(--fs-caption); color: var(--muted); margin-top: 4px; }
.notif-item.unread { background: rgba(139,124,246,.06); }
.dropdown-empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: var(--fs-body); }
.user-menu { width: 220px; padding: 6px; }
.user-menu a, .user-menu button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  color: var(--text-2); padding: 10px 12px; border-radius: 8px; font-size: var(--fs-body);
}
.user-menu a:hover, .user-menu button:hover { background: var(--fill-2); color: var(--text); }

/* Layout */
main { position: relative; z-index: 0; }
.page { width: min(1440px, 100%); margin: 0 auto; padding: 28px 36px 48px; position: relative; z-index: auto; min-width: 0; }
.page, .page-mid, .page-narrow, .row, .row-main, .row-2, .row-3, .overview, .overview .zone, .panel, .card, .table-wrap, .addr-box, .bal-cards, .round-grid { min-width: 0; max-width: 100%; }
.page-narrow { width: min(480px, 100%); margin: 0 auto; padding: 48px 24px 80px; position: relative; z-index: auto; }
.page-mid { width: min(1120px, 100%); margin: 0 auto; padding: 28px 36px 48px; position: relative; z-index: auto; }

.hero-head, .page-head {
  display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.hero-head h1, .page-head h1 { font-size: var(--fs-h1); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.03em; }
.hero-head p, .page-head p, .sub { margin-top: 6px; font-size: var(--fs-body); line-height: var(--lh-body); color: var(--muted); }
.meta-row { display: flex; align-items: center; gap: 10px; font-size: var(--fs-body); color: var(--muted); flex-wrap: wrap; }
.pill, .pill-sample {
  font-size: var(--fs-caption); font-weight: var(--fw-semibold); letter-spacing: .02em; color: var(--text-2);
  background: var(--fill-2); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; display: inline-block;
}
.badge {
  font-size: var(--fs-caption); font-weight: var(--fw-semibold); letter-spacing: .04em; text-transform: uppercase;
  color: #9de8f5; background: rgba(34,211,238,.08); border: 1px solid rgba(34,211,238,.22);
  padding: 3px 8px; border-radius: 999px; display: inline-block;
}
.badge.ended, .badge.neutral { color: var(--muted); background: var(--fill-2); border-color: var(--line); }
.badge.warn { color: var(--amber); background: rgba(245,193,108,.1); border-color: rgba(245,193,108,.28); }
.badge.ok { color: var(--green-text); background: rgba(61,220,151,.1); border-color: rgba(61,220,151,.22); }
.badge.hold { color: var(--amber); background: rgba(245,193,108,.1); border-color: rgba(245,193,108,.28); }
.badge.void { color: var(--red-text); background: rgba(249,113,113,.1); border-color: rgba(249,113,113,.22); }

.panel, .card {
  background: rgba(16,18,27,.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; gap: 12px; flex-wrap: wrap; }
.card-h h2, .card-h h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.02em; }
.section-title { font-size: var(--fs-h2); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.03em; }
.card-h .hint { font-size: var(--fs-caption); color: var(--muted); }
.pad { padding: 22px 24px; }

.row { display: grid; gap: var(--gap); margin-bottom: var(--gap); }
.row-main { grid-template-columns: 1.7fr 1fr; }
.row-bottom { grid-template-columns: 1.9fr 1fr; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { display: grid; gap: var(--gap); grid-template-columns: 1fr 1fr 1fr; }

/* Overview hero */
.overview { display: grid; grid-template-columns: 1.15fr 1.15fr 0.95fr; margin-bottom: var(--gap); }
.overview .zone { padding: 22px 26px 24px; display: flex; flex-direction: column; justify-content: flex-start; position: relative; }
.overview .zone + .zone::before {
  content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 1px; background: var(--line);
}
.lbl { font-size: var(--fs-caption); font-weight: var(--fw-medium); color: var(--muted); }
.hero-val { font-size: var(--fs-stat); font-weight: var(--fw-semibold); letter-spacing: -0.03em; line-height: var(--lh-heading); margin-top: 16px; }
.hero-val .unit { font-size: var(--fs-body-lg); font-weight: var(--fw-medium); color: var(--muted); margin-left: 8px; letter-spacing: -0.01em; }
.hero-sub { margin-top: 10px; font-size: var(--fs-body); color: var(--muted); }
.hero-sub .up { color: var(--green-text); font-weight: var(--fw-semibold); }
.bal-head { font-size: var(--fs-caption); font-weight: var(--fw-medium); color: var(--muted); }
.bal-list { margin-top: 12px; }
.bal-row { display: flex; align-items: baseline; justify-content: space-between; padding: 9px 0; font-size: var(--fs-body); }
.bal-row + .bal-row { border-top: 1px solid var(--line-2); }
.bal-row .k { color: var(--muted); font-weight: var(--fw-medium); }
.bal-row .v { font-size: var(--fs-body-lg); font-weight: var(--fw-semibold); letter-spacing: -0.025em; }
.bal-row .v .u { font-size: var(--fs-caption); font-weight: var(--fw-medium); color: var(--muted); margin-left: 5px; }
.bal-foot { margin-top: 12px; font-size: var(--fs-caption); color: var(--muted); }

.chart-wrap { height: 292px; padding: 8px 16px 18px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* Sale */
.sale { padding: 22px 24px; display: flex; flex-direction: column; }
.sale-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sale-round { font-size: var(--fs-caption); color: var(--muted); font-weight: var(--fw-medium); }
.sale h3, .sale-top h2, .sale-top h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.02em; }
.price { font-size: var(--fs-stat); font-weight: var(--fw-semibold); letter-spacing: -0.03em; line-height: var(--lh-heading); margin: 12px 0 4px; }
.price .unit { font-size: var(--fs-body-lg); font-weight: var(--fw-medium); color: var(--muted); margin-left: 7px; }
.per { font-size: var(--fs-body); color: var(--muted); margin-bottom: 20px; }
.prog-label { display: flex; justify-content: space-between; font-size: var(--fs-body); margin-bottom: 8px; gap: 8px; }
.prog-label .left { font-weight: var(--fw-semibold); }
.prog-label .right { color: var(--muted); }
.bar { height: 7px; background: rgba(255,255,255,.07); border-radius: 999px; overflow: hidden; }
.bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #22d3ee, #8b7cf6);
  border-radius: 999px; box-shadow: 0 0 10px rgba(34,211,238,.35);
}
.bar.quiet > span { background: #8b7cf6; box-shadow: none; }
.cd-label { font-size: var(--fs-body); color: var(--muted); margin: 20px 0 8px; }
.cd { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 420px; }
.cd-cell {
  background: var(--fill); border: 1px solid var(--line); border-radius: 10px; text-align: center; padding: 9px 0 8px;
}
.cd-cell b { display: block; font-size: var(--fs-h3); font-weight: var(--fw-semibold); letter-spacing: -0.03em; line-height: var(--lh-heading); }
.cd-cell span { font-size: var(--fs-caption); color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }

/* Buttons */
.btn, .btn-buy, .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border: 0; border-radius: 10px;
  background: linear-gradient(90deg, #0e7490, #5b4ed1);
  color: #fff; font-size: var(--fs-body); font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-cta);
}
.btn-buy { margin-top: 20px; width: 100%; }
.btn:hover, .btn-buy:hover, .btn-primary:hover { filter: brightness(1.05); color: #fff; }
.btn:disabled, .btn-buy:disabled, .btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; box-shadow: none; }
.btn-secondary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: 10px; font-size: var(--fs-body); font-weight: var(--fw-semibold);
  background: var(--fill-2); color: var(--text); border: 1px solid var(--line); box-shadow: none;
}
.btn-secondary:hover, .btn-ghost:hover { background: rgba(255,255,255,.07); color: var(--text); }
.btn-danger { background: rgba(249,113,113,.12); color: var(--red-text); border: 1px solid rgba(249,113,113,.3); box-shadow: none; }
.btn-danger:hover { filter: none; background: rgba(249,113,113,.18); color: var(--red-text); }
.btn-sm { height: 36px; padding: 0 12px; font-size: var(--fs-body); border-radius: 8px; white-space: nowrap; }
.btn-block { width: 100%; }
.sale-note, .note { margin-top: 12px; font-size: var(--fs-caption); color: var(--muted); line-height: 1.55; }
.link { color: #b4aafc; font-weight: var(--fw-semibold); font-size: var(--fs-body); background: none; border: 0; padding: 0; }
.link:hover { color: #d0c9ff; }

/* Tables */
.table-wrap { overflow-x: auto; padding-bottom: 6px; width: 100%; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
thead th {
  text-align: left; font-size: var(--fs-caption); font-weight: var(--fw-medium); color: var(--muted);
  padding: 14px 18px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
thead th.r, td.r { text-align: right; }
tbody td {
  padding: 13px 18px; border-bottom: 1px solid var(--line-2); vertical-align: middle; color: var(--text-2);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: rgba(255,255,255,.02); }
.type { display: flex; align-items: center; gap: 10px; font-weight: var(--fw-medium); color: var(--text); white-space: nowrap; }
.ico {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--fill-2); border: 1px solid var(--line); color: var(--text-2);
}
.ico svg { width: 14px; height: 14px; }
.ico.in { color: var(--green-text); }
.td-sub { font-size: var(--fs-caption); color: var(--muted); margin-top: 2px; font-weight: var(--fw-regular); }
.amt-pos, .amt-neg { font-weight: var(--fw-semibold); white-space: nowrap; }
.amt-pos { color: var(--green-text); }
.amt-neg { color: var(--text); }
.time { color: var(--muted); white-space: nowrap; }
.st {
  display: inline-block; font-size: var(--fs-caption); font-weight: var(--fw-medium); color: var(--green-text);
  background: rgba(61,220,151,.08); padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.st.pending, .st.review { color: var(--amber); background: rgba(245,193,108,.1); }
.st.hold { color: var(--amber); background: rgba(245,193,108,.1); }
.st.void, .st.failed { color: var(--red-text); background: rgba(249,113,113,.1); }
.st.ok { color: var(--green-text); background: rgba(61,220,151,.1); }
.st.neutral { color: var(--muted); background: var(--fill-2); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
label.fl { display: flex; flex-direction: column; align-items: stretch; position: relative; }
label.fl > span, .fl-label { display: block; font-size: var(--fs-caption); font-weight: var(--fw-medium); color: var(--muted); margin-bottom: 6px; }
label.fl > input, label.fl > select, label.fl > textarea { flex: none; margin: 0; }
label.fl > .help, label.fl > .field-err { margin-top: 6px; }
/* Chrome may inject a password-manager node between a new-password input and its hint. */
label.fl > :not(span):not(input):not(select):not(textarea):not(.help):not(.field-err) {
  position: absolute !important; width: 0 !important; height: 0 !important; margin: 0 !important;
  padding: 0 !important; border: 0 !important; overflow: hidden !important; clip: rect(0,0,0,0) !important;
}
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 10px;
  background: var(--fill); border: 1px solid var(--line); color: var(--text); font-size: var(--fs-body); outline: none;
}
textarea { height: auto; padding: 10px 12px; min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(139,124,246,.55); }
input[type=date] {
  width: auto; min-width: 148px; height: 36px; color-scheme: dark;
}
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters label.fl { display: flex; align-items: center; gap: 8px; font-size: var(--fs-body); color: var(--muted); }
.input-row button, .addr-box button { flex-shrink: 0; white-space: nowrap; }
input.err, select.err { border-color: rgba(249,113,113,.7); }
.field-err { font-size: var(--fs-caption); color: var(--red-text); margin-top: 6px; }
.help { font-size: var(--fs-caption); color: var(--muted); margin-top: 6px; line-height: 1.45; }
.qty {
  display: flex; align-items: center; gap: 8px;
}
.qty button {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--fill-2); color: var(--text); font-size: var(--fs-h3); line-height: 1;
}
.qty input { width: 80px; text-align: center; height: 36px; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.auth-card { padding: 28px 28px 32px; }
.auth-card h1 { font-size: var(--fs-h1); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.03em; margin-bottom: 6px; }
.auth-card .lead { font-size: var(--fs-body); color: var(--muted); margin-bottom: 22px; line-height: 1.5; }
.demo-hint {
  margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: var(--fill);
  border: 1px dashed var(--line); font-size: var(--fs-caption); color: var(--muted); line-height: 1.55;
}
.demo-hint b { color: var(--text-2); font-weight: var(--fw-semibold); }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  width: min(520px, 100%); background: #12141d; border: 1px solid var(--line);
  border-radius: 16px; padding: 24px; max-height: min(90vh, 800px); overflow: auto; position: relative; z-index: 61;
}
.modal.wide { width: min(640px, 100%); }
.modal h2 { font-size: var(--fs-h2); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.03em; margin-bottom: 8px; }
.modal .lead { font-size: var(--fs-body); color: var(--muted); margin-bottom: 18px; line-height: 1.5; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: var(--fs-body); border-bottom: 1px solid var(--line-2); }
.kv .k { color: var(--muted); }
.kv .v { font-weight: var(--fw-semibold); text-align: right; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.success-mark {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(61,220,151,.12); color: var(--green-text); margin-bottom: 14px; font-size: var(--fs-h2);
}

/* Toast */
.toasts { position: fixed; bottom: 24px; right: 20px; z-index: 80; display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; }
.toast {
  min-width: 280px; max-width: 380px; background: #161822; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font-size: var(--fs-body); color: var(--text); box-shadow: 0 12px 32px rgba(0,0,0,.35);
  pointer-events: auto; cursor: pointer;
}
.toast.ok { border-color: rgba(61,220,151,.3); }
.toast.err { border-color: rgba(249,113,113,.4); }

/* Footer */
footer.app-footer {
  width: min(1440px, 100%); margin: 0 auto; padding: 8px 36px 32px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  font-size: var(--fs-caption); color: var(--muted); position: relative; z-index: 1;
}
footer.app-footer a { color: var(--muted); margin-right: 16px; }
footer.app-footer a:hover { color: var(--text-2); }

/* Landing */
.landing-hero { padding: 72px 36px 48px; width: min(1440px, 100%); margin: 0 auto; position: relative; z-index: 1; }
.landing-hero h1, .landing-hero .display {
  font-size: var(--fs-display); font-weight: var(--fw-semibold); letter-spacing: -0.04em; line-height: var(--lh-heading); max-width: 16ch;
}
.landing-hero .lead { margin-top: 16px; font-size: var(--fs-h3); color: var(--text-2); max-width: 42ch; line-height: 1.55; }
.landing-hero .actions { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 12px 0 32px; }
.step { padding: 22px; }
.step .n {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--fill-2); border: 1px solid var(--line); font-size: var(--fs-caption); font-weight: var(--fw-semibold); color: var(--text-2); margin-bottom: 14px;
}
.step h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-heading); margin-bottom: 8px; }
.step p { font-size: var(--fs-body); color: var(--muted); line-height: 1.55; }
.features { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 32px; }
.fees-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.feature { padding: 20px 22px; }
.feature h2, .feature h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-heading); margin-bottom: 6px; }
.feature p { font-size: var(--fs-body); color: var(--muted); line-height: 1.55; }

/* Wallet / misc */
.bal-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.bal-card { padding: 22px 24px; }
.bal-card .lbl { margin-bottom: 8px; }
.bal-card .val { font-size: var(--fs-stat); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: -0.03em; }
.bal-card .val .u { font-size: var(--fs-body-lg); color: var(--muted); font-weight: var(--fw-medium); margin-left: 6px; }
.bal-card .split { margin-top: 10px; font-size: var(--fs-caption); color: var(--muted); }
.addr-box {
  background: var(--fill); border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: var(--fs-body); word-break: normal;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-width: 0; max-width: 100%;
}
.addr-box > span, .addr-box > b { word-break: break-all; min-width: 0; }
.addr-box button { flex-shrink: 0; white-space: nowrap; word-break: normal; }
.qr-wrap {
  width: 168px; height: 168px; padding: 10px; background: #fff; border-radius: 12px; margin: 12px 0;
}
.qr-wrap svg { width: 100%; height: 100%; display: block; }
.warn-box {
  background: rgba(245,193,108,.08); border: 1px solid rgba(245,193,108,.25);
  color: #e8c48a; border-radius: 12px; padding: 12px 14px; font-size: var(--fs-body); line-height: 1.55; margin: 12px 0;
}
.info-box {
  background: var(--fill); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: var(--fs-body); color: var(--text-2); line-height: 1.55; margin: 12px 0;
}
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button {
  background: transparent; border: 0; color: var(--muted); padding: 10px 14px; font-size: var(--fs-body); font-weight: var(--fw-semibold);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--violet); }
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted); font-size: var(--fs-body); line-height: 1.55;
}
.empty h2, .empty h3 { color: var(--text); font-size: var(--fs-body-lg); margin-bottom: 6px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { height: 36px; width: auto; min-width: 140px; font-size: var(--fs-body); }
.share-card, .round-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; }
.round-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.tier-table td, .tier-table th { padding: 10px 14px; }
.tier-table tr.current td { background: rgba(139,124,246,.08); color: var(--text); }
.expand { background: rgba(255,255,255,.015); }
.expand td { padding: 0 18px 14px 18px; }
.hour-row { font-size: var(--fs-caption); color: var(--text-2); padding: 6px 0; display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line-2); }
.banner {
  background: rgba(139,124,246,.08); border: 1px solid rgba(139,124,246,.22);
  border-radius: 12px; padding: 12px 14px; font-size: var(--fs-body); color: var(--text-2); line-height: 1.55; margin-bottom: 16px;
}
.info-box.notice-subtle {
  background: transparent; border: 1px solid var(--line);
  color: var(--muted); font-size: var(--fs-body); margin-bottom: 10px;
}
.action-disabled {
  display: inline-block;
  font-size: var(--fs-body);
  color: var(--muted);
  line-height: var(--lh-body);
  max-width: 16rem;
  white-space: pre-line;
  text-align: right;
  overflow-wrap: normal;
}

/* Prototype control (header) */
.proto-chip {
  height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px dashed rgba(255,255,255,.22); background: transparent;
  color: var(--muted); font-size: var(--fs-caption); font-weight: var(--fw-semibold); letter-spacing: .06em;
  text-transform: uppercase;
}
.proto-chip:hover { color: var(--text); border-color: rgba(255,255,255,.35); }
.proto-drop { position: relative; }
.proto-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 70;
  width: 280px; background: #12141d; border: 1px dashed rgba(255,255,255,.2);
  border-radius: 14px; padding: 12px; font-size: var(--fs-body); color: var(--text-2);
  box-shadow: 0 12px 32px rgba(0,0,0,.4);
}
.proto-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.proto-panel h4 { font-size: var(--fs-caption); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.proto-panel p { font-size: var(--fs-caption); color: var(--muted); margin-bottom: 8px; line-height: var(--lh-body); }
.proto-panel > button {
  width: 100%; height: 36px; margin-top: 6px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--fill-2); color: var(--text); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
.proto-toggle { background: transparent; border: 0; color: var(--text); font-weight: var(--fw-semibold); font-size: var(--fs-caption); padding: 0; width: auto; height: auto; }

/* Tighten header chrome at ~1280 without shrinking type below tokens */
@media (max-width: 1360px) {
  header.app-header { padding: 0 20px; }
  .brand { margin-right: 16px; }
  nav.main a { padding: 0 8px; }
  nav.main a.active::after { left: 8px; right: 8px; }
  .header-right { gap: 8px; }
  .user-chip { gap: 8px; padding: 3px 8px 3px 3px; }
}

/* Responsive */
@media (max-width: 1100px) {
  header.app-header { padding: 0 16px; }
  nav.main { display: none; }
  .btn-menu { display: grid; }

  .header-right .lang, .header-right .proto-drop { display: none; }
  .mobile-tools { display: flex; flex-direction: column; gap: 12px; padding: 16px 4px 8px; border-top: 1px solid var(--line); margin-top: 8px; }
  .mobile-tools .proto-drop { display: block; }
  .mobile-tools .proto-chip { width: 100%; border-radius: 10px; height: 36px; }
  .mobile-tools .proto-panel { position: static; width: 100%; margin-top: 8px; }
  .user-meta { display: none; }
  .page, .page-mid, .landing-hero, footer.app-footer { padding-left: 16px; padding-right: 16px; }
  .overview { grid-template-columns: 1fr; }
  .overview .zone + .zone::before { top: 0; bottom: auto; right: 18px; left: 18px; width: auto; height: 1px; }
  .row-main, .row-bottom, .row-2, .row-3, .bal-cards, .steps, .features, .round-grid { grid-template-columns: 1fr; }
  :root { --fs-display: 36px; }
  .landing-hero { padding-top: 40px; }
  .dropdown-panel { width: min(360px, calc(100vw - 24px)); }
}
@media (max-width: 640px) {
  :root { --fs-display: 32px; --fs-stat: 28px; }
  .btn, .btn-buy, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-sm,
  .icon-btn, .lang button, .proto-chip, .qty button,
  input, select, textarea, .input-row button, .addr-box button {
    min-height: 44px; height: 44px;
  }
  .icon-btn { width: 44px; min-width: 44px; }
  .qty button { width: 44px; }
  thead th, tbody td { padding-left: 10px; padding-right: 10px; }
  .action-disabled { max-width: none; }
  .chart-wrap { height: 220px; }
  .toasts { left: 12px; right: 12px; bottom: auto; top: 72px; flex-direction: column; }
  .toast { max-width: none; min-width: 0; }
  .proto-panel { right: 0; left: auto; width: min(260px, calc(100vw - 24px)); }
  .modal { padding: 18px; }
  .auth-card { padding: 22px 18px; }
}


/* Click-test polish: actions, ledger cards, live validation */
.field-err:empty { display: none; margin: 0; }
.shares-table { font-size: var(--fs-body); }
.actions-cell { white-space: nowrap; min-width: 11.5rem; vertical-align: middle; }
.row-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  white-space: normal;
}
.row-actions-btns {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.nowrap { white-space: nowrap; }
input.err, .qty input.err { border-color: var(--red, #f87171); }
button[disabled], .btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.ledger-list { display: none; }
.ledger-card {
  background: var(--panel, var(--fill));
  border: 1px solid var(--line);
  border-radius: var(--radius, 14px);
  padding: 12px 14px;
}
.ledger-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ledger-card-amt { font-size: var(--fs-body-lg); font-weight: var(--fw-semibold); text-align: right; flex-shrink: 0; }
.ledger-card-amt .num { white-space: nowrap; }
.ledger-card-details { color: var(--muted); font-size: var(--fs-body); margin-top: 6px; line-height: var(--lh-body); }
.ledger-card-time { margin-top: 4px; font-size: var(--fs-caption); color: var(--muted); }
.amt-col .num { white-space: nowrap; }

.deposit-list { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 16px; }
.txid-break, .txid-break .num { overflow-wrap: anywhere; word-break: break-all; }
.shares-list { display: none; }
.shares-card-dl {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 10px 0 8px;
}
.shares-card-dl dt { font-size: var(--fs-caption); color: var(--muted); font-weight: var(--fw-medium); }
.shares-card-dl dd { font-weight: var(--fw-semibold); }

@media (max-width: 640px) {
  .ledger-list { display: flex; flex-direction: column; gap: 10px; }
  .ledger-table { display: none; }
  .actions-cell, .row-actions { min-width: 0; }
  .shares-list { display: flex; flex-direction: column; gap: 10px; }
  .shares-table-panel { display: none; }
  .shares-card-actions, .shares-card-actions .row-actions-btns {
    align-items: flex-start; justify-content: flex-start;
  }
}
