/* ==========================================================================
   GZONE Media — admin UI v2
   No build step: plain CSS with custom properties. Light + dark themes.
   ========================================================================== */

/* ---------- Tokens ------------------------------------------------------- */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --line: #e2e5eb;
  --line-strong: #cdd2db;
  --ink: #1a1e26;
  --ink-2: #4a5263;
  --ink-3: #7b8394;
  --accent: #2b50e6;
  --accent-hover: #2142c9;
  --accent-ink: #ffffff;
  --accent-soft: #e9eeff;
  --accent-line: #c5d1ff;
  --ok: #13804f;
  --ok-soft: #e2f4ea;
  --warn: #9a5f08;
  --warn-soft: #fcf0d9;
  --danger: #c3342b;
  --danger-hover: #a92a22;
  --danger-soft: #fdebea;
  --focus: 0 0 0 3px rgba(43, 80, 230, .32);
  --shadow-pop: 0 18px 48px -12px rgba(16, 22, 40, .28), 0 2px 6px rgba(16, 22, 40, .08);
  --sidebar-bg: #ffffff;
  --mark: #1a1e26;

  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;

  --sidebar-w: 256px;
  --topbar-h: 64px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117;
    --surface: #161a22;
    --surface-2: #1b2029;
    --surface-3: #232935;
    --line: #262c38;
    --line-strong: #353d4c;
    --ink: #e8ebf1;
    --ink-2: #b2b9c7;
    --ink-3: #848c9c;
    --accent: #7d95ff;
    --accent-hover: #98abff;
    --accent-ink: #0c1230;
    --accent-soft: #1d2645;
    --accent-line: #34437a;
    --ok: #4cc58b;
    --ok-soft: #13291f;
    --warn: #e4ad55;
    --warn-soft: #2e2413;
    --danger: #ff7a70;
    --danger-hover: #ff958d;
    --danger-soft: #331816;
    --focus: 0 0 0 3px rgba(125, 149, 255, .4);
    --shadow-pop: 0 18px 48px -12px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .4);
    --sidebar-bg: #12161d;
    --mark: #e8ebf1;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1117;
  --surface: #161a22;
  --surface-2: #1b2029;
  --surface-3: #232935;
  --line: #262c38;
  --line-strong: #353d4c;
  --ink: #e8ebf1;
  --ink-2: #b2b9c7;
  --ink-3: #848c9c;
  --accent: #7d95ff;
  --accent-hover: #98abff;
  --accent-ink: #0c1230;
  --accent-soft: #1d2645;
  --accent-line: #34437a;
  --ok: #4cc58b;
  --ok-soft: #13291f;
  --warn: #e4ad55;
  --warn-soft: #2e2413;
  --danger: #ff7a70;
  --danger-hover: #ff958d;
  --danger-soft: #331816;
  --focus: 0 0 0 3px rgba(125, 149, 255, .4);
  --shadow-pop: 0 18px 48px -12px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .4);
  --sidebar-bg: #12161d;
  --mark: #e8ebf1;
  color-scheme: dark;
}

/* ---------- Base --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, svg, video { display: block; max-width: 100%; }
code, .mono { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-xs); }

.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;
}

.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 16px; height: 16px; }

.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Shell -------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 20px;
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; object-fit: contain; flex: none; }
.brand-text { min-width: 0; }
.brand-name { display: flex; align-items: center; gap: 6px; line-height: 1.2; }
/* Official GZONE wordmark (white PNG from gzone.vn) used as a mask, so it
   takes the text colour: dark on the light sidebar, white in dark mode. */
.brand-word {
  display: inline-block;
  width: 59px; height: 16px;
  background: currentColor;
  -webkit-mask: url("brand/gzone-logo.png") no-repeat center / contain;
          mask: url("brand/gzone-logo.png") no-repeat center / contain;
}
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-3); letter-spacing: 0; }

.nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-heading {
  padding: 0 10px 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
}
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 500;
}
.nav a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav a[aria-current="page"] .icon { color: var(--accent); }
.nav .icon { color: var(--ink-3); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px;
}
.me {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px 10px;
  min-width: 0;
}
.me-text { min-width: 0; }
.me-name { font-weight: 600; font-size: 13px; }
.me-sub { font-size: 12px; color: var(--ink-3); }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  flex: none;
  object-fit: cover;
  background: var(--surface-3);
  color: var(--ink-2);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 32px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar.is-scrolled { border-bottom-color: var(--line); }
.topbar-title { font-size: 17px; font-weight: 600; min-width: 0; }
.topbar-spacer { flex: 1; }
.btn.menu-btn { display: none; }

.content {
  width: 100%;
  min-width: 0; /* flex item: let .table-wrap scroll instead of widening the page */
  padding: 8px 32px 56px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 12px 0 20px;
}
.page-head h1 { font-size: 24px; }
.page-head p { color: var(--ink-2); margin-top: 4px; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.scrim { display: none; }

/* ---------- Buttons ------------------------------------------------------ */
.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-line: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--btn-line);
  border-radius: var(--r-sm);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font: inherit;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; background: var(--surface-3); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.btn-primary { --btn-bg: var(--accent); --btn-ink: var(--accent-ink); --btn-line: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { --btn-bg: var(--danger); --btn-ink: #fff; --btn-line: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-ghost { --btn-bg: transparent; --btn-line: transparent; --btn-ink: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); }
.btn-ghost-danger { --btn-bg: transparent; --btn-line: transparent; --btn-ink: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-soft); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }

.btn-google {
  height: 46px;
  width: 100%;
  gap: 12px;
  border-radius: 23px;
  font-size: 15px;
  --btn-bg: #ffffff;
  --btn-ink: #1f1f1f;
  --btn-line: #c9cdd4;
}
.btn-google:hover { background: #f5f7fa; }
.btn-google svg { width: 20px; height: 20px; }

/* ---------- Forms -------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-row + .field, .field + .field-row, .field-row + .field-row { margin-top: 16px; }
.label { font-weight: 500; font-size: 13px; color: var(--ink); }
.hint { font-size: 12.5px; color: var(--ink-3); }
.error-text { font-size: 12.5px; color: var(--danger); }

.input, .select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.input::placeholder { color: var(--ink-3); }
.input:hover, .select:hover { border-color: var(--ink-3); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input.mono { font-size: 13px; }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237b8394' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
input[type="date"].input { padding-right: 8px; }

.input-group { display: flex; }
.input-group .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .btn { border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-left: -1px; }

.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search .icon { position: absolute; left: 11px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 36px; }
.search kbd { position: absolute; right: 8px; }

kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--ink-3);
  background: var(--surface-2);
}

.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radio-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.radio-card input { accent-color: var(--accent); margin: 0; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Panels & tables --------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel + .panel, .panel + .grid-2, .grid-2 + .panel { margin-top: 20px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 15px; }
.panel-head p { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.panel-body { padding: 20px; }
.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 13px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.toolbar .search { flex: 1 1 240px; max-width: 360px; }
.toolbar .grow { flex: 1; }

.table-wrap { position: relative; overflow-x: auto; } /* contain .sr-only labels so they cannot widen the page */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 10px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .col-actions { text-align: right; white-space: nowrap; width: 1%; }
.table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover { color: var(--ink); text-decoration: none; }
.table th a[aria-sort] { color: var(--ink); }

.cell-user { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.cell-user .name { font-weight: 600; }
.cell-user .sub { color: var(--ink-3); font-size: 12.5px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.chip-plain::before { display: none; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }

.copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  cursor: pointer;
}
.copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy .icon { width: 14px; height: 14px; color: var(--ink-3); }
.copy:hover { border-color: var(--line-strong); }
.copy.is-copied { background: var(--ok-soft); color: var(--ok); }
.copy.is-copied .icon { color: var(--ok); }

/* Segmented filter (tabs) */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-md);
  background: var(--surface-3);
}
.segmented a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13px;
}
.segmented a:hover { color: var(--ink); text-decoration: none; }
.segmented a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 22, 40, .12); }
.segmented .count { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Pagination */
.pager { display: flex; align-items: center; gap: 4px; }
.pager a, .pager span {
  min-width: 32px; height: 32px;
  padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.pager a:hover { background: var(--surface-3); text-decoration: none; color: var(--ink); }
.pager [aria-current="page"] { background: var(--ink); color: var(--surface); font-weight: 600; }
.pager .is-disabled { opacity: .4; }

/* Empty state */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-2);
}
.empty .icon { width: 28px; height: 28px; margin: 0 auto 12px; color: var(--ink-3); }
.empty h3 { font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.empty p { max-width: 46ch; margin: 0 auto; }
.empty .btn { margin-top: 16px; }

/* Alerts */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}
.alert .icon { margin-top: 1px; }
.alert strong { color: var(--ink); }
.alert-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.alert-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert-accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink-2); }
.alert-accent .icon { color: var(--accent); }
.alert + .panel, .alert + .alert { margin-top: 16px; }
.mb { margin-bottom: 20px; }

