/* ==========================================================================
   Admin Panel - design system
   Brand palette sampled from the meteorbet88 logo:
   royal blue  #07269a   |   meteor gold  #dea31b
   ========================================================================== */

:root,
[data-theme="light"] {
  /* brand */
  --brand-300: #6b86ee;
  --brand-400: #3b57d9;
  --brand: #1a3ac4;
  --brand-600: #102ba8;
  --brand-700: #07269a;
  --brand-800: #061d78;
  --accent-300: #f6cf6a;
  --accent-400: #f0b429;
  --accent: #dea31b;
  --accent-600: #b8830e;

  /* aliases kept for existing markup */
  --primary: var(--brand);
  --primary-2: var(--brand-600);

  /* surfaces */
  --bg: #f3f6fc;
  --bg-accent: #e9eef9;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #eef2fa;
  --text: #0d1526;
  --text-soft: #47536b;
  --muted: #6b7893;
  --line: #e3e8f2;
  --line-strong: #ccd5e6;

  /* status */
  --success: #0f7a53;
  --danger: #cf2222;
  --warning: #b8730a;
  --success-soft: rgba(15, 122, 83, 0.11);
  --danger-soft: rgba(207, 34, 34, 0.11);
  --warning-soft: rgba(184, 115, 10, 0.13);
  --brand-soft: rgba(26, 58, 196, 0.09);

  /* sidebar - light surface so the full-colour logo stays readable */
  --sidebar: #ffffff;
  --sidebar-2: #f6f8fd;
  --sidebar-text: #101a2e;
  --sidebar-muted: #5c6a86;
  --sidebar-strong: #07269a;
  --sidebar-accent: #b8830e;
  --sidebar-hover: rgba(26, 58, 196, 0.07);
  --sidebar-active: rgba(26, 58, 196, 0.1);
  --sidebar-line: #e3e8f2;
  --sidebar-danger: #cf2222;
  --sidebar-danger-soft: rgba(207, 34, 34, 0.09);
  --tip-bg: #101a2e;
  --tip-text: #ffffff;

  /* shape + depth */
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(13, 21, 38, 0.06), 0 1px 3px rgba(13, 21, 38, 0.04);
  --shadow: 0 2px 4px rgba(13, 21, 38, 0.04), 0 10px 26px rgba(13, 21, 38, 0.07);
  --shadow-lg: 0 4px 10px rgba(13, 21, 38, 0.07), 0 24px 52px rgba(13, 21, 38, 0.14);
  --ring: 0 0 0 3px rgba(26, 58, 196, 0.22);

  --rail: 76px;
  --side-w: 260px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --brand-300: #a9bcff;
  --brand-400: #8ba3fb;
  --brand: #6f8bf7;
  --brand-600: #4f6ff0;
  --brand-700: #3c5ce2;
  --brand-800: #2c47c4;
  --accent-300: #ffdd94;
  --accent-400: #f7c53f;
  --accent: #f0b429;
  --accent-600: #d99a12;

  --bg: #060a13;
  --bg-accent: #0e1526;
  --surface: #111a2b;
  --surface-2: #0c1322;
  --surface-3: #17223a;
  --text: #e9eefb;
  --text-soft: #b7c3db;
  --muted: #8b99b4;
  --line: #202d46;
  --line-strong: #32436a;

  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --success-soft: rgba(52, 211, 153, 0.13);
  --danger-soft: rgba(248, 113, 113, 0.13);
  --warning-soft: rgba(251, 191, 36, 0.14);
  --brand-soft: rgba(111, 139, 247, 0.14);

  --sidebar: #0a1224;
  --sidebar-2: #05080f;
  --sidebar-text: #e6ecfb;
  --sidebar-muted: #8b9cc0;
  --sidebar-strong: #ffffff;
  --sidebar-accent: #f7c53f;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(255, 255, 255, 0.1);
  --sidebar-line: rgba(255, 255, 255, 0.08);
  --sidebar-danger: #ffb9b9;
  --sidebar-danger-soft: rgba(248, 113, 113, 0.14);
  --tip-bg: #16233f;
  --tip-text: #e6ecfb;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 6px 14px rgba(0, 0, 0, 0.45), 0 28px 60px rgba(0, 0, 0, 0.55);
  --ring: 0 0 0 3px rgba(111, 139, 247, 0.3);
}

/* --------------------------------------------------------------- base --- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* Safety net only: every known source of horizontal overflow is fixed at the
   source below (grid tracks use minmax(0, 1fr), scroll containers get min-width: 0).
   `clip` on the x axis alone keeps overflow-y visible so the sticky topbar works. */
html { overflow-x: clip; }

body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(900px 460px at 100% -12%, rgba(26, 58, 196, 0.1), transparent 55%),
    radial-gradient(760px 380px at -5% 0%, rgba(222, 163, 27, 0.09), transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(900px 460px at 100% -12%, rgba(79, 111, 240, 0.16), transparent 55%),
    radial-gradient(760px 380px at -5% 0%, rgba(222, 163, 27, 0.08), transparent 50%);
}

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.015em; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

