/* ============================================================================
 * SZL HOLDINGS — KANCHAY operator console layer v1.2.0  ·  szl-console.css
 * ADDITIVE. Load AFTER szl-design-system.css (KANCHAY v1.3.0); uses only its tokens.
 * Adds what operator surfaces need and the base system does not ship: form fields,
 * sidebar navigation, stat tiles, toolbar, drawer, dialog, severity chips, meters,
 * sparkline and heat cells, status dots, skeletons. Dark operator surface first;
 * every piece also reads on [data-surface="light"].
 * Brand assets (c) 2026 SZL Holdings · CC BY 4.0 · code Apache-2.0
 * SPDX-License-Identifier: Apache-2.0
 * (c) 2026 Lutar, Stephen P. - SZL Holdings - ORCID 0009-0001-0110-4173
 * ========================================================================== */

/* --- 0 · Status inks: status as text or small marks, AA on each surface ----- */
:root, [data-surface="dark"] {
  --ink-good: var(--color-success-light);
  --ink-warn: var(--color-warning-light);
  --ink-bad: var(--color-error-light);
  --ink-info: var(--color-info-light);
}
[data-surface="light"] {
  --ink-good: var(--color-success-strong);
  --ink-warn: var(--color-hatun-800);
  --ink-bad: var(--color-yawar-600);
  --ink-info: var(--link);
}

/* --- 1 · Form fields -------------------------------------------------------- */
.field { display: grid; gap: var(--space-2); }
.field__label {
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-ghost);
}
.input, .select {
  box-sizing: border-box; inline-size: 100%; min-block-size: 2.25rem;
  padding: var(--space-2) var(--space-3);
  font: var(--weight-regular) var(--text-sm)/1.4 var(--font-body); color: var(--text);
  background: transparent; border: var(--border-hairline) solid var(--control-edge);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}
.input::placeholder { color: var(--text-ghost); }
.input:focus-visible, .select:focus-visible { outline: none; border-color: var(--focus); box-shadow: var(--shadow-focus); }
.input:disabled, .select:disabled { opacity: .5; cursor: not-allowed; }
.select option { background: var(--surface); color: var(--text); }
.input--mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums lining-nums; }
@media (pointer: coarse) { .input, .select { min-block-size: var(--target-size-coarse); } }

