/* ==========================================================================
   NEXORA AI — design system: tokens, base, components
   Hand-written, no build step. Brand colours are overridden at runtime from
   admin settings via inline :root { --brand, --ink } in the layouts.
   ========================================================================== */

:root {
  --brand: #16a34a;
  --ink: #062a2d;
  --brand-600: color-mix(in oklab, var(--brand) 86%, #000);
  --brand-700: color-mix(in oklab, var(--brand) 72%, #000);
  --brand-50: color-mix(in oklab, var(--brand) 7%, #fff);
  --brand-100: color-mix(in oklab, var(--brand) 14%, #fff);
  --brand-200: color-mix(in oklab, var(--brand) 26%, #fff);
  --brand-contrast: #fff;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f2f4f7;
  --hover: #f4f5f7;
  --border: #e5e7eb;
  --border-strong: #d3d8df;
  --text: #0e1726;
  --text-2: #3f4b5b;
  --text-3: #667085;
  --text-4: #98a2b3;
  --field: #ffffff;
  --card-bg: var(--surface);

  --green: #16a34a;  --green-bg: #ecfdf3;  --green-bd: #abefc6;
  --amber: #b54708;  --amber-bg: #fffaeb;  --amber-bd: #fedf89;
  --red: #d92d20;    --red-bg: #fef3f2;    --red-bd: #fecdca;
  --blue: #1570ef;   --blue-bg: #eff8ff;   --blue-bd: #b2ddff;
  --violet: #6938ef; --violet-bg: #f4f3ff; --violet-bd: #d9d6fe;
  --gray-bg: #f2f4f7; --gray-bd: #e4e7ec;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 4px 12px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .18), 0 8px 16px -8px rgba(16, 24, 40, .08);
  --ring: 0 0 0 4px color-mix(in oklab, var(--brand) 18%, transparent);

  --font: "Inter", "Noto Sans Bengali", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);

  color-scheme: light;
}

/* Dark theme: deep teal, matched to the SKO TechLabs admin panel. */
[data-theme="dark"] {
  --brand-50: color-mix(in oklab, var(--brand) 15%, #05363a);
  --brand-100: color-mix(in oklab, var(--brand) 26%, #05363a);
  --brand-200: color-mix(in oklab, var(--brand) 40%, #05363a);
  /* Brand shades used for text must get lighter, not darker, on teal. */
  --brand-600: color-mix(in oklab, var(--brand) 74%, #fff);
  --brand-700: color-mix(in oklab, var(--brand) 60%, #fff);
  --bg: #01272a;
  --surface: #05363a;
  --surface-2: #073e42;
  --surface-3: #0a474b;
  --hover: #0a4448;
  --field: #03292d;
  --card-bg: linear-gradient(160deg, #083f42 0%, #042f32 100%);
  --border: rgba(237, 245, 242, .09);
  --border-strong: rgba(237, 245, 242, .16);
  --text: #f3f7f4;
  --text-2: #c2d1ce;
  --text-3: #8fa7a4;
  --text-4: #6a8582;
  --green: #2bcb68;  --green-bg: rgba(43, 203, 104, .12);   --green-bd: rgba(43, 203, 104, .32);
  --amber: #eab96b;  --amber-bg: rgba(234, 185, 107, .12);  --amber-bd: rgba(234, 185, 107, .34);
  --red: #f07878;    --red-bg: rgba(240, 120, 120, .12);    --red-bd: rgba(240, 120, 120, .34);
  --blue: #7cc4e4;   --blue-bg: rgba(124, 196, 228, .12);   --blue-bd: rgba(124, 196, 228, .3);
  --violet: #b8a4fb; --violet-bg: rgba(184, 164, 251, .13); --violet-bd: rgba(184, 164, 251, .3);
  --gray-bg: rgba(237, 245, 242, .06); --gray-bd: rgba(237, 245, 242, .12);
  --shadow-xs: 0 1px 2px rgba(0, 14, 16, .35);
  --shadow-sm: 0 2px 6px rgba(0, 14, 16, .4);
  --shadow: 0 14px 32px -10px rgba(0, 14, 16, .6);
  --shadow-lg: 0 28px 64px -16px rgba(0, 10, 12, .75);
  --ring: 0 0 0 4px color-mix(in oklab, var(--brand) 28%, transparent);
  color-scheme: dark;
}

/* ---------- 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.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4, h5 { margin: 0; color: var(--text); letter-spacing: -.015em; line-height: 1.25; font-weight: 650; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; } h4 { font-size: 14px; }
p { margin: 0; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
img, svg { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, kbd, pre { font-family: var(--mono); font-size: 12.5px; }
:not(pre) > code { background: var(--surface-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--text); }
::selection { background: var(--brand-200); color: #04201a; } /* dark text: selected white hero text stayed white on the light highlight */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
[x-cloak] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* ---------- Icons ---------- */
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--btn-bd); background: var(--btn-bg); color: var(--btn-fg);
  font: 550 13.5px/1 var(--font); white-space: nowrap; cursor: pointer; user-select: none;
  box-shadow: var(--shadow-xs); transition: background .15s, border-color .15s, box-shadow .15s, transform .05s, color .15s;
}
.btn:hover { background: var(--hover); color: var(--btn-fg); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn.is-disabled { opacity: .55; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { --btn-bg: var(--brand); --btn-fg: var(--brand-contrast); --btn-bd: var(--brand-600); box-shadow: 0 1px 2px rgba(16,24,40,.12), inset 0 1px 0 rgba(255,255,255,.14); }
.btn-primary:hover { background: var(--brand-600); color: #fff; }
.btn-dark { --btn-bg: var(--text); --btn-fg: var(--surface); --btn-bd: var(--text); }
.btn-dark:hover { background: var(--text-2); color: var(--surface); }
.btn-danger { --btn-bg: var(--red); --btn-fg: #fff; --btn-bd: var(--red); }
.btn-danger:hover { background: color-mix(in oklab, var(--red) 88%, #000); color: #fff; }
.btn-soft { --btn-bg: var(--brand-50); --btn-fg: var(--brand-700); --btn-bd: var(--brand-100); box-shadow: none; }
.btn-soft:hover { background: var(--brand-100); }
[data-theme="dark"] .btn-soft { --btn-fg: color-mix(in oklab, var(--brand) 70%, #fff); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--red); box-shadow: none; }
.btn-danger-ghost:hover { background: var(--red-bg); color: var(--red); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 11px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--btn-fg) transparent var(--btn-fg) transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards ---------- */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header.plain { border-bottom: 0; padding-bottom: 4px; }

/* A help panel worth reading once and in the way every time after. Closed, it is one quiet line. */
details.card.help > summary { cursor: pointer; list-style: none; border-bottom: 0; }
details.card.help > summary::-webkit-details-marker { display: none; }
details.card.help > summary::after { content: ""; width: 7px; height: 7px; margin-left: auto; flex: none;
  border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg) translateY(-2px); transition: transform .18s; }
details.card.help[open] > summary { border-bottom: 1px solid var(--border); }
details.card.help[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
details.card.help > summary:hover .card-title { color: var(--brand); }
.card-title { font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 14px 16px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-link { display: block; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.card-link:hover { border-color: var(--border-strong); box-shadow: var(--shadow); color: inherit; transform: translateY(-1px); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1; white-space: nowrap; border: 1px solid var(--gray-bd); background: var(--gray-bg); color: var(--text-2); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-bg); color: var(--green); border-color: var(--green-bd); }
.badge-amber { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-bd); }
.badge-red { background: var(--red-bg); color: var(--red); border-color: var(--red-bd); }
.badge-blue { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-bd); }
.badge-violet { background: var(--violet-bg); color: var(--violet); border-color: var(--violet-bd); }
.badge-brand { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
[data-theme="dark"] .badge-brand { color: color-mix(in oklab, var(--brand) 70%, #fff); }
.badge-lg { height: 26px; padding: 0 10px; font-size: 12.5px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px 16px; }
.form-grid > .field { grid-column: span 12; }
.span-3 { grid-column: span 3 !important; } .span-4 { grid-column: span 4 !important; } .span-6 { grid-column: span 6 !important; } .span-8 { grid-column: span 8 !important; } .span-9 { grid-column: span 9 !important; }
.form-section { grid-column: span 12; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--border); }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.form-section h3 { font-size: 14px; }
.form-section p { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--red); }
.hint { font-size: 12px; color: var(--text-3); }
.error-text { font-size: 12px; color: var(--red); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--field); color: var(--text);
  font: 400 14px/1.4 var(--font); box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.textarea.mono, .input.mono { font-family: var(--mono); font-size: 12.5px; }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in oklab, var(--border-strong) 60%, var(--text-4)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input[readonly] { background: var(--surface-3); color: var(--text-2); }
.is-invalid .input, .is-invalid .select, .is-invalid .textarea, .input.is-invalid { border-color: var(--red); }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text-3); font-size: 13px; border-radius: 9px 0 0 9px; border-right: 0; }
.input-group .input { border-radius: 0 9px 9px 0; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-4); pointer-events: none; }
.input-icon .input { padding-left: 36px; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13.5px; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 22px; background: var(--border-strong); position: relative; transition: background .2s var(--ease); flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.switch-sm .track { width: 32px; height: 18px; } .switch-sm .track::after { width: 12px; height: 12px; } .switch-sm input:checked + .track::after { transform: translateX(14px); }

/* Checkbox */
.check { display: inline-flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); flex-shrink: 0; cursor: pointer; }

/* Checkbox pills (tags / checkboxes fields) */
.pill-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-picker label { position: relative; }
.pill-picker input { position: absolute; opacity: 0; }
.pill-picker span { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; color: var(--text-2); cursor: pointer; transition: all .15s; }
.pill-picker span::before { content: ""; width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--border-strong); background: var(--surface); transition: all .15s; }
.pill-picker input:checked + span { border-color: var(--brand); background: var(--brand-50); color: var(--brand-700); }
.pill-picker input:checked + span::before { background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/10px no-repeat; border-color: var(--brand); }
.pill-picker input:focus-visible + span { box-shadow: var(--ring); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.perm-grid label { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); font-size: 13px; color: var(--text-2); }
.perm-grid label:has(input:checked) { border-color: var(--brand-200); background: var(--brand-50); color: var(--text); }
.perm-grid input { accent-color: var(--brand); margin-top: 2px; }

/* Color field */
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type=color] { width: 44px; height: 38px; padding: 3px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; }
.color-field .input { font-family: var(--mono); text-transform: uppercase; }

/* File / image upload */
.upload { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2); }
.upload-preview { width: 56px; height: 56px; border-radius: 10px; background: var(--surface-3) center/cover no-repeat; border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-4); overflow: hidden; flex-shrink: 0; }
.upload-preview img { width: 100%; height: 100%; object-fit: contain; }
.upload-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.upload input[type=file] { font-size: 12.5px; color: var(--text-3); max-width: 100%; }
.upload input[type=file]::file-selector-button { height: 30px; padding: 0 12px; margin-right: 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 550 12.5px var(--font); cursor: pointer; }

/* Repeaters (list / key-value / params) */
.repeater { display: flex; flex-direction: column; gap: 8px; }
.repeater-row { display: flex; gap: 8px; align-items: center; }
.repeater-row .input { flex: 1; }
.repeater-add { align-self: flex-start; }
.params-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.params-table th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 0 4px; }
.params-table td { padding: 0 4px; vertical-align: middle; }
.params-table .input, .params-table .select { height: 34px; font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .045em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover { color: var(--text); }
.table th.is-sorted { color: var(--text); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .col-check { width: 44px; padding-right: 0; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table .cell-title { color: var(--text); font-weight: 550; }
.table .cell-sub { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; margin-top: 1px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.table-compact td { padding: 9px 14px; }
.table-thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); background: var(--surface-3); }
.row-actions { display: inline-flex; gap: 2px; justify-content: flex-end; }

/* ---------- Avatars ---------- */
.avatar { --size: 32px; width: var(--size); height: var(--size); border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0; font-size: calc(var(--size) * .38); font-weight: 650; color: #fff; background: linear-gradient(135deg, var(--brand), color-mix(in oklab, var(--brand) 55%, #0ea5e9)); overflow: hidden; letter-spacing: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { --size: 26px; } .avatar-lg { --size: 44px; } .avatar-xl { --size: 64px; }
.avatar-square { border-radius: 10px; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--blue-bd); background: var(--blue-bg); color: var(--text); font-size: 13.5px; }
.alert .icon { color: var(--blue); margin-top: 1px; }
.alert-title { font-weight: 650; margin-bottom: 2px; }
.alert-success { border-color: var(--green-bd); background: var(--green-bg); } .alert-success .icon { color: var(--green); }
.alert-warning { border-color: var(--amber-bd); background: var(--amber-bg); } .alert-warning .icon { color: var(--amber); }
.alert-danger { border-color: var(--red-bd); background: var(--red-bg); } .alert-danger .icon { color: var(--red); }
.alert-brand { border-color: var(--brand-200); background: var(--brand-50); } .alert-brand .icon { color: var(--brand-600); }

/* ---------- Tabs / segmented ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-3); font-weight: 550; font-size: 13.5px; white-space: nowrap; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; font-family: var(--font); }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--brand); }
.tab .count { font-size: 11px; background: var(--surface-3); color: var(--text-3); border-radius: 999px; padding: 1px 7px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 10px; border: 1px solid var(--border); }
.segmented a, .segmented button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; height: 28px; padding: 0 12px; border-radius: 7px; font: 550 12.5px var(--font); color: var(--text-3); border: 0; background: transparent; cursor: pointer; }
.segmented .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 60; opacity: 0; transform: translateY(-4px) scale(.98); pointer-events: none; transition: opacity .14s, transform .14s var(--ease); }
.dropdown.is-open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-menu.left { right: auto; left: 0; }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font: 500 13.5px var(--font); background: none; border: 0; cursor: pointer; text-align: left; }
.dropdown-item:hover { background: var(--hover); color: var(--text); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: var(--red-bg); }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-label { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-4); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(10, 14, 19, .5); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .18s; }
.modal.is-open { opacity: 1; pointer-events: auto; }
.modal-dialog { width: 100%; max-width: 480px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); transform: translateY(8px) scale(.98); transition: transform .2s var(--ease); }
.modal.is-open .modal-dialog { transform: none; }
.modal-lg .modal-dialog { max-width: 720px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.modal-title { font-size: 16px; font-weight: 650; }
.modal-body { padding: 10px 20px 20px; color: var(--text-2); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.modal-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--red-bg); color: var(--red); margin-bottom: 10px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in .25s var(--ease); }
.toast .icon { margin-top: 1px; }
.toast-success .icon { color: #4ade80; } .toast-error .icon { color: #f87171; } .toast-info .icon { color: #60a5fa; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 0; }
.toast.is-leaving { animation: toast-out .2s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------- Code ---------- */
.code-block { position: relative; background: #0b1220; color: #d7e0ea; border-radius: 12px; border: 1px solid #1c2636; overflow: hidden; }
.code-block pre { margin: 0; padding: 16px 18px; overflow-x: auto; line-height: 1.65; font-size: 12.5px; }
.code-block .code-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 8px 16px; border-bottom: 1px solid #1c2636; color: #8a9bb0; font-size: 12px; }
.code-block .copy-btn { background: #172033; color: #b6c3d4; border: 1px solid #253248; height: 26px; padding: 0 10px; border-radius: 7px; font: 550 12px var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.code-block .copy-btn:hover { background: #1d2940; color: #fff; }
.tok-k { color: #c792ea; } .tok-s { color: #a5e3a1; } .tok-n { color: #f6c177; } .tok-c { color: #6c7a90; } .tok-p { color: #7fd1ff; }
.copy-field { display: flex; gap: 6px; }
.copy-field .input { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); }
kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface); color: var(--text-3); font-size: 11px; }

/* ---------- Progress / meter ---------- */
.meter { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .6s var(--ease); }
.meter.warn > span { background: #f59e0b; } .meter.full > span { background: var(--red); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-600); border: 1px solid var(--brand-100); margin-bottom: 4px; }
.empty-icon .icon { width: 26px; height: 26px; }
.empty h3 { font-size: 16px; }
.empty p { color: var(--text-3); max-width: 420px; font-size: 13.5px; }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--hover) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); flex-wrap: wrap; }
.pagination-links { display: flex; gap: 4px; }
.pagination-links a, .pagination-links span { min-width: 32px; height: 32px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); color: var(--text-2); font-weight: 550; background: var(--surface); }
.pagination-links a:hover { background: var(--hover); color: var(--text); }
.pagination-links .is-active { background: var(--text); color: var(--surface); border-color: var(--text); }
.pagination-links .is-disabled { opacity: .45; }

/* ---------- Utilities ---------- */
.flex { display: flex; } .inline-flex { display: inline-flex; } .grid { display: grid; }
.items-center { align-items: center; } .items-start { align-items: flex-start; } .justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; } .justify-center { justify-content: center; }
.flex-1 { flex: 1; min-width: 0; } .wrap { flex-wrap: wrap; } .col { flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.p-0 { padding: 0 !important; }
.w-full { width: 100%; }
.muted { color: var(--text-3); } .muted-2 { color: var(--text-4); } .strong { font-weight: 650; color: var(--text); }
.text-xs { font-size: 12px; } .text-sm { font-size: 13px; } .text-md { font-size: 15px; } .text-lg { font-size: 18px; }
.text-right { text-align: right; } .text-center { text-align: center; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.text-green { color: var(--green); } .text-red { color: var(--red); } .text-amber { color: var(--amber); } .text-brand { color: var(--brand-600); }
.divider-y > * + * { border-top: 1px solid var(--border); }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cols-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid > .field, .span-3, .span-4, .span-6, .span-8, .span-9 { grid-column: span 12 !important; }
  .hide-sm { display: none !important; }
}

/* ---------- Dark (teal) theme touches ---------- */
[data-theme="dark"] .btn-primary { --btn-bd: var(--brand); }
[data-theme="dark"] .btn-primary:hover { background: color-mix(in oklab, var(--brand) 86%, #000); }
[data-theme="dark"] .btn-danger { --btn-bg: #d64a4a; --btn-bd: #d64a4a; }
[data-theme="dark"] .btn-danger:hover { background: #c03d3d; }
[data-theme="dark"] .table th { background: rgba(1, 30, 33, .5); }
[data-theme="dark"] .table tbody tr:hover { background: rgba(237, 245, 242, .03); }
[data-theme="dark"] .switch .track { background: rgba(237, 245, 242, .18); }
[data-theme="dark"] .upload { background: rgba(1, 30, 33, .35); }
[data-theme="dark"] .code-block { background: #011d20; border-color: rgba(237, 245, 242, .1); }
[data-theme="dark"] .code-block .code-head { border-color: rgba(237, 245, 242, .08); }
[data-theme="dark"] .code-block .copy-btn { background: rgba(237, 245, 242, .06); border-color: rgba(237, 245, 242, .12); }
[data-theme="dark"] .pagination-links .is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .toast { background: #0b4a4e; color: var(--text); border: 1px solid var(--border-strong); }
[data-theme="dark"] .modal { background: rgba(0, 16, 18, .6); }