svg.ico {
  display: block;
  flex: none;
  width: 20px;
  height: 20px;
  stroke: currentColor;
  transition: color 0.14s var(--ease), transform 0.18s var(--ease);
}
svg.ico-sm {
  width: 14px;
  height: 14px;
  stroke-width: 2.25;
}

/* icon sizing by context */
.nav-ico svg.ico {
  width: 18px;
  height: 18px;
}
.icon-btn svg.ico,
.sidebar-close svg.ico {
  width: 20px;
  height: 20px;
}
.theme-ico svg.ico,
.layout-ico svg.ico {
  width: 18px;
  height: 18px;
}
.layout-option-ico svg.ico {
  width: 18px;
  height: 18px;
}
.breadcrumb svg.ico {
  width: 14px;
  height: 14px;
  opacity: 0.72;
}
.breadcrumb .crumb-link:hover svg.ico {
  opacity: 1;
  color: var(--brand);
}
.topnav-chevron svg.ico,
.nav-chevron svg.ico {
  opacity: 0.55;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--surface);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  box-shadow: var(--shadow);
}
.skip-link:focus { left: 0; text-decoration: none; }

/* -------------------------------------------------------------- shell --- */
.app-shell { display: flex; min-width: 0; width: 100%; min-height: 100vh; }
.sidebar-rail { display: none; }

.main {
  flex: 1;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------ sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 272px;
  max-width: 86vw;
  z-index: 60;
  display: flex;
  flex-direction: column;
  color: var(--sidebar-text);
  background: linear-gradient(175deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  border-right: 1px solid var(--sidebar-line);
  transform: translateX(-102%);
  transition: transform 0.22s var(--ease);
}
.sidebar.open { transform: none; box-shadow: var(--shadow-lg); }

/* soft gold hairline along the sidebar edge */
.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(222, 163, 27, 0.35), transparent);
  pointer-events: none;
}

.brand {
  position: relative;
  height: 68px;
  flex: none;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--sidebar-line);
  overflow: hidden;
}
.brand-link {
  position: relative;
  display: block;
  flex: 1;
  height: 100%;
  min-width: 0;
  text-decoration: none;
}
.brand-link:hover { text-decoration: none; }

.brand-mark {
  position: absolute;
  left: 38px;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  opacity: 0;
  transition: opacity 0.14s var(--ease);
}
.brand-mark img { width: 34px; height: 34px; object-fit: contain; display: block; }

.brand-full {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: block;
  white-space: nowrap;
  transition: opacity 0.18s var(--ease) 0.03s;
}
.brand-logo { display: block; height: 26px; width: auto; max-width: 200px; }
.brand-sub {
  display: block;
  margin-top: 3px;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}
.logo-on-dark { display: none; }
[data-theme="dark"] .logo-on-light { display: none; }
[data-theme="dark"] .logo-on-dark { display: block; }

.sidebar-close {
  flex: none;
  margin-right: 0.75rem;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--sidebar-line);
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
  cursor: pointer;
}
.sidebar-close:hover { background: var(--sidebar-hover); }

.nav {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.nav-scroll {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.35rem 0.625rem 0.55rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(128, 128, 128, 0.28) transparent;
}
.nav-scroll::-webkit-scrollbar { width: 5px; }
.nav-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.28);
}

.nav-group + .nav-group,
.nav-link + .nav-group,
.nav-group + .nav-link { margin-top: 0.12rem; }

.nav-section-label {
  padding: 0.45rem 1rem 0.35rem;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  opacity: 0.88;
  white-space: nowrap;
  transition: opacity 0.14s var(--ease);
}

.nav-divider {
  height: 1px;
  margin: 0.45rem 0.75rem 0.35rem;
  background: var(--sidebar-line);
}

.nav-scroll a,
.nav-group-toggle,
.pin-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  padding: 0.5rem 1rem;
  margin: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.nav-group-toggle .nav-ico,
.nav-scroll a .nav-ico,
.pin-btn .nav-ico {
  background: transparent;
  border: 0;
  box-shadow: none;
}
.nav-scroll a:hover,
.nav-group-toggle:hover,
.pin-btn:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
  text-decoration: none;
}
.nav-scroll a:active,
.nav-group-toggle:active { transform: translateY(1px); }

.nav-group-toggle .nav-chevron {
  flex: none;
  margin-left: auto;
  opacity: 0.55;
  transition: transform 0.2s var(--ease), opacity 0.14s var(--ease);
}
.nav-group.is-open > .nav-group-toggle .nav-chevron { transform: rotate(180deg); opacity: 0.85; }
.nav-group.has-active > .nav-group-toggle {
  color: var(--sidebar-text);
  font-weight: 600;
}
.nav-group.has-active > .nav-group-toggle .nav-ico { color: var(--sidebar-accent); }
.nav-group-toggle.flyout-open {
  background: var(--sidebar-active);
  color: var(--sidebar-strong);
}

.nav-submenu {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.24s var(--ease);
}
.nav-group.is-open .nav-submenu { max-height: 320px; }