/* --- 2 · Sidebar navigation (operator shell) ------------------------------- */
.sidebar {
  box-sizing: border-box; display: flex; flex-direction: column; flex: none;
  inline-size: 15rem; block-size: 100%;
  background: var(--bg-deep); border-inline-end: var(--border-hairline) solid var(--border-subtle);
  transition: inline-size var(--duration-base) var(--ease-standard);
}
.sidebar[data-collapsed="true"] { inline-size: 4rem; }
.sidebar__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  min-block-size: 3.5rem; padding-inline: var(--space-4);
  border-block-end: var(--border-hairline) solid var(--border-subtle);
}
.sidebar[data-collapsed="true"] .sidebar__head { justify-content: center; padding-inline: 0; }
.sidebar__brand { display: flex; align-items: center; gap: var(--space-3); min-inline-size: 0; color: var(--text); text-decoration: none; font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.sidebar__brand img, .sidebar__brand svg { block-size: 24px; inline-size: auto; display: block; }
.sidebar__toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  inline-size: 2rem; block-size: 2rem; border: 0; border-radius: var(--radius-md);
  background: none; color: var(--text-ghost); cursor: pointer;
}
.sidebar__toggle:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; padding: var(--space-3) var(--space-2); }
.sidebar__section {
  margin: 0; padding: var(--space-1) var(--space-3) var(--space-2);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-ghost);
}
.sidebar__divider { block-size: 1px; flex: none; margin: var(--space-3); background: var(--hairline); }
.sidebar__link {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-sub); text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.sidebar__link:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); text-decoration: none; }
.sidebar__link[aria-current="page"] { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.sidebar__link[aria-current="page"]::after {
  content: ""; position: absolute; inset-inline-end: var(--space-3); inset-block-start: 50%;
  inline-size: 6px; block-size: 6px; margin-block-start: -3px;
  border-radius: var(--radius-full); background: var(--accent);
}
.sidebar__icon { display: inline-flex; flex: none; inline-size: 18px; block-size: 18px; color: var(--text-ghost); }
.sidebar__icon svg { inline-size: 18px; block-size: 18px; }
.sidebar__link[aria-current="page"] .sidebar__icon { color: var(--text); }
.sidebar[data-collapsed="true"] .sidebar__link { justify-content: center; padding: var(--space-2); }
.sidebar[data-collapsed="true"] .sidebar__link[aria-current="page"]::after { inset-inline-end: 4px; }
@media (pointer: coarse) { .sidebar__link { min-block-size: var(--target-size-coarse); } }

/* --- 3 · Page header -------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-6); margin-block-end: var(--space-6); }
.page-head__title { margin: var(--space-2) 0 0; font: var(--weight-bold) var(--text-2xl)/var(--leading-snug) var(--font-display); letter-spacing: var(--tracking-tight); color: var(--text); text-wrap: balance; }
.page-head__lead { max-inline-size: var(--measure); margin: var(--space-2) 0 0; color: var(--text-sub); }

/* --- 4 · Stat tiles (wrap a .metric) ---------------------------------------- */
.stat-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.stat {
  display: grid; gap: var(--space-1); padding: var(--space-4);
  background: var(--surface); border: var(--border-hairline) solid var(--border); border-radius: var(--radius-md);
}
.stat .metric__value { font-variant-numeric: tabular-nums lining-nums; }
.stat[data-tone="good"] .metric__value { color: var(--ink-good); }
.stat[data-tone="warn"] .metric__value { color: var(--ink-warn); }
.stat[data-tone="bad"] .metric__value { color: var(--ink-bad); }
.stat[data-tone="premium"] .metric__value { color: var(--premium); }
.stat__sub { font-size: var(--text-xs); color: var(--text-ghost); }

/* --- 5 · Toolbar ------------------------------------------------------------ */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  margin-block-end: var(--space-4); padding: var(--space-3);
  background: var(--surface-alt); border: var(--border-hairline) solid var(--border-subtle); border-radius: var(--radius-md);
}
.toolbar__grow { flex: 1 1 14rem; min-inline-size: 0; }

/* --- 6 · Drawer (row detail) and dialog ------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: color-mix(in srgb, var(--color-space-900) 72%, transparent);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; z-index: var(--z-modal);
  box-sizing: border-box; inline-size: min(30rem, 100%); overflow-y: auto;
  background: var(--surface); border-inline-start: var(--border-hairline) solid var(--border);
  box-shadow: var(--shadow-xl);
  animation: szl-drawer-in var(--duration-base) var(--ease-out) both;
}
.drawer__head {
  position: sticky; inset-block-start: 0; z-index: var(--z-raised);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4) var(--space-5); border-block-end: var(--border-hairline) solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.drawer__title, .dialog__title { margin: var(--space-1) 0 0; font: var(--weight-semibold) var(--text-lg)/var(--leading-snug) var(--font-display); letter-spacing: var(--tracking-tight); color: var(--text); }
.drawer__sub { margin-block-start: 2px; font-size: var(--text-xs); color: var(--text-ghost); overflow-wrap: anywhere; }
.drawer__body { display: grid; gap: var(--space-4); padding: var(--space-5); }
.close-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  inline-size: var(--target-size-coarse); block-size: var(--target-size-coarse); margin: -10px -12px 0 0;
  border: 0; border-radius: var(--radius-md); background: none; color: var(--text-ghost); font-size: var(--text-sm); cursor: pointer;
}
.close-btn:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); }
.dialog-layer { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: var(--space-4); }
.dialog {
  position: relative; box-sizing: border-box; inline-size: min(30rem, 100%); max-block-size: min(92vh, 92dvh); overflow: auto;
  padding: var(--space-8); background: var(--surface); color: var(--text);
  border: var(--border-hairline) solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  animation: szl-dialog-in var(--duration-base) var(--ease-emphasized) both;
}
.dialog__body { margin: var(--space-3) 0 0; color: var(--text-sub); }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-block-start: var(--space-6); }
.copy-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3);
  margin-block-start: var(--space-5); padding: var(--space-3) var(--space-4);
  background: var(--bg-deep); border: var(--border-hairline) solid var(--border-subtle); border-radius: var(--radius-md);
}
.copy-row__value { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text); user-select: all; overflow-wrap: anywhere; }
@keyframes szl-drawer-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
@keyframes szl-dialog-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --- 7 · Severity chips (findings) ------------------------------------------ */
.sev {
  --_tone: var(--text-ghost);
  display: inline-flex; align-items: center; padding: 2px var(--space-2);
  font: var(--weight-semibold) var(--text-xs)/1.3 var(--font-mono); letter-spacing: .05em; text-transform: uppercase;
  color: var(--_tone); border: var(--border-hairline) solid color-mix(in srgb, var(--_tone) 45%, transparent);
  border-radius: var(--radius-sm); background: color-mix(in srgb, var(--_tone) 10%, transparent);
}
.sev--critical { --_tone: var(--ink-bad); }
.sev--high { --_tone: var(--ink-warn); }
.sev--medium { --_tone: var(--text-sub); }
.sev--low { --_tone: var(--text-ghost); }
.sev--info { --_tone: var(--ink-info); }

