/* ─────────────────────────────────────────────────────────────────────────
   KlinGreen — Component styles
   ──────────────────────────────────────────────────────────────────────── */

/* ── Button ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-weight: var(--fw-medium);
  font-size: var(--fs-body-md);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 0 14px;
  height: 36px;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  user-select: none;
  cursor: default;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-body-sm); border-radius: var(--radius-sm); }
.btn-md { height: 36px; padding: 0 14px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: var(--fs-body-lg); border-radius: var(--radius-md); }

.btn-primary {
  background: var(--brand-600);
  color: var(--text-on-brand);
}
.btn-primary:hover { background: oklch(from var(--brand-600) calc(l - 0.04) c h); }
.btn-primary:active { background: var(--brand-800); }

.btn-secondary {
  background: var(--bg-primary);
  border-color: var(--border-default);
  color: var(--text-primary);
}
.btn-secondary:hover { background: var(--bg-secondary); border-color: var(--border-strong); }
.btn-secondary:active { background: var(--bg-tertiary); }

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
}
.btn-ghost:hover { background: var(--bg-secondary); }
.btn-ghost:active { background: var(--bg-tertiary); }

.btn-danger {
  background: var(--danger-solid);
  color: white;
}
.btn-danger:hover { background: oklch(from var(--danger-solid) calc(l - 0.04) c h); }

.btn-success {
  background: var(--success-solid);
  color: white;
}
.btn-success:hover { background: oklch(from var(--success-solid) calc(l - 0.04) c h); }

.btn-icon { padding: 0; width: 36px; }
.btn-icon.btn-sm { width: 28px; }
.btn-icon.btn-lg { width: 44px; }

.btn-loading { position: relative; color: transparent !important; }
.btn-loading::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--text-on-brand);
  animation: spin 0.7s linear infinite;
}
.btn-secondary.btn-loading::after, .btn-ghost.btn-loading::after { color: var(--text-primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-split {
  display: inline-flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border-default);
}
.btn-split .btn { border-radius: 0; box-shadow: none; border: 0; }
.btn-split .btn + .btn { border-left: 1px solid var(--border-default); }

/* ── Form: input, textarea, select ──────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  display: flex;
  gap: 4px;
  align-items: center;
}
.field-label .req { color: var(--danger-solid); }
.field-help {
  font-size: var(--fs-caption);
  color: var(--text-tertiary);
}
.field-error {
  font-size: var(--fs-caption);
  color: var(--danger-text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.input, .select-trigger, .textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--fs-body-md);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 36px;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:hover, .textarea:hover, .select-trigger:hover { border-color: var(--border-control-hover); }
.input:focus, .textarea:focus, .select-trigger:focus,
.input.focused, .select-trigger.focused {
  border-color: var(--border-focus);
  box-shadow: var(--ring-focus);
}
.input[disabled], .textarea[disabled] {
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  cursor: not-allowed;
}
.input.error, .textarea.error, .select-trigger.error { border-color: var(--danger-solid); }
.input.error:focus { box-shadow: 0 0 0 3px oklch(58% 0.18 25 / 0.25); }

.input-sm { height: 28px; padding: 0 8px; font-size: var(--fs-body-sm); }
.input-lg { height: 44px; padding: 0 14px; font-size: var(--fs-body-lg); }

.textarea {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  line-height: var(--lh-body);
  resize: vertical;
}

.input-affix {
  position: relative;
  display: flex;
  align-items: center;
}
.input-affix .ti {
  position: absolute;
  left: 10px;
  color: var(--text-tertiary);
  pointer-events: none;
}
.input-affix .ti.right { left: auto; right: 10px; }
.input-affix .input { padding-left: 32px; }
.input-affix.has-right .input { padding-right: 32px; }
.input-affix .clr {
  position: absolute;
  right: 8px;
  width: 20px; height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  border-radius: var(--radius-full);
  cursor: default;
}
.input-affix .clr:hover { background: var(--bg-secondary); color: var(--text-primary); }

/* Select trigger */
.select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  padding-right: 8px;
}
.select-trigger .chev { color: var(--text-tertiary); }

/* Multi-select chips inside input */
.chips-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 36px;
  padding: 5px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}
.chips-input .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--fs-body-sm);
}
.chips-input .chip .x {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
}
.chips-input .chip .x:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.chips-input input {
  flex: 1;
  min-width: 80px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-body-md);
}

