/* ==========================================================================
   TRYVIS INVENTORY — framework subset
   Replaces Bootstrap. Only what the templates actually use, so the app ships
   one small stylesheet from its own server instead of 230 KB from a CDN.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
h1, h2, h3, h4, h5, h6, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; }
img, svg { vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
table { border-collapse: collapse; width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ------------------------------------------------------------------ grid */
.row { display: flex; flex-wrap: wrap; margin: 0 -.5rem; }
.row > * { padding: 0 .5rem; width: 100%; }
.g-1 { margin: -.125rem; } .g-1 > * { padding: .125rem; }
.g-2 { margin: -.25rem; } .g-2 > * { padding: .25rem; }
.g-3 { margin: -.5rem; } .g-3 > * { padding: .5rem; }
.col { flex: 1 0 0%; width: auto; }

.col-1 { width: 8.3333%; } .col-2 { width: 16.6667%; } .col-3 { width: 25%; }
.col-4 { width: 33.3333%; } .col-5 { width: 41.6667%; } .col-6 { width: 50%; }
.col-7 { width: 58.3333%; } .col-8 { width: 66.6667%; } .col-9 { width: 75%; }
.col-10 { width: 83.3333%; } .col-11 { width: 91.6667%; } .col-12 { width: 100%; }

@media (min-width: 768px) {
  .col-md-1 { width: 8.3333%; } .col-md-2 { width: 16.6667%; } .col-md-3 { width: 25%; }
  .col-md-4 { width: 33.3333%; } .col-md-5 { width: 41.6667%; } .col-md-6 { width: 50%; }
  .col-md-7 { width: 58.3333%; } .col-md-8 { width: 66.6667%; } .col-md-9 { width: 75%; }
  .col-md-10 { width: 83.3333%; } .col-md-12 { width: 100%; }
}
@media (min-width: 992px) {
  .col-lg-2 { width: 16.6667%; } .col-lg-3 { width: 25%; } .col-lg-4 { width: 33.3333%; }
  .col-lg-5 { width: 41.6667%; } .col-lg-6 { width: 50%; } .col-lg-7 { width: 58.3333%; }
  .col-lg-8 { width: 66.6667%; } .col-lg-9 { width: 75%; } .col-lg-12 { width: 100%; }
}

/* ------------------------------------------------------------- utilities */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }
@media (min-width: 576px) { .d-sm-block { display: block !important; } .d-sm-flex { display: flex !important; } }
@media (min-width: 768px) { .d-md-block { display: block !important; } .d-md-none { display: none !important; } }
@media (min-width: 992px) { .d-lg-block { display: block !important; } .d-lg-none { display: none !important; } }

.flex-wrap { flex-wrap: wrap; }
.flex-fill { flex: 1 1 auto; }
.flex-column { flex-direction: column; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.align-middle { vertical-align: middle; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }

.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: 1rem; } .gap-4 { gap: 1.5rem; }

