/* ============================================================================
   LicenseStore — Apple-style admin UI (vanilla, no framework)
   ========================================================================== */
:root {
  --bg: #f5f5f7;
  --bg-grad: radial-gradient(1200px 600px at 70% -10%, #e7eefc 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 20%, #f3e9ff 0%, transparent 55%);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --accent-press: #0063c1;
  --green: #1fa463;
  --red: #e0314b;
  --amber: #c77700;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(.2,.7,.2,1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-grad: radial-gradient(1200px 600px at 70% -10%, #10203f 0%, transparent 60%),
               radial-gradient(900px 500px at -10% 20%, #221033 0%, transparent 55%);
    --surface: rgba(28, 28, 30, 0.66);
    --surface-solid: #1c1c1e;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989d;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #0a84ff;
    --accent-press: #339cff;
    --green: #30d572;
    --red: #ff5a6e;
    --amber: #ffb648;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

.glass {
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--line);
}

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 590; cursor: pointer;
  border: none; border-radius: 980px; padding: 9px 18px;
  transition: transform .18s var(--ease), background .18s var(--ease), opacity .18s var(--ease);
  color: var(--text);
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-press); }
.btn-ghost { background: rgba(127,127,127,.12); }
.btn-ghost:hover { background: rgba(127,127,127,.2); }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn-danger { background: rgba(224,49,75,.12); color: var(--red); }
.btn-danger:hover { background: rgba(224,49,75,.22); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; padding: 40px 34px;
  border-radius: 26px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 18px;
  animation: rise .6s var(--ease) both;
}
.brand { text-align: center; margin-bottom: 6px; }
.brand-mark {
  font-size: 34px; line-height: 1; color: var(--accent);
  filter: drop-shadow(0 4px 12px rgba(0,113,227,.4));
}
.brand-mark.sm { font-size: 20px; }
.brand h1 { margin: 12px 0 2px; font-size: 26px; font-weight: 680; letter-spacing: -0.03em; }
.brand p { margin: 0; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); }
.field input {
  font: inherit; color: var(--text); padding: 12px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-solid); outline: none;
  transition: border .18s var(--ease), box-shadow .18s var(--ease);
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,113,227,.16); }
.login-card .btn-primary { padding: 12px; font-size: 16px; }
.login-err { min-height: 18px; margin: 0; font-size: 13px; color: var(--red); text-align: center; }
.shake { animation: shake .4s var(--ease); }
.foot { font-size: 12px; }

/* ---------- app shell ---------- */
.app { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px; border-left: none; border-right: none; border-top: none;
}
.topbar-left { display: flex; align-items: center; gap: 9px; font-size: 16px; letter-spacing: -0.02em; }
.tabs { display: flex; gap: 4px; margin: 0 auto; }
.tab {
  font: inherit; font-weight: 560; font-size: 14px; cursor: pointer;
  border: none; background: transparent; color: var(--muted);
  padding: 7px 15px; border-radius: 980px; transition: all .18s var(--ease);
}
.tab:hover { color: var(--text); background: rgba(127,127,127,.1); }
.tab.active { color: var(--text); background: rgba(127,127,127,.16); }
.topbar-right { display: flex; gap: 8px; }

.content { max-width: 1080px; margin: 0 auto; padding: 30px 22px 60px; }
.view { animation: fade .4s var(--ease) both; }

/* ---------- stat cards ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat .num { font-size: 38px; font-weight: 680; letter-spacing: -0.04em; line-height: 1; }
.stat .lbl { margin-top: 8px; font-size: 13px; color: var(--muted); }
.stat .num.accent { color: var(--accent); }
.stat .num.green { color: var(--green); }

/* ---------- cards / tables ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 17px; font-weight: 620; letter-spacing: -0.02em; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-weight: 560; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 12px 22px; border-bottom: 1px solid var(--line);
}
td { padding: 14px 22px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s var(--ease); }
tbody tr:hover { background: rgba(127,127,127,.05); }
td code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.empty { padding: 40px; text-align: center; color: var(--muted); font-size: 14px; }

/* expandable bindings row */
.sub-row td { background: rgba(127,127,127,.05); padding: 0 22px; }
.binds { padding: 6px 0 12px; display: flex; flex-direction: column; gap: 6px; }
.bind { display: flex; gap: 14px; align-items: center; font-size: 13px; color: var(--muted); }
.bind .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.bind.blocked .dot { background: var(--red); }

/* ---------- pills ---------- */
.pill {
  display: inline-block; padding: 3px 11px; border-radius: 980px;
  font-size: 12px; font-weight: 580;
}
.pill.active { background: rgba(31,164,99,.14); color: var(--green); }
.pill.revoked { background: rgba(224,49,75,.14); color: var(--red); }
.pill.expired { background: rgba(199,119,0,.16); color: var(--amber); }