/* Checkbox + Radio */
.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: default;
  font-size: var(--fs-body-md);
  color: var(--text-primary);
}
.checkbox .box, .radio .dot {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}
.checkbox .box { border-radius: 3px; }
.radio .dot { border-radius: 50%; }
.checkbox input, .radio input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox.checked .box, .checkbox.indeterminate .box {
  background: var(--brand-600);
  border-color: var(--brand-600);
}
.radio.checked .dot {
  background: var(--brand-600);
  border-color: var(--brand-600);
}
.radio.checked .dot::after {
  content: "";
  width: 6px; height: 6px;
  background: white;
  border-radius: 50%;
}
.checkbox .box svg, .radio .dot svg { display: block; }

/* Toggle */
.toggle {
  width: 32px; height: 18px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  position: relative;
  cursor: default;
  transition: background var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform var(--dur-default) var(--ease-spring);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle.on { background: var(--brand-600); }
.toggle.on::after { transform: translateX(14px); }
.toggle.lg { width: 40px; height: 22px; }
.toggle.lg::after { width: 18px; height: 18px; }
.toggle.lg.on::after { transform: translateX(18px); }

/* Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  height: 18px;
  display: block;
}
.slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}
.slider::-moz-range-track {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  background: var(--brand-600);
  border: 2px solid white;
  border-radius: 50%;
  margin-top: -6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.slider::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--brand-600);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Date picker (visual mock) */
.datepick {
  width: 280px;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-3);
  padding: 16px;
}
.datepick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body-md);
}
.datepick-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.datepick-grid .dh {
  text-align: center;
  font-size: var(--fs-caption);
  color: var(--text-tertiary);
  padding: 6px 0 8px;
}
.datepick-grid .d {
  text-align: center;
  font-size: var(--fs-body-sm);
  padding: 7px 0;
  border-radius: var(--radius-md);
  cursor: default;
}
.datepick-grid .d:hover { background: var(--bg-secondary); }
.datepick-grid .d.muted { color: var(--text-tertiary); }
.datepick-grid .d.today { box-shadow: inset 0 0 0 1px var(--border-strong); }
.datepick-grid .d.sel {
  background: var(--brand-600);
  color: white;
}
.datepick-grid .d.in-range { background: var(--brand-tint); color: var(--brand-on-tint); border-radius: 0;}
.datepick-grid .d.range-start { background: var(--brand-600); color: white; border-radius: var(--radius-md) 0 0 var(--radius-md); }
.datepick-grid .d.range-end { background: var(--brand-600); color: white; border-radius: 0 var(--radius-md) var(--radius-md) 0; }

/* File upload dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.dropzone.hover, .dropzone.dragover {
  border-color: var(--brand-600);
  background: var(--brand-tint);
  color: var(--brand-on-tint);
}
.dropzone .ic {
  font-size: 24px;
  color: var(--brand-600);
}

/* Rich text toolbar */
.rt-bar {
  display: flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--bg-secondary);
}
.rt-bar .btn-ghost { height: 28px; width: 28px; padding: 0; }
.rt-body {
  border: 1px solid var(--border-default);
  border-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: 12px;
  min-height: 100px;
  font-size: var(--fs-body-md);
  color: var(--text-primary);
}

/* ── Badge ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  line-height: 1;
  white-space: nowrap;
}
.badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger-border); }
.badge-info    { background: var(--info-bg);    color: var(--info-text);    border-color: var(--info-border); }
.badge-brand   { background: var(--brand-tint); color: var(--brand-on-tint); border-color: transparent; }
.badge-solid-brand { background: var(--brand-600); color: var(--text-on-brand); border-color: transparent; }

/* Compliance status badge — five-state */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  border: 1px solid;
}
.status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-compliant     { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.status-partial       { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.status-non-compliant { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger-text); }
.status-not-applicable{ background: var(--bg-secondary); border-color: var(--border-subtle); color: var(--text-tertiary); }
.status-pending       { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info-text); }

.status-iconic {
  width: 18px; height: 18px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-subtle);
}
.tabs .tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: var(--fs-body-md);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: default;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.tabs .tab:hover { color: var(--text-primary); }
.tabs .tab.active {
  color: var(--brand-on-tint);
  border-bottom-color: var(--brand-600);
}

.tabs-pill {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}
.tabs-pill .tab {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  margin: 0;
  border: 0;
}
.tabs-pill .tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--elev-1);
}

