:root {
  --canvas: #f4f7f8;
  --surface: #ffffff;
  --subtle: #f7f9fa;
  --ink: #1a1c1c;
  --muted: #5f6b6d;
  --line: #d5dedf;
  --hairline: #e6eced;
  --primary: #0f766e;
  --primary-hover: #0c625b;
  --primary-soft: #d7f0ec;
  --saffron-soft: #fef3c7;
  --saffron-ink: #92580a;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fdecec;
  --danger-ink: #a51d1d;
  --bar: #0b3b47;
  --bar-ink: #e3eef0;
  --bar-muted: #9fb8bd;
  --font: Tajawal, "Segoe UI", Tahoma, sans-serif;
  --r-tag: 4px;
  --r-control: 6px;
  --r-panel: 8px;
  --control: 40px;
  --gutter: 24px;
  --measure: 1200px;
}
* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 400 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; overflow-wrap: break-word; min-width: 0; }
.noscript { padding: var(--gutter); }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control); padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); color: var(--ink); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background-color .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--subtle); border-color: #c3cfd1; }
.btn:active { background: var(--hairline); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger-ink); border-color: #efc4c4; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.solid:hover { background: var(--danger-hover); }
.btn.small { height: 32px; padding: 0 12px; font-size: 14px; }
.btn.link { border-color: transparent; background: none; color: var(--primary); padding: 0 8px; }
.btn.link:hover { background: var(--primary-soft); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.input { height: var(--control); width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); }
.input:hover { border-color: #c3cfd1; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.input.code { letter-spacing: 0; font-size: 18px; text-align: center; }
select.input { padding-inline-end: 8px; }

/* sign in */
.signin { min-height: 100dvh; display: grid; place-items: center; padding: var(--gutter) 16px; background: var(--bar); }
.signin-panel { width: min(100%, 380px); background: var(--surface); border-radius: var(--r-panel); padding: 32px 28px 28px; display: grid; gap: 18px; }
.wordmark { display: flex; align-items: baseline; gap: 10px; }
.wordmark b { font-size: 22px; letter-spacing: 0; direction: ltr; }
.wordmark span { color: var(--muted); }
.signin-panel h1 { font-size: 18px; }
.error { color: var(--danger-ink); font-size: 14px; min-height: 22px; }

/* frame */
.bar { background: var(--bar); color: var(--bar-ink); }
.bar-in { max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter); height: 56px; display: flex; align-items: center; gap: 28px; }
.bar .wordmark b { font-size: 18px; color: #fff; }
.bar .wordmark span { color: var(--bar-muted); font-size: 14px; }
.tabs { display: flex; gap: 4px; height: 100%; flex: 1; min-width: 0; overflow-x: auto; }
.tab { height: 100%; border: 0; background: none; color: var(--bar-muted); padding: 0 12px; cursor: pointer; border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; }
.tab:hover { color: #fff; }
.tab[aria-current="page"] { color: #fff; border-bottom-color: #5fc4b8; }
.bar .btn.link { color: var(--bar-ink); }
.bar .btn.link:hover { background: rgba(255, 255, 255, .08); }
main { max-width: var(--measure); margin: 0 auto; padding: var(--gutter); display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head h1 { font-size: 20px; }

/* numbers strip, doubling as the filter */
.strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.strip button { border: 0; border-inline-start: 1px solid var(--hairline); background: none; padding: 14px 16px; text-align: start; cursor: pointer; display: grid; gap: 2px; min-width: 0; }
.strip button:first-child { border-inline-start: 0; }
.strip button:hover { background: var(--subtle); }
.strip button[aria-pressed="true"] { background: var(--primary-soft); }
.strip .k { color: var(--muted); font-size: 13px; }
.strip .v { font-size: 22px; font-weight: 700; }
.strip .warn .v { color: var(--saffron-ink); }
.strip .bad .v { color: var(--danger-ink); }

.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tools .input { max-width: 380px; }

/* tables */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--subtle); color: var(--muted); font-size: 13px; font-weight: 500; text-align: start; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover td { background: var(--subtle); }
tbody tr.row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.who { display: grid; gap: 0; min-width: 180px; }
.who b { font-weight: 500; }
.who small { color: var(--muted); font-size: 13px; }
.who .ltr, .list .ltr { justify-self: start; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.tag { display: inline-block; padding: 1px 8px; border-radius: var(--r-tag); font-size: 13px; font-weight: 500; white-space: nowrap; }
.tag.trial { background: var(--saffron-soft); color: var(--saffron-ink); }
.tag.annual, .tag.lifetime { background: var(--primary-soft); color: var(--primary-hover); }
.tag.off { background: var(--danger-soft); color: var(--danger-ink); }
.tag.plain { background: var(--hairline); color: var(--muted); }

/* device panel */
.scrim { position: fixed; inset: 0; background: rgba(11, 59, 71, .35); z-index: 10; }
.sheet { position: fixed; inset-block: 0; inset-inline-end: 0; width: min(100%, 460px); background: var(--surface); z-index: 11; display: flex; flex-direction: column; border-inline-start: 1px solid var(--line); }
.sheet-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 20px 24px 16px; border-bottom: 1px solid var(--hairline); }
.sheet-head h2 { font-size: 18px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 24px 24px; display: grid; gap: 20px; align-content: start; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.idline { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.idline .num { font-size: 13px; white-space: nowrap; }
.section-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.actions .wide { grid-column: 1 / -1; }
.extend { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.confirm { border: 1px solid var(--line); border-radius: var(--r-panel); padding: 14px; display: grid; gap: 12px; background: var(--subtle); }
.confirm.danger { border-color: #efc4c4; background: #fff8f8; }
.confirm p { margin: 0; }
.confirm .row-btns { display: flex; gap: 8px; }
.note { color: var(--muted); font-size: 13px; margin: 0; }
.list { display: grid; }
.list > div { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--hairline); font-size: 14px; }
.list > div:last-child { border-bottom: 0; }
.list .when { color: var(--muted); grid-row: span 2; white-space: nowrap; }

/* codes */
.make { display: grid; grid-template-columns: 160px 110px minmax(0, 1fr) auto; gap: 12px; align-items: end; padding: 16px; }
.made { padding: 16px; border-top: 1px solid var(--hairline); display: grid; gap: 10px; }
.made pre { margin: 0; padding: 12px; background: var(--subtle); border: 1px solid var(--hairline); border-radius: var(--r-control); font: 500 15px/1.9 var(--font); font-variant-numeric: tabular-nums; direction: ltr; text-align: left; white-space: pre-wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-control); overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-inline-start: 1px solid var(--line); background: none; height: 36px; padding: 0 14px; cursor: pointer; }
.seg button:first-child { border-inline-start: 0; }
.seg button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-hover); font-weight: 500; }

#toast { position: fixed; inset-inline-start: 50%; bottom: 24px; transform: translateX(50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-control); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 20; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; }

@media (max-width: 900px) {
  .strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .strip button:nth-child(4) { border-inline-start: 0; }
  .strip button:nth-child(n+4) { border-top: 1px solid var(--hairline); }
  .make { grid-template-columns: 1fr 1fr; }
  .make .grow { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .bar-in { gap: 12px; }
  .bar .wordmark span { display: none; }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip button:nth-child(odd) { border-inline-start: 0; }
  .strip button:nth-child(4) { border-inline-start: 1px solid var(--hairline); }
  .strip button:nth-child(n+3) { border-top: 1px solid var(--hairline); }
  .sheet-head, .sheet-body { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