/* ---------- timeline / logs ---------- */
.timeline { padding: 8px 0; }
.tl {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 22px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.timeline .tl:last-child { border-bottom: none; }
.tl .ic {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
}
.tl .ic.ok { background: var(--green); }
.tl .ic.fail { background: var(--red); }
.tl .ic.bind { background: var(--accent); }
.tl .ic.neutral { background: #8e8e93; }
.tl .body { flex: 1; min-width: 0; }
.tl .body .t1 { font-weight: 540; }
.tl .body .t2 { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.tl .when { color: var(--muted); font-size: 12px; white-space: nowrap; }

.seg { display: inline-flex; background: rgba(127,127,127,.12); border-radius: 980px; padding: 3px; }
.seg-btn {
  font: inherit; font-size: 13px; font-weight: 540; cursor: pointer; border: none;
  background: transparent; color: var(--muted); padding: 5px 13px; border-radius: 980px;
  transition: all .18s var(--ease);
}
.seg-btn.active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.32); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .25s var(--ease);
}
.sheet {
  width: 100%; max-width: 460px; margin-bottom: 0;
  border-radius: 26px 26px 0 0; padding: 26px 26px 30px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px;
  animation: slideup .4s var(--ease);
}
.sheet h2 { margin: 0; font-size: 20px; font-weight: 640; letter-spacing: -0.02em; }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }
.sheet-actions .btn { flex: 1; padding: 12px; }
.key-result { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.key-line { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.key-line code {
  flex: 1; font-size: 16px; font-weight: 600; letter-spacing: .04em;
  padding: 10px 14px; background: rgba(127,127,127,.1); border-radius: var(--radius-sm);
}
@media (min-width: 520px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 26px; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 80; padding: 12px 22px; border-radius: 980px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 540;
  box-shadow: var(--shadow-lg); animation: rise .35s var(--ease);
}

/* ---------- wizard mã hoá ---------- */
.wizard { max-width: 760px; margin: 0 auto; }
.steps {
  display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 22px;
  justify-content: center; flex-wrap: wrap;
}
.step {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 560;
  color: var(--muted); padding: 6px 14px 6px 6px; border-radius: 980px;
  background: rgba(127,127,127,.07); transition: .3s var(--ease);
}
.step .dot {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(127,127,127,.18); color: var(--muted); font-size: 13px; font-weight: 680;
}
.step.active { color: var(--text); background: rgba(0,113,227,.12); }
.step.active .dot { background: var(--accent); color: #fff; }
.step.done .dot { background: var(--green); color: #fff; }
.step.done .dot::after { content: '✓'; }
.step.done .dot { font-size: 0; }
.step.done .dot::after { font-size: 13px; }

.wactions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.wactions.center { justify-content: center; }
.small { font-size: 12.5px; }

.drop {
  display: block; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 54px 24px; background: var(--card); transition: .25s var(--ease);
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(0,113,227,.05); }
.drop-ic { font-size: 40px; line-height: 1; color: var(--accent); }
.drop-t1 { margin-top: 14px; font-size: 16px; font-weight: 560; }
.drop-t2 { margin-top: 4px; font-size: 13px; }
.drop-name {
  margin: 16px auto 0; max-width: 90%; padding: 9px 16px; font-weight: 560; font-size: 14px;
  background: rgba(0,113,227,.1); color: var(--accent); border-radius: 980px; display: inline-block;
}

.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.an-cell { padding: 14px 16px; background: rgba(127,127,127,.06); border-radius: var(--radius-sm); }
.an-l { font-size: 12px; color: var(--muted); font-weight: 540; }
.an-v { font-size: 17px; font-weight: 640; margin-top: 4px; }
.an-v.green { color: var(--green); } .an-v.accent { color: var(--accent); }

.cfg { display: flex; flex-direction: column; gap: 16px; }
.cfg-2col { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 560px) { .cfg-2col { grid-template-columns: 1fr 1fr; } }
.cfg-block .cfg-lbl { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.toggles { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; }
.toggle {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: rgba(127,127,127,.06); border-radius: var(--radius-sm); cursor: pointer;
}
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.tg-name { flex: 1; font-family: ui-monospace, monospace; font-size: 13px; }
.tg-grp {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 2px 8px; background: rgba(127,127,127,.12); border-radius: 980px;
}
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: rgba(127,127,127,.06); border-radius: var(--radius-sm);
  font-weight: 540; cursor: pointer;
}
.switch { width: 20px; height: 20px; accent-color: var(--accent); }

.done-card { text-align: center; animation: slideup .4s var(--ease); }
.done-ic {
  width: 64px; height: 64px; margin: 4px auto 10px; border-radius: 50%;
  display: grid; place-items: center; font-size: 32px; color: #fff;
  background: var(--green); box-shadow: 0 8px 24px rgba(52,199,89,.35);
}
.done-card .key-result { text-align: left; margin: 18px 0; }

/* ---------- animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(7px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(3px)} }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