/* ── Breadcrumb ──────────────────────────────────────────────── */
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-body-sm);
  color: var(--text-tertiary);
  flex-wrap: wrap;
}
.crumbs a { color: var(--text-tertiary); }
.crumbs a:hover { color: var(--text-primary); }
.crumbs .sep { opacity: 0.5; }
.crumbs .here { color: var(--text-primary); font-weight: var(--fw-medium); }

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-primary);
}
.topbar .logo { display: inline-flex; align-items: center; gap: 8px; font-weight: var(--fw-semibold); }
.topbar .logo .mark { width: 24px; height: 24px; }
.topbar .search {
  flex: 1;
  max-width: 480px;
}
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand-on-tint);
  font-size: 12px;
  font-weight: var(--fw-semibold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Sidebar nav ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar-group { display: flex; flex-direction: column; gap: 2px; }
.sidebar-group .lbl {
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  font-weight: var(--fw-semibold);
  color: var(--text-tertiary);
  padding: 6px 10px 4px;
}
.sidebar.collapsed .lbl, .sidebar.collapsed .nav-item .nav-lbl, .sidebar.collapsed .nav-badge { display: none; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-body-md);
  font-weight: var(--fw-medium);
  cursor: default;
}
.nav-item:hover { background: var(--bg-secondary); color: var(--text-primary); }
.nav-item.active {
  background: var(--brand-tint);
  color: var(--brand-on-tint);
}
.nav-item .ic { font-size: 18px; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: var(--fw-semibold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.nav-item.active .nav-badge { background: var(--brand-600); color: white; }
.nav-sub {
  margin-left: 28px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-sub .nav-item { height: 28px; font-size: var(--fs-body-sm); }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  overflow: hidden;
}
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-body-sm);
}
.tbl th, .tbl td {
  text-align: left;
  padding: 0 14px;
  height: var(--row-h);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.tbl thead th {
  background: var(--bg-secondary);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  height: 36px;
  position: sticky;
  top: 0;
  z-index: 1;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--bg-secondary); }
.tbl tbody tr.selected td { background: var(--brand-tint); }
.tbl .num { font-variant-numeric: tabular-nums; text-align: right; font-family: var(--font-mono); font-size: var(--fs-body-sm); }
.tbl th.sortable { cursor: default; }
.tbl th.sortable .sort-ind { display: inline-flex; margin-left: 4px; color: var(--text-tertiary); opacity: 0.5; }
.tbl th.sortable.active .sort-ind { color: var(--brand-on-tint); opacity: 1; }
.tbl tr.skel td { padding: 12px 14px; }
.skel-bar {
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
    var(--bg-secondary) 0%,
    var(--bg-tertiary) 50%,
    var(--bg-secondary) 100%);
  background-size: 400% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* Bulk action toolbar over table */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--brand-tint);
  border-bottom: 1px solid var(--brand-200);
  font-size: var(--fs-body-sm);
  color: var(--brand-on-tint);
}
.bulk-bar .actions { margin-left: auto; display: flex; gap: 6px; }

/* Pagination */
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-body-sm);
  color: var(--text-secondary);
}
.pager .pages { display: flex; gap: 2px; margin-left: auto; }
.pager .pg {
  min-width: 28px; height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-body-sm);
  color: var(--text-secondary);
  cursor: default;
}
.pager .pg:hover { background: var(--bg-secondary); color: var(--text-primary); }
.pager .pg.active {
  background: var(--brand-600);
  color: var(--text-on-brand);
}

/* Dense data grid */
.tbl-dense th, .tbl-dense td { height: 32px; padding: 0 10px; font-size: var(--fs-body-sm); }
.tbl-zebra tbody tr:nth-child(even) td { background: var(--bg-secondary); }

/* ── Stat card ───────────────────────────────────────────────── */
.stat {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.stat .lbl {
  font-size: var(--fs-caption);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  color: var(--text-tertiary);
  margin-bottom: 8px;
  font-weight: var(--fw-semibold);
}
.stat .val {
  font-size: 30px;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-display);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.stat .val .u { font-size: 16px; color: var(--text-tertiary); margin-left: 4px; font-weight: var(--fw-medium); }
.stat .trend {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-body-sm);
  color: var(--text-secondary);
}
.stat .trend.up { color: var(--success-text); }
.stat .trend.down { color: var(--danger-text); }
.stat .spark { margin-top: 12px; }