.m-0 { margin: 0 !important; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: .25rem !important; }
.mb-2 { margin-bottom: .5rem !important; } .mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; } .mb-5 { margin-bottom: 2.5rem !important; }
.mt-1 { margin-top: .25rem !important; } .mt-2 { margin-top: .5rem !important; }
.mt-3 { margin-top: 1rem !important; } .mt-4 { margin-top: 1.5rem !important; }
.my-2 { margin: .5rem 0 !important; } .my-3 { margin: 1rem 0 !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.ms-1 { margin-left: .25rem !important; } .ms-2 { margin-left: .5rem !important; }
.ms-3 { margin-left: 1rem !important; } .ms-auto { margin-left: auto !important; }
.me-1 { margin-right: .25rem !important; } .me-2 { margin-right: .5rem !important; }

.p-0 { padding: 0 !important; } .p-2 { padding: .5rem !important; }
.p-3 { padding: 1rem !important; } .p-4 { padding: 1.5rem !important; }
.pt-2 { padding-top: .5rem !important; } .pt-3 { padding-top: 1rem !important; }
.pb-2 { padding-bottom: .5rem !important; }
.px-2 { padding-left: .5rem !important; padding-right: .5rem !important; }
.px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
.py-1 { padding-top: .25rem !important; padding-bottom: .25rem !important; }
.py-2 { padding-top: .5rem !important; padding-bottom: .5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }

.w-100 { width: 100% !important; } .h-100 { height: 100% !important; }
.text-start { text-align: left !important; }
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.text-muted { color: var(--muted) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-dark { color: var(--text) !important; }
.text-white { color: #fff !important; }
.text-white-50 { color: rgba(255, 255, 255, .55) !important; }
.small { font-size: 12.5px; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }
.bg-white { background: var(--surface) !important; }
.shadow { box-shadow: var(--shadow-lg) !important; }
.position-relative { position: relative; }
.overflow-hidden { overflow: hidden; }

/* ----------------------------------------------------------------- forms */
.form-label { display: block; margin-bottom: .3rem; font-size: 12.5px; font-weight: 550; }
.form-control, .form-select {
  display: block; width: 100%;
  padding: .45rem .7rem;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font-size: 13.5px; line-height: 1.5;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
  -webkit-appearance: none; appearance: none;
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m3 6 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center;
  background-size: 15px; padding-right: 2rem;
}
.form-control:focus, .form-select:focus {
  outline: 0; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
.form-control::placeholder { color: var(--faint); }
.form-control[type="date"] { min-height: 36px; }
textarea.form-control { min-height: 60px; }
.form-control-sm, .form-select-sm { padding: .3rem .55rem; font-size: 12.5px; }
.form-text { margin-top: .25rem; font-size: 12px; color: var(--muted); }

.form-check { display: flex; align-items: center; gap: .5rem; min-height: 1.4rem; }
.form-check-input {
  width: 16px; height: 16px; margin: 0; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.form-check-input:checked {
  background: var(--blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E") center/13px no-repeat;
  border-color: var(--blue);
}
.form-check-input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.form-check-label { cursor: pointer; font-size: 13.5px; }

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

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .45rem .9rem; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 550; line-height: 1.5;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: .3rem .65rem; font-size: 12.5px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; color: #fff; }
.btn-outline-primary { color: var(--blue); border-color: var(--border); background: var(--surface); }
.btn-outline-primary:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-outline-secondary { color: var(--muted); border-color: var(--border); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); border-color: #CBD5E1; }
.btn-link { color: var(--muted); background: none; border: 0; }
.btn-link:hover { color: var(--text); text-decoration: underline; }

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.card-header {
  padding: .8rem 1rem; border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px; background: var(--surface); border-radius: var(--r) var(--r) 0 0;
}
.card-header strong { font-weight: 600; }

/* ---------------------------------------------------------------- tables */
.table { color: var(--text); font-size: 13.5px; }
.table > thead > tr > th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--muted); font-weight: 600; text-align: left;
  padding: .6rem 1rem; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table > tbody > tr > td { padding: .65rem 1rem; border-bottom: 1px solid var(--border-soft); }
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table-hover > tbody > tr:hover > td { background: var(--surface-2); }
.table-sm > thead > tr > th, .table-sm > tbody > tr > td { padding: .5rem .85rem; }
.table > tfoot > tr > th, .table-light { background: var(--surface-2); }
.table > tfoot > tr > th { padding: .55rem 1rem; font-size: 13px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; line-height: 1.5; color: #fff;
}
.bg-light { background: var(--border-soft) !important; color: var(--muted) !important; }
.bg-success { background: var(--success) !important; }
.bg-warning { background: var(--warning) !important; color: #3A2600 !important; }
.bg-danger { background: var(--danger) !important; }
.bg-primary { background: var(--blue) !important; }

/* ---------------------------------------------------------------- alerts */
.alert { padding: .7rem .9rem; border-radius: var(--r); border: 1px solid transparent; font-size: 13.5px; }
.alert-success { background: var(--success-bg); border-color: rgba(22, 163, 74, .2); color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: rgba(245, 158, 11, .28); color: #B45309; }
.alert-danger { background: var(--danger-bg); border-color: rgba(220, 38, 38, .2); color: var(--danger); }
.alert-info { background: var(--info-bg); border-color: rgba(14, 165, 233, .2); color: #0369A1; }

/* ------------------------------------------------------------------ tabs */
.nav { display: flex; list-style: none; }
.nav-tabs { gap: 2px; }
.nav-item { list-style: none; }
.nav-tabs .nav-link {
  display: block; padding: .5rem .75rem; cursor: pointer;
  border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 13.5px; font-weight: 550; background: none;
}
.nav-tabs .nav-link:hover { color: var(--text); border-bottom-color: var(--border); text-decoration: none; }
.nav-tabs .nav-link.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* dropdown — see supplementary block below */


/* ==========================================================================
   TRYVIS INVENTORY — design system
   Layered over Bootstrap: tokens, shell, and components. Bootstrap keeps
   doing the grid and form plumbing; everything you actually see is here.
   ========================================================================== */

:root {
  /* ── Dark-first design (matches the Tryvis brand image) ── */
  --navy: #0B1120;
  --navy-2: #111827;
  --blue: #3B82F6;
  --blue-dark: #2563EB;
  --sky: #38BDF8;
  --accent-green: #10B981;
  --accent-orange: #F59E0B;
  --accent-purple: #8B5CF6;

  /* page chrome — dark by default */
  --bg: #080E1A;
  --surface: #111827;
  --surface-2: #0F172A;
  --surface-3: #1C2840;

  /* text */
  --text: #F1F5F9;
  --muted: #94A3B8;
  --faint: #475569;

  /* borders */
  --border: #1E2D45;
  --border-soft: #162036;

  /* semantic */
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, .12);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, .12);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, .12);
  --info: #38BDF8;
  --info-bg: rgba(56, 189, 248, .12);
  --blue-bg: rgba(59, 130, 246, .12);

  /* shape */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.6);

  /* metrics */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 62px;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* Light theme override — keeps things readable in office light */
[data-theme="light"],
:root:not([data-theme="dark"]):not([data-theme="system"]) {
  /* intentionally keeping it dark-navy so design matches */
}

[data-theme="light"] {
  --bg: #F0F4F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #EEF2F8;
  --text: #0F172A;
  --muted: #64748B;
  --faint: #94A3B8;
  --border: #DDE3EE;
  --border-soft: #EEF2F7;
  --success-bg: #ECFDF5;
  --warning-bg: #FFFBEB;
  --danger-bg: #FEF2F2;
  --info-bg: #F0F9FF;
  --blue-bg: #EFF6FF;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.12);
}

* { -webkit-font-smoothing: antialiased; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               "Noto Sans", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(59,130,246,.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(139,92,246,.06), transparent);
  background-attachment: fixed;
}

.tabular { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #080E1A;
  border-right: 1px solid rgba(255,255,255,.05);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width .2s var(--ease), transform .2s var(--ease);
}

[data-theme="light"] .sidebar { background: #0B1423; border-right-color: rgba(0,0,0,.18); }

.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar__mark {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #3B82F6, #38BDF8);
  box-shadow: 0 4px 12px rgba(59,130,246,.45);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .5px;
}
.sidebar__word { line-height: 1.1; overflow: hidden; white-space: nowrap; }
.sidebar__close {
  display: none; margin-left: auto; width: 32px; height: 32px;
  border-radius: var(--r-sm); color: #93A3B8; cursor: pointer;
  place-items: center;
}
.sidebar__close:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar__close svg { width: 18px; height: 18px; }
.sidebar__word b { color: #fff; font-size: 14px; letter-spacing: 1.4px; display: block; }
.sidebar__word span { color: #7A8BA6; font-size: 10px; letter-spacing: 1.8px; text-transform: uppercase; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 10px 24px; }
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 3px; }

.nav-group { margin-top: 16px; }
.nav-group:first-child { margin-top: 0; }
.nav-group__label {
  color: #64748B; font-size: 10px; font-weight: 600;
  letter-spacing: 1.3px; text-transform: uppercase;
  padding: 0 10px 7px; white-space: nowrap; overflow: hidden;
}

.nav-link-x {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: var(--r-sm);
  color: #7A90A8; text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.nav-link-x svg { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 1.8; }
.nav-link-x:hover { background: rgba(255,255,255,.06); color: #E2E8F0; }
.nav-link-x.is-active {
  background: linear-gradient(90deg, rgba(59,130,246,.22), rgba(59,130,246,.08));
  border-left: 2.5px solid #3B82F6;
  padding-left: 7.5px;
  color: #fff;
}
.nav-link-x.is-active svg { color: #38BDF8; }
.nav-link-x__text { flex: 1; overflow: hidden; }
.nav-badge {
  min-width: 20px; padding: 1px 6px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
  text-align: center; background: rgba(255, 255, 255, .12); color: #DDE5EF;
}
.nav-badge--danger { background: var(--danger); color: #fff; }
.nav-badge--warning { background: var(--warning); color: #3A2600; }

/* collapsed rail */
.shell.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.shell.is-collapsed .sidebar__word,
.shell.is-collapsed .nav-link-x__text,
.shell.is-collapsed .nav-group__label,
.shell.is-collapsed .nav-badge { display: none; }
.shell.is-collapsed .nav-link-x { justify-content: center; padding: 10px; }
.shell.is-collapsed .nav-group { margin-top: 10px; border-top: 1px solid rgba(255, 255, 255, .07); padding-top: 10px; }
.shell.is-collapsed .nav-group:first-child { border-top: 0; padding-top: 0; }
.shell.is-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
.shell.is-collapsed .nav-link-x { position: relative; }
.shell.is-collapsed .nav-link-x::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%) scale(.96);
  background: var(--navy); color: #fff; padding: 5px 9px; border-radius: var(--r-sm);
  font-size: 12px; white-space: nowrap; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .12s var(--ease), transform .12s var(--ease);
  z-index: 10;
}
.shell.is-collapsed .nav-link-x:hover::after { opacity: 1; transform: translateY(-50%) scale(1); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; transition: margin .2s var(--ease); }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--topbar-h);
  background: rgba(8, 14, 26, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
}
[data-theme="light"] .topbar {
  background: rgba(240, 244, 249, .85);
  border-bottom-color: var(--border);
}
.icon-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 1px solid transparent; background: transparent;
  border-radius: var(--r-sm); color: var(--muted); cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.icon-btn:hover { background: var(--border-soft); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.8; }

.crumb { font-size: 12px; color: var(--faint); }
.crumb b { display: block; font-size: 15px; color: var(--text); font-weight: 600; letter-spacing: -.1px; }

/* search */
.search { position: relative; margin-left: auto; width: min(400px, 40vw); }
.search__input {
  width: 100%; height: 36px;
  padding: 0 36px 0 34px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text); font-size: 13.5px;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.search__input::placeholder { color: var(--faint); }
.search__input:focus {
  outline: none; border-color: var(--blue); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.search__icon {
  position: absolute; left: 10px; top: 9px;
  width: 17px; height: 17px; color: var(--faint); pointer-events: none;
}
.search__kbd {
  position: absolute; right: 8px; top: 8px;
  font-size: 10.5px; color: var(--faint);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
  background: var(--surface);
}
.search__results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  max-height: 60vh; overflow-y: auto; display: none; padding: 6px;
}
.search__results.is-open { display: block; }
.search__group {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--faint); font-weight: 600; padding: 9px 10px 4px;
}
.search__hit {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--text); text-decoration: none; font-size: 13.5px;
}
.search__hit:hover, .search__hit.is-cursor { background: var(--blue-bg); color: var(--text); }
.search__hit small { color: var(--muted); margin-left: auto; font-size: 12px; white-space: nowrap; }
.search__empty { padding: 18px 12px; text-align: center; color: var(--muted); font-size: 13px; }

/* user chip */
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 4px 4px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; color: var(--text);
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 27px; height: 27px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--sky));
  color: #fff; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 600;
}
.user-chip__name { font-size: 13px; font-weight: 500; line-height: 1.15; }
.user-chip__role { font-size: 10.5px; color: var(--muted); }

/* ---------------------------------------------------------------- page */
.page { padding: 24px 22px 56px; max-width: 1440px; }
.page__head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page__title { font-size: 25px; font-weight: 650; letter-spacing: -.5px; margin: 0; }
.page__sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.page__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.section-head {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px;
}
.section-head h2 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -.1px; }
.section-head a { margin-left: auto; font-size: 12.5px; color: var(--blue); text-decoration: none; font-weight: 500; }
.section-head a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- card */
.card-x {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.card-x:hover { border-color: rgba(59,130,246,.22); }
.card-x__head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border-soft);
  background: rgba(255,255,255,.02);
}
.card-x__head h3 { font-size: 13.5px; font-weight: 600; margin: 0; }
.card-x__head .spacer { margin-left: auto; }
.card-x__body { padding: 18px; }
.card-x__foot { padding: 12px 18px; border-top: 1px solid var(--border-soft); background: rgba(255,255,255,.02); border-radius: 0 0 var(--r-lg) var(--r-lg); }

[data-theme="light"] .card-x { background: #fff; }
[data-theme="light"] .card-x:hover { border-color: rgba(59,130,246,.3); box-shadow: 0 4px 16px rgba(59,130,246,.08); }

/* KPI */
.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 18px 15px;
  display: flex; flex-direction: column; gap: 10px; height: 100%;
  overflow: hidden;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.kpi::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .18s var(--ease);
  background: linear-gradient(135deg, rgba(59,130,246,.06), transparent 60%);
}
.kpi:hover { border-color: rgba(59,130,246,.3); box-shadow: 0 8px 24px rgba(0,0,0,.35); transform: translateY(-2px); }
.kpi:hover::before { opacity: 1; }
.kpi__top { display: flex; align-items: center; gap: 10px; }
.kpi__icon {
  width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(59,130,246,.25), rgba(56,189,248,.12));
  color: #60A5FA;
  box-shadow: 0 4px 12px rgba(59,130,246,.2);
}
.kpi__icon svg { width: 19px; height: 19px; stroke-width: 1.8; }
.kpi__icon--success {
  background: linear-gradient(135deg, rgba(16,185,129,.25), rgba(16,185,129,.08));
  color: #34D399; box-shadow: 0 4px 12px rgba(16,185,129,.2);
}
.kpi__icon--warning {
  background: linear-gradient(135deg, rgba(245,158,11,.25), rgba(245,158,11,.08));
  color: #FCD34D; box-shadow: 0 4px 12px rgba(245,158,11,.2);
}
.kpi__icon--danger {
  background: linear-gradient(135deg, rgba(239,68,68,.25), rgba(239,68,68,.08));
  color: #F87171; box-shadow: 0 4px 12px rgba(239,68,68,.2);
}
.kpi__icon--info {
  background: linear-gradient(135deg, rgba(56,189,248,.25), rgba(56,189,248,.08));
  color: #38BDF8; box-shadow: 0 4px 12px rgba(56,189,248,.2);
}
.kpi__icon--purple {
  background: linear-gradient(135deg, rgba(139,92,246,.25), rgba(139,92,246,.08));
  color: #A78BFA; box-shadow: 0 4px 12px rgba(139,92,246,.2);
}
.kpi__label {
  font-size: 11px; font-weight: 600; letter-spacing: .9px;
  text-transform: uppercase; color: var(--muted);
}
.kpi__value { font-size: 28px; font-weight: 700; letter-spacing: -1.2px; line-height: 1.05; color: var(--text); }
.kpi__value small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi__foot { display: flex; align-items: center; gap: 7px; margin-top: auto; font-size: 12.5px; color: var(--muted); }
.kpi__link { margin-left: auto; color: var(--blue); text-decoration: none; font-weight: 500; font-size: 12.5px; }
.kpi__link:hover { text-decoration: underline; }

/* gradient card variants — match the design image */
.kpi--blue   { background: linear-gradient(135deg, #1E3A6E, #172B52); border-color: rgba(59,130,246,.35); }
.kpi--green  { background: linear-gradient(135deg, #064E35, #053426); border-color: rgba(16,185,129,.35); }
.kpi--orange { background: linear-gradient(135deg, #7C3000, #5A2200); border-color: rgba(245,158,11,.35); }
.kpi--purple { background: linear-gradient(135deg, #3B1F6B, #2A1450); border-color: rgba(139,92,246,.35); }
.kpi--blue .kpi__value, .kpi--green .kpi__value,
.kpi--orange .kpi__value, .kpi--purple .kpi__value { color: #fff; }
.kpi--blue .kpi__label, .kpi--green .kpi__label,
.kpi--orange .kpi__label, .kpi--purple .kpi__label { color: rgba(255,255,255,.65); }
.kpi--blue .kpi__foot, .kpi--green .kpi__foot,
.kpi--orange .kpi__foot, .kpi--purple .kpi__foot { color: rgba(255,255,255,.55); }

.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12.5px; }
.trend--up { color: var(--success); }
.trend--down { color: var(--danger); }
.trend--flat { color: var(--muted); }
.trend svg { width: 13px; height: 13px; }

/* ---------------------------------------------------------------- badges */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .1px;
  border: 1px solid transparent; white-space: nowrap;
}
.chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip--success { background: var(--success-bg); color: var(--success); }
.chip--warning { background: var(--warning-bg); color: #B45309; }
.chip--danger { background: var(--danger-bg); color: var(--danger); }
.chip--info { background: var(--info-bg); color: #0369A1; }
.chip--primary { background: var(--blue-bg); color: var(--blue-dark); }
.chip--muted { background: var(--border-soft); color: var(--muted); }
.chip--dark { background: #E2E8F0; color: #334155; }
[data-theme="dark"] .chip--dark { background: #1F2937; color: #CBD5E1; }
.chip--plain::before { display: none; }

/* ---------------------------------------------------------------- health */
.health-ring { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.health-ring svg { transform: rotate(-90deg); }
.health-ring__mid {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.health-ring__mid b { font-size: 26px; font-weight: 650; letter-spacing: -1px; display: block; line-height: 1; }
.health-ring__mid span { font-size: 11px; color: var(--muted); }

.health-bar { display: flex; height: 7px; border-radius: 4px; overflow: hidden; background: var(--border-soft); }
.health-bar span { display: block; }

.legend { display: grid; gap: 7px; }
.legend__row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend__dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.legend__row b { margin-left: auto; font-weight: 600; }

/* ---------------------------------------------------------------- alerts */
.alert-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border-soft);
  text-decoration: none; color: inherit;
}
.alert-row:last-child { border-bottom: 0; }
.alert-row:hover { background: var(--surface-2); }
.alert-row__bar { width: 3px; align-self: stretch; border-radius: 3px; flex-shrink: 0; }
.alert-row__main { min-width: 0; flex: 1; }
.alert-row__name { font-weight: 550; font-size: 13.5px; }
.alert-row__meta { font-size: 12px; color: var(--muted); }
.alert-row__num { text-align: right; flex-shrink: 0; }
.alert-row__num b { display: block; font-size: 15px; font-weight: 650; }
.alert-row__num span { font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------------- activity */
.feed { position: relative; padding-left: 4px; }
.feed__row { display: flex; gap: 12px; padding: 9px 0; }
.feed__time { font-size: 11.5px; color: var(--faint); width: 52px; flex-shrink: 0; padding-top: 2px; }
.feed__spine { position: relative; width: 9px; flex-shrink: 0; }
.feed__dot {
  width: 9px; height: 9px; border-radius: 50%; margin-top: 5px;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1.5px currentColor;
}
.feed__line { position: absolute; left: 4px; top: 18px; bottom: -9px; width: 1px; background: var(--border); }
.feed__row:last-child .feed__line { display: none; }
.feed__body { min-width: 0; flex: 1; font-size: 13px; }
.feed__body b { font-weight: 550; }
.feed__body small { display: block; color: var(--muted); font-size: 12px; }
.feed__qty { font-weight: 650; font-size: 13px; white-space: nowrap; }

/* ---------------------------------------------------------------- tables */
.table-x { width: 100%; border-collapse: collapse; }
.table-x thead th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--muted); font-weight: 600; text-align: left;
  padding: 9px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table-x tbody td { padding: 10px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; }
.table-x tbody tr:last-child td { border-bottom: 0; }
.table-x tbody tr:hover { background: var(--surface-2); }
.table-x .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------- charts */
.chart { width: 100%; height: auto; display: block; }
.chart-labels { display: flex; justify-content: space-between; padding: 6px 8px 0; font-size: 11.5px; color: var(--faint); }

/* ---------------------------------------------------------------- states */
.empty { text-align: center; padding: 34px 20px; }
.empty__icon {
  width: 42px; height: 42px; margin: 0 auto 12px;
  border-radius: 11px; background: var(--border-soft);
  display: grid; place-items: center; color: var(--faint);
}
.empty__icon svg { width: 20px; height: 20px; stroke-width: 1.6; }
.empty h4 { font-size: 14px; font-weight: 600; margin: 0 0 3px; }
.empty p { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

/* ---------------------------------------------------------------- buttons */
.btn-x {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 550; text-decoration: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: all .12s var(--ease);
}
.btn-x svg { width: 15px; height: 15px; stroke-width: 2; }
.btn-x:hover { background: var(--surface-2); border-color: #CBD5E1; color: var(--text); }
.btn-x--primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-x--primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-x--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-x--danger:hover { background: #B91C1C; border-color: #B91C1C; color: #fff; }
.btn-x--sm { padding: 5px 10px; font-size: 12.5px; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.quick {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface);
  text-decoration: none; color: var(--text); font-size: 13.5px; font-weight: 550;
  transition: all .13s var(--ease);
}
.quick:hover { border-color: var(--blue); background: var(--blue-bg); color: var(--blue-dark); transform: translateY(-1px); }
.quick__icon { width: 30px; height: 30px; border-radius: 8px; background: var(--blue-bg); color: var(--blue); display: grid; place-items: center; flex-shrink: 0; }
.quick:hover .quick__icon { background: var(--blue); color: #fff; }
.quick__icon svg { width: 16px; height: 16px; stroke-width: 1.9; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 1080; display: grid; gap: 9px; }
.toast-x {
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 280px; max-width: 400px;
  padding: 12px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 13.5px;
  animation: toast-in .2s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast-x__mark { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-x--success .toast-x__mark { color: var(--success); }
.toast-x--danger .toast-x__mark { color: var(--danger); }
.toast-x--warning .toast-x__mark { color: var(--warning); }
.toast-x--info .toast-x__mark { color: var(--info); }
.toast-x button { margin-left: auto; border: 0; background: none; color: var(--faint); cursor: pointer; padding: 0; }

/* ---------------------------------------------------------------- forms */
.form-control, .form-select {
  border-color: var(--border); background: var(--surface); color: var(--text);
  font-size: 13.5px; border-radius: var(--r-sm);
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
  background: var(--surface); color: var(--text);
}
.form-control::placeholder { color: var(--faint); }
.form-label { font-size: 12.5px; font-weight: 550; color: var(--text); }
.form-text { color: var(--muted); font-size: 12px; }

/* focus visibility everywhere */
a:focus-visible, button:focus-visible, .nav-link-x:focus-visible,
.btn-x:focus-visible, .quick:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px; border-radius: var(--r-sm);
}

/* ---------------------------------------------------------------- responsive */
.scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  z-index: 1035; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease);
}

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .shell.is-drawer-open .sidebar { transform: none; }
  .sidebar__close { display: grid; }
  .shell.is-drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .main, .shell.is-collapsed .main { margin-left: 0; }
  .search { width: auto; flex: 1; }
  .search__kbd { display: none; }
  .user-chip__name, .user-chip__role { display: none; }
  .page { padding: 16px 14px 40px; }
  .page__title { font-size: 21px; }
}

@media (max-width: 575.98px) {
  .kpi__value { font-size: 23px; }
  .table-x thead th, .table-x tbody td { padding: 9px 12px; }
}

@media print {
  .sidebar, .topbar, .page__actions, .toasts { display: none !important; }
  .main { margin: 0 !important; }
  .card-x { border: 1px solid #ccc; box-shadow: none; }
}

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

/* ---------------------------------------------------------------- brief */
.brief {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--blue) 5%, var(--surface)) 0%, var(--surface) 58%);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.brief__head { display: flex; align-items: center; gap: 11px; padding: 14px 18px 10px; }
.brief__mark {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--sky));
}
.brief__mark svg { width: 17px; height: 17px; stroke-width: 1.9; }
.brief__head b { font-size: 14px; font-weight: 600; display: block; line-height: 1.2; }
.brief__meta { font-size: 11.5px; color: var(--muted); }
.brief__body { padding: 2px 18px 6px; }
.brief__body p { font-size: 14.5px; line-height: 1.62; margin: 0 0 10px; max-width: 74ch; }
.brief__body p:last-child { margin-bottom: 0; }
.brief__foot {
  padding: 10px 18px 13px; font-size: 12.5px;
  border-top: 1px solid var(--border-soft); margin-top: 12px;
  background: var(--surface-2);
}
@media (max-width: 575.98px) {
  .brief__body p { font-size: 14px; }
  .brief__head, .brief__body, .brief__foot { padding-left: 14px; padding-right: 14px; }
}

/* ==========================================================================
   Tables on a phone
   A wide table inside a scroll box is usable but still awkward with a thumb.
   `.table--stack` turns each row into its own little card below 640px, with
   the column name carried across from the header via data-label.
   ========================================================================== */
@media (max-width: 639.98px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr {
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin: 0 0 10px;
    padding: 4px 0;
    background: var(--surface);
  }
  .table--stack tr:hover > td { background: transparent; }
  .table--stack td {
    display: flex; align-items: center; gap: 12px;
    padding: 7px 13px !important;
    border: 0 !important;
    text-align: left !important;
    min-height: 34px;
  }
  .table--stack td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px;
    color: var(--muted); font-weight: 600;
  }
  .table--stack td:empty { display: none; }
  .table--stack td[data-label=""]::before { display: none; }
  /* the first cell reads as the card's title */
  .table--stack td:first-child {
    display: block;
    border-bottom: 1px solid var(--border-soft) !important;
    padding-bottom: 9px !important;
    font-weight: 600; font-size: 14.5px;
  }
  .table--stack td:first-child::before { display: none; }
  .table--stack .num { justify-content: flex-start; }
  .table--stack tfoot { display: block; }
  .table--stack tfoot tr { background: var(--surface-2); }
  .table--stack tfoot th { display: flex; justify-content: space-between; padding: 7px 13px; }

  /* action buttons stop crowding each other */
  .table--stack td .btn-x, .table--stack td .btn { flex: 1; justify-content: center; }
  .table--stack td:last-child { gap: 8px; padding-top: 10px !important; }
}

/* summary strip above a list */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 10px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 14px;
}
.stat-tile__label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); font-weight: 600; display: block; margin-bottom: 4px;
}
.stat-tile__value { font-size: 21px; font-weight: 650; letter-spacing: -.6px; line-height: 1.1; }
.stat-tile__value small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat-tile__foot { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat-tile--danger .stat-tile__value { color: var(--danger); }
.stat-tile--success .stat-tile__value { color: var(--success); }
.stat-tile--warning .stat-tile__value { color: #B45309; }

/* horizontal bars, for "by category" style breakdowns */
.hbar { display: grid; gap: 9px; }
.hbar__row { display: grid; grid-template-columns: minmax(84px, 30%) 1fr auto; gap: 10px; align-items: center; }
.hbar__label { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar__track { height: 8px; border-radius: 4px; background: var(--border-soft); overflow: hidden; }
.hbar__fill { height: 100%; border-radius: 4px; }
.hbar__value { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 479.98px) {
  .hbar__row { grid-template-columns: 1fr auto; }
  .hbar__track { grid-column: 1 / -1; }
}

/* a filter bar that wraps instead of overflowing */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters > * { flex: 1 1 160px; min-width: 0; }
.filters > .filters__go { flex: 0 0 auto; }
@media (max-width: 575.98px) { .filters > * { flex: 1 1 100%; } }

/* donut */
.donut { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut svg { transform: rotate(-90deg); flex-shrink: 0; }
.donut__mid { text-align: center; }

/* Line-item forms (quotation, invoice, purchase, job). These keep their columns
   on a phone and scroll sideways inside their own box, because stacking a row
   of inputs loses the sense that they belong to one line. */
@media (max-width: 767.98px) {
  .table-wrap table.align-middle { min-width: 540px; }
  .table-wrap table.align-middle .form-control,
  .table-wrap table.align-middle .form-select { font-size: 12.5px; padding: .3rem .45rem; }
  .card-x__body > .table-wrap, .card.p-3 > .table-wrap { margin: 0 -4px; }
}

/* On a phone the page itself must never scroll sideways, whatever is inside. */
html, body { max-width: 100%; overflow-x: hidden; }
.page, .main { min-width: 0; }
.table-wrap { max-width: 100%; }

/* ================================================================
   TRYVIS DARK THEME — supplementary styles
   ================================================================ */

[data-theme="light"] body { background-image: none; }

/* Stat tiles — pill-style responsive grid */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.stat-tile:hover { border-color: rgba(59,130,246,.25); transform: translateY(-1px); }
.stat-tile__label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--muted); font-weight: 600; display: block; margin-bottom: 5px;
}
.stat-tile__value { font-size: 22px; font-weight: 700; letter-spacing: -.8px; line-height: 1.1; }
.stat-tile__value small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat-tile__foot { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat-tile--danger .stat-tile__value { color: var(--danger); }
.stat-tile--success .stat-tile__value { color: var(--success); }
.stat-tile--warning .stat-tile__value { color: var(--warning); }

/* Tables — dark-styled */
.table-x {
  width: 100%; border-collapse: collapse;
}
.table-x thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  font-weight: 600; color: var(--muted);
  padding: .7rem 1rem;
  background: rgba(255,255,255,.02);
  border-bottom: 1px solid var(--border);
  white-space: nowrap; text-align: left;
}
.table-x tbody tr { transition: background .1s; }
.table-x tbody tr:hover td { background: rgba(59,130,246,.05); }
.table-x tbody td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px; color: var(--text);
  vertical-align: middle;
}
.table-x tbody tr:last-child td { border-bottom: 0; }
.table-x tfoot th {
  padding: .7rem 1rem;
  font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,.02);
  border-top: 1px solid var(--border);
}
.table-x td a { color: var(--blue); font-weight: 500; }
.table-x td a:hover { color: var(--sky); }
.table-x .num { text-align: right; }
[data-theme="light"] .table-x thead th { background: #F8FAFC; }
[data-theme="light"] .table-x tbody tr:hover td { background: #EFF6FF; }
[data-theme="light"] .table-x tfoot th { background: #F8FAFC; }

/* Chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .2px;
}
.chip--success { background: var(--success-bg); color: var(--success); }
.chip--danger  { background: var(--danger-bg);  color: var(--danger);  }
.chip--warning { background: var(--warning-bg); color: var(--warning); }
.chip--muted   { background: rgba(255,255,255,.07); color: var(--muted); }
.chip--primary { background: var(--blue-bg); color: var(--blue); }
[data-theme="light"] .chip--muted { background: #F1F5F9; }

/* Buttons */
.btn-x {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  color: var(--text); cursor: pointer; text-decoration: none;
  transition: all .12s var(--ease);
  white-space: nowrap;
}
.btn-x svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-x:hover { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.15); color: #fff; }
.btn-x--primary {
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 12px rgba(59,130,246,.35);
}
.btn-x--primary:hover {
  background: linear-gradient(135deg, #60A5FA, #3B82F6);
  box-shadow: 0 6px 18px rgba(59,130,246,.5); color: #fff;
}
.btn-x--sm { padding: 4px 10px; font-size: 12px; }
.btn-x--danger { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.3); color: var(--danger); }
.btn-x--danger:hover { background: var(--danger); color: #fff; border-color: transparent; }
[data-theme="light"] .btn-x { background: #fff; color: var(--text); }
[data-theme="light"] .btn-x:hover { background: #F1F5F9; border-color: #CBD5E1; color: var(--text); }

/* Form controls — dark-styled */
.form-control, .form-select {
  width: 100%; padding: .45rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.04);
  color: var(--text); font-size: 13.5px;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
  background: rgba(255,255,255,.06);
}
.form-control::placeholder { color: var(--faint); }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; display: block; }
.form-text { font-size: 12px; color: var(--faint); margin-top: 4px; }
[data-theme="light"] .form-control, [data-theme="light"] .form-select {
  background: #fff; border-color: #DDE3EE;
}
[data-theme="light"] .form-control:focus, [data-theme="light"] .form-select:focus {
  background: #fff;
}

/* Select arrow fix on dark */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  background-size: 14px;
  padding-right: 2.2rem;
}

/* Horizontal bars */
.hbar { display: grid; gap: 10px; }
.hbar__row { display: grid; grid-template-columns: minmax(90px, 32%) 1fr auto; gap: 10px; align-items: center; }
.hbar__label { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar__track { height: 7px; border-radius: 4px; background: rgba(255,255,255,.07); overflow: hidden; }
.hbar__fill { height: 100%; border-radius: 4px; }
.hbar__value { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }
[data-theme="light"] .hbar__track { background: #E2E8F0; }
@media (max-width: 479.98px) {
  .hbar__row { grid-template-columns: 1fr auto; }
  .hbar__track { grid-column: 1 / -1; }
}

/* Charts */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-labels {
  display: flex; justify-content: space-between;
  padding-top: 6px; font-size: 10.5px; color: var(--faint);
}

/* Legend */
.legend { display: grid; gap: 7px; }
.legend__row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend__dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Donut */
.donut { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut svg { transform: rotate(-90deg); flex-shrink: 0; }

/* Empty state */
.empty-state {
  text-align: center; padding: 44px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-state__icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: rgba(255,255,255,.05);
  display: grid; place-items: center; margin-bottom: 4px;
  color: var(--faint);
}
.empty-state__icon svg { width: 26px; height: 26px; stroke-width: 1.5; }
.empty-state__title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0; }
.empty-state__text { font-size: 13.5px; color: var(--muted); max-width: 360px; margin: 0; }

/* Activity feed */
.feed { display: grid; gap: 1px; }
.feed__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  transition: background .1s;
}
.feed__item:last-child { border-bottom: 0; }
.feed__item:hover { background: rgba(59,130,246,.04); }
.feed__dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--blue);
}
.feed__dot--success { background: var(--success); }
.feed__dot--warning { background: var(--warning); }
.feed__dot--danger  { background: var(--danger); }
.feed__body { flex: 1; min-width: 0; }
.feed__body strong { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed__body span { font-size: 12px; color: var(--muted); }
.feed__time { font-size: 11.5px; color: var(--faint); white-space: nowrap; }

/* Toast notifications */
.toasts { position: fixed; bottom: 24px; right: 20px; z-index: 9999; display: grid; gap: 10px; }
.toast-x {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; border-radius: var(--r);
  background: var(--surface-3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px; color: var(--text);
  animation: slideUp .22s var(--ease) both;
  max-width: min(380px, calc(100vw - 40px));
}
.toast-x--success { border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.12); color: #34D399; }
.toast-x--danger  { border-color: rgba(239,68,68,.35);  background: rgba(239,68,68,.12);  color: #F87171; }
.toast-x__mark { width: 18px; height: 18px; flex-shrink: 0; }
.toast-x button { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 17px; line-height: 1; padding: 0 2px; }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Alert boxes */
.alert { padding: .75rem 1rem; border-radius: var(--r-sm); border: 1px solid transparent; margin-bottom: 1rem; font-size: 13.5px; }
.alert-success { background: var(--success-bg); border-color: rgba(16,185,129,.25); color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: rgba(245,158,11,.25); color: var(--warning); }
.alert-danger  { background: var(--danger-bg);  border-color: rgba(239,68,68,.25);  color: var(--danger); }

/* Filters bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters > * { flex: 1 1 170px; min-width: 0; }
.filters > .filters__go { flex: 0 0 auto; }
@media (max-width: 575.98px) { .filters > * { flex: 1 1 100%; } }

/* Row/col grid */
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.row.g-3 > * { padding: 0 8px; margin-bottom: 16px; }
.col-lg-4 { flex: 0 0 100%; max-width: 100%; }
.col-lg-5 { flex: 0 0 100%; max-width: 100%; }
.col-lg-6 { flex: 0 0 100%; max-width: 100%; }
.col-lg-7 { flex: 0 0 100%; max-width: 100%; }
.col-12   { flex: 0 0 100%; max-width: 100%; }
@media (min-width: 992px) {
  .col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-lg-5 { flex: 0 0 41.666%; max-width: 41.666%; }
  .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
  .col-lg-7 { flex: 0 0 58.333%; max-width: 58.333%; }
}
.h-100 { height: 100%; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.flex-fill { flex: 1; }
.gap-3 { gap: 16px; }
.gap-1 { gap: 6px; }
.flex-wrap { flex-wrap: wrap; }
.ms-1 { margin-left: 4px; }
.ms-auto { margin-left: auto; }
.me-1 { margin-right: 4px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 16px; }
.p-3 { padding: 16px; }
.p-4 { padding: 22px; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }
.small { font-size: 12.5px; }
.w-100 { width: 100%; }
.text-end { text-align: right !important; }
.text-start { text-align: left !important; }
.text-center { text-align: center !important; }
.d-none { display: none !important; }
.d-sm-block { display: none; }
@media (min-width: 576px) { .d-sm-block { display: block !important; } }
.justify-content-center { justify-content: center; }
.flex-column { flex-direction: column; }
.spacer { margin-left: auto; }

/* ── Login page ── */
.login-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  justify-content: center; margin-bottom: 28px;
}
.login-logo__mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #3B82F6, #38BDF8);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 6px 18px rgba(59,130,246,.45);
}
.login-logo__name { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.login-logo__sub  { font-size: 11px; color: var(--muted); letter-spacing: 1.6px; text-transform: uppercase; }
.login-title { font-size: 20px; font-weight: 700; letter-spacing: -.3px; text-align: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* ── Dropdown ── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: #111827;       /* explicit dark — never inherits a light surface */
  border: 1px solid #1E2D45;
  border-radius: var(--r); box-shadow: 0 16px 40px rgba(0,0,0,.7);
  z-index: 1060; padding: 6px 0; min-width: 210px;
  display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: block; padding: 8px 16px;
  font-size: 13.5px; color: #E2E8F0;   /* explicit light text */
  text-decoration: none; background: none; border: 0;
  width: 100%; text-align: left; cursor: pointer;
  transition: background .1s;
}
.dropdown-item:hover { background: rgba(59,130,246,.15); color: #60A5FA; }
.dropdown-item form { margin: 0; }
.dropdown-item form button { all: unset; width: 100%; }
.dropdown-header { padding: 6px 16px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .9px; color: #475569; }
.dropdown-divider { height: 1px; background: #1E2D45; margin: 5px 0; }
/* on light theme, keep it looking clean */
[data-theme="light"] .dropdown-menu {
  background: #ffffff;
  border-color: #DDE3EE;
  box-shadow: 0 8px 24px rgba(15,23,42,.12);
}
[data-theme="light"] .dropdown-item { color: #0F172A; }
[data-theme="light"] .dropdown-item:hover { background: #EFF6FF; color: #2563EB; }
[data-theme="light"] .dropdown-divider { background: #E2E8F0; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.dropdown-menu-end { right: 0; left: auto; }
.shadow { box-shadow: var(--shadow-lg) !important; }

/* native <select> options inherit the page bg on some browsers — force dark */
select option {
  background: #111827;
  color: #E2E8F0;
}
[data-theme="light"] select option {
  background: #ffffff;
  color: #0F172A;
}

/* ── Password / setup pages max-width ── */
@media (min-width: 640px) {
  .form-narrow { max-width: 560px; }
}

/* ── Table wrap scroll ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* ── Print ── */
@media print {
  .sidebar, .topbar, .toasts, #jamiibot-widget { display: none !important; }
  .main { margin-left: 0 !important; }
  .page { padding: 0 !important; }
}

/* ================================================================
   CHATBOT WIDGET — show only when logged in, injected via base.html
   The script tag is placed just before </body>
   ================================================================ */

/* ── Real logo image (replaces text mark) ── */
.sidebar__logo {
  height: 36px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  /* on dark sidebar, boost brightness a little so the gear pops */
  filter: brightness(1.1) drop-shadow(0 1px 3px rgba(0,0,0,.5));
  flex-shrink: 0;
}

/* When sidebar collapses, show only the gear icon part */
.shell.is-collapsed .sidebar__logo {
  height: 28px;
  max-width: 28px;
  object-fit: cover;
  object-position: center;
}

/* Login page logo */
.login-logo__img {
  height: 64px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  filter: brightness(1.05) drop-shadow(0 2px 8px rgba(0,0,0,.4));
}
.login-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
}