/* ---------- Dialogs ------------------------------------------------------ */
dialog.modal {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
dialog.modal-sm { width: min(420px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(12, 16, 26, .45); }
dialog.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 0;
}
.modal-head h2 { font-size: 17px; }
.modal-head p { color: var(--ink-3); margin-top: 4px; font-size: 13px; }
.modal-body { padding: 18px 22px 4px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 18px 22px 20px;
}

/* ---------- Toasts ------------------------------------------------------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: toast-in .2s ease-out;
}
.toast .icon { margin-top: 1px; }
.toast-ok .icon { color: #5fd49b; }
.toast-error .icon { color: #ff8a80; }
.toast p { flex: 1; }
.toast button { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 0; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Dashboard ---------------------------------------------------- */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: 20px;
}
.stat {
  padding: 18px 20px;
  border-left: 1px solid var(--line);
  color: inherit;
}
.stat:first-child { border-left: 0; }
a.stat:hover { background: var(--surface-2); text-decoration: none; }
.stat-label { color: var(--ink-3); font-size: 13px; }
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.stat-lead .stat-value { color: var(--accent); }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.grid-2 > .panel + .panel { margin-top: 0; }
.stack > * + * { margin-top: 20px; }

/* Bar chart */
.bars {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  align-items: end;
  gap: 6px;
  height: 180px;
  padding: 8px 0 0;
}
.bar {
  position: relative;
  height: 100%;
  display: flex;
  align-items: flex-end;
}
.bar i {
  display: block;
  width: 100%;
  height: var(--h);
  min-height: 2px;
  border-radius: 4px 4px 1px 1px;
  background: var(--accent);
  opacity: .85;
}
.bar.is-weekend i { opacity: .5; }
.bar.is-today i { opacity: 1; }
.bar:hover i { opacity: 1; }
.bar .tip {
  position: absolute;
  left: 50%;
  bottom: calc(var(--h) + 6px);
  transform: translateX(-50%);
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--ink);
  color: var(--surface);
  font-size: 11.5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .1s;
}
.bar:hover .tip, .bar:focus-visible .tip { opacity: 1; }
.bars-axis {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Contact sheet — the signature element: thumbnails framed with crop marks */
.sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 22px 18px;
  padding: 22px 20px 20px;
}
.frame { position: relative; min-width: 0; color: inherit; }
.frame:hover { text-decoration: none; }
.frame-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-3);
  overflow: hidden;
  border-radius: 2px;
}
.frame-media img, .frame-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.frame-media .icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 26px; height: 26px;
  color: var(--ink-3);
}
.frame::before, .frame::after,
.frame-media::before, .frame-media::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border-color: var(--mark);
  border-style: solid;
  opacity: .55;
  z-index: 1;
  pointer-events: none;
}
.frame::before { top: -6px; left: -6px; border-width: 1px 0 0 1px; }
.frame::after { top: -6px; right: -6px; border-width: 1px 1px 0 0; }
.frame-media::before { bottom: -6px; left: -6px; border-width: 0 0 1px 1px; }
.frame-media::after { bottom: -6px; right: -6px; border-width: 0 1px 1px 0; }
.frame-media { overflow: visible; }
.frame-media > img, .frame-media > video, .frame-media > .thumb-fallback { border-radius: 2px; overflow: hidden; }
.frame:hover .frame-media img { filter: brightness(1.05); }
.frame-cap {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.35;
}
.frame-cap b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frame-cap span { color: var(--ink-3); }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { color: var(--ink-3); font-size: 12.5px; }