/* ── Progress ────────────────────────────────────────────────── */
.progress {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress .bar {
  height: 100%;
  background: var(--brand-600);
  border-radius: var(--radius-full);
  transition: width var(--dur-slow) var(--ease-out);
}
.progress.thin { height: 4px; }
.progress.thick { height: 12px; }

/* Segmented bar */
.seg-bar {
  display: flex;
  height: 12px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--bg-tertiary);
}
.seg-bar > span { height: 100%; }

/* Step indicator */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
}
.steps .step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.steps .step .n {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-default);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
}
.steps .step.active .n { background: var(--brand-600); border-color: var(--brand-600); color: white; }
.steps .step.done .n   { background: var(--success-solid); border-color: var(--success-solid); color: white; }
.steps .step .lbl { font-size: var(--fs-body-sm); color: var(--text-secondary); font-weight: var(--fw-medium); }
.steps .step.active .lbl { color: var(--text-primary); }
.steps .step.done .lbl { color: var(--text-primary); }
.steps .line {
  flex: 1;
  height: 1.5px;
  background: var(--border-default);
  margin: 0 12px;
  min-width: 24px;
}
.steps .line.done { background: var(--success-solid); }

/* ── Toast / Alert ───────────────────────────────────────────── */
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  box-shadow: var(--elev-3);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  min-width: 320px;
  max-width: 420px;
  position: relative;
  overflow: hidden;
}
.toast .ic { flex-shrink: 0; font-size: 20px; margin-top: 1px; }
.toast .body { flex: 1; min-width: 0; }
.toast .body .t { font-weight: var(--fw-semibold); font-size: var(--fs-body-md); }
.toast .body .d { font-size: var(--fs-body-sm); color: var(--text-secondary); margin-top: 2px; }
.toast .body .act { margin-top: 8px; display: flex; gap: 6px; }
.toast .x { color: var(--text-tertiary); width: 24px; height: 24px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast .x:hover { background: var(--bg-secondary); color: var(--text-primary); }
.toast::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--brand-600);
  animation: toast-progress 6s linear forwards;
  transform-origin: left;
}
.toast.success { border-left: 3px solid var(--success-solid); }
.toast.success .ic { color: var(--success-solid); }
.toast.success::after { background: var(--success-solid); }
.toast.warning { border-left: 3px solid var(--warning-solid); }
.toast.warning .ic { color: var(--warning-solid); }
.toast.warning::after { background: var(--warning-solid); }
.toast.danger  { border-left: 3px solid var(--danger-solid); }
.toast.danger .ic { color: var(--danger-solid); }
.toast.danger::after { background: var(--danger-solid); }
.toast.info    { border-left: 3px solid var(--info-solid); }
.toast.info .ic { color: var(--info-solid); }
@keyframes toast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: var(--fs-body-sm);
}
.alert .ic { flex-shrink: 0; margin-top: 1px; }
.alert .body { flex: 1; }
.alert .t { font-weight: var(--fw-semibold); color: inherit; }
.alert .d { color: inherit; opacity: 0.92; margin-top: 2px; }
.alert-info    { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info-text); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger-text); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-shell {
  position: relative;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--elev-4);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 4px;
}
.modal-head .t { font-size: var(--fs-heading-md); font-weight: var(--fw-semibold); }
.modal-body { padding: 8px 20px 20px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

/* Reusable modal backdrop — center any .modal-shell over a dimmed page.
   Used by the global confirm dialog (kgConfirm) and any ad-hoc modal. */
.kg-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 1000; overflow: auto;
}
.kg-modal-backdrop[hidden] { display: none; }

/* Confirmation dialog (window.confirm replacement) — see kgConfirm() in base.html. */
.kg-confirm-shell { width: 100%; max-width: 440px; }
.kg-confirm-msg { font-size: var(--fs-body-sm); color: var(--text-secondary); margin: 0; }

/* ── Dropdown / menu ─────────────────────────────────────────── */
.menu {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-3);
  padding: 4px;
  min-width: 200px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: var(--fs-body-sm);
  color: var(--text-primary);
  cursor: default;
}
.menu-item .ic { color: var(--text-tertiary); }
.menu-item:hover { background: var(--bg-secondary); }
.menu-item .kbd { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); }
.menu-item.danger { color: var(--danger-text); }
.menu-item.danger .ic { color: var(--danger-text); }
.menu-item.danger:hover { background: var(--danger-bg); }
.menu-divider { height: 1px; background: var(--border-subtle); margin: 4px 0; }

