/* =====================================================================
   VKit UI  v1.0  -  theme + layout + components + data grid (one file)
   No framework, no build step.  Pair with  vkit.js.

   THEME  : <html data-theme="indigo|ocean|teal|emerald|amber|rose|slate"
                  data-mode="light|dark">
            (vkit.js restores the user's last choice automatically)
   LAYERS : 1. tokens (:root)  2. theme overrides  3. dark mode
            4. base  5. layout shell  6. components  7. VGrid  8. extras
   CUSTOM : add your own brand below - only the --primary* tokens change:
            [data-theme="brand"] { --primary:#7c3aed; --primary-600:#6d28d9;
              --primary-700:#5b21b6; --primary-50:#f5f3ff; --primary-100:#ede9fe; }
   ===================================================================== */

/* ============================ 1-3. TOKENS / THEMES / DARK ============================ */
:root {
  --primary: #4f46e5; --primary-600: #4338ca; --primary-700: #3730a3; --primary-50: #eef2ff; --primary-100: #e0e7ff;
  --primary-contrast: #ffffff;
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f8fafc; --surface-3: #eef1f6;
  --border: #e3e8ef; --border-strong: #cfd6e1;
  --text: #0f172a; --text-2: #334155; --muted: #64748b; --muted-2: #94a3b8;
  --success: #16a34a; --success-bg: #dcfce7; --warning: #d97706; --warning-bg: #fef3c7;
  --danger: #dc2626; --danger-bg: #fee2e2; --info: #0284c7; --info-bg: #e0f2fe;
  --sidebar-bg: #0f172a; --sidebar-text: #cbd5e1; --sidebar-muted: #64748b; --sidebar-hover: rgba(255,255,255,.06); --sidebar-active: rgba(255,255,255,.10);
  --radius: 4px; --radius-sm: 4px; --radius-lg: 4px;
  --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,.14);
  --shadow-card: 0 1px 1px rgba(15,23,42,.05), 0 3px 6px rgba(15,23,42,.07), 0 10px 22px -6px rgba(15,23,42,.14);
  --shadow-card-hover: 0 2px 3px rgba(15,23,42,.07), 0 8px 16px rgba(15,23,42,.10), 0 18px 34px -10px rgba(15,23,42,.20);
  --chart-1: var(--primary); --chart-2: #0ea5e9; --chart-3: #10b981; --chart-4: #f59e0b; --chart-5: #ef4444; --chart-6: #8b5cf6;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "SFMono-Regular", Menlo, monospace;
  --sidebar-w: 256px; --sidebar-w-mini: 68px; --topbar-h: 60px;
  --grid-head: var(--primary-700); --grid-head-text: #ffffff; --grid-head-hover: var(--primary-600); --grid-filter: var(--primary-50);
  color-scheme: light;
}
[data-theme="teal"]    { --primary:#0d9488; --primary-600:#0f766e; --primary-700:#115e59; --primary-50:#f0fdfa; --primary-100:#ccfbf1; }
[data-theme="emerald"] { --primary:#059669; --primary-600:#047857; --primary-700:#065f46; --primary-50:#ecfdf5; --primary-100:#d1fae5; }
[data-theme="rose"]    { --primary:#e11d48; --primary-600:#be123c; --primary-700:#9f1239; --primary-50:#fff1f2; --primary-100:#ffe4e6; }
[data-theme="amber"]   { --primary:#d97706; --primary-600:#b45309; --primary-700:#92400e; --primary-50:#fffbeb; --primary-100:#fef3c7; }
[data-theme="slate"]   { --primary:#334155; --primary-600:#1e293b; --primary-700:#0f172a; --primary-50:#f1f5f9; --primary-100:#e2e8f0; }
[data-theme="ocean"]   { --primary:#2563eb; --primary-600:#1d4ed8; --primary-700:#1e40af; --primary-50:#eff6ff; --primary-100:#dbeafe; }

[data-mode="dark"] {
  --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --surface-3: #1f2937;
  --border: #1f2a3c; --border-strong: #334155;
  --text: #e5e7eb; --text-2: #cbd5e1; --muted: #94a3b8; --muted-2: #64748b;
  --primary-50: rgba(99,102,241,.12); --primary-100: rgba(99,102,241,.22);
  --success-bg: rgba(22,163,74,.18); --warning-bg: rgba(217,119,6,.18); --danger-bg: rgba(220,38,38,.18); --info-bg: rgba(2,132,199,.18);
  --sidebar-bg: #070c18;
  --shadow: 0 1px 3px rgba(0,0,0,.5); --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
  --shadow-card: 0 1px 2px rgba(0,0,0,.5), 0 6px 16px rgba(0,0,0,.45); --shadow-card-hover: 0 2px 4px rgba(0,0,0,.55), 0 12px 28px rgba(0,0,0,.55);
  --grid-head: #1e293b; --grid-head-text: #e2e8f0; --grid-head-hover: #334155; --grid-filter: #0f172a;
  color-scheme: dark;
}
[data-mode="dark"][data-theme="teal"], [data-mode="dark"][data-theme="emerald"] { --primary-50: rgba(16,185,129,.12); --primary-100: rgba(16,185,129,.22); }
[data-mode="dark"][data-theme="rose"]  { --primary-50: rgba(225,29,72,.14); --primary-100: rgba(225,29,72,.24); }
[data-mode="dark"][data-theme="amber"] { --primary-50: rgba(217,119,6,.14); --primary-100: rgba(217,119,6,.24); }
[data-mode="dark"][data-theme="slate"] { --primary: #64748b; --primary-600: #94a3b8; --primary-50: rgba(148,163,184,.12); --primary-100: rgba(148,163,184,.2); }

/* ============================ 4. BASE ============================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ============================ 5. LAYOUT SHELL (sidebar + topbar + content) ============================ */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 40; transition: width .2s ease, transform .2s ease;
}
.sb-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: none; }
.sb-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.sb-title { font-weight: 650; color: #fff; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-sub { font-size: 11px; color: var(--sidebar-muted); white-space: nowrap; }
.sb-nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.sb-nav ul { list-style: none; margin: 0; padding: 0; }
.sb-link, .sb-group > button {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text);
  font: inherit; font-size: 13.5px; background: none; border: 0; cursor: pointer; text-align: left; white-space: nowrap;
}
.sb-link:hover, .sb-group > button:hover { background: var(--sidebar-hover); text-decoration: none; color: #fff; }
.sb-link.active { background: var(--primary); color: #fff; }
.sb-group > button .chev { margin-left: auto; transition: transform .2s; opacity: .6; }
.sb-group.open > button .chev { transform: rotate(90deg); }
.sb-group > ul { display: none; padding: 2px 0 6px 18px; }
.sb-group.open > ul { display: block; }
.sb-group > ul .sb-link { font-size: 13px; padding: 7px 12px; color: #aab4c4; }
.sb-group > ul .sb-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.sb-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 14px 12px 6px; }
.sb-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.06); font-size: 11px; color: var(--sidebar-muted); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin .2s ease; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 0 20px;
}
@supports not (background: color-mix(in srgb, red 50%, blue)) { .topbar { background: var(--surface); } }
.tb-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-crumb { font-size: 12px; color: var(--muted); }
.tb-spacer { flex: 1; }
.tb-search { position: relative; width: 280px; max-width: 34vw; }
.tb-search .input { padding-left: 34px; height: 36px; background: var(--surface-2); }
.tb-search .icon { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 9px; border: 1px solid transparent; background: none;
  color: var(--text-2); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-3); }
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 60;
}
.dropdown.open > .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button.dd-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--text); font: inherit; font-size: 13.5px;
  width: 100%; background: none; border: 0; cursor: pointer; text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button.dd-item:hover { background: var(--surface-3); text-decoration: none; }
.dd-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dd-head b { display: block; font-size: 13.5px; }
.dd-head span { font-size: 12px; color: var(--muted); }
.theme-swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 6px 8px 10px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-100); color: var(--primary-700); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
[data-mode="dark"] .avatar { color: #fff; }

.content { padding: 22px 24px 40px; flex: 1; max-width: 1680px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 21px; font-weight: 650; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* collapsed sidebar (desktop) */
.sb-mini .sidebar { width: var(--sidebar-w-mini); }
.sb-mini .main { margin-left: var(--sidebar-w-mini); }
.sb-mini .sb-title, .sb-mini .sb-sub, .sb-mini .sb-label, .sb-mini .chev, .sb-mini .sb-section, .sb-mini .sb-foot { display: none; }
.sb-mini .sb-group > ul { display: none !important; }
.sb-mini .sb-nav { padding: 10px 8px; }
.sb-mini .sb-link, .sb-mini .sb-group > button { justify-content: center; padding: 10px; }
.sb-mini .sidebar:hover { width: var(--sidebar-w); box-shadow: var(--shadow-lg); }
.sb-mini .sidebar:hover .sb-title, .sb-mini .sidebar:hover .sb-sub, .sb-mini .sidebar:hover .sb-label, .sb-mini .sidebar:hover .chev { display: block; }
.sb-mini .sidebar:hover .sb-link, .sb-mini .sidebar:hover .sb-group > button { justify-content: flex-start; padding: 9px 12px; }
.sb-mini .sidebar:hover .sb-group.open > ul { display: block !important; }
.sb-backdrop { display: none; }

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .main, .sb-mini .main { margin-left: 0; }
  .sb-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sb-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; }
  .sb-mini .sb-title, .sb-mini .sb-sub, .sb-mini .sb-label, .sb-mini .chev { display: block; }
  .tb-search { display: none; }
  .content { padding: 16px 16px 32px; }
}

/* ============================ 6. COMPONENTS: CARDS / GRID LAYOUT ============================ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 620; display: flex; align-items: center; gap: 8px; }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1199px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } .span-2 { grid-column: auto; } }

/* ============================ FORMS ============================ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .wide { grid-column: span 2; }
@media (max-width: 600px) { .form-grid .wide { grid-column: auto; } }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin: 6px 0 -2px; grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.req::after { content: " *"; color: var(--danger); }
.help { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; height: 38px; padding: 7px 11px; font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; min-width: 0;
}
textarea.input { height: auto; min-height: 76px; resize: vertical; }
select.input { padding-right: 30px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.input[readonly], .input:disabled { background: var(--surface-2); color: var(--muted); }
.input.lg { height: 46px; font-size: 16px; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.switch input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 22px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .2s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { left: 19px; }
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .field { min-width: 160px; flex: 1 1 160px; max-width: 260px; }
.filter-bar .actions { display: flex; gap: 8px; }

/* ============================ BUTTONS ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; font: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; text-decoration: none !important; user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.94); background: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); background: var(--danger); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-soft { background: var(--primary-50); border-color: transparent; color: var(--primary); }
.btn-soft:hover { background: var(--primary-100); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; gap: 5px; border-radius: 6px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }

/* ============================ BADGES / ALERTS ============================ */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1.6; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.b-success { background: var(--success-bg); color: var(--success); }
.b-warning { background: var(--warning-bg); color: var(--warning); }
.b-danger { background: var(--danger-bg); color: var(--danger); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-primary { background: var(--primary-50); color: var(--primary); }
.b-muted { background: var(--surface-3); color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.6); } 70% { box-shadow: 0 0 0 8px rgba(220,38,38,0); } 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); } }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); font-size: 13.5px; border: 1px solid transparent; margin-bottom: 14px; }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }

/* ============================ KPI / STATS ============================ */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow-card); min-width: 0; transition: box-shadow .2s, transform .2s; }
.kpi:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.kpi-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex: none; }
.kpi-icon.green { background: var(--success-bg); color: var(--success); }
.kpi-icon.amber { background: var(--warning-bg); color: var(--warning); }
.kpi-icon.red { background: var(--danger-bg); color: var(--danger); }
.kpi-icon.blue { background: var(--info-bg); color: var(--info); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-sub .up { color: var(--success); font-weight: 600; } .kpi-sub .down { color: var(--danger); font-weight: 600; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.mini-list { list-style: none; padding: 0; margin: 0; }
.mini-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .meta { font-size: 12px; color: var(--muted); }
.empty { padding: 30px 18px; text-align: center; color: var(--muted); font-size: 13.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.text-muted { color: var(--muted); } .text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .flex-1 { flex: 1; }
.nowrap { white-space: nowrap; }

/* ============================ TABLE (simple) ============================ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--grid-head-text); font-weight: 600; padding: 10px 12px; background: var(--grid-head); border-bottom: 1px solid var(--grid-head); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.table .input { height: 34px; }

/* ============================ 7. VGRID (DevExpress style data grid) ============================ */
.vgrid { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); display: flex; flex-direction: column; min-width: 0; margin-bottom: 18px; }
.vg-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.vg-title { font-weight: 620; font-size: 14.5px; margin-right: 6px; display: flex; align-items: center; gap: 8px; }
.vg-count { font-size: 12px; color: var(--muted); font-weight: 500; }
.vg-search { position: relative; flex: 1 1 220px; max-width: 340px; margin-left: auto; }
.vg-search .input { height: 34px; padding-left: 32px; }
.vg-search .icon { position: absolute; left: 10px; top: 8px; color: var(--muted); width: 16px; height: 16px; }
.vg-scroll { overflow: auto; max-height: calc(100vh - 290px); min-height: 160px; position: relative; }
.vgrid.auto-height .vg-scroll { max-height: none; }
.vg-table { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; min-width: 100%; }
.vg-table th, .vg-table td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0 10px; height: 36px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vg-table th:last-child, .vg-table td:last-child { border-right: 0; }
.vg-table thead th { position: sticky; top: 0; z-index: 3; background: var(--grid-head); font-weight: 650; font-size: 12.5px; color: var(--grid-head-text); text-align: left; user-select: none; border-right-color: rgba(255,255,255,.18); border-bottom-color: var(--grid-head); }
.vg-table thead tr.vg-filter th { top: 37px; background: var(--grid-filter); padding: 4px 5px; height: 38px; font-weight: 400; border-right-color: var(--border); border-bottom-color: var(--border-strong); }
.vg-table thead th.sortable { cursor: pointer; }
.vg-table thead tr:first-child th.sortable:hover { background: var(--grid-head-hover); }
.vg-th { display: flex; align-items: center; gap: 4px; }
.vg-th .lbl-t { overflow: hidden; text-overflow: ellipsis; }
.vg-sort { opacity: .35; font-size: 10px; display: inline-flex; flex-direction: column; line-height: .8; margin-left: auto; }
.vg-sort.asc, .vg-sort.desc { opacity: 1; color: #fff; }
.vg-sort .n { font-size: 9px; }
.vg-resize { position: absolute; right: -3px; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 4; }
.vg-resize:hover, .vg-resize.active { background: var(--primary); opacity: .5; }
.vg-table th.drag-over { box-shadow: inset 3px 0 0 var(--primary); }
.vg-table th.dragging { opacity: .45; }
.vg-filter input { width: 100%; height: 28px; border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px; font: inherit; font-size: 12.5px; background: var(--surface-2); color: var(--text); }
.vg-filter input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.vg-filter input.has { border-color: var(--primary); background: var(--primary-50); }
.vg-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 70%, var(--surface)); }
.vg-table tbody tr:hover td { background: var(--primary-50); }
.vg-table td.num, .vg-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.vg-table th.num .vg-th { flex-direction: row-reverse; }
.vg-table th.num .vg-sort { margin-left: 0; margin-right: auto; }
.vg-table td.center, .vg-table th.center { text-align: center; }
.vg-table tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border-strong); z-index: 2; }
.vg-table td.vg-actions { overflow: visible; padding: 0 6px; }
.vg-actions .act { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; color: var(--muted); margin-right: 2px; text-decoration: none; }
.vg-actions .act:hover { background: var(--primary-100); color: var(--primary); }
.vg-actions .act.danger:hover { background: var(--danger-bg); color: var(--danger); }
.vg-empty { padding: 40px 10px; text-align: center; color: var(--muted); }
.vg-foot { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.vg-pager { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.vg-pager button { min-width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; font: inherit; font-size: 12.5px; padding: 0 8px; }
.vg-pager button:hover:not(:disabled) { background: var(--surface-3); }
.vg-pager button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.vg-pager button:disabled { opacity: .45; cursor: default; }
.vg-foot select { height: 30px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; padding: 0 6px; }
.vg-menu { position: absolute; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; max-height: 360px; overflow: auto; min-width: 220px; }
.vg-menu label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.vg-menu label:hover { background: var(--surface-3); }
.vg-menu input { accent-color: var(--primary); }
.vg-group-row td { background: var(--surface-3) !important; font-weight: 650; cursor: pointer; }
.vg-link { font-weight: 600; }

/* ============================ TOAST / MODAL ============================ */
.toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--success);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toastIn .25s ease; color: var(--text); }
.toast.error { border-left-color: var(--danger); } .toast.warning { border-left-color: var(--warning); } .toast.info { border-left-color: var(--info); }
.toast .t-icon { color: var(--success); } .toast.error .t-icon { color: var(--danger); } .toast.warning .t-icon { color: var(--warning); } .toast.info .t-icon { color: var(--info); }
.toast .t-msg { flex: 1; word-break: break-word; }
.toast .t-x { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 900; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-back.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto; animation: toastIn .2s ease; }
.modal.lg { width: min(820px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 650; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ============================ AUTOCOMPLETE ============================ */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 80; max-height: 300px; overflow: auto; display: none; }
.ac-list.open { display: block; }
.ac-item { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.ac-item:last-child { border-bottom: 0; }
.ac-item.active, .ac-item:hover { background: var(--primary-50); }
.ac-item small { color: var(--muted); }

/* ============================ CHARTS ============================ */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .grid line { stroke: var(--border); }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; padding: 6px 9px; border-radius: 7px; white-space: nowrap; transform: translate(-50%, -110%); display: none; z-index: 5; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }


/* ============================ STEPS / TOTALS ============================ */
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; font-size: 14px; max-width: 360px; margin-left: auto; }
.totals .grand { font-size: 18px; font-weight: 750; color: var(--primary); border-top: 1px solid var(--border); padding-top: 8px; }
.steps { display: flex; gap: 0; margin-bottom: 18px; overflow-x: auto; }
.step { flex: 1; min-width: 120px; text-align: center; position: relative; font-size: 12.5px; color: var(--muted); padding-top: 34px; }
.step::before { content: attr(data-n); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); color: var(--muted); display: grid; place-items: center; font-weight: 700; z-index: 1; }
.step::after { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--border); }
.step:first-child::after { display: none; }
.step.done::before { background: var(--success); color: #fff; content: "\2713"; }
.step.done::after, .step.current::after { background: var(--success); }
.step.current::before { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-100); }
.step.current { color: var(--text); font-weight: 600; }
.step.cancel::before { background: var(--danger); color: #fff; content: "\2715"; }

/* ============================ LOGIN (optional) ============================ */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); }
.auth-art { background: linear-gradient(135deg, var(--primary-700), var(--primary) 55%, #0ea5e9); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 70px solid rgba(255,255,255,.07); right: -160px; bottom: -180px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-box { width: min(380px, 100%); }
.auth-box h2 { font-size: 24px; margin-bottom: 4px; }
.auth-box .sub { color: var(--muted); margin-bottom: 26px; }
.auth-box .field { margin-bottom: 16px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-art { display: none; } }
.auth-brand { display: flex; gap: 14px; align-items: center; position: relative; z-index: 1; }
.auth-brand b { display: block; font-size: 18px; }
.auth-brand span { display: block; font-size: 13px; opacity: .8; }
.auth-logo { width: 46px; height: 46px; border-radius: 4px; display: grid; place-items: center; background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); color: #fff; flex: none; }
.auth-logo .icon { width: 24px; height: 24px; }
.auth-illus { width: min(460px, 100%); align-self: center; position: relative; z-index: 1; filter: drop-shadow(0 18px 30px rgba(0,0,0,.18)); }
.auth-meta { display: grid; gap: 8px; font-size: 13px; position: relative; z-index: 1; }
.auth-meta div { display: flex; gap: 8px; align-items: center; opacity: .9; }
.auth-meta small { opacity: .7; margin-top: 6px; }
.auth-badge { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 600; color: var(--primary-700); background: var(--primary-50); padding: 4px 10px; border-radius: 4px; margin-bottom: 14px; }
.auth-mobile-brand { display: none; gap: 10px; align-items: center; margin-bottom: 26px; }
.auth-mobile-brand .auth-logo { background: var(--primary); width: 40px; height: 40px; }
@media (max-width: 900px) { .auth-mobile-brand { display: flex; } }
[data-mode="dark"] .auth-badge { color: #fff; background: rgba(255,255,255,.08); }

/* ============================ TABS / PRINT MODES ============================ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.link-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 8px 10px; }
.link-box input { flex: 1; border: 0; background: transparent; font-family: var(--mono); font-size: 12.5px; color: var(--text); min-width: 0; }
.link-box input:focus { outline: none; }

/* ============================ COLLAPSIBLE FILTER CARD (auto, vkit.js) ============================ */
.filter-card { overflow: hidden; }
.filter-card > .filter-head { padding: 9px 14px; cursor: pointer; background: var(--primary-50); border-bottom: 1px solid var(--primary-100); color: var(--primary-700); }
.filter-card > .filter-head h3 { font-size: 13.5px; color: var(--primary-700); }
.filter-card > .filter-head .icon-btn { color: var(--primary-700); }
[data-mode="dark"] .filter-card > .filter-head, .dark .filter-card > .filter-head { background: color-mix(in srgb, var(--primary) 16%, transparent); border-bottom-color: color-mix(in srgb, var(--primary) 30%, transparent); color: inherit; }
[data-mode="dark"] .filter-card > .filter-head h3, .dark .filter-card > .filter-head h3 { color: inherit; }
.filter-card .filter-summary { flex: 1; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: none; }
.filter-card.collapsed .filter-summary { display: block; }
.filter-card.collapsed > :not(.filter-head) { display: none !important; }
.filter-card.collapsed > .filter-head { border-bottom: 0; }
.filter-toggle .chev-up { transform: rotate(-90deg); transition: transform .2s; }
.filter-card.collapsed .filter-toggle .chev-up { transform: rotate(90deg); }

/* ============================ TOP BAR PAGE ACTIONS ============================ */
.tb-actions { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; margin-left: 12px; }
.tb-actions:empty { display: none; }
.tb-actions .btn { height: 34px; padding: 0 12px; font-size: 13px; }
@media (max-width: 1360px) { .topbar:has(.tb-actions > *) .tb-search { display: none; } }
@media (max-width: 760px) {
  .tb-actions .btn { font-size: 0; gap: 0; padding: 0 9px; }
  .tb-actions .btn .icon { width: 18px; height: 18px; }
  .tb-actions .badge { display: none; }
  .tb-title { font-size: 14px; }
}
.topbar > div:nth-child(2) { flex: 0 1 auto; min-width: 150px; }
.tb-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1680px) { .topbar:has(.tb-actions > :nth-child(4)) .tb-search { display: none; } }
@media (max-width: 1100px) { .tb-actions .btn { font-size: 0; gap: 0; padding: 0 9px; } .tb-actions .btn .icon { width: 18px; height: 18px; } }

/* ============================ GRID HEADER DETAILS ============================ */
.vg-table thead tr:first-child th .vg-resize:hover, .vg-table thead tr:first-child th .vg-resize.active { background: #fff; opacity: .6; }
.vg-table thead th.drag-over { box-shadow: inset 3px 0 0 #fff; }
.vgrid .vg-scroll { border-radius: 0; }

/* ============================ IMAGE FIELD ============================ */
.photo-field { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.photo-preview, .photo-empty { width: 132px; height: 96px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); box-shadow: var(--shadow-sm); }
.photo-preview.round, .photo-empty.round { width: 96px; height: 96px; border-radius: 50%; }
.photo-empty { display: grid; place-items: center; color: var(--muted-2); }
.photo-actions { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 220px; }
.photo-actions input[type=file] { height: auto; padding: 6px; }
.grid-thumb { width: 44px; height: 28px; object-fit: cover; border-radius: 3px; vertical-align: middle; border: 1px solid var(--border); }
.grid-thumb.round { width: 28px; height: 28px; border-radius: 50%; }

/* ============================ PRINT ============================ */
@media print {
  @page { margin: 12mm; }
  body { background: #fff !important; color: #000; font-size: 12px; }
  .sidebar, .topbar, .no-print, .vg-toolbar, .vg-foot, .vg-filter, .page-actions, .toast-wrap, .sb-backdrop { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  .card, .vgrid { border: 0 !important; box-shadow: none !important; }
  .vg-scroll { max-height: none !important; overflow: visible !important; }
  .vg-table thead th { position: static; }
}
@media print {
  body.pm-doc .screen { display: none !important; }
  body.pm-doc .tabs { display: none !important; }
  body.pm-doc .tab-pane { display: none !important; }
  body.pm-doc .tab-pane.printing { display: block !important; }
}
