/* Xenyst Pulse */
:root {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --panel: #f1f1f3;
  --ink: #0d0d12;
  --text: #24242c;
  --muted: #6b6b78;
  --faint: #a0a0ad;
  --line: #e5e5ea;
  --line-soft: #efeff3;
  --accent: #3b3fd8;
  --accent-2: #2f33c4;
  --accent-soft: #eeeffd;
  --accent-ink: #2f33c4;
  --on-accent: #ffffff;
  --ok: #138a55; --ok-soft: #e6f6ee;
  --warn: #a8650b; --warn-soft: #fdf3e2;
  --bad: #c2343f; --bad-soft: #fcebec;
  --code-bg: #121319; --code-text: #d9dbe8; --code-line: #23242e;
  --shadow-sm: 0 1px 2px rgb(15 15 25 / 5%), 0 2px 6px rgb(15 15 25 / 4%);
  --shadow: 0 1px 2px rgb(13 13 18 / 4%), 0 18px 48px rgb(59 63 216 / 8%);
  --shadow-pop: 0 2px 6px rgb(15 15 25 / 6%), 0 30px 80px rgb(20 22 60 / 22%);
  --radius: 22px; --radius-sm: 14px;
  --sidebar: 244px;
  color-scheme: light;
  font-family: Figtree, Anuphan, Prompt, "Leelawadee UI", Tahoma, system-ui, sans-serif;
  font-size: 14.5px; line-height: 1.6; color: var(--text);
  -webkit-font-smoothing: antialiased;
}
:root[data-theme=dark] {
  --bg: #08080c;
  --surface: #121219;
  --surface-2: #181821;
  --panel: #16161e;
  --ink: #f3f3f7;
  --text: #dcdce4;
  --muted: #9797a6;
  --faint: #6b6b7a;
  --line: #262630;
  --line-soft: #1e1e27;
  --accent: #7175ff;
  --accent-2: #8487ff;
  --accent-soft: rgb(113 117 255 / 14%);
  --accent-ink: #a3a6ff;
  --on-accent: #ffffff;
  --ok: #3ccf8b; --ok-soft: rgb(60 207 139 / 12%);
  --warn: #f0b555; --warn-soft: rgb(240 181 85 / 12%);
  --bad: #ff6b74; --bad-soft: rgb(255 107 116 / 12%);
  --code-bg: #0b0b10; --code-text: #d9dbe8; --code-line: #1f2029;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 18px 48px rgb(0 0 0 / 30%);
  --shadow-pop: 0 30px 80px rgb(0 0 0 / 60%);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; color: var(--ink); }
h2 { font-size: 16.5px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
h3 { font-size: 14.5px; font-weight: 600; color: var(--ink); }
a { color: var(--accent-ink); text-decoration: none; }
code, pre, .mono { font-family: "JetBrains Mono", Consolas, ui-monospace, monospace; }
code { font-size: 12.5px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); padding: 1px 7px; border-radius: 7px; overflow-wrap: anywhere; }
small, .muted { color: var(--muted); }
small { font-size: 12.5px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: var(--accent-soft); }