/* Tooltip */
.tip {
  background: var(--gray-900);
  color: var(--gray-50);
  font-size: var(--fs-caption);
  padding: 6px 8px;
  border-radius: var(--radius-md);
  max-width: 200px;
  position: relative;
  box-shadow: var(--elev-2);
}
.tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--gray-900);
}

/* Popover */
.popover {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-3);
  padding: 14px;
  min-width: 280px;
}
.popover-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* Command palette */
.cmdk {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--elev-4);
  width: 560px;
  max-width: 100%;
  overflow: hidden;
}
.cmdk-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--fs-body-md);
}
.cmdk-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-body-md);
}
.cmdk-body { padding: 6px; max-height: 380px; overflow-y: auto; }
.cmdk-group-lbl {
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 8px 10px 4px;
  font-weight: var(--fw-semibold);
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: var(--fs-body-sm);
}
.cmdk-item.active { background: var(--brand-tint); color: var(--brand-on-tint); }
.cmdk-item .ic { color: var(--text-tertiary); }
.cmdk-item.active .ic { color: var(--brand-on-tint); }
.cmdk-item .meta { margin-left: auto; font-size: 11px; color: var(--text-tertiary); }
.cmdk-foot {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  padding: 8px 14px;
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.cmdk-foot .kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  margin: 0 2px;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty .ill {
  width: 80px; height: 80px;
  margin: 0 auto 16px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--brand-tint), var(--bg-secondary));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-on-tint);
  font-size: 32px;
}
.empty .t { font-size: var(--fs-heading-md); font-weight: var(--fw-semibold); color: var(--text-primary); margin-bottom: 4px; }
.empty .d { font-size: var(--fs-body-md); max-width: 40ch; margin: 0 auto 16px; }

/* ── Score ring ──────────────────────────────────────────────── */
.score-ring {
  display: inline-block;
  position: relative;
  width: 160px;
  height: 160px;
}
.score-ring svg { transform: rotate(-90deg); }
.score-ring .ring-bg { fill: none; stroke: var(--bg-tertiary); }
.score-ring .ring-fg { fill: none; stroke: var(--brand-600); stroke-linecap: round; transition: stroke-dashoffset var(--dur-slow) var(--ease-out); }
.score-ring .ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.score-ring .ring-center .v {
  font-size: 36px;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-display);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.score-ring .ring-center .l {
  font-size: var(--fs-caption);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  margin-top: 4px;
}

/* ── Connector chip ──────────────────────────────────────────── */
.connector {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  font-size: var(--fs-body-sm);
  color: var(--text-primary);
}
.connector .src-ic {
  width: 14px; height: 14px;
  border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  color: white;
  font-size: 9px;
  font-weight: var(--fw-bold);
}
.connector .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success-solid);
}
.connector.error .dot { background: var(--danger-solid); }
.connector.disconnected .dot { background: var(--text-tertiary); }
.connector .meta { color: var(--text-tertiary); font-size: var(--fs-caption); margin-left: 2px; }

/* ── Activity log entry ──────────────────────────────────────── */
.activity {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  font-size: var(--fs-body-sm);
}
.activity .av {
  width: 28px; height: 28px;
  flex-shrink: 0;
}
.activity .body { flex: 1; min-width: 0; }
.activity .who { font-weight: var(--fw-semibold); color: var(--text-primary); }
.activity .what { color: var(--text-secondary); }
.activity .ref { color: var(--brand-on-tint); font-weight: var(--fw-medium); }
.activity .time { font-size: var(--fs-caption); color: var(--text-tertiary); margin-top: 2px; }