.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; width: var(--w); background: var(--accent); border-radius: 3px; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ink-3); }
.dot-ok { background: var(--ok); }
.dot-danger { background: var(--danger); }
.dot-accent { background: var(--accent); }

.welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 28px;
}
.welcome h2 { font-size: 20px; }
.welcome p { color: var(--ink-2); margin-top: 6px; max-width: 60ch; }


/* Audit */
.audit-meta { font-family: var(--mono); font-size: 12px; color: var(--ink-3); max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Auth (login) ------------------------------------------------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr);
  background: var(--surface);
}
.auth-art {
  position: relative;
  overflow: hidden;
  /* GZONE brand navy (theme colour of gzone.vn) with a soft red glow from the logo */
  background:
    radial-gradient(1100px 520px at 105% 115%, rgba(219, 32, 34, .28), transparent 60%),
    radial-gradient(800px 480px at -10% -20%, rgba(43, 80, 230, .30), transparent 60%),
    #010b26;
  color: #fff;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-art .brand { padding: 0; height: auto; color: #fff; }
.auth-art .brand-mark { width: 36px; height: 36px; }
.auth-art .brand-word { width: 70px; height: 19px; }
.auth-art .brand small { color: rgba(255, 255, 255, .7); }
.auth-title {
  font-size: clamp(36px, 4.4vw, 60px);
  line-height: 1.14;
  font-weight: 700;
  letter-spacing: -0.035em;
  max-width: 11ch;
}
.auth-lede { margin-top: 18px; max-width: 40ch; color: rgba(255, 255, 255, .78); font-size: 15px; }
.auth-foot { font-size: 12.5px; color: rgba(255, 255, 255, .6); }

/* Crop-marked contact sheet behind the headline */
.auth-art > div:not(.auth-sheet), .auth-art > .brand { position: relative; z-index: 1; }
.auth-sheet {
  position: absolute;
  right: -40px;
  top: 50%;
  transform: translateY(-50%) rotate(-6deg);
  display: grid;
  grid-template-columns: repeat(3, 150px);
  gap: 28px;
  opacity: .22;
  pointer-events: none;
}
.auth-sheet span {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(255, 255, 255, .5);
}
.auth-sheet span::before, .auth-sheet span::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: solid #fff;
}
.auth-sheet span::before { top: -9px; left: -9px; border-width: 1px 0 0 1px; }
.auth-sheet span::after { bottom: -9px; right: -9px; border-width: 0 1px 1px 0; }
.auth-sheet span:nth-child(3n+2) { background: rgba(255, 255, 255, .14); }

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 26px; letter-spacing: -0.02em; }
.auth-card > p { color: var(--ink-2); margin-top: 8px; }
.auth-card .alert { margin-top: 20px; }
.auth-actions { margin-top: 28px; display: grid; gap: 12px; }
.auth-help { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; }
.auth-help ul { margin: 8px 0 0; padding-left: 18px; }
.auth-help li + li { margin-top: 4px; }

