/* VetOnCloud License Hub — one stylesheet, no build step. */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line: #e3e8ec;
  --line-strong: #cfd7de;
  --text: #17222b;
  --text-2: #4a5864;
  --muted: #7a8894;
  --brand: #0e5c55;
  --brand-2: #12756c;
  --brand-ink: #e9f6f4;
  --brand-soft: #e4f3f1;
  --side: #0b2e2b;
  --side-2: #113b37;
  --ok: #0f7a4a;   --ok-bg: #e5f5ec;
  --warn: #9a5b00; --warn-bg: #fff3df;
  --bad: #b42318;  --bad-bg: #fdecea;
  --info: #1f5fbf; --info-bg: #e8f0fd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --font: "IBM Plex Sans Thai", "Noto Sans Thai", "Sarabun", "Leelawadee UI", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 15.5px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: .92em; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--side) 0%, #082422 100%); color: #cfe5e2; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; color: #fff; font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #2bb3a3, #0e7c72); box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.brand .logo svg { width: 19px; height: 19px; stroke: #fff; }
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: #8fb8b3; letter-spacing: .04em; text-transform: uppercase; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f9994; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: #cfe5e2; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(43,179,163,.18); color: #fff; box-shadow: inset 3px 0 0 #2bb3a3; }
.nav .count { margin-left: auto; background: #e8a33d; color: #3a2400; font-size: 11.5px; font-weight: 700; border-radius: 20px; padding: 0 7px; }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; color: #8fb8b3; }
.side-foot form { margin-top: 8px; }
.side-foot button { background: none; border: 1px solid rgba(255,255,255,.15); color: #cfe5e2; border-radius: 8px; padding: 6px 10px; width: 100%; cursor: pointer; font: inherit; display: flex; gap: 8px; align-items: center; justify-content: center; }
.side-foot button:hover { background: rgba(255,255,255,.06); }
.key-state { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: #31c48d; box-shadow: 0 0 0 3px rgba(49,196,141,.18); }
.dot.bad { background: #f05252; box-shadow: 0 0 0 3px rgba(240,82,82,.18); }
.dot.warn { background: #f0a43a; box-shadow: 0 0 0 3px rgba(240,164,58,.2); }

.main { min-width: 0; }
.page { max-width: 1240px; margin: 0 auto; padding: 28px 32px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumb { font-size: 13px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; margin-bottom: 8px; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card > .card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card > .card-body { padding: 18px 20px; }
.card + .card, .grid + .card, .card + .grid { margin-top: 18px; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.stack > * + * { margin-top: 14px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: block; color: inherit; position: relative; overflow: hidden; }
a.stat:hover { text-decoration: none; border-color: var(--line-strong); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12px; }
.stat::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent, transparent); }
.stat.brand { --accent: var(--brand-2); } .stat.ok { --accent: #31c48d; } .stat.warn { --accent: #f0a43a; } .stat.bad { --accent: #f05252; } .stat.info { --accent: #3f83f8; }
.stat.active { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- Toolbar & inputs ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search { position: relative; flex: 1; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-left: 34px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented a { padding: 5px 12px; border-radius: 7px; color: var(--text-2); font-weight: 500; font-size: 13px; }
.segmented a:hover { text-decoration: none; background: #eef2f4; }
.segmented a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

label.field { display: block; }
label.field > span, .field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
input[type=text], input[type=password], input[type=url], input:not([type]), select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  font: inherit; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.form-actions .grow { margin-right: auto; color: var(--muted); font-size: 12.5px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg.i { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); border-color: #f3c4bf; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: #eef2f4; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.inline { display: inline; }

/* ---------- Pills & chips ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef2f4; color: var(--text-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.pill.plain::before { display: none; }
.pill.active, .pill.forever, .pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.expiring, .pill.pending, .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.grace, .pill.expired, .pill.bad, .pill.blocked { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.none { background: transparent; color: var(--muted); padding-left: 0; }
.pill.none::before { display: none; }
.pkg { display: inline-block; white-space: nowrap; padding: 3px 10px; border-radius: 7px; font-weight: 700; font-size: 12.5px; background: var(--brand-soft); color: var(--brand); }
.pkg.empty { background: #eef2f4; color: var(--muted); font-weight: 500; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr.link-row { cursor: pointer; }
.table tbody tr.link-row:hover { background: #f6faf9; }
.table tr.attention td:first-child { box-shadow: inset 3px 0 0 #f0a43a; }
.table .sub { color: var(--muted); font-size: 12px; }
.table.compact td, .table.compact th { padding: 9px 14px; }
.svc { display: flex; flex-direction: column; gap: 2px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 13.5px; color: #fff; flex: none;
  background: hsl(var(--h, 170) 45% 42%); }
.avatar.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 18px; }
.who strong { display: block; color: var(--text); }
.who a:hover { text-decoration: none; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Key/value ---------- */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.meter { height: 6px; border-radius: 6px; background: #e8edf0; overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; background: var(--brand-2); border-radius: 6px; }
.meter.hot > span { background: #f05252; }
.usage { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.usage .u { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.usage .u .n { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.usage .u .n small { font-size: 12.5px; color: var(--muted); font-weight: 500; }

/* ---------- Hero (install header) ---------- */
.hero { display: flex; align-items: center; gap: 16px; padding: 20px; }
.hero .title { flex: 1; min-width: 0; }
.hero .title h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.copyable { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 3px 8px; margin-top: 6px; cursor: pointer; }
.copyable:hover { color: var(--text); }
.copyable svg { width: 14px; height: 14px; }

/* ---------- Services grid in renew form ---------- */
.svc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.svc-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.svc-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.svc-card .name { font-weight: 650; }
.svc-card .until { color: var(--muted); font-size: 12.5px; }
.svc-card select { background: var(--surface); }

/* ---------- Scope toggles ---------- */
.scopes { display: grid; gap: 10px; }
.scope { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; }
.scope:hover { border-color: var(--line-strong); }
.scope input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand-2); flex: none; }
.scope:has(input:checked) { border-color: var(--brand-2); background: var(--brand-soft); }
.scope:has(input:disabled) { cursor: default; }
.scope b { display: block; font-weight: 650; }
.scope span { color: var(--muted); font-size: 12.5px; }

/* ---------- Token reveal ---------- */
.reveal { border: 1px solid #a7dcd4; background: linear-gradient(180deg, #effaf8, #e6f6f3); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.reveal h2 { display: flex; gap: 8px; align-items: center; color: var(--brand); }
.reveal p { margin: 6px 0 12px; color: var(--text-2); }
.token-box { display: flex; gap: 8px; align-items: stretch; }
.token-box input { font-family: var(--mono); font-size: 13.5px; background: #fff; letter-spacing: .01em; }

/* ---------- Banners ---------- */
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid transparent; }
.banner svg.i { margin-top: 1px; }
.banner.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe6cf; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: #f4d9a8; }
.banner.err { background: var(--bad-bg); color: var(--bad); border-color: #f3c4bf; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { width: 52px; height: 52px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 12px; }
.empty .ic svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ---------- Timeline (history) ---------- */
.kind { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 6px; background: #eef2f4; color: var(--text-2); }
.kind.issue { background: var(--info-bg); color: var(--info); }
.kind.renew { background: var(--brand-soft); color: var(--brand); }
.kind.import { background: #f1ecfb; color: #6440b8; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% -10%, #1d6a62 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #134b46 0%, transparent 55%), var(--side); padding: 24px; }
.login .card { width: 100%; max-width: 400px; padding: 30px; box-shadow: var(--shadow-lg); border: 0; }
.login .brand { color: var(--text); padding: 0 0 22px; }
.login .brand small { color: var(--muted); }
.login .stack { margin-top: 4px; }
.login .btn { width: 100%; padding: 10px; }

/* ---------- Details ---------- */
details.more > summary { cursor: pointer; color: var(--brand-2); font-weight: 600; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { margin-bottom: 14px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.cols-3-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; }
  .side .nav-label, .side-foot .key-state { display: none; }
  .brand { padding: 0 10px 0 0; }
  .nav { display: flex; gap: 4px; flex-wrap: wrap; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .page { padding: 20px 16px 48px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-2, .svc-grid, .usage { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 8px; }
}