.activity-day {
  font-size: var(--fs-caption);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  color: var(--text-tertiary);
  font-weight: var(--fw-semibold);
  padding: 14px 0 6px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ── Notification item ───────────────────────────────────────── */
.notif {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  position: relative;
}
.notif:hover { background: var(--bg-secondary); }
.notif .ic {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.notif .body { flex: 1; min-width: 0; }
.notif .t { font-weight: var(--fw-semibold); font-size: var(--fs-body-sm); color: var(--text-primary); }
.notif .d { font-size: var(--fs-body-sm); color: var(--text-secondary); line-height: var(--lh-tight); margin-top: 2px; }
.notif .meta { display: flex; align-items: center; gap: 12px; margin-top: 6px; font-size: var(--fs-caption); color: var(--text-tertiary); }
.notif .unread {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand-600);
}

/* ── Sponsorship strip ───────────────────────────────────────── */
.sponsor-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--brand-tint), color-mix(in oklab, var(--brand-tint) 70%, transparent));
  border: 1px solid color-mix(in oklab, var(--brand-600) 25%, transparent);
  border-radius: var(--radius-lg);
  font-size: var(--fs-body-sm);
  color: var(--brand-on-tint);
}
.sponsor-strip .lbl { font-weight: var(--fw-semibold); }
.sponsor-strip .meta { color: var(--text-secondary); }
.sponsor-strip .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── Logo mark (nested rotated squares from logo SVG) ────────── */
.logo-mark {
  display: inline-block;
  position: relative;
  width: 28px;
  height: 28px;
}
.logo-mark svg { width: 100%; height: 100%; }

/* ── Helpers ─────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.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)); }
@media (max-width: 880px){
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.gap-12 { gap: 12px; }
.row.gap-16 { gap: 16px; }
.row.gap-24 { gap: 24px; }

.col { display: flex; flex-direction: column; gap: 8px; }
.col.gap-12 { gap: 12px; }
.col.gap-16 { gap: 16px; }
.col.gap-24 { gap: 24px; }

.spacer { flex: 1; }

/* ── Mobile: wide tables scroll horizontally instead of clipping ──────
   The table itself becomes the scroll container (display:block) so it
   works whether the table sits in a .table-wrap or directly in a card,
   and never forces the page wider than the viewport. */
@media (max-width: 640px) {
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tbl th, .tbl td { white-space: nowrap; }
}

/* ── Área explorer (Alcance 1 · Procesos) ─────────────────────────────
   Read-only subsector→process browser shown on the process-capture
   surfaces (guided + invoice). Token-driven so it resolves per theme;
   chips are an accordion — one open panel at a time. */
.kg-area-explorer { margin-top: 4px; }
.kg-area-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.kg-area-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-full);
  border: 1px solid var(--border-default); background: var(--bg-secondary);
  color: var(--text-primary); font-family: inherit; font-size: var(--fs-body-sm);
  cursor: pointer; transition: background .12s, border-color .12s;
}
.kg-area-chip:hover { border-color: var(--border-strong); background: var(--bg-tertiary); }
.kg-area-chip[aria-expanded="true"] {
  background: var(--brand-tint); border-color: var(--brand-600); color: var(--brand-on-tint);
}
.kg-area-count {
  font-size: var(--fs-caption); color: var(--text-tertiary);
  background: var(--bg-primary); border-radius: var(--radius-full);
  padding: 0 7px; min-width: 20px; text-align: center;
}
.kg-area-chip[aria-expanded="true"] .kg-area-count { color: var(--brand-600); background: var(--bg-primary); }
.kg-area-panel {
  margin-top: 10px; padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--bg-secondary); border: 1px solid var(--border-subtle);
}
.kg-area-panel-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.kg-area-panel-sub { font-size: var(--fs-caption); color: var(--text-tertiary); }
.kg-area-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.kg-area-list li {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  font-size: var(--fs-body-sm); color: var(--text-secondary);
}
.kg-area-fuente { font-weight: var(--fw-medium); color: var(--text-primary); }
.kg-area-act { color: var(--text-tertiary); }
.kg-area-unit { margin-left: auto; font-size: var(--fs-caption); color: var(--text-tertiary); }

/* Qué SÍ / NO va aquí — scannable guidance lists on the process surfaces. */
.kg-scope-guide { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 14px; }
@media (max-width: 640px) { .kg-scope-guide { grid-template-columns: 1fr; } }
.kg-scope-card {
  padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--bg-secondary); border: 1px solid var(--border-subtle);
}
.kg-scope-card-title {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-body-sm); font-weight: var(--fw-semibold); margin-bottom: 6px;
}
.kg-scope-card.is-yes .kg-scope-card-title { color: var(--leaf-600); }
.kg-scope-card.is-no .kg-scope-card-title { color: var(--text-secondary); }
.kg-scope-card ul { margin: 0; padding-left: 18px; }
.kg-scope-card li { font-size: var(--fs-caption); color: var(--text-secondary); margin-bottom: 3px; }