.nav-sub {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.4rem 1rem 0.4rem 2.45rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-muted);
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.nav-sub:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
  text-decoration: none;
}
.nav-sub-dot {
  position: absolute;
  left: 1.28rem;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
}
.nav-sub.active {
  background: var(--sidebar-active);
  color: var(--sidebar-strong);
  font-weight: 600;
}
.nav-sub.active .nav-sub-dot {
  opacity: 1;
  background: var(--sidebar-accent);
}

.nav-flyout {
  position: fixed;
  z-index: 80;
  min-width: 210px;
  max-width: 260px;
  padding: 0.45rem;
  border-radius: var(--radius);
  border: 1px solid var(--sidebar-line);
  background: linear-gradient(175deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  box-shadow: var(--shadow-lg);
  animation: nav-flyout-in 0.16s var(--ease);
}
.nav-flyout[hidden] { display: none !important; }
.nav-flyout-head {
  padding: 0.35rem 0.65rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}
.nav-flyout-body { display: grid; gap: 2px; }
.nav-flyout .nav-sub {
  padding-left: 1.35rem;
}
.nav-flyout .nav-sub-dot { left: 0.55rem; }
@keyframes nav-flyout-in {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}

.nav-scroll a.nav-link.active,
.nav-scroll a.active:not(.nav-sub) {
  background: var(--sidebar-active);
  color: var(--sidebar-strong);
  font-weight: 600;
}
.nav-scroll a.nav-link.active::before,
.nav-scroll a.active:not(.nav-sub)::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--accent-400), var(--accent-600));
}
.nav-scroll a.nav-logout { margin-top: 0.15rem; }
.nav-scroll a.nav-logout:hover { color: var(--sidebar-danger); background: var(--sidebar-danger-soft); }

.nav-ico {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--sidebar-muted);
  transition: color 0.14s var(--ease);
}
.nav-scroll a:hover .nav-ico,
.nav-group-toggle:hover .nav-ico,
.pin-btn:hover .nav-ico {
  color: var(--sidebar-text);
}
.nav-scroll a.nav-link.active .nav-ico,
.nav-scroll a.active:not(.nav-sub) .nav-ico {
  color: var(--sidebar-accent);
}
.nav-group.has-active > .nav-group-toggle .nav-ico {
  color: var(--sidebar-accent);
}
.nav-scroll a.nav-logout:hover .nav-ico {
  color: var(--sidebar-danger);
}
.nav-label { white-space: nowrap; transition: opacity 0.14s var(--ease); }

.sidebar-foot {
  flex: none;
  padding: 0.5rem 0.625rem 0.7rem;
  border-top: 1px solid var(--sidebar-line);
}
.pin-btn { font-size: 0.85rem; }
.pin-btn .nav-ico { transition: transform 0.18s var(--ease); }
[data-sidebar="pinned"] .pin-btn { color: var(--sidebar-accent); }
[data-sidebar="pinned"] .pin-btn .nav-ico { transform: rotate(-35deg); }
.foot-version {
  padding: 0.3rem 1rem 0;
  font-size: 0.7rem;
  color: var(--sidebar-muted);
  font-variant-numeric: tabular-nums;
}

/* tooltip shown while the rail is collapsed */
.nav-scroll a::after,
.nav-group-toggle::after,
.pin-btn::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  background: var(--tip-bg);
  border: 1px solid var(--tip-bg);
  color: var(--tip-text);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.12s var(--ease), transform 0.12s var(--ease);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.55);
  backdrop-filter: blur(2px);
  z-index: 50;
}
.sidebar-backdrop.open { display: block; }

/* ------------------------------------------------------------- topbar --- */
.header-shell {
  position: sticky;
  top: 0;
  z-index: 30;
  flex: none;
  background: var(--bg);
  overflow: visible;
}
[data-nav-layout="top"] .header-shell {
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
[data-nav-layout="side"] .header-shell .topbar {
  border-bottom: 1px solid var(--line);
}
.topbar {
  position: relative;
  top: auto;
  z-index: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
@supports (backdrop-filter: blur(10px)) {
  .topbar {
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(12px) saturate(140%);
  }
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.breadcrumb {
  display: none;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 1px;
}
.breadcrumb > span { display: inline-flex; align-items: center; gap: 0.3rem; }
.breadcrumb .crumb-sep { opacity: 0.6; }
.breadcrumb .crumb-current { color: var(--text-soft); font-weight: 600; }

.breadcrumb .crumb-current { color: var(--text-soft); font-weight: 600; }
.breadcrumb .crumb-link {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.14s var(--ease);
}
.breadcrumb .crumb-link:hover { color: var(--brand); text-decoration: none; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  height: 40px;
  padding: 0 0.7rem 0 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background 0.14s var(--ease), color 0.14s var(--ease), border-color 0.14s var(--ease);
}
.back-btn:hover {
  color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  background: var(--surface-2);
  text-decoration: none;
}
.back-btn:active { transform: translateY(1px); }
.back-btn .ico { width: 18px; height: 18px; }
.back-label {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }

.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.14s var(--ease), color 0.14s var(--ease), border-color 0.14s var(--ease);
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand-300); background: var(--surface-2); }
.icon-btn:active { transform: translateY(1px); }

.theme-ico { display: none; }
[data-theme-mode="light"] .theme-ico-sun { display: block; }
[data-theme-mode="dark"] .theme-ico-moon { display: block; }
[data-theme-mode="system"] .theme-ico-system { display: block; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 40px;
  padding: 0 0.85rem 0 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-soft);
  max-width: 190px;
}
.user-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-400));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ content --- */
.content {
  flex: 1;
  width: 100%;
  max-width: none;
  padding: 1.5rem 1.25rem 2rem;
}
.app-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  max-width: none;
  padding: 1rem 1.25rem 1.6rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.footer-brand { font-weight: 600; color: var(--text-soft); }