/* Buttons */
button, .btn {
  font: inherit; font-weight: 600; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
button:hover, .btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--line) 60%, var(--muted)); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 2px; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgb(13 13 18 / 10%), 0 6px 16px color-mix(in srgb, var(--accent) 28%, transparent); }
.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.danger { color: var(--bad); }
.danger:hover { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.primary.danger, button.solid-danger { background: var(--bad); border-color: var(--bad); color: #fff; box-shadow: none; }
.primary.danger:hover { background: color-mix(in srgb, var(--bad) 88%, #000); }
.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.ghost:hover { background: var(--surface-2); border-color: transparent; }
.sm { min-height: 32px; padding: 0 11px; font-size: 13px; border-radius: 10px; gap: 6px; }
.sm .icon { width: 15px; height: 15px; }
.lg { min-height: 48px; font-size: 15px; border-radius: 14px; }
.link { border: 0; background: none; box-shadow: none; padding: 0; min-height: 0; color: var(--accent-ink); font-weight: 600; font-size: 13.5px; }
.link:hover { background: none; color: var(--accent); text-decoration: underline; }
.block { width: 100%; }
.busy { pointer-events: none; opacity: .65; }
.icon-btn { width: 40px; padding: 0; }
.icon-btn.sm { width: 32px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 16px; }
.optional { font-weight: 400; color: var(--faint); margin-left: 4px; }
input, select, textarea {
  font: inherit; font-size: 14.5px; display: block; width: 100%; margin-top: 7px;
  min-height: 44px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; padding-right: 40px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a98' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; }
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
input[type=number] { appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
label small { display: block; font-weight: 400; margin-top: 6px; line-height: 1.55; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.error { color: var(--bad); font-size: 13px; min-height: 0; }
.error:empty { display: none; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; pointer-events: none; }
.input-icon input { margin: 0; padding-left: 38px; min-height: 38px; border-radius: 11px; font-size: 13.5px; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 15.5px; letter-spacing: -.01em; }
.brand b { font-weight: 700; }
.brand-name { font-weight: 500; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #5458f0, #2f33c4); box-shadow: inset 0 1px 0 rgb(255 255 255 / 25%), 0 4px 12px rgb(59 63 216 / 30%); }
.brand-mark .icon { width: 18px; height: 18px; stroke-width: 2.6; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-shell { width: min(980px, 100%); display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 32px; box-shadow: var(--shadow); overflow: hidden; }
.login-hero { position: relative; padding: 40px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px; overflow: hidden; }
.login-hero::after { content: ""; position: absolute; inset: auto -80px -120px auto; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%); }
.login-hero h2 { margin-top: 40px; font-size: 36px; line-height: 1.2; letter-spacing: -.02em; font-weight: 600; }
.login-hero h2 span { color: var(--faint); }
.login-hero p { color: var(--muted); max-width: 380px; line-height: 1.75; }
.login-points { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; position: relative; z-index: 1; }
.login-points li { display: flex; align-items: center; gap: 12px; font-weight: 500; color: var(--ink); }
.login-points .icon { width: 34px; height: 34px; padding: 8px; border-radius: 11px; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.login-card { position: relative; padding: 48px 44px; display: flex; flex-direction: column; justify-content: center; }
.login-card h1 { font-size: 28px; }
.login-card .muted { margin: 6px 0 28px; }
.login-card .theme-toggle { position: absolute; top: 18px; right: 18px; }

/* Shell */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 14px; padding: 20px 14px 16px; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; z-index: 40; }
.sidebar > * { flex-shrink: 0; }
.sidebar > :empty { display: none; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px; }
.sidebar-close { display: none; }
.new-btn { min-height: 42px; }
#nav { display: grid; gap: 2px; }
.nav-label { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 12px 12px 4px; }
.nav-label:first-child { padding-top: 0; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; color: var(--muted); font-weight: 500; font-size: 14px; transition: background .15s, color .15s; }
#nav a:hover { background: var(--surface-2); color: var(--ink); }
#nav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
#nav a .count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 99px; display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 700; background: var(--warn-soft); color: var(--warn); }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.status-card { display: grid; gap: 8px; padding: 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.status-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.status-line span:last-child { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.foot-row { display: flex; justify-content: space-between; gap: 6px; }
.foot-row .sm { flex: 1; }
.topbar { display: none; }
.scrim { position: fixed; inset: 0; background: rgb(8 8 12 / 45%); backdrop-filter: blur(2px); z-index: 35; }
main { min-width: 0; padding: 36px 40px 64px; }
#content { max-width: 1240px; margin: 0 auto; display: grid; gap: 20px; outline: 0; }

/* Page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 640px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow-sm); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 20px 24px 14px; margin: 0; }
.card.soft { background: var(--panel); box-shadow: none; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.card > p, .prose { color: var(--muted); line-height: 1.75; }
.card > p + p { margin-top: 10px; }
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.stack { display: grid; gap: 14px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); min-width: 0; }
.stat-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; margin-top: 12px; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-value small { font-size: 13px; font-weight: 500; margin-left: 4px; }
.stat > small { display: block; margin-top: 6px; }
.chip { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); flex: none; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.lg { width: 48px; height: 48px; border-radius: 15px; }
.chip.lg .icon { width: 22px; height: 22px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; line-height: 1.6; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.badge.plain::before { display: none; }
.ok-text { color: var(--ok); display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.warn-text { color: var(--warn); }
.error-text { display: block; color: var(--bad); font-size: 12px; margin-top: 4px; }

/* Toolbar & segmented control */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 0 24px 16px; }
.toolbar .input-icon { flex: 1; min-width: 200px; max-width: 320px; margin-left: auto; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button { min-height: 30px; padding: 0 12px; border: 0; background: transparent; box-shadow: none; color: var(--muted); font-size: 13px; font-weight: 600; border-radius: 9px; }
.seg button:hover { color: var(--ink); background: transparent; }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg button .n { font-size: 11.5px; color: var(--faint); font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 10px 16px; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--text); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td strong { color: var(--ink); font-weight: 600; }
td small { display: block; margin-top: 1px; }
td .actions { justify-content: flex-end; flex-wrap: nowrap; }
.money { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.table-foot { padding: 12px 24px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12.5px; }

/* Empty, callout, notice */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 44px 20px; color: var(--muted); text-align: center; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); font-size: 13.5px; line-height: 1.7; }
.callout > .icon { color: var(--warn); margin-top: 2px; }
.callout.info { background: var(--accent-soft); }
.callout.info > .icon { color: var(--accent-ink); }
.callout.bad { background: var(--bad-soft); }
.callout.bad > .icon { color: var(--bad); }
.callout.ok { background: var(--ok-soft); }
.callout.ok > .icon { color: var(--ok); }
.callout .actions { margin-top: 8px; }
.banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); flex-wrap: wrap; }
.banner > div { flex: 1; min-width: 200px; }
.banner strong { display: block; color: var(--ink); }
.banner small { display: block; }

/* Code */
pre { margin: 0; background: var(--code-bg); color: var(--code-text); padding: 18px 20px; border-radius: 0 0 16px 16px; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; line-height: 1.8; }
.code { border-radius: 16px; overflow: hidden; border: 1px solid var(--code-line); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 4%); }
.code-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; background: var(--code-bg); border-bottom: 1px solid var(--code-line); color: #8d8fa3; font-size: 12px; font-weight: 600; }
.code-head .dots { display: inline-flex; gap: 6px; }
.code-head .dots i { width: 9px; height: 9px; border-radius: 50%; background: #2c2d39; }
.code-head button { margin-left: auto; background: transparent; border-color: #2c2d39; color: #c5c7d6; box-shadow: none; }
.code-head button:hover { background: #1d1e28; border-color: #3a3b48; }
.code + p, .code + .callout, p + .code { margin-top: 14px; }

/* Key/value list */
.kv { display: grid; }
.kv > div { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.kv > div:last-child { border-bottom: 0; }
.kv > div > span:first-child { color: var(--muted); flex: none; }
.kv > div > :last-child { text-align: right; overflow-wrap: anywhere; min-width: 0; }
.copy-field { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.copy-field code { flex: 1; background: none; border: 0; padding: 0; font-size: 12.5px; min-width: 0; }

/* Checklist & progress */
.progress { height: 8px; border-radius: 9px; background: var(--line-soft); overflow: hidden; margin: 4px 0 14px; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #8a6bff); }
.checklist { display: grid; gap: 4px; }
.checklist a { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 12px; color: var(--text); }
.checklist a:hover { background: var(--surface-2); }
.checklist strong { display: block; color: var(--ink); font-weight: 600; font-size: 13.5px; }
.checklist small { display: block; line-height: 1.45; }
.checklist .tick { width: 24px; height: 24px; border-radius: 50%; border: 1.5px dashed var(--faint); display: grid; place-items: center; flex: none; color: transparent; }
.checklist .done .tick { border: 0; background: var(--ok); color: #fff; }
.checklist .done .tick .icon { width: 14px; height: 14px; stroke-width: 3; }
.checklist .done strong { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.checklist .go { margin-left: auto; color: var(--faint); width: 16px; height: 16px; }

/* Bar chart */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 190px; padding-top: 10px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar i { display: block; width: 100%; max-width: 44px; min-height: 4px; border-radius: 10px 10px 6px 6px; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #8a6bff)); transition: height .4s ease; }
.bar.zero i { background: var(--line); }
.bar span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.bar b { font-size: 11px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-total { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.chart-total strong { font-size: 24px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; }

/* Accounts */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.account-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); display: grid; gap: 14px; align-content: start; }
.account-top { display: flex; gap: 12px; align-items: flex-start; }
.account-top > div { flex: 1; min-width: 0; }
.account-top strong { display: block; color: var(--ink); font-size: 15px; font-weight: 600; }
.account-top small { display: block; overflow-wrap: anywhere; }
.steps { display: grid; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.step { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.step .icon { width: 16px; height: 16px; }
.step.done { color: var(--ok); }
.step.now { color: var(--ink); font-weight: 600; }
.bind-list { display: grid; gap: 8px; }
.bind-list button { white-space: normal; text-align: left; justify-content: flex-start; line-height: 1.5; padding: 8px 12px; height: auto; }
.account-card .actions { border-top: 1px solid var(--line-soft); padding-top: 12px; }
.add-card { border: 1.5px dashed var(--line); background: transparent; box-shadow: none; min-height: 200px; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--muted); border-radius: var(--radius); font-weight: 600; white-space: normal; }
.add-card:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.reqs { display: grid; gap: 6px; margin-top: 14px; }
details.advanced summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 18px 24px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced summary .icon { transition: transform .2s; }
details.advanced[open] summary .icon { transform: rotate(180deg); }
details.advanced summary:hover { color: var(--ink); }

/* 2FA */
.qr { display: block; width: 180px; height: 180px; padding: 10px; border-radius: 16px; background: #fff; border: 1px solid var(--line); }

/* Dialog */
dialog { width: 480px; max-width: calc(100% - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; border: 1px solid var(--line); border-radius: 26px; padding: 28px; box-shadow: var(--shadow-pop); color: var(--text); background: var(--surface); }
dialog.wide { width: 680px; }
dialog::backdrop { background: rgb(8 8 12 / 50%); backdrop-filter: blur(4px); }
dialog[open] { animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.dialog-head > div { flex: 1; min-width: 0; }
.dialog-head h2 { font-size: 19px; line-height: 1.4; }
.dialog-head p { color: var(--muted); margin-top: 4px; line-height: 1.65; font-size: 13.5px; }
.dialog-head .x { margin: -6px -8px 0 0; }
dialog .actions.end { margin-top: 22px; }
dialog pre { max-height: 50vh; overflow: auto; border-radius: 14px; }
.big-amount { text-align: center; padding: 22px; border-radius: 18px; background: var(--panel); margin-bottom: 16px; }
.big-amount span { display: block; color: var(--muted); font-size: 13px; }
.big-amount strong { display: block; font-size: 38px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; line-height: 1.3; font-variant-numeric: tabular-nums; }

/* Toast */
#toast { position: fixed; bottom: 24px; right: 24px; z-index: 100; display: flex; gap: 10px; align-items: flex-start; max-width: min(420px, calc(100% - 32px)); padding: 14px 18px; background: var(--ink); color: var(--bg); border-radius: 16px; box-shadow: var(--shadow-pop); font-size: 13.5px; line-height: 1.55; font-weight: 500; animation: pop .2s ease; }
#toast .icon { color: #5fe0a8; margin-top: 1px; }
#toast.bad .icon { color: #ff8a92; }

/* LINE connect dialog (line-modal.js): plain QR, numbered steps, one status line */
dialog.line-dialog { width: min(440px, calc(100vw - 32px)); padding: 30px 32px 22px; text-align: center; }
.line-dialog h2 { margin: 0 0 20px; font-size: 18px; }
.line-close { position: absolute; right: 14px; top: 14px; padding: 0; min-height: 32px; width: 32px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted); box-shadow: var(--shadow-sm); }
.line-close svg { width: 15px; height: 15px; }
.line-intro { color: var(--muted); margin: 0 0 18px; }
.line-consent { display: grid; gap: 14px; text-align: left; }
.line-consent label, .line-consent .error { margin: 0; }
.line-stage { display: flex; flex-direction: column; align-items: center; }
.line-visual { display: grid; place-items: center; min-height: 212px; width: 100%; }
.line-qr { position: relative; width: 208px; height: 208px; display: grid; place-items: center; border-radius: 14px; background: #fff; overflow: hidden; }
.line-qr img, .line-qr-ghost { width: 100%; height: 100%; object-fit: contain; transition: filter .5s ease, opacity .5s ease; }
.line-qr img { animation: qr-in .45s ease both; }
.line-qr-ghost { display: block; border-radius: 10px; background: linear-gradient(110deg, var(--line-soft) 30%, var(--surface-2) 50%, var(--line-soft) 70%) 0 0 / 220% 100%; animation: shimmer 1.4s linear infinite; }
:root[data-theme=dark] .line-qr { background: #fff; }
.line-qr.has-pin img, .line-qr.has-pin .line-qr-ghost { filter: blur(5px); opacity: .28; }
.line-pin-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; animation: fade .35s ease both; }
.line-pin-label { color: #55555f; font-size: 13px; font-weight: 500; }
.line-pin { display: flex; gap: 6px; color: #121218; font-size: 36px; font-weight: 700; letter-spacing: 0; font-variant-numeric: tabular-nums; line-height: 1.15; }
.line-pin span { display: inline-block; min-width: .62em; animation: digit .4s cubic-bezier(.2, .8, .2, 1) both; }
.line-pin span:nth-child(2) { animation-delay: .05s; } .line-pin span:nth-child(3) { animation-delay: .1s; } .line-pin span:nth-child(4) { animation-delay: .15s; }
.line-pin span:nth-child(5) { animation-delay: .2s; } .line-pin span:nth-child(6) { animation-delay: .25s; } .line-pin span:nth-child(n+7) { animation-delay: .3s; }
.line-steps { margin: 22px 0 0; padding: 0 0 0 22px; text-align: left; color: var(--text); font-size: 13.5px; line-height: 1.95; align-self: stretch; max-width: 320px; margin-inline: auto; }
.line-stage[data-view=success] .line-steps, .line-stage[data-view=error] .line-steps { display: none; }
.line-state { display: inline-flex; align-items: center; gap: 10px; margin-top: 16px; }
.line-dot { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
.line-stage[data-view=success] .line-dot, .line-stage[data-view=error] .line-dot { display: none; }
.line-status { margin: 0; color: var(--text); font-size: 14px; font-weight: 500; }
.line-stage[data-view=success] .line-status, .line-stage[data-view=error] .line-status { font-size: 16px; font-weight: 600; color: var(--ink); }
.line-hint { margin-top: 4px; font-size: 13px; color: var(--muted); }
.line-hint:empty { display: none; }
.line-retry { margin-top: 16px; }
.line-cancel { display: flex; margin: 12px auto 0; background: transparent; border: 0; box-shadow: none; color: var(--muted); font-weight: 500; }
.line-cancel:hover { background: var(--surface-2); color: var(--ink); }
.line-error-icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--bad-soft); color: var(--bad); font-size: 28px; font-weight: 700; animation: shake .45s .05s ease both; }
.line-success { display: grid; place-items: center; width: 80px; height: 80px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); animation: line-pop .45s cubic-bezier(.2, .9, .3, 1.3) both; }
.line-success svg { width: 62px; height: 62px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.line-success svg circle { opacity: .2; }
.line-success svg path { stroke-dasharray: 34; stroke-dashoffset: 34; animation: line-draw .4s .2s ease forwards; }
@keyframes qr-in { from { opacity: 0; transform: scale(.96); } }
@keyframes shimmer { to { background-position: -220% 0; } }
@keyframes digit { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
@keyframes line-pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes line-draw { to { stroke-dashoffset: 0; } }

/* Profile switch (Sandbox / live) */
.env-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.env-seg button { min-height: 34px; padding: 0 8px; border: 0; background: transparent; box-shadow: none; color: var(--muted); font-size: 13px; border-radius: 11px; gap: 6px; }
.env-seg button .icon { width: 15px; height: 15px; }
.env-seg button:hover { background: transparent; color: var(--ink); }
.env-seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
:root[data-env=test] .env-seg button[aria-pressed=true] { color: var(--warn); }
:root[data-env=live] .env-seg button[aria-pressed=true] { color: var(--ok); }
.env-bar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; max-width: 1240px; margin: -12px auto 20px; padding: 8px 16px; border-radius: 12px; background: var(--warn-soft); color: var(--text); font-size: 13px; text-align: center; }
.env-bar > span { display: inline-flex; align-items: center; gap: 8px; }
.env-bar .icon { color: var(--warn); width: 16px; height: 16px; }
.env-bar b { color: var(--warn); }
.env-pill { min-height: 34px; padding: 0 12px; border-radius: 99px; font-size: 12.5px; gap: 6px; box-shadow: none; }
.env-pill .icon { width: 14px; height: 14px; }
:root[data-env=test] .env-pill { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
:root[data-env=live] .env-pill { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.topbar-end { display: flex; align-items: center; gap: 8px; }

/* Dashboard hub (LINE + live/sandbox) */
.grid.hub { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
.hub-card { display: flex; flex-direction: column; gap: 16px; }
.hub-top { display: flex; align-items: flex-start; gap: 14px; }
.hub-top > div { flex: 1; min-width: 0; }
.hub-top h2 { font-size: 16.5px; }
.hub-top small { display: block; margin-top: 2px; line-height: 1.5; }
.hub-actions { margin-top: auto; }
.hub-actions small { flex: 1 1 160px; }
.hub-card.sandbox { background: linear-gradient(160deg, color-mix(in srgb, var(--warn-soft) 70%, var(--surface)), var(--surface) 60%); }
.mini-steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 8px; }
.mini-steps li { counter-increment: s; display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text); }
.mini-steps li::before { content: counter(s); width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); }
.mini-kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mini-kv span { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 12px; color: var(--muted); }
.mini-kv strong { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.reqs { margin-top: 0; }
.reqs .step { padding: 8px 10px; border-radius: 10px; color: var(--muted); }
.reqs .step:hover { background: var(--surface-2); }
.reqs .step.done { color: var(--ok); }
.step span { min-width: 0; }

/* Cards & misc polish */
.card.flush > .toolbar:first-child { padding-top: 18px; }
.card-actions { display: flex; }
.push { margin-left: auto; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.6; }
.nowrap { white-space: nowrap; }
.add-card small { font-weight: 400; color: var(--faint); }
.add-card .chip { margin: 0 auto; }
.banner .btn, .banner button { flex: none; }
.page-head > div:first-child { min-width: 0; }

/* Small spacing utilities used by dialogs */
.note { margin-top: 14px; font-size: 12.5px; line-height: 1.6; }
.note.top { margin: 0 0 16px; }
label.cap { margin: 14px 0 8px; }
label.cap:first-child { margin-top: 0; }
.gap { height: 16px; }
.card > p + .actions, .card > p + form, .card > .kv + .actions { margin-top: 16px; }

/* ---------- Responsive ---------- */
/* Wide screens: give content room, keep line length sane */
@media (min-width: 1600px) {
  #content, .env-bar { max-width: 1360px; }
  main { padding: 44px 56px 72px; }
}
/* Laptop */
@media (max-width: 1280px) {
  :root { --sidebar: 224px; }
  main { padding: 32px 28px 56px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid.wide-left, .grid.hub { grid-template-columns: 1fr; }
  .grid.two { grid-template-columns: 1fr; }
}
/* Tablet: sidebar becomes a drawer */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
  .topbar .brand-name { white-space: nowrap; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(304px, 86vw); transform: translateX(-102%); transition: transform .22s ease, visibility .22s; visibility: hidden; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .sidebar.open { transform: none; visibility: visible; box-shadow: var(--shadow-pop); }
  .sidebar-close { display: inline-flex; }
  main { padding: 24px 20px 56px; }
  .env-bar { margin: -8px auto 16px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .stat { padding: 16px; }
  .stat .chip { width: 30px; height: 30px; border-radius: 10px; }
  .stat .chip .icon { width: 16px; height: 16px; }
  .stat-value { font-size: 22px; }
  h1 { font-size: 26px; }
}
@media (max-width: 820px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; border-radius: 26px; }
  .login-hero { display: none; }
  .login-card { padding: 44px 24px 32px; }
}
/* Phone */
@media (max-width: 600px) {
  :root { font-size: 14px; }
  main { padding: 18px 14px 48px; }
  #content { gap: 14px; }
  h1 { font-size: 23px; }
  .page-head { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 2px; }
  .page-head .actions { width: 100%; }
  .page-head .actions > * { flex: 1; }
  .hide-sm { display: none !important; }
  .card { padding: 18px 16px; border-radius: 20px; }
  .card.flush > .card-head { padding: 16px 16px 10px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; border-radius: 18px; }
  .stat-top { font-size: 12px; }
  .stat .chip { display: none; }
  .stat-value { font-size: 20px; margin-top: 6px; }
  .stat > small { font-size: 11.5px; line-height: 1.4; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { padding: 0 16px 12px; gap: 8px; }
  .card.flush > .toolbar:first-child { padding-top: 14px; }
  .toolbar .seg { width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .toolbar .seg::-webkit-scrollbar { display: none; }
  .toolbar .seg button { flex: none; }
  .toolbar .input-icon { max-width: none; margin-left: 0; flex-basis: 100%; }
  th:first-child, td:first-child { padding-left: 16px; }
  th:last-child, td:last-child { padding-right: 16px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 660px; }
  td { white-space: nowrap; }
  .table-foot { padding: 10px 16px; }
  .account-grid { grid-template-columns: 1fr; }
  .account-card { padding: 16px; border-radius: 20px; }
  .banner { padding: 12px 14px; gap: 12px; border-radius: 16px; }
  .banner > div { min-width: 0; flex-basis: calc(100% - 60px); }
  .banner .btn, .banner > button { width: 100%; }
  .hub-top .badge { display: none; }
  .mini-kv strong { font-size: 14px; }
  .hub-actions > button, .hub-actions > a { flex: 1; }
  .bars { gap: 6px; height: 150px; }
  .bar b { display: none; }
  .bar span { font-size: 10.5px; white-space: normal; text-align: center; line-height: 1.3; }
  .chart-total strong { font-size: 20px; }
  .kv > div { flex-direction: column; align-items: flex-start; gap: 2px; }
  .kv > div > :last-child { text-align: left; }
  .code-head > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  pre { padding: 14px; font-size: 11.5px; }
  /* Dialogs become bottom sheets */
  dialog, dialog.wide { width: 100%; max-width: 100%; margin: auto 0 0; padding: 22px 16px max(18px, env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; max-height: 92dvh; border-bottom: 0; }
  dialog[open] { animation: sheet .22s ease; }
  dialog .actions.end > * { flex: 1; }
  .big-amount strong { font-size: 32px; }
  dialog.line-dialog { width: 100%; padding: 30px 18px max(22px, env(safe-area-inset-bottom)); }
  #toast { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); max-width: none; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
/* Very small phones */
@media (max-width: 360px) {
  .stats { grid-template-columns: 1fr; }
  .topbar .brand-name { display: none; }
  .mini-kv { grid-template-columns: 1fr 1fr; }
}
/* Short landscape screens: keep sidebar scrollable and compact */
@media (max-height: 640px) and (min-width: 961px) {
  .sidebar { gap: 12px; padding-top: 14px; }
  #nav a { padding: 7px 12px; }
  .nav-label { padding-top: 8px; }
}
@media (hover: none) {
  .sm { min-height: 36px; }
  .icon-btn.sm { width: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .line-success svg path { stroke-dashoffset: 0; }
}
/* Grid tracks must never grow past the viewport because of a wide child (tables, code, long IDs). */
#content { grid-template-columns: minmax(0, 1fr); }
.grid > *, .stats > *, .account-grid > * { min-width: 0; }
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar .brand { min-width: 0; }
}
@media (max-width: 440px) {
  .topbar .brand-name { display: none; }
}
.chart-card { display: flex; flex-direction: column; }
.chart-card .bars { flex: 1; min-height: 190px; height: auto; }
td.num, td strong { white-space: nowrap; }
@media (max-width: 960px) {
  .table-wrap table { min-width: 720px; }
  td { white-space: nowrap; }
}
@media (max-width: 600px) {
  .chart-card .bars { min-height: 150px; }
}
.mini-steps li { align-items: flex-start; line-height: 1.55; }
.mini-steps li::before { margin-top: 0; }

/* ---------- Motion ---------- */
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-spring: cubic-bezier(.2, .9, .3, 1.3); }
/* Page enter: sections rise in one after another (only on navigation, not on live refresh) */
#content.enter > * { animation: rise-in .5s var(--ease-out) both; }
#content.enter > *:nth-child(2) { animation-delay: .04s; }
#content.enter > *:nth-child(3) { animation-delay: .08s; }
#content.enter > *:nth-child(4) { animation-delay: .12s; }
#content.enter > *:nth-child(5) { animation-delay: .16s; }
#content.enter > *:nth-child(6) { animation-delay: .2s; }
#content.enter > *:nth-child(n+7) { animation-delay: .24s; }
#content.enter .stats > * { animation: rise-in .5s var(--ease-out) both; }
#content.enter .stats > :nth-child(2) { animation-delay: .17s; }
#content.enter .stats > :nth-child(3) { animation-delay: .22s; }
#content.enter .stats > :nth-child(4) { animation-delay: .27s; }
#content.enter .account-grid > * { animation: rise-in .5s var(--ease-out) both; }
#content.enter .account-grid > :nth-child(2) { animation-delay: .08s; }
#content.enter .account-grid > :nth-child(n+3) { animation-delay: .14s; }
#content.enter tbody tr { animation: fade-in .4s .15s ease both; }
#content.enter .bar i { animation: grow .8s var(--ease-out) both; transform-origin: bottom; }
#content.enter .bar:nth-child(2) i { animation-delay: .05s; } #content.enter .bar:nth-child(3) i { animation-delay: .1s; }
#content.enter .bar:nth-child(4) i { animation-delay: .15s; } #content.enter .bar:nth-child(5) i { animation-delay: .2s; }
#content.enter .bar:nth-child(6) i { animation-delay: .25s; } #content.enter .bar:nth-child(7) i { animation-delay: .3s; }
#content.enter .progress span { animation: fill 1s .2s var(--ease-out) both; transform-origin: left; }
#content.enter .checklist .done .tick { animation: pop-in .45s var(--ease-spring) both; }
#content.enter .checklist a:nth-child(2) .tick { animation-delay: .06s; } #content.enter .checklist a:nth-child(3) .tick { animation-delay: .12s; }
#content.enter .checklist a:nth-child(4) .tick { animation-delay: .18s; } #content.enter .checklist a:nth-child(n+5) .tick { animation-delay: .24s; }

/* Hover & press */
.primary:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgb(13 13 18 / 10%), 0 10px 24px color-mix(in srgb, var(--accent) 34%, transparent); }
button:active, .btn:active { transform: translateY(0) scale(.97); }
.card, .stat, .account-card { transition: border-color .2s, box-shadow .25s var(--ease-out), transform .25s var(--ease-out); }
.stat:hover, .account-card:hover, .hub-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
#nav a { transition: background .2s, color .2s, padding .2s var(--ease-out); }
#nav a:hover:not(.active) { padding-left: 15px; }
#nav a.active .icon { animation: pop-in .35s var(--ease-spring); }
.checklist a .go { transition: transform .2s var(--ease-out), color .2s; }
.checklist a:hover .go { transform: translateX(3px); color: var(--accent); }
.seg button, .env-seg button { transition: background .2s, color .2s, box-shadow .2s; }
.env-seg button[aria-pressed=true] .icon { animation: pop-in .4s var(--ease-spring); }
.add-card .chip { transition: transform .3s var(--ease-spring); }
.add-card:hover .chip { transform: rotate(90deg) scale(1.08); }
details.advanced[open] > :not(summary) { animation: rise-in .35s var(--ease-out); }

/* Live status dots breathe */
.dot.ok { animation: breathe-ok 2.4s ease-in-out infinite; }
.dot.warn { animation: breathe-warn 1.4s ease-in-out infinite; }
.chip.warn > .icon, .chip.ok > .icon { transition: transform .3s; }

/* Profile bar slides down when Sandbox is on */
.env-bar:not([hidden]) { animation: slide-down .4s var(--ease-out); }

/* Dialogs, toast */
dialog::backdrop { animation: fade-in .25s ease; }
dialog[open] { animation: dialog-in .32s var(--ease-spring); }
#toast { animation: toast-in .45s var(--ease-spring); }
#toast.out { animation: toast-out .3s ease forwards; }
#toast .icon { animation: pop-in .4s .1s var(--ease-spring) both; }

/* Login */
.login-shell { animation: rise-in .6s var(--ease-out) both; }
.login-points li { animation: rise-in .5s var(--ease-out) both; }
.login-points li:nth-child(1) { animation-delay: .2s; } .login-points li:nth-child(2) { animation-delay: .3s; } .login-points li:nth-child(3) { animation-delay: .4s; }
.login-hero::after { animation: float 9s ease-in-out infinite; }

/* Theme switch cross-fade (View Transitions where supported) */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .4s; }

@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes fill { from { transform: scaleX(0); } }
@keyframes pop-in { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes breathe-ok { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 14%, transparent); } }
@keyframes breathe-warn { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--warn) 16%, transparent); } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-10px); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(24px) scale(.94); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-30px, -24px); } }
@media (max-width: 600px) {
  dialog[open] { animation: sheet .32s var(--ease-out); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .line-success svg path { stroke-dashoffset: 0; }
  .line-pin span, .line-pin-overlay, .line-burst i { opacity: 1; }
  .line-burst { display: none; }
}

/* ---------- Simplified navigation: 4 sidebar items + in-page tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 12px 16px; color: var(--muted); font-weight: 500; font-size: 14.5px; white-space: nowrap; transition: color .2s; }
.tabs a:hover { color: var(--ink); }
.tabs a::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); transform: scaleX(0); transition: transform .25s var(--ease-out); }
.tabs a.active { color: var(--accent-ink); font-weight: 600; }
.tabs a.active::after { transform: scaleX(1); }
.tabs .count { min-width: 20px; height: 19px; padding: 0 6px; border-radius: 99px; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--warn-soft); color: var(--warn); }
#nav .nav-label { padding-top: 0; }

/* ---------- LINE onboarding + status row ---------- */
.onboarding { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 44px 28px 36px; }
.onb-icon { width: 68px; height: 68px; border-radius: 20px; display: grid; place-items: center; background: #06c755; color: #fff; box-shadow: 0 12px 30px rgb(6 199 85 / 28%); animation: pop-in .5s var(--ease-spring) both; }
.onb-icon .icon { width: 34px; height: 34px; fill: currentColor; stroke: none; }
.onboarding h2 { font-size: 22px; margin-top: 8px; }
.onboarding > p { color: var(--muted); max-width: 560px; line-height: 1.75; }
.onb-error { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-size: 13px; font-weight: 500; }
.onb-error .icon { width: 16px; height: 16px; }
.onb-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: min(760px, 100%); margin: 14px 0 10px; }
.onb-step { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line-soft); }
.onb-step > span { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; background: var(--line); color: var(--muted); }
.onb-step.on > span { background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.onb-step strong { display: block; color: var(--ink); font-size: 14px; }
.onb-step small { display: block; line-height: 1.5; margin-top: 2px; }
.onboarding .lg { min-width: 200px; }
.onboarding > small { margin-top: 4px; }
.line-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line-soft); flex-wrap: wrap; }
.line-row > div:not(.actions) { flex: 1; min-width: 180px; }
.line-row strong { display: block; color: var(--ink); font-weight: 600; }
.line-row small { display: block; }
.line-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--line); color: var(--muted); flex: none; }
.line-avatar.ok { background: #06c755; color: #fff; }
.line-avatar.warn { background: var(--warn-soft); color: var(--warn); }
@media (max-width: 720px) {
  .onb-steps { grid-template-columns: 1fr; }
  .onboarding { padding: 32px 18px 28px; }
  .onboarding .lg { width: 100%; }
}

/* ---------- Custom dropdown (replaces native select) ---------- */
.dd { position: relative; margin-top: 7px; }
.dd-trigger { width: 100%; justify-content: space-between; min-height: 44px; padding: 0 12px 0 14px; border-radius: 12px; font-weight: 500; font-size: 14.5px; color: var(--ink); box-shadow: none; text-align: left; }
.dd-trigger:active { transform: none; }
.dd-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dd-trigger .icon { color: var(--faint); width: 16px; height: 16px; transition: transform .2s var(--ease-out); }
.dd.open .dd-trigger { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.dd.open .dd-trigger .icon { transform: rotate(180deg); color: var(--accent); }
.dd-menu { position: fixed; z-index: 1000; max-height: 280px; overflow-y: auto; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop); animation: dd-in .16s var(--ease-out); }
.dd-menu [role=option] { width: 100%; justify-content: space-between; gap: 10px; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 10px; box-shadow: none; background: transparent; color: var(--text); font-weight: 500; font-size: 14px; text-align: left; white-space: normal; line-height: 1.4; }
.dd-menu [role=option]:hover, .dd-menu [role=option]:focus-visible { background: var(--surface-2); outline: 0; }
.dd-menu [role=option] .icon { width: 16px; height: 16px; color: var(--accent); opacity: 0; flex: none; }
.dd-menu [role=option][aria-selected=true] { color: var(--accent-ink); font-weight: 600; background: var(--accent-soft); }
.dd-menu [role=option][aria-selected=true] .icon { opacity: 1; }
.dd-menu [role=option]:active { transform: none; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- Custom tooltip (replaces native title) ---------- */
[data-tip] { position: relative; }
[data-tip]::after { content: none; position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 60; transform: translate(-50%, 4px); padding: 6px 10px; border-radius: 9px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 500; line-height: 1.3; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s, transform .15s; box-shadow: var(--shadow-sm); }
[data-tip]:hover::after, [data-tip]:focus-visible::after { content: attr(data-tip); opacity: 1; transform: translate(-50%, 0); animation: tip-in .15s ease; }
@keyframes tip-in { from { opacity: 0; } }
td:last-child [data-tip]::after { left: auto; right: 0; transform: translate(0, 4px); }
td:last-child [data-tip]:hover::after, td:last-child [data-tip]:focus-visible::after { transform: none; }
.bar[data-tip]::after { bottom: auto; top: -6px; }
@media (hover: none) { [data-tip]::after { display: none; } }

/* ---------- Drop-down alert (replaces the corner toast) ---------- */
#toast { left: 50%; right: auto; top: 16px; bottom: auto; width: min(440px, calc(100% - 24px)); max-width: none; transform: translateX(-50%); display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 16px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-pop); overflow: hidden; animation: alert-in .45s var(--ease-spring); }
#toast.out { animation: alert-out .25s ease forwards; }
#toast .t-ic { width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
#toast.bad .t-ic { background: var(--bad-soft); color: var(--bad); }
#toast .t-ic .icon { width: 17px; height: 17px; stroke-width: 2.4; color: inherit; margin: 0; animation: pop-in .4s .1s var(--ease-spring) both; }
#toast .t-msg { flex: 1; min-width: 0; display: grid; gap: 1px; padding-top: 1px; }
#toast .t-msg strong { color: var(--ink); font-size: 14px; }
#toast .t-msg span { color: var(--muted); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; font-weight: 400; }
#toast .t-x { width: 28px; min-height: 28px; padding: 0; border: 0; box-shadow: none; background: transparent; color: var(--faint); border-radius: 8px; }
#toast .t-x:hover { background: var(--surface-2); color: var(--ink); }
#toast .t-x .icon { width: 15px; height: 15px; animation: none; color: inherit; margin: 0; }
#toast .t-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--ok); transform-origin: left; animation: toast-drain 5s linear forwards; opacity: .7; }
#toast.bad .t-bar { background: var(--bad); }
@keyframes alert-in { from { opacity: 0; transform: translate(-50%, -24px) scale(.96); } to { transform: translate(-50%, 0); } }
@keyframes alert-out { to { opacity: 0; transform: translate(-50%, -16px) scale(.97); } }
@keyframes toast-drain { to { transform: scaleX(0); } }
@media (max-width: 600px) { #toast { top: max(10px, env(safe-area-inset-top)); left: 50%; right: auto; bottom: auto; } }

/* ---------- Native chrome replaced: scrollbars, autofill, search/reveal buttons ---------- */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 35%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 32%, transparent); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--muted) 55%, transparent); }
::-webkit-scrollbar-corner { background: transparent; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus { -webkit-text-fill-color: var(--ink); -webkit-box-shadow: 0 0 0 40px var(--surface) inset; caret-color: var(--ink); transition: background-color 9999s; }
input[type=search]::-webkit-search-cancel-button, input[type=search]::-webkit-search-decoration { -webkit-appearance: none; }
input::-ms-reveal, input::-ms-clear { display: none; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.pw { position: relative; display: block; }
.pw input { padding-right: 48px; }
.pw-eye { position: absolute; right: 6px; top: calc(50% + 3.5px); transform: translateY(-50%); width: 36px; min-height: 36px; padding: 0; border-radius: 10px; color: var(--faint); }
.pw-eye:active { transform: translateY(-50%) scale(.95); }
.pw-eye.on { color: var(--accent); }

/* ---------- Auth (sign in / sign up / Google completion / 2FA) ---------- */
.login-shell { position: relative; min-height: 600px; }
.auth-theme { position: absolute; top: 18px; right: 18px; z-index: 2; }
.login-card { gap: 0; padding: 52px 48px 40px; }
.login-card h1 { font-size: 28px; letter-spacing: -.02em; }
.login-card > .muted { margin: 6px 0 24px; }
.login-card > .chip.lg { margin-bottom: 16px; }
.login-card > .callout { margin-bottom: 18px; }
.login-card form.form-grid { gap: 0 14px; }
.login-card label { margin-bottom: 14px; }
.login-card .error:not(:empty) { margin: -2px 0 12px; }
.google-btn { gap: 12px; background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 600; box-shadow: var(--shadow-sm); }
.google-btn:hover { background: var(--surface-2); }
.g-logo { width: 20px; height: 20px; flex: none; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--faint); font-size: 12.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-switch { margin-top: 20px; text-align: center; color: var(--muted); font-size: 14px; }
.auth-switch a { font-weight: 600; }
.who { display: inline-flex; align-items: center; gap: 10px; align-self: flex-start; padding: 8px 14px; margin-bottom: 18px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 500; font-size: 13.5px; color: var(--ink); max-width: 100%; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.otp-input { font-size: 24px; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }
#auth-card > * { animation: rise-in .45s var(--ease-out) both; }
#auth-card > :nth-child(2) { animation-delay: .04s; } #auth-card > :nth-child(3) { animation-delay: .08s; } #auth-card > :nth-child(n+4) { animation-delay: .12s; }

/* Custom checkbox (no native control) */
.check { display: flex !important; align-items: flex-start; gap: 10px; font-weight: 400 !important; color: var(--text) !important; font-size: 13.5px !important; line-height: 1.6; cursor: pointer; position: relative; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.check .box { width: 20px; height: 20px; flex: none; margin-top: 1px; border-radius: 6px; border: 1.5px solid color-mix(in srgb, var(--muted) 55%, transparent); background: var(--surface); display: grid; place-items: center; color: transparent; transition: background .15s, border-color .15s, box-shadow .15s; }
.check .box .icon { width: 13px; height: 13px; stroke-width: 3; transform: scale(.4); transition: transform .2s var(--ease-spring); }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); color: #fff; }
.check input:checked + .box .icon { transform: scale(1); }
.check input:focus-visible + .box { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.check .link { font-size: inherit; margin: 0 4px; font-weight: 600; }

/* ---------- Sidebar user card ---------- */
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; color: var(--text); border: 1px solid transparent; transition: background .15s, border-color .15s; }
.user-card:hover { background: var(--surface-2); border-color: var(--line); }
.user-card:empty { display: none; }
.user-card > span:nth-child(2) { flex: 1; min-width: 0; display: grid; }
.user-card strong { color: var(--ink); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .go { width: 15px; height: 15px; color: var(--faint); transform: rotate(-90deg); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; background: linear-gradient(145deg, #5458f0, #8a6bff); color: #fff; font-weight: 700; font-size: 15px; }
#nav .count.bad { background: var(--bad-soft); color: var(--bad); }
#nav .nav-label { padding-top: 14px; }
#nav .nav-label:first-child { padding-top: 0; }

/* ---------- Welcome, plan, billing ---------- */
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card.feature { display: grid; gap: 6px; align-content: start; }
.card.feature .chip { margin-bottom: 6px; }
.card.feature strong { color: var(--ink); font-size: 15px; }
.plan-usage strong { font-size: 30px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.plan-usage strong small { font-size: 14px; font-weight: 500; color: var(--muted); }
.plan-usage .progress { margin: 10px 0 18px; }
.plan-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.plan-list li { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
.plan-list .icon { width: 18px; height: 18px; padding: 3px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); stroke-width: 2.6; }
.fee-figure { display: grid; gap: 2px; margin-bottom: 12px; }
.fee-figure strong { font-size: 30px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.banner.bad { border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); background: color-mix(in srgb, var(--bad-soft) 60%, var(--surface)); }
.pay-box { display: grid; justify-items: center; gap: 4px; }
.pay-box .big-amount { width: 100%; }
.pay-qr { width: 240px; height: 240px; padding: 10px; border-radius: 18px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); animation: qr-in .5s ease both; }
.pay-box .line-state { margin-top: 12px; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 25%, var(--line)); }
.danger-zone h2 { color: var(--bad); }
.legal-links { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; padding: 4px 0 8px; }
.legal-links .link { color: var(--muted); font-weight: 500; }
ol.legal { margin: 0; padding-left: 20px; display: grid; gap: 12px; color: var(--text); line-height: 1.75; font-size: 14px; }
ol.legal strong { color: var(--ink); }
.skeleton { height: 18px; border-radius: 8px; background: linear-gradient(110deg, var(--line-soft) 30%, var(--surface-2) 50%, var(--line-soft) 70%) 0 0 / 220% 100%; animation: shimmer 1.4s linear infinite; margin: 8px 0; }
.skeleton.short { width: 55%; }
@media (max-width: 1100px) { .grid.three { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .login-shell { min-height: 0; }
  .login-card { padding: 44px 22px 30px; }
  .login-card form.form-grid { grid-template-columns: 1fr; }
}
.grid.top { align-items: start; }

.settings-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; }
.settings-grid > .card { padding: clamp(16px, 2vw, 24px); }
.settings-grid > .card > .actions { margin-top: 14px; }
.settings-grid .card-head { margin-bottom: 12px; }
.settings-grid .kv > div { gap: 12px; }
.settings-grid input[readonly] { text-overflow: ellipsis; }
.audit-head { align-items: center; }
.audit-head .input-icon { flex: 0 1 240px; }
.audit-card td { overflow-wrap: anywhere; }
#content[data-page=billing] .empty { padding: 12px 24px 24px; align-items: flex-start; text-align: start; }
#content[data-page=billing] .empty .chip { display: none; }
.suspension-note { white-space: normal; overflow-wrap: anywhere; width: max-content; max-width: 22ch; }
.legal-page { max-width: 860px; }
.legal-copy { display: grid; gap: 10px; overflow-wrap: anywhere; }
.legal-copy h2:not(:first-child) { margin-top: 14px; }
.legal-copy ul { margin: 0; padding-inline-start: 1.4rem; }
.legal-copy li + li { margin-top: 8px; }
.legal-copy a, .login-card .legal-links a { text-decoration: underline; text-underline-offset: 3px; }
.legal-links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 18px; }
[data-public-legal] .login-shell { grid-template-columns: minmax(0, 1fr); max-width: 860px; }
[data-public-legal] .login-hero { display: none; }
[data-public-legal] .login-card { padding: clamp(16px, 4vw, 40px); }
[data-public-legal] .legal-page { box-shadow: none; }
[data-public-legal] .login-card > p { margin-top: 16px; }
.table-wrap:focus-visible { outline-offset: -3px; }
.table-wrap th { text-wrap: nowrap; }
.table-wrap td:first-child strong { overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .audit-head .input-icon { flex-basis: 100%; }
  .settings-grid .form-grid { grid-template-columns: minmax(0, 1fr); }
  .audit-card .table-wrap table { min-width: 0; table-layout: fixed; }
  .audit-card :is(th, td) { padding-inline: 8px; }
  .audit-card td.num { white-space: normal; }
}
input[readonly] { background: var(--surface-2); color: var(--muted); cursor: default; }
input[readonly]:focus { border-color: var(--line); box-shadow: none; }