/* --- 8 · Status dot --------------------------------------------------------- */
.dot { display: inline-block; inline-size: .5rem; block-size: .5rem; flex: none; border-radius: var(--radius-full); background: var(--text-ghost); }
.dot--ok { background: var(--color-success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-success) 22%, transparent); }
.dot--warn { background: var(--color-warning); }
.dot--err { background: var(--color-error); }
.dot--live { animation: szl-pulse 2.2s var(--ease-standard) infinite; }
@keyframes szl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (forced-colors: active) { .dot { border: 1px solid currentColor; } }

/* --- 9 · Meter, sparkline, heat cell ---------------------------------------- */
.meter { inline-size: 100%; block-size: 6px; overflow: hidden; border-radius: var(--radius-full); background: color-mix(in srgb, var(--text) 10%, transparent); }
.meter__fill { block-size: 100%; border-radius: var(--radius-full); background: var(--_tone, var(--color-silver-300)); transition: inline-size var(--duration-base) var(--ease-standard); }
.meter[data-tone="good"] { --_tone: var(--color-success); }
.meter[data-tone="warn"] { --_tone: var(--color-warning); }
.meter[data-tone="bad"] { --_tone: var(--color-error); }
.spark { display: block; overflow: visible; }
.spark path { fill: none; stroke: var(--_tone, var(--color-silver-300)); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark[data-tone="good"] { --_tone: var(--color-success); }
.spark[data-tone="warn"] { --_tone: var(--color-warning); }
.spark[data-tone="bad"] { --_tone: var(--color-error); }
.heat {
  box-sizing: border-box; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font: var(--weight-medium) var(--text-xs)/1 var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--text); border: var(--border-hairline) solid var(--border-subtle); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--color-error) var(--heat, 8%), transparent);
}

/* --- 10 · Skeleton ---------------------------------------------------------- */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-raised) 50%, var(--surface) 75%);
  background-size: 200% 100%; animation: szl-shimmer 1.8s ease-in-out infinite;
}
@keyframes szl-shimmer { 0% { background-position: 200% center; } 100% { background-position: -200% center; } }

/* --- 11 · Focus (every console control) ------------------------------------- */
:where(.sidebar__link, .sidebar__toggle, .close-btn, .sidebar__brand):focus-visible {
  outline: var(--border-focus) solid var(--focus); outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .drawer, .dialog, .skeleton, .dot--live { animation: none; }
  .sidebar, .meter__fill { transition: none; }
}
/* End — szl-console.css · ADDITIVE to szl-design-system.css · CC BY 4.0 · ORCID 0009-0001-0110-4173 */