.footer-dot { opacity: 0.6; }

/* -------------------------------------------------------------- cards --- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 0.9rem;
  margin-bottom: 1.1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.05rem 1.15rem;
}
.card h3 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.card .value {
  margin-top: 0.3rem;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* stat tiles get a little brand character */
.cards > .card {
  position: relative;
  overflow: hidden;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease), border-color 0.16s var(--ease);
}
.cards > .card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--brand), var(--accent));
  opacity: 0.85;
}
.cards > .card::after {
  content: "";
  position: absolute;
  top: -46px;
  right: -46px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--brand-soft), transparent 68%);
  pointer-events: none;
}
.cards > .card > * { position: relative; z-index: 1; }
.cards > .card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
}

.panel { margin-bottom: 1.1rem; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.panel-head h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
}
.panel-head h2 + .mono { margin-top: 0.2rem; }

/* `minmax(0, 1fr)` is mandatory here: the implicit `minmax(auto, 1fr)` lets a column
   grow to the min-content width of its contents, and the 760px-wide tables inside
   these panels would then push the whole document wider than the viewport. */
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
}
.grid-2 > * { min-width: 0; }

/* -------------------------------------------------------------- forms --- */
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 0.35rem;
}
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.form-grid > * { min-width: 0; }
.form-grid .full { grid-column: 1 / -1; }
.help { color: var(--muted); font-size: 0.8rem; margin-top: 0.35rem; }
pre.help {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  overflow: auto;
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--surface-3);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
}

/* `input:not([type])` matters: several forms render a bare <input> that
   defaults to text but would otherwise miss every attribute selector below. */
input:not([type]), input[type="text"], input[type="url"], input[type="password"],
input[type="search"], input[type="datetime-local"], input[type="date"],
input[type="number"], input[type="file"], input[type="email"], select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  font: inherit;
  transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
textarea { min-height: 110px; resize: vertical; }
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); width: 16px; height: 16px; }

/* ------------------------------------------------------------ buttons --- */
/* NOTE: keep this selector free of element qualifiers, otherwise `button.btn`
   would out-rank the `.btn-secondary` / `.btn-danger` variants below. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.65rem 1.05rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  color: #fff;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: filter 0.14s var(--ease), transform 0.1s var(--ease), box-shadow 0.14s var(--ease), background 0.14s var(--ease);
}
.btn:hover { filter: brightness(1.08); text-decoration: none; box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-soft);
  border-color: var(--line-strong);
}
.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--brand);
  border-color: var(--brand-300);
  filter: none;
}
.btn-danger {
  background: linear-gradient(135deg, #e03b3b, #b81c1c);
  color: #fff;
  border-color: transparent;
}
.btn-sm {
  min-height: 34px;
  padding: 0.35rem 0.7rem;
  border-radius: 9px;
  font-size: 0.82rem;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ------------------------------------------------------------- tables --- */
.table-wrap {
  overflow: auto;
  /* keep the sideways scrolling inside this box instead of on the document */
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.88rem;
  vertical-align: middle;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
tbody tr { transition: background 0.12s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td .btn-row { flex-wrap: nowrap; }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
}
.muted { color: var(--muted); }
.truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------- badges + feedback --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  background: var(--surface-3);
  color: var(--muted);
}
.badge-active { background: var(--success-soft); color: var(--success); border-color: var(--success-soft); }
.badge-disabled { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }
.badge-expired { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-soft); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filters .grow { flex: 1; min-width: 190px; }

/* Floating notifications. Newest sits on top; the countdown bar drives the
   auto-dismiss so hovering can pause it. */
.toast-stack {
  position: fixed;
  z-index: 120;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  --toast-accent: var(--brand);
  --toast-tint: var(--brand-soft);
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.7rem;
  overflow: hidden;
  padding: 0.85rem 0.9rem 0.95rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--toast-accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.16);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 0.42s cubic-bezier(0.21, 1.02, 0.73, 1) both;
}

.toast.toast-out {
  animation: toast-out 0.32s ease forwards;
}

.toast-icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: var(--toast-tint);
  color: var(--toast-accent);
}

.toast-icon svg {
  width: 16px;
  height: 16px;
}