/* ---------- Error pages -------------------------------------------------- */
.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
}
.error-code { font-size: 72px; font-weight: 700; letter-spacing: -0.04em; color: var(--accent); line-height: 1; }
.error-page h1 { font-size: 22px; margin-top: 12px; }
.error-page p { color: var(--ink-2); margin-top: 8px; max-width: 46ch; }
.error-page .btn { margin-top: 24px; }

/* ---------- Responsive --------------------------------------------------- */
@media (max-width: 1180px) {
  .stat-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(4) { border-left: 0; }
  .stat:nth-child(n+4) { border-top: 1px solid var(--line); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-pop);
  }
  .is-nav-open .sidebar { transform: none; }
  .is-nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(12, 16, 26, .45);
    z-index: 35;
  }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 4px 16px 40px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { padding: 28px 24px 32px; min-height: 0; }
  .auth-title { font-size: 34px; margin-top: 28px; }
  .auth-sheet { display: none; }
  .auth-foot { display: none; }
  .auth-panel { padding: 32px 16px 48px; align-items: flex-start; }
}

@media (max-width: 640px) {
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-left: 0; border-top: 1px solid var(--line); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .stat:nth-child(5) { grid-column: 1 / -1; border-left: 0; }
  .page-head h1 { font-size: 21px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .toolbar { padding: 12px 16px; }
  .toolbar .search { max-width: none; }
  .table th, .table td { padding-left: 14px; padding-right: 14px; }
  .bars { gap: 3px; height: 140px; }
  .bars-axis { gap: 3px; font-size: 10px; }
  .bars-axis span:nth-child(even) { visibility: hidden; }
  .sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 20px 16px; }
  .welcome { grid-template-columns: minmax(0, 1fr); padding: 20px; }
  .hide-sm { display: none !important; }
  .panel-head, .panel-body, .list li { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Media library ---------------------------------------------- */
.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: -6px 0 16px;
  font-size: 14px;
  color: var(--ink-3);
}
.crumbs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--r-xs);
  color: var(--ink-2);
  font-weight: 500;
}
.crumbs a:hover { background: var(--surface-3); text-decoration: none; color: var(--ink); }
.crumbs a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }

.media-panel { position: relative; }
.media-panel .dropzone-hint {
  display: none;
  position: absolute;
  inset: 8px;
  z-index: 5;
  border: 2px dashed var(--accent);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent-soft) 92%, transparent);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--accent);
  text-align: center;
  pointer-events: none;
}
.media-panel .dropzone-hint .icon { width: 32px; height: 32px; }
.media-panel .dropzone-hint span { color: var(--ink-2); font-size: 13px; }
.media-panel.is-dragging .dropzone-hint { display: flex; }

.selection-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent-line);
}
.selection-bar[hidden] { display: none; }
.selection-bar .grow { flex: 1; }

.upload-queue { border-bottom: 1px solid var(--line); padding: 12px 20px; display: grid; gap: 8px; }
.upload-queue[hidden] { display: none; }
.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.queue-head strong { flex: 1; }
.queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(80px, 1fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.queue-status { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-row.is-done .queue-status { color: var(--ok); }
.queue-row.is-error .queue-status { color: var(--danger); }
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.queue-row.is-done .progress i { background: var(--ok); }
.queue-row.is-error .progress i { background: var(--danger); }

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  padding: 18px 20px 4px;
}
.folder-tile {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  min-width: 0;
}
.folder-tile:hover { border-color: var(--line-strong); }
.folder-tile > a {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  color: var(--ink);
  font-weight: 500;
}
.folder-tile > a:hover { text-decoration: none; }
.folder-tile > a .icon { color: var(--accent); flex: none; }
.folder-tile .item-actions { opacity: 0; transition: opacity .12s; }
.folder-tile:hover .item-actions, .folder-tile:focus-within .item-actions { opacity: 1; }

.item-actions { display: inline-flex; align-items: center; gap: 2px; }
.item-actions form { display: inline; }

.media-sheet { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); }
.media-tile { margin: 0; }
.media-tile .frame-media {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  cursor: zoom-in;
  font: inherit;
  color: inherit;
}
.media-tile .thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-3);
}
.media-tile .thumb-fallback .icon { position: static; margin: 0; }
.media-tile .thumb-fallback b { font-size: 11px; letter-spacing: .04em; }
.media-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  opacity: 0;
  transition: opacity .12s;
}
.media-tile:hover .media-check, .media-check:focus-visible, .media-check:checked { opacity: 1; }
.media-tile { position: relative; }
.media-cap-text { min-width: 0; }
.media-cap-text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-cap .item-actions {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  padding: 2px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 4px 14px rgb(0 0 0 / .12);
  opacity: 0; transition: opacity .12s;
}
.media-tile:hover .media-cap .item-actions, .media-tile:focus-within .media-cap .item-actions { opacity: 1; }
@media (hover: none) { .media-cap .item-actions, .folder-tile .item-actions, .media-check { opacity: 1; } }
.media-tile.is-selected .frame-media { box-shadow: 0 0 0 3px var(--accent); border-radius: 3px; }
.check { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }

.media-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.media-name .icon { color: var(--ink-3); flex: none; }
a.media-name .icon { color: var(--accent); }
.media-table tr.is-selected td { background: var(--accent-soft); }

dialog.modal-lg { width: min(960px, calc(100vw - 32px)); }
.preview-stage {
  display: grid;
  place-items: center;
  min-height: 240px;
  max-height: 64vh;
  background: var(--surface-3);
  border-radius: var(--r-md);
  overflow: hidden;
}
.preview-stage img, .preview-stage video { max-width: 100%; max-height: 64vh; object-fit: contain; }
.preview-stage audio { width: min(480px, 90%); }
.uploaded-body { max-height: 60vh; overflow: auto; padding-top: 4px; padding-bottom: 4px; }
.uploaded-list { list-style: none; margin: 0; padding: 0; }
.uploaded-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.uploaded-row:last-child { border-bottom: 0; }
.uploaded-thumb {
  width: 56px; height: 56px; border-radius: 6px; overflow: hidden; display: grid; place-items: center;
  background: var(--surface-3); color: var(--ink-3); font-size: 11px; letter-spacing: .04em;
}
.uploaded-thumb img { width: 100%; height: 100%; object-fit: cover; }
.uploaded-info { min-width: 0; display: grid; gap: 4px; }
.uploaded-info b { font-weight: 500; font-size: 13.5px; }
.uploaded-url { max-width: 100%; justify-self: start; }
.uploaded-url span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-file { padding: 32px; color: var(--ink-2); text-align: center; max-width: 40ch; }
.preview-url { margin-top: 12px; max-width: 100%; }
.modal-foot .grow { flex: 1; }

@media (max-width: 640px) {
  .media-sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .folder-grid { grid-template-columns: minmax(0, 1fr); padding: 14px 16px 0; }
  .folder-tile .item-actions { opacity: 1; }
  .media-check { opacity: 1; }
  .media-cap .item-actions { position: static; opacity: 1; margin: 4px 0 0 -6px; padding: 0; background: none; border: 0; box-shadow: none; }
  .queue-row { grid-template-columns: minmax(0, 1fr) 70px; }
  .uploaded-row { grid-template-columns: 44px minmax(0, 1fr); }
  .uploaded-thumb { width: 44px; height: 44px; }
  .uploaded-row > .btn { grid-column: 2; justify-self: start; }
  #uploaded-dialog .modal-foot { flex-wrap: wrap; }
  #uploaded-dialog .modal-foot .grow { display: none; }
  #uploaded-dialog .modal-foot > .btn { flex: 1; justify-content: center; }
  #uploaded-dialog [data-uploaded-copy-html] { order: 3; flex-basis: 100%; }
  .queue-status { grid-column: 1 / -1; }
  .selection-bar { padding: 10px 16px; flex-wrap: wrap; }
}
