/*
 * Kho eSIM GOTASIM — giao diện quản trị.
 * Token màu/bo góc/đổ bóng lấy theo apps/shopify/assets/base.css (MOBROAM/GOTASIM).
 * Font: Plus Jakarta Sans nếu máy đã cài, còn lại dùng font hệ thống (CSP không cho tải font ngoài).
 */
:root {
  color-scheme: light dark;

  --primary: #1958d8;
  --primary-hover: #1247b4;
  --primary-solid: #1958d8;
  --primary-tint: #eaf1fe;
  --primary-tint-2: #f3f7fe;

  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #eef2f7;
  --ink: #0e1726;
  --ink-2: #2a3546;
  --muted: #546074;
  --subtle: #656f7f;
  --line: rgb(14 23 38 / 0.08);
  --line-input: rgb(14 23 38 / 0.16);
  --line-strong: rgb(14 23 38 / 0.2);

  --ok-ink: #0e6b4c;
  --ok-bg: #e3f3ec;
  --err-ink: #a42a1a;
  --err-bg: #fdecea;
  --warn-ink: #7a4f00;
  --warn-bg: #fff4d6;
  --accent: #f5b82e;
  --test-ink: #5b34c4;
  --test-bg: #efe9fd;

  --viettel: #e60028;
  --vinaphone: #0a6ed1;
  --mobifone: #1b3f94;

  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-card: 0 1px 2px rgb(14 23 38 / 0.05);
  --shadow-hover: 0 6px 18px rgb(25 88 216 / 0.1);
  --shadow-pop: 0 20px 50px rgb(14 23 38 / 0.16);

  --sidebar-w: 248px;
  --banner-h: 38px;
  --tap: 36px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #7aa7f7;
    --primary-hover: #a3c2fa;
    --primary-solid: #2f6be6;
    --primary-tint: rgb(110 160 245 / 0.14);
    --primary-tint-2: rgb(110 160 245 / 0.08);

    --bg: #0b1220;
    --surface: #111a2b;
    --surface-2: #0e1626;
    --surface-3: #1a2539;
    --ink: #e6ecf5;
    --ink-2: #c5cedc;
    --muted: #9aa6b9;
    --subtle: #8792a5;
    --line: rgb(255 255 255 / 0.08);
    --line-input: rgb(255 255 255 / 0.18);
    --line-strong: rgb(255 255 255 / 0.24);

    --ok-ink: #6fdcb0;
    --ok-bg: rgb(111 220 176 / 0.12);
    --err-ink: #ff9585;
    --err-bg: rgb(255 120 100 / 0.13);
    --warn-ink: #f7cf6a;
    --warn-bg: rgb(245 184 46 / 0.14);
    --test-ink: #c2adff;
    --test-bg: rgb(160 130 255 / 0.15);

    --viettel: #ff4d6a;
    --vinaphone: #4da3ff;
    --mobifone: #8ea8ff;

    --shadow-card: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-hover: 0 6px 18px rgb(0 0 0 / 0.35);
    --shadow-pop: 0 20px 50px rgb(0 0 0 / 0.55);
  }
}

@media (pointer: coarse) {
  :root { --tap: 44px; }
}

/* ---------- nền tảng ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, fieldset { margin: 0; }
:where(h1, h2, h3) { text-wrap: balance; line-height: 1.25; }
:where(p, li, dd) { text-wrap: pretty; }
ul, ol { padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; min-width: 0; }
img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; font-variant-numeric: tabular-nums; }
strong { font-weight: 650; }
::selection { background: color-mix(in srgb, var(--primary) 24%, transparent); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Thuộc tính hidden luôn thắng các class đặt display (vd .empty). */
[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--primary-solid); color: #fff; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tabular, .num, .stat__value, time { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; word-break: break-word; }
.text-danger { color: var(--err-ink); }
.text-warn { color: var(--warn-ink); }