.toast-body { min-width: 0; }

.toast-title {
  display: block;
  margin-bottom: 0.1rem;
  color: var(--toast-accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.toast-message { overflow-wrap: anywhere; }

.toast-close {
  display: grid;
  width: 24px;
  height: 24px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  place-items: center;
}

.toast-close:hover {
  background: var(--toast-tint);
  color: var(--toast-accent);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform-origin: left center;
  background: var(--toast-accent);
  opacity: 0.55;
  animation: toast-countdown 4.5s linear forwards;
}

.toast:hover .toast-progress,
.toast:focus-within .toast-progress {
  animation-play-state: paused;
}

.toast-success { --toast-accent: var(--success); --toast-tint: var(--success-soft); }
.toast-error { --toast-accent: var(--danger); --toast-tint: var(--danger-soft); }
.toast-info { --toast-accent: var(--brand); --toast-tint: var(--brand-soft); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(28px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(28px) scale(0.96); }
}

@keyframes toast-countdown {
  to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .toast-progress { animation-duration: 6s; }
}

@media (max-width: 640px) {
  .toast-stack {
    top: auto;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    width: auto;
    flex-direction: column-reverse;
  }
}

.pagination { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination a, .pagination span {
  min-width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pagination a:hover { border-color: var(--brand-300); color: var(--brand); text-decoration: none; }
.pagination .current {
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.stack > * + * { margin-top: 0.9rem; }

/* --------------------------------------------------- modal + widgets --- */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.6);
  z-index: 80;
}
.modal.open { display: flex; }
.modal-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-lg);
}
.modal-card h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }

.confirm-modal .modal-card { animation: toast-in 0.28s ease both; }
.confirm-modal .confirm-title { color: var(--danger); }
.confirm-modal .confirm-text { margin: 0 0 1.15rem; font-size: 0.88rem; line-height: 1.5; }
.confirm-modal .confirm-actions { justify-content: flex-end; }
.modal-card p { margin: 0 0 1.1rem; color: var(--muted); }

.chart-box { position: relative; height: 260px; }

.success-box {
  border: 1px solid var(--success);
  background: var(--success-soft);
  border-radius: var(--radius);
  padding: 1.05rem 1.15rem;
  margin-bottom: 1.1rem;
}

.qr-box {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

hr { border: 0; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------- analytics --- */
/* Same reason as .grid-2: minmax(0, 1fr) instead of the implicit
   minmax(auto, 1fr), so a wide child can never stretch the track and put a
   scrollbar on the document. */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
  margin-bottom: 1.1rem;
}
.grid-4 > * { min-width: 0; }
.grid-4 > .panel { margin-bottom: 0; }

.chart-box-lg { height: 330px; }

/* period picker */
.range-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
  margin-bottom: 1.1rem;
}
.range-presets { display: flex; flex-wrap: wrap; gap: 0.35rem; min-width: 0; }
.range-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.range-pill:hover { border-color: var(--brand-300); color: var(--brand); text-decoration: none; }
.range-pill.is-active {
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
/* "Custom" only reflects state; the date inputs next to it are the control */
.range-pill.is-static { cursor: default; }
.range-pill.is-static:hover { border-color: var(--line-strong); color: var(--text-soft); }
.range-pill.is-static.is-active:hover { border-color: transparent; color: #fff; }

.range-custom { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; min-width: 0; }
.range-custom label { margin: 0; font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.range-custom input[type="date"] {
  width: auto;
  min-width: 138px;
  padding: 0.36rem 0.55rem;
  font-size: 0.82rem;
}
/* the native calendar glyph follows color-scheme, not color */
[data-theme="dark"] .range-custom input[type="date"] { color-scheme: dark; }
.range-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-left: auto; }

/* KPI comparison */
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.5rem; }
.kpi-sub { font-size: 0.72rem; color: var(--muted); }
.delta {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.delta-up { background: var(--success-soft); color: var(--success); }
.delta-down { background: var(--danger-soft); color: var(--danger); }

/* breakdown bars */
.bars { display: flex; flex-direction: column; gap: 0.6rem; }
.bar-row { min-width: 0; }
.bar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.28rem;
  font-size: 0.82rem;
}
.bar-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-soft);
}
.bar-val { flex: none; font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

/* share column inside the top links table */
.share { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 108px; }
.share-track {
  flex: 1;
  height: 6px;
  min-width: 44px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.share-fill { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.share-num { flex: none; font-size: 0.8rem; color: var(--text-soft); font-variant-numeric: tabular-nums; }

.th-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.th-sort:hover { color: var(--brand); text-decoration: none; }

/* day x hour heatmap - scrolls inside its own box, never the page */
.heat-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
  max-width: 100%;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}
.heat-grid {
  display: grid;
  grid-template-columns: 38px repeat(24, minmax(12px, 1fr));
  gap: 3px;
  min-width: 400px;
}
.heat-corner { display: block; }
.heat-hour {
  font-size: 0.62rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.heat-day {
  display: flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-soft);
}
.heat-cell {
  position: relative;
  display: block;
  height: 18px;
  border-radius: 4px;
  background: var(--surface-3);
}
.heat-cell > i { position: absolute; inset: 0; border-radius: 4px; background: var(--brand); }
.heat-legend { display: flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; }
.heat-demo { width: 16px; height: 16px; flex: none; }

/* empty period */
.empty-state { text-align: center; padding: 2.4rem 1.25rem; margin-bottom: 1.1rem; }
.empty-state h2 { margin: 0.8rem 0 0.4rem; font-size: 1.1rem; }
.empty-state p { margin: 0 auto 0.5rem; max-width: 52ch; }
.empty-ico {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
}
.empty-ico .ico {
  width: 28px;
  height: 28px;
  stroke-width: 1.75;
}

/* -------------------------------------------------------------- loader --- */
.app-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  transition: opacity 0.28s var(--ease), visibility 0.28s var(--ease);
  animation: loader-failsafe 0.2s ease 3s forwards;
}
.app-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  animation: none;
}
@keyframes loader-failsafe {
  to { opacity: 0; visibility: hidden; pointer-events: none; }
}
.app-loader-glow {
  position: absolute;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}
