/* Layout: fixed left rail (sites / billing) + working pane; rail collapses to a top bar on phones */
:root {
  --bg: #F3F5F8; --surface: #FFFFFF; --surface-2: #EBEFF4; --line: #DCE2E9;
  --fg: #121820; --muted: #5A6573; --accent: #1F5AE0; --accent-weak: #E2EAFC; --on-accent: #FFFFFF;
  --ok: #187F51; --ok-weak: #DCF2E6; --warn: #9A6412; --warn-weak: #FAEFD9; --bad: #B8382F;
  --f-display: "Bai Jamjuree", "IBM Plex Sans Thai", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Thai", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0D1116; --surface: #141A21; --surface-2: #1B222B; --line: #29323D;
  --fg: #E5E9EF; --muted: #95A0AD; --accent: #7398FF; --accent-weak: #1B2949; --on-accent: #0D1116;
  --ok: #4CC48D; --ok-weak: #12301F; --warn: #E2AA4C; --warn-weak: #362911; --bad: #F07A72; color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0D1116; --surface: #141A21; --surface-2: #1B222B; --line: #29323D;
  --fg: #E5E9EF; --muted: #95A0AD; --accent: #7398FF; --accent-weak: #1B2949; --on-accent: #0D1116;
  --ok: #4CC48D; --ok-weak: #12301F; --warn: #E2AA4C; --warn-weak: #362911; --bad: #F07A72; color-scheme: dark;
}
html, body, #root { height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 14px; line-height: 1.55; }
* { box-sizing: border-box; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.rail { border-right: 1px solid var(--line); background: var(--surface); padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-family: var(--f-display); font-weight: 700; font-size: 17px; letter-spacing: 0.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--fg); color: var(--bg); display: grid; place-items: center; font-size: 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav button:hover { background: var(--surface-2); color: var(--fg); }
.nav button[aria-current="true"] { background: var(--accent-weak); color: var(--accent); }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0 10px 6px; }
.rail-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }

.main { min-width: 0; padding-block: 24px 64px; padding-inline: clamp(16px, 4vw, 44px); }
.banner { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; color: var(--warn); background: var(--warn-weak); padding: 4px 10px; border-radius: 99px; margin-bottom: 18px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 22px; }
.head h1 { font-family: var(--f-display); font-weight: 600; font-size: 26px; line-height: 1.2; margin: 0; text-wrap: balance; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumb button { border: 0; background: none; padding: 0; color: var(--accent); }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-weak); }
.pill.warn { color: var(--warn); background: var(--warn-weak); }
.pill.idle { color: var(--muted); background: var(--surface-2); }
.pill.live { color: var(--accent); background: var(--accent-weak); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.panel-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-h h2 { margin: 0; font-family: var(--f-display); font-size: 16px; font-weight: 600; }
.panel-b { padding: 18px; }

/* site list */
.sites { display: flex; flex-direction: column; }
.site-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) auto auto; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%; }
.site-row:last-child { border-bottom: 0; }
.site-row:hover { background: var(--surface-2); }
.site-name { font-weight: 600; font-size: 15px; }
.site-url { font-family: var(--f-mono); font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-small { font-size: 13px; color: var(--muted); white-space: nowrap; }

.newsite { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.field { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden; min-width: 0; flex: 1 1 260px; }
.field input { border: 0; background: none; padding: 7px 10px; min-width: 0; flex: 1; outline: none; }
.field span { padding: 7px 10px; color: var(--muted); background: var(--surface-2); font-family: var(--f-mono); font-size: 12.5px; display: flex; align-items: center; }
.field:focus-within { border-color: var(--accent); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 12px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--fg); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

.drop { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 28px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-weak); }
.drop strong { font-family: var(--f-display); font-size: 16px; font-weight: 600; }
.progress { width: 100%; max-width: 360px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 18px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.stat { background: var(--surface); padding: 14px 18px; }
.stat b { display: block; font-family: var(--f-display); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.spark { display: block; width: 100%; height: 90px; }

pre.cli { margin: 0; background: var(--surface-2); border-radius: 6px; padding: 12px 14px; overflow-x: auto; font-family: var(--f-mono); font-size: 12.5px; line-height: 1.7; }
pre.cli .c { color: var(--muted); }
pre.cli .g { color: var(--ok); }

/* deploys */
.dep { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.dep:last-child { border-bottom: 0; }
.dep-id { font-family: var(--f-mono); font-weight: 500; }
.dep-meta { font-size: 13px; color: var(--muted); }
.dep-act { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.confirm { display: flex; gap: 8px; align-items: center; font-size: 13px; flex-wrap: wrap; justify-content: flex-end; }

/* domains */
.dom { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.dom:last-child { border-bottom: 0; }
.dom-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.dom-host { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.dns-wrap { overflow-x: auto; }
table.dns { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 420px; }
table.dns th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 10px; background: var(--surface-2); }
table.dns td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-family: var(--f-mono); }
.adddom { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 18px; border-top: 1px solid var(--line); }
.err { color: var(--bad); font-size: 13px; width: 100%; }

/* billing */
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.plan { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.plan.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan h3 { margin: 0; font-family: var(--f-display); font-size: 17px; font-weight: 600; }
.price { font-family: var(--f-display); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.price small { font-family: var(--f-body); font-size: 13px; font-weight: 400; color: var(--muted); }
.plan ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.plan li::before { content: "✓"; color: var(--ok); margin-right: 8px; }
.plan .btn { margin-top: auto; }
.meter { display: flex; flex-direction: column; gap: 6px; }
.meter-top { display: flex; justify-content: space-between; font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar i.hi { background: var(--warn); }
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 28px; }

/* modal */
.scrim { position: fixed; inset: 0; background: rgb(8 12 18 / 0.45); display: grid; place-items: center; padding: 16px; z-index: 10; animation: fade .15s ease-out; }
.modal { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 20px 50px rgb(0 0 0 / 0.25); animation: rise .18s ease-out; }
.modal-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 4px; }
.modal-h h2 { margin: 0; font-family: var(--f-display); font-size: 19px; font-weight: 600; }
.modal-x { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.modal-x:hover { background: var(--surface-2); color: var(--fg); }
.modal-b { padding: 8px 20px 4px; display: flex; flex-direction: column; gap: 10px; }
.modal-b label { font-size: 13px; font-weight: 500; }
.modal-b .field { flex: none; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 20px 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 6px; font-size: 13px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 16px; gap: 12px; overflow-x: auto; }
  .nav { flex-direction: row; }
  .nav-label, .rail-foot { display: none; }
  .grid2, .plans, .meters { grid-template-columns: 1fr; }
  .site-row { grid-template-columns: minmax(0, 1fr) auto; }
  .site-row .hide-sm { display: none; }
  .dep { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .dep-act { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* auth */
.auth { min-height: 100%; display: grid; place-items: center; padding-block: 32px; padding-inline: 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { margin: 0; font-family: var(--f-display); font-size: 24px; font-weight: 600; }
.auth-card label { font-size: 13px; font-weight: 500; }
.auth-card .field { flex: none; }
.auth-switch { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 500; }
.loading { color: var(--muted); padding: 40px 0; }
.empty { padding: 36px 18px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty strong { font-family: var(--f-display); font-size: 17px; font-weight: 600; }
.rail-foot .btn { margin-left: auto; }
.danger-zone { display: flex; flex-direction: column; gap: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.drop-list { font-family: var(--f-mono); font-size: 12px; color: var(--muted); text-align: left; max-width: 100%; overflow-wrap: anywhere; }