/* ---------- banner chế độ ---------- */
.mode-banner {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  min-height: var(--banner-h); padding: 6px 20px; font-size: 13.5px;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 1101px) {
  .mode-banner > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.mode-banner__tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; letter-spacing: 0.08em;
}
.mode-banner--sandbox { background: var(--warn-bg); color: var(--warn-ink); }
.mode-banner--sandbox .mode-banner__tag { background: var(--accent); color: #3a2600; }
.mode-banner--live { background: var(--err-bg); color: var(--err-ink); }
.mode-banner--live .mode-banner__tag { background: #c62828; color: #fff; }

/* ---------- khung ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100dvh - var(--banner-h));
}

.sidebar {
  position: sticky; top: var(--banner-h); align-self: start;
  display: flex; flex-direction: column; gap: 20px;
  height: calc(100dvh - var(--banner-h)); overflow-y: auto; padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px; color: var(--ink); text-decoration: none;
}
.brand:hover { color: var(--ink); }
.brand__mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-solid); color: #fff;
}
.brand__mark .icon { width: 20px; height: 20px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__name { font-weight: 800; letter-spacing: 0.02em; }
.brand__sub { font-size: 12.5px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 550; text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.nav__item .icon { color: var(--subtle); }
.nav__item:hover { background: var(--surface-3); color: var(--ink); }
.nav__item[aria-current="page"] { background: var(--primary-tint); color: var(--primary); }
.nav__item[aria-current="page"] .icon { color: var(--primary); }
.nav__badge {
  margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px;
  background: var(--err-ink); color: var(--surface); font-size: 12px; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums;
}
.tabs__item .nav__badge { margin-left: 6px; }

.sidebar__foot {
  margin-top: auto; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 8px 0; border-top: 1px solid var(--line);
}
.sidebar__user { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main {
  width: 100%; max-width: 1240px; padding: 28px 32px 64px;
  display: flex; flex-direction: column; gap: 20px;
}
.main:focus { outline: none; }

@media (max-width: 1100px) {
  .mode-banner { position: static; flex-wrap: wrap; padding: 6px 16px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 8px 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar__foot { order: 2; margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; align-items: center; }
  .sidebar__user { display: none; }
  .nav {
    order: 3; display: grid; width: 100%; gap: 4px;
    grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  }
  .nav__item {
    position: relative; flex-direction: column; justify-content: center; gap: 2px;
    padding: 6px 4px; font-size: 12px; text-align: center; line-height: 1.2;
  }
  .nav__item .nav__badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; font-size: 11px; }
  .main { padding: 20px 16px 48px; }
}

/* ---------- tiêu đề trang ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.page-head__main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.page-title { font-size: 26px; font-weight: 750; letter-spacing: -0.01em; }
.page-sub { margin-top: 4px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 13.5px; color: var(--muted); flex-wrap: wrap; }
.breadcrumb a { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; min-height: 24px; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .icon { width: 14px; height: 14px; }
.breadcrumb [aria-current] { color: var(--ink); font-weight: 600; }

/* ---------- nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 7px 14px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--primary-solid); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); color: #fff; }
@media (prefers-color-scheme: dark) {
  .btn--primary:hover:not(:disabled) { background: #1f56c9; }
}
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-input); }
.btn--secondary:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--surface-3); color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn--danger { background: #c62828; color: #fff; }
.btn--danger:hover { background: #a31f1f; color: #fff; }
.btn--danger-text { color: var(--err-ink); }
.btn--danger-text:hover { background: var(--err-bg); color: var(--err-ink); }
.btn--sm { min-height: max(30px, calc(var(--tap) - 6px)); padding: 4px 10px; font-size: 13.5px; gap: 6px; }
.btn--sm .icon { width: 16px; height: 16px; }
.btn--block { width: 100%; }
.btn--icon { min-height: var(--tap); min-width: var(--tap); padding: 0; }
.btn[data-busy-active] { cursor: progress; }
.btn.is-copied { color: var(--ok-ink); background: var(--ok-bg); }

.link-btn {
  min-height: 24px; padding: 0; border: 0; background: none;
  color: var(--primary); font: inherit; font-weight: 550; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

/* ---------- form ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form--grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 16px;
  padding: 4px 20px 20px;
}
.form--inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); margin-top: 8px; }
.form--inline .field { flex: 1 1 260px; }
.form__group { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.form__legend { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 4px; }
.form__actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.form__actions--full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--narrow { max-width: 110px; }
.field__label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field__label--inline { align-self: center; }
.field__hint { font-size: 13px; color: var(--muted); }
.field__error { font-size: 13px; font-weight: 550; color: var(--err-ink); }
.field__error::before { content: "⚠ "; }

.input {
  width: 100%; min-height: var(--tap); padding: 8px 12px;
  border: 1px solid var(--line-input); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: max(16px, 1em);
  transition: border-color 0.15s, box-shadow 0.15s;
}
@media (min-width: 1101px) { .input { font-size: 14.5px; } }
.input::placeholder { color: var(--subtle); opacity: 1; }
.input:hover { border-color: var(--line-strong); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--err-ink); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--err-ink) 22%, transparent); }
.input--sm { min-height: max(32px, calc(var(--tap) - 4px)); padding: 5px 10px; }
.input--num { font-variant-numeric: tabular-nums; max-width: 140px; }
.input--code { font-family: var(--font-mono); font-size: 22px; letter-spacing: 0.3em; text-align: center; padding: 10px; }
.input--file { padding: 6px; cursor: pointer; }
.input--file::file-selector-button {
  margin-right: 12px; padding: 6px 12px; border: 1px solid var(--line-input); border-radius: 6px;
  background: var(--surface-3); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select--auto { width: auto; min-width: 220px; }

.check { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); cursor: pointer; font-size: 14.5px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary-solid); }
.check--sm { font-size: 13.5px; min-height: 32px; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }

.search { position: relative; display: block; flex: 1 1 260px; max-width: 420px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--subtle); pointer-events: none; }
.input--search { padding-left: 36px; }
.search--sm { flex: 0 1 200px; }
.search--sm .icon { width: 16px; height: 16px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- thẻ & bố cục ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); min-width: 0;
}
.card > .form, .card > p, .card > .prose { padding: 0 20px 20px; }
.card > form:not(.form) { padding: 0 20px 20px; }
.card--muted { background: var(--surface-2); box-shadow: none; }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px 12px;
}
.card__head--wrap { flex-wrap: wrap; }
.card__title { font-size: 16px; font-weight: 700; }
.card__link { font-size: 13.5px; font-weight: 600; text-decoration: none; min-height: 24px; display: inline-flex; align-items: center; }

.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.split--wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.split--aside { grid-template-columns: minmax(0, 1fr) 320px; }
@media (max-width: 1100px) {
  .split, .split--wide, .split--aside { grid-template-columns: minmax(0, 1fr); }
}
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---------- số liệu ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat__value { font-size: 24px; }
}
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  color: inherit; text-decoration: none;
}
.stat__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat__value { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; }
.stat__hint { font-size: 12.5px; color: var(--subtle); }
.stat--link { transition: box-shadow 0.15s, border-color 0.15s; }
.stat--link:hover { border-color: color-mix(in srgb, var(--primary) 35%, transparent); box-shadow: var(--shadow-hover); color: inherit; }
.stat--alert { border-color: color-mix(in srgb, var(--err-ink) 40%, transparent); background: var(--err-bg); }
.stat--alert .stat__value, .stat--alert .stat__hint { color: var(--err-ink); }
.stat--ok .stat__value { color: var(--ok-ink); }
.stat--test .stat__value { color: var(--test-ink); }
.inline-form { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.inline-form .input--num { width: 72px; }

/* ---------- nhà mạng ---------- */
.carrier-logo {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 11px;
  color: #fff; font-size: 11.5px; font-weight: 800; letter-spacing: 0.02em;
  background: var(--primary-solid);
}
.carrier-logo--viettel { background: var(--viettel); }
.carrier-logo--vinaphone { background: var(--vinaphone); }
.carrier-logo--mobifone { background: var(--mobifone); }
@media (prefers-color-scheme: dark) { .carrier-logo { color: #0b1220; } }

.carrier-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.carrier-card {
  display: flex; flex-direction: column; gap: 14px; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  color: inherit; text-decoration: none; transition: box-shadow 0.15s, border-color 0.15s;
}
.carrier-card:hover { color: inherit; border-color: color-mix(in srgb, var(--primary) 35%, transparent); box-shadow: var(--shadow-hover); }
.carrier-card__head { display: flex; align-items: center; gap: 12px; }
.carrier-card__head > .icon { margin-left: auto; color: var(--subtle); }
.carrier-card__name { font-size: 16px; font-weight: 700; }
.carrier-card__meta { font-size: 12.5px; color: var(--muted); }
.carrier-card__nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.carrier-card__nums dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.carrier-card__nums dd { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }

.meter { width: 100%; height: 6px; }
.meter__track { fill: var(--surface-3); }
.meter__fill { fill: var(--primary-solid); }

/* ---------- cây thư mục ---------- */
.folder-group { display: flex; flex-direction: column; gap: 12px; scroll-margin-top: calc(var(--banner-h) + 16px); }
.folder-group__head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.folder-group__title { font-size: 18px; font-weight: 700; }
.folder-group__meta { color: var(--muted); font-size: 13.5px; }
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 12px; }
.folder {
  position: relative; display: flex; flex-direction: column; gap: 4px; height: 100%;
  padding: 16px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card);
  color: inherit; text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.folder:hover { color: inherit; border-color: color-mix(in srgb, var(--primary) 40%, transparent); box-shadow: var(--shadow-hover); background: var(--primary-tint-2); }
.folder--low { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.folder__icon { width: 44px; height: 37px; margin-bottom: 6px; color: var(--primary-solid); }
.folder__icon--viettel { color: var(--viettel); }
.folder__icon--vinaphone { color: var(--vinaphone); }
.folder__icon--mobifone { color: var(--mobifone); }
.folder__icon--lg { width: 56px; height: 47px; margin: 0; }
.folder__name { font-weight: 650; line-height: 1.3; }
.folder__code { font-size: 12px; color: var(--muted); }
.folder__counts { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.folder__counts strong { color: var(--ink); font-size: 15px; }
.folder__badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.folder__badges:empty { display: none; }

/* ---------- bảng ---------- */
.table-wrap {
  position: relative; overflow-x: auto; border-top: 1px solid var(--line); -webkit-overflow-scrolling: touch;
  /* Bóng ở mép khi còn nội dung cuộn ngang (lớp local che bóng khi đã cuộn tới mép). */
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgb(14 23 38 / 0.18), transparent) left center / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgb(14 23 38 / 0.18), transparent) right center / 14px 100% no-repeat scroll;
}
.card > .table-wrap:first-child { border-top: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.card > .table-wrap:only-child { border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 10px 14px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--primary-tint-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table--compact td { padding: 8px 14px; }
.actions-col { text-align: right; width: 1%; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.cell-link { display: inline-flex; align-items: center; min-height: 24px; font-weight: 600; text-decoration: none; color: var(--ink); }
.cell-link:hover { color: var(--primary); text-decoration: underline; }
.cell-sub { display: block; font-size: 12.5px; color: var(--muted); }
a.cell-sub--link { display: flex; align-items: center; width: fit-content; min-height: 24px; color: var(--primary); }
.actor { white-space: nowrap; min-width: 12ch; }
.iccid { white-space: nowrap; letter-spacing: 0.02em; }
.table-foot { padding: 10px 20px 16px; font-size: 13.5px; }
/* Bảng đơn hàng ở Phân bổ: mỗi đơn là một bảng riêng nên cố định độ rộng cột để các thẻ thẳng hàng. */
.table--orders { table-layout: fixed; }
.table--orders .col-status { width: 140px; }
.table--orders .col-time { width: 170px; }
.table--orders .col-actions { width: 210px; }
.table--orders td { overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .table:not(.table--stack):not(.table--fit) { min-width: 640px; }
  .table .col-opt { display: none; }
  /* table--stack: mỗi dòng thành một thẻ gọn (dữ liệu chính dòng trên, thao tác dòng dưới). */
  .table--stack thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .table--stack, .table--stack tbody { display: block; }
  .table--stack tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--line);
  }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td { display: block; padding: 0; border: 0; }
  .table--stack tbody tr:hover td { background: none; }
  .table--stack .cell-full, .table--stack .actions-col { flex-basis: 100%; }
  .table--stack .actions-col { width: auto; text-align: left; }
  .table--stack .row-actions { justify-content: flex-start; flex-wrap: wrap; }
}

/* ---------- chip trạng thái (có chữ, không chỉ màu) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px;
  border-radius: 999px; font-size: 12.5px; font-weight: 650; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
}
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip--available { background: var(--ok-bg); color: var(--ok-ink); }
.chip--assigned { background: var(--primary-tint); color: var(--primary); }
.chip--void { background: var(--surface-3); color: var(--muted); }
.chip--void .chip__dot { background: transparent; border: 1.5px solid currentColor; }
.chip--short { background: var(--err-bg); color: var(--err-ink); }
.chip--mail-sent { background: var(--ok-bg); color: var(--ok-ink); }
.chip--mail-pending { background: var(--primary-tint); color: var(--primary); }
.chip--mail-failed { background: var(--err-bg); color: var(--err-ink); }
.chip--mail-no_email { background: var(--warn-bg); color: var(--warn-ink); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 650; white-space: nowrap; vertical-align: middle;
  background: var(--surface-3); color: var(--muted);
}
.badge .icon { width: 13px; height: 13px; }
.badge--ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge--warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge--test { background: var(--test-bg); color: var(--test-ink); }
.badge--brand { background: var(--primary-tint); color: var(--primary); }
.action-tag { font-weight: 600; }
.kv-inline { display: inline-block; margin-right: 12px; font-size: 13px; }

/* ---------- thông báo ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border-radius: var(--radius-md); border: 1px solid transparent; font-size: 14px;
}
.alert .icon { margin-top: 1px; }
.alert--ok { background: var(--ok-bg); color: var(--ok-ink); border-color: color-mix(in srgb, var(--ok-ink) 20%, transparent); }
.alert--err { background: var(--err-bg); color: var(--err-ink); border-color: color-mix(in srgb, var(--err-ink) 20%, transparent); }
.alert--warn { background: var(--warn-bg); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn-ink) 20%, transparent); }
.alert--test { background: var(--test-bg); color: var(--test-ink); border-color: color-mix(in srgb, var(--test-ink) 20%, transparent); }
.alert--block { padding: 16px 18px; }
.alert--block > div { display: flex; flex-direction: column; gap: 6px; }
.alert__title { font-size: 15px; font-weight: 700; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 20px; text-align: center; }
.empty--page { padding: 64px 20px; }
.empty__title { font-weight: 700; color: var(--ink); }
.error-code { font-size: 13px; font-weight: 800; letter-spacing: 0.12em; color: var(--primary); }

/* ---------- danh sách ---------- */
.list { border-top: 1px solid var(--line); }
.list__item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
}
.list__item:last-child { border-bottom: 0; }
.list__item > div { min-width: 0; }
.list__title { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.list__title .icon { width: 16px; height: 16px; color: var(--subtle); }
.list__sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.list__time { flex: none; font-size: 12.5px; color: var(--subtle); }

/* ---------- lọc, tab, phân trang ---------- */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.filters > * { min-width: 0; max-width: 100%; }
.segmented {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3);
  overflow-x: auto; max-width: 100%; scrollbar-width: none;
}
.segmented__item {
  display: inline-flex; align-items: center; min-height: max(28px, calc(var(--tap) - 8px)); padding: 4px 10px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap;
}
.segmented__item:hover { color: var(--ink); }
.segmented__item[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(14 23 38 / 0.12); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs__item {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 8px 14px; margin-bottom: -1px;
  border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.tabs__item:hover { color: var(--ink); }
.tabs__item[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager__links { display: flex; align-items: center; gap: 8px; }
.pager__page { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager__info { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager__info--solo { padding: 10px 20px 14px; border-top: 1px solid var(--line); }

/* ---------- popover (huỷ / thu hồi): Popover API, hiện ở top layer nên không bị bảng cắt ---------- */
.popover {
  width: min(360px, calc(100vw - 32px)); padding: 0; margin: auto;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
}
.popover::backdrop { background: rgb(8 13 24 / 0.35); }
.popover__body { display: flex; flex-direction: column; gap: 10px; padding: 18px; text-align: left; white-space: normal; }
.popover__title { font-size: 16px; font-weight: 700; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.popover__title .mono { font-size: 13px; color: var(--muted); font-weight: 500; }
.popover__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.disclosure__summary {
  display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 14px 20px;
  font-weight: 700; cursor: pointer; list-style: none; color: var(--primary);
}
.disclosure__summary::-webkit-details-marker { display: none; }
.disclosure[open] .disclosure__summary { border-bottom: 1px solid var(--line); margin-bottom: 16px; }

/* ---------- bước nhập kho ---------- */
.steps { display: flex; gap: 8px; flex-wrap: wrap; counter-reset: none; }
.steps__item {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; color: var(--muted);
}
.steps__item[aria-current="step"] { border-color: var(--primary); color: var(--primary); background: var(--primary-tint-2); }
.steps__item--done { color: var(--ok-ink); }
.step-num {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-2); font-size: 12.5px; font-weight: 750;
}
.steps__item[aria-current="step"] .step-num { background: var(--primary-solid); color: #fff; }
.steps__item--done .step-num { background: var(--ok-bg); color: var(--ok-ink); }
.step-num .icon { width: 14px; height: 14px; }

.confirm-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; flex-wrap: wrap; }
.confirm-bar > p { padding: 0; color: var(--muted); }
.confirm-bar__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.confirm-bar__actions form { padding: 0; }

.prose { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.bullets { display: flex; flex-direction: column; gap: 4px; padding-left: 18px; list-style: disc; color: var(--ink-2); }

/* ---------- phân bổ ---------- */
.order__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 20px 10px; }
.order__name { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.order__delivery {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 20px 14px;
  border-top: 1px solid var(--line); font-size: 13.5px;
}
.order__delivery-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--ink-2); }
.order__delivery-label .icon { width: 16px; height: 16px; }
.order__delivery-to { color: var(--ink-2); }
.order__delivery-err { flex-basis: 100%; font-size: 12.5px; color: var(--err-ink); overflow-wrap: anywhere; }
.order__delivery-actions { margin-left: auto; }
@media (max-width: 560px) { .order__delivery-actions { margin-left: 0; } }

/* ---------- loại SIM ---------- */
.type-list { display: flex; flex-direction: column; gap: 10px; }
.type-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 14px 18px; scroll-margin-top: calc(var(--banner-h) + 16px); }
.type-row:target { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.type-row--archived { opacity: 0.72; }
.type-row__info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.type-row__name { font-weight: 650; }
.type-row__edit > summary { list-style: none; }
.type-row__edit > summary::-webkit-details-marker { display: none; }
.type-row__edit[open] { grid-column: 1 / -1; }
.type-row__panel { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.type-row__form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 0 !important; }
.type-row__form .field { flex: 1 1 180px; }
.type-row__form .field--grow { flex: 3 1 260px; }
.type-row__form .field--narrow { flex: 0 0 90px; }
.type-row__error { flex-basis: 100%; }
.type-row__archive { display: flex; justify-content: flex-end; padding: 8px 0 0 !important; border-top: 1px dashed var(--line); }

/* ---------- xem mã / TOTP ---------- */
.reveal { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; padding: 24px; align-items: start; }
@media (max-width: 760px) { .reveal { grid-template-columns: minmax(0, 1fr); justify-items: center; } }
.reveal__qr { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; font-size: 13px; }
.reveal__fields { display: flex; flex-direction: column; gap: 16px; width: 100%; }
.kv dt { font-size: 12.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kv dd { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.kv code { padding: 6px 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }

.qr { border-radius: var(--radius-md); background: #fff; padding: 10px; border: 1px solid var(--line); image-rendering: pixelated; }
.qr--lg { width: 280px; height: 280px; }
.totp-setup { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.totp-setup__text { flex: 1 1 200px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.secret { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.secret code { padding: 6px 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); letter-spacing: 0.06em; overflow-wrap: anywhere; }
.alert .secret code { background: var(--surface); }

/* ---------- trang đăng nhập ---------- */
.is-auth .auth {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  min-height: 100dvh; padding: 32px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--primary-tint), transparent 70%),
    var(--bg);
}
.auth:focus { outline: none; }
.auth__brand { display: flex; align-items: center; gap: 10px; }
.auth__foot { font-size: 12.5px; color: var(--subtle); text-align: center; }
.auth-card {
  width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; padding: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
}
.auth-card--wide { max-width: 520px; }
.auth-card--inline { align-self: center; box-shadow: var(--shadow-card); }
.auth-card__icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--primary-tint); color: var(--primary); }
.auth-card__icon .icon { width: 22px; height: 22px; }
.auth-card__title { font-size: 22px; font-weight: 750; }
.auth-card__lead { color: var(--muted); font-size: 14.5px; }
.auth-card__alt { display: flex; justify-content: center; }

/* ---------- hộp thoại xác nhận ---------- */
.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
}
.dialog::backdrop { background: rgb(8 13 24 / 0.5); }
.dialog__body { display: flex; flex-direction: column; gap: 12px; padding: 22px; }
.dialog__title { font-size: 18px; font-weight: 700; }
.dialog__text { color: var(--ink-2); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.dialog[open] { animation: pop-in 0.16s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* ---------- vùng bấm trên màn cảm ứng (≥ 44px) ---------- */
.empty a:not(.btn) { display: inline-flex; align-items: center; min-height: 24px; }
@media (pointer: coarse) {
  .btn--sm, .segmented__item, .input--sm, .check--sm { min-height: var(--tap); }
  .card__link, .breadcrumb a, .cell-link, a.cell-sub--link, .empty a:not(.btn) { min-height: var(--tap); }
}

/* ---------- chuyển động ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar, .mode-banner, .page-actions, .row-actions, .skip-link { display: none !important; }
  .shell { display: block; }
}