.app-loader-glow-a {
  top: 25%;
  left: -8rem;
  background: rgba(59, 130, 246, 0.08);
}
.app-loader-glow-b {
  bottom: 25%;
  right: -8rem;
  background: rgba(99, 102, 241, 0.08);
}
.app-loader-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1rem;
}
.app-loader-logo {
  display: block;
  height: 44px;
  width: auto;
  max-width: 220px;
  margin: 0 auto 8px;
  filter: brightness(0) invert(1);
  opacity: 0.92;
}
.app-loader-sub {
  margin: 0 0 28px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.6);
}
.app-loader-spin svg { animation: loader-spin 1.2s ease-in-out infinite; }
.app-loader-text {
  margin: 20px 0 0;
  font-size: 12px;
  color: rgba(148, 163, 184, 0.45);
}
@keyframes loader-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- login --- */
.login-body { background: var(--bg); }
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}
.login-hero {
  display: none;
  position: relative;
  overflow: hidden;
  color: #e2e8f0;
  background: linear-gradient(160deg, #06102a 0%, #0f172a 42%, #111827 100%);
}
.login-hero-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  pointer-events: none;
}
.login-hero-glow-a {
  top: 12%;
  left: -5rem;
  width: 22rem;
  height: 22rem;
  background: rgba(59, 130, 246, 0.14);
}
.login-hero-glow-b {
  bottom: 8%;
  right: -4rem;
  width: 20rem;
  height: 20rem;
  background: rgba(222, 163, 27, 0.1);
}
.login-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 420px;
  padding: 3rem 2.5rem;
}
.login-hero-logo {
  display: block;
  height: 42px;
  width: auto;
  margin-bottom: 0.55rem;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}
.login-hero-sub {
  margin: 0 0 1.75rem;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.65);
}
.login-hero-title {
  margin: 0 0 1.25rem;
  font-size: 1.55rem;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f8fafc;
}
.login-hero-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.65rem;
  color: rgba(203, 213, 225, 0.88);
  font-size: 0.92rem;
}
.login-hero-list li {
  position: relative;
  padding-left: 1.35rem;
}
.login-hero-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-400), var(--brand-400));
}

.login-main {
  display: grid;
  place-items: center;
  padding: 1.5rem 1.25rem;
  position: relative;
}
.login-main::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(720px 420px at 15% -10%, rgba(26, 58, 196, 0.14), transparent 58%),
    radial-gradient(620px 380px at 92% 8%, rgba(222, 163, 27, 0.1), transparent 55%);
  pointer-events: none;
}
.login-main-inner {
  position: relative;
  width: 100%;
  max-width: 420px;
}
.login-brand-mobile {
  text-align: center;
  margin-bottom: 1.35rem;
}
.login-brand-mobile img {
  height: 46px;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}
.login-brand-mobile .brand-sub {
  margin-top: 0.55rem;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1.25rem;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(720px 420px at 15% -10%, rgba(26, 58, 196, 0.22), transparent 58%),
    radial-gradient(620px 380px at 92% 8%, rgba(222, 163, 27, 0.16), transparent 55%),
    radial-gradient(700px 500px at 50% 115%, rgba(7, 38, 154, 0.16), transparent 60%);
  pointer-events: none;
}
.login-wrap { position: relative; width: 100%; max-width: 420px; }
.login-brand { text-align: center; margin-bottom: 1.4rem; }
.login-brand img { height: 46px; width: auto; max-width: 100%; margin: 0 auto; }
.login-brand .brand-sub {
  margin-top: 0.55rem;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.login-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { margin: 0 0 0.3rem; font-size: 1.35rem; font-weight: 700; }
.login-card p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.login-error { margin-bottom: 0.25rem; }
.btn-login {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.72rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.login-foot {
  margin: 1.2rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.76rem;
}

@media (min-width: 960px) {
  .login-shell { grid-template-columns: minmax(340px, 44%) 1fr; }
  .login-hero { display: flex; align-items: center; }
  .login-brand-mobile { display: none; }
  .login-main { padding: 2rem; }
}

/* ==================================================== desktop / rail === */
@media (min-width: 1024px) {
  .sidebar-rail {
    display: block;
    flex: 0 0 var(--side-w);
    width: var(--side-w);
    transition: flex-basis 0.18s var(--ease), width 0.18s var(--ease);
  }

  .sidebar {
    width: var(--side-w);
    max-width: none;
    transform: none;
    box-shadow: none;
    container-type: inline-size;
    container-name: sidebar;
    transition: width 0.18s var(--ease), box-shadow 0.18s var(--ease);
  }

  .nav-label,
  .nav-section-label,
  .brand-full { opacity: 1; pointer-events: auto; }
  .brand-mark { opacity: 0; }
  .sidebar-close { display: none; }
  #menuToggle { display: none; }
  .sidebar-backdrop { display: none !important; }
  .breadcrumb { display: flex; }
  .back-label { max-width: 180px; }

  /* mode rail: hanya kalau user sengaja collapse sidebar */
  [data-sidebar="unpinned"] .sidebar-rail { flex-basis: var(--rail); width: var(--rail); }
  [data-sidebar="unpinned"] .sidebar { width: var(--rail); }
  [data-sidebar="unpinned"] .nav-label,
  [data-sidebar="unpinned"] .nav-section-label,
  [data-sidebar="unpinned"] .brand-full { opacity: 0; pointer-events: none; }
  [data-sidebar="unpinned"] .brand-mark { opacity: 1; }

  [data-sidebar="unpinned"] .sidebar:not(:hover):not(:focus-within) {
    overflow: hidden;
  }
  [data-sidebar="unpinned"] .sidebar:not(:hover):not(:focus-within) .nav-submenu {
    display: none !important;
    max-height: 0 !important;
    overflow: hidden !important;
  }
  [data-sidebar="unpinned"] .sidebar:not(:hover):not(:focus-within) .nav-chevron {
    display: none;
  }

  .topbar { padding: 0.85rem 1.75rem; }
  .content { padding: 1.75rem 1.75rem 2.25rem; }
  .app-footer { padding: 1rem 1.75rem 1.75rem; }
}

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  [data-sidebar="unpinned"] .sidebar:hover,
  [data-sidebar="unpinned"] .sidebar:focus-within {
    width: var(--side-w);
    box-shadow: var(--shadow-lg);
  }
  [data-sidebar="unpinned"] .sidebar:hover .nav-label,
  [data-sidebar="unpinned"] .sidebar:focus-within .nav-label,
  [data-sidebar="unpinned"] .sidebar:hover .nav-section-label,
  [data-sidebar="unpinned"] .sidebar:focus-within .nav-section-label,
  [data-sidebar="unpinned"] .sidebar:hover .brand-full,
  [data-sidebar="unpinned"] .sidebar:focus-within .brand-full { opacity: 1; pointer-events: auto; }
  [data-sidebar="unpinned"] .sidebar:hover .brand-mark,
  [data-sidebar="unpinned"] .sidebar:focus-within .brand-mark { opacity: 0; }

  @container sidebar (max-width: 150px) {
    .nav-submenu { display: none; }
    .nav-chevron { display: none; }
    .nav-scroll a:hover::after,
    .nav-group-toggle:hover::after,
    .pin-btn:hover::after {
      opacity: 1;
      transform: translateY(-50%) translateX(0);
    }
  }
}

/* ======================================================== breakpoints === */
@media (max-width: 1400px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1600px) {
  .content { padding: 1.85rem 2.25rem 2.5rem; }
  .app-footer { padding: 1rem 2.25rem 1.85rem; }
  .topbar { padding-left: 2.25rem; padding-right: 2.25rem; }
  .cards { gap: 1rem; }
  .chart-box { height: 300px; }
  .chart-box-lg { height: 360px; }
}

@media (min-width: 1920px) {
  .grid-2 { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
  .cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
}

@media (max-width: 1200px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1023.98px) {
  .nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .topbar { padding: 0.7rem 1rem; }
  .content { padding: 1.15rem 1rem 1.75rem; }
  .app-footer { padding: 0.9rem 1rem 1.4rem; }
  .user-name { display: none; }
  .user-chip { padding: 0 0.35rem; }
}

@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
  .cards-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 0.9rem 1rem; }
  .card .value { font-size: 1.55rem; }
  .topbar-title h1 { font-size: 1.05rem; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .grow { min-width: 0; }
  .filters .btn { width: 100%; }
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .chart-box-lg { height: 270px; }
  .range-actions { margin-left: 0; }
  .range-custom { width: 100%; }
  .range-custom input[type="date"] { flex: 1 1 40%; min-width: 0; }
}

@media (max-width: 520px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
  .cards-3 { grid-template-columns: minmax(0, 1fr); }
  .btn { min-height: 44px; width: 100%; }
  .btn-row > .btn, .btn-row > button, .btn-row > form { flex: 1 1 100%; }
  .btn-row > form .btn, .btn-row > form button { width: 100%; }
  .btn-sm { min-height: 38px; }
  td .btn-row { flex-wrap: wrap; min-width: 210px; }
  td .btn-row > .btn, td .btn-row > button, td .btn-row > form { flex: 1 1 auto; width: auto; }
  .modal-card { padding: 1.1rem; }
  .login-card { padding: 1.35rem; }
  /* the picker keeps compact buttons instead of the full-width rule above */
  .range-bar .btn { width: auto; }
  .range-actions { width: 100%; }
  .range-actions .btn { flex: 1 1 auto; }
}

/* short desktop viewports: scroll the menu (tooltips would be clipped, so drop them) */
@media (max-height: 640px) and (min-width: 1024px) {
  .nav-scroll { overflow-y: auto; }
  .nav-scroll a::after,
  .nav-group-toggle::after,
  .pin-btn::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .sidebar, .sidebar-rail, .topbar, .topnav, .app-footer, .sidebar-backdrop { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
}

/* ========================================================= page motion === */
.page-stage {
  animation: page-in 0.34s var(--ease) both;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
body.page-leaving .page-stage {
  animation: page-out 0.22s var(--ease) forwards;
}
body.page-leaving .main {
  opacity: 0.94;
  transition: opacity 0.22s var(--ease);
}
@keyframes page-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-6px); }
}

/* ===================================================== layout picker === */
.layout-picker { position: relative; }
.layout-ico { display: none; }
[data-nav-mode="auto"] .layout-ico-auto,
[data-nav-mode="top"] .layout-ico-top,
[data-nav-mode="side"] .layout-ico-side { display: block; }
.layout-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 90;
  min-width: 230px;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: menu-in 0.16s var(--ease);
}
.layout-menu[hidden] { display: none !important; }
.layout-menu-title {
  margin: 0;
  padding: 0.4rem 0.65rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.layout-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s var(--ease);
}
.layout-option:hover { background: var(--surface-2); }
.layout-option.is-active { background: var(--brand-soft); color: var(--brand); }
.layout-option-ico { flex: none; width: 20px; height: 20px; display: grid; place-items: center; color: var(--text-soft); }
.layout-option-text { display: grid; gap: 1px; }
.layout-option-text strong { font-size: 0.86rem; font-weight: 600; }
.layout-option-text small { font-size: 0.72rem; color: var(--muted); }
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================ topnav === */
.topnav {
  display: none;
  flex: none;
  border-bottom: none;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
[data-nav-layout="top"] .topnav {
  display: block;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.topnav-scroll {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.15rem;
  overflow: visible;
  padding: 0.35rem 1rem 0.45rem;
}
.topnav-link,
.topnav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
  min-height: 36px;
  padding: 0.45rem 0.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.topnav-trigger .nav-ico,
.topnav-link .nav-ico {
  flex: none;
}
.topnav-trigger .topnav-label {
  flex: none;
}
.topnav-link:hover,
.topnav-trigger:hover {
  background: var(--surface-2);
  color: var(--brand);
  text-decoration: none;
}
.topnav-link.active,
.topnav-item.has-active > .topnav-trigger {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.topnav-link.active .nav-ico,
.topnav-item.has-active > .topnav-trigger .nav-ico {
  color: var(--brand);
}
.layout-option.is-active .layout-option-ico {
  color: var(--brand);
}
.topnav-item {
  position: relative;
  flex: none;
  display: block;
}
.topnav-chevron {
  flex: none;
  display: inline-flex;
  align-items: center;
  margin-left: 0.1rem;
  opacity: 0.55;
  transition: transform 0.2s var(--ease);
}
.topnav-item.open .topnav-chevron { transform: rotate(180deg); }
.topnav-dropdown {
  display: none;
  position: fixed;
  z-index: 200;
  min-width: 190px;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.topnav-item.open .topnav-dropdown {
  display: grid;
  gap: 2px;
  animation: menu-in 0.16s var(--ease);
}
.topnav-sub {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.topnav-sub:hover { background: var(--surface-2); color: var(--brand); text-decoration: none; }
.topnav-sub.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.topnav-logout:hover { color: var(--danger); background: var(--danger-soft); }

/* layout modes */
[data-nav-layout="top"] .topnav { display: block; }
[data-nav-layout="top"] .topbar { border-bottom: none; }
[data-nav-layout="top"] .topnav-scroll {
  padding-left: 1.75rem;
  padding-right: 1.75rem;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
[data-nav-layout="top"] .topnav-scroll::-webkit-scrollbar { display: none; }
[data-nav-layout="top"] .sidebar-rail,
[data-nav-layout="top"] .sidebar { display: none !important; }
[data-nav-layout="top"] .sidebar-foot { display: none; }
[data-nav-layout="top"] .main { margin-left: 0 !important; }
[data-nav-layout="top"] #menuToggle { display: none !important; }
[data-nav-layout="side"] .topnav { display: none !important; }

