/* ==========================================================================
   Zee Pharmaceuticals ERP — Components
   ========================================================================== */

/* --------------------------------------------------------------- Buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: var(--brand-500);
  color: var(--ink-on-brand);
  box-shadow: var(--sh-xs);
}
.btn-primary:hover { background: var(--brand-600); }

.btn-default {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
  box-shadow: var(--sh-xs);
}
.btn-default:hover { background: var(--surface-2); border-color: var(--ink-muted); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }

.btn-subtle { background: var(--surface-3); color: var(--ink-2); }
.btn-subtle:hover { background: var(--border); color: var(--ink); }

.btn-danger { background: var(--critical); color: #fff; }
.btn-danger:hover { filter: brightness(0.93); }

.btn-brand-soft { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-100); }
.btn-brand-soft:hover { background: var(--brand-100); }

.btn-sm { height: 28px; padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-sm); gap: var(--sp-1); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 42px; padding: 0 var(--sp-6); font-size: var(--fs-base); border-radius: var(--r-lg); }
.btn-lg svg { width: 17px; height: 17px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-icon.btn-lg { width: 42px; }
.btn-block { width: 100%; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }

/* ------------------------------------------------------------- Segmented -- */
.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-3);
  border-radius: var(--r-md);
  gap: 2px;
}
.segmented button {
  height: 28px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ink-3);
  transition: all var(--dur-1) var(--ease);
  white-space: nowrap;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-xs);
}

/* ------------------------------------------------------------------ Card -- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.card-flat { box-shadow: none; }
.card-inset { background: var(--surface-2); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 48px;
}
.card-head-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-head h3 { font-size: var(--fs-md); font-weight: var(--fw-semi); letter-spacing: -0.005em; }
.card-head .sub { font-size: var(--fs-xs); color: var(--ink-3); }
.card-head-actions { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }

.card-body { padding: var(--sp-5); }
.card-body-tight { padding: var(--sp-4); }
.card-body-flush { padding: 0; }
.card-foot {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

/* ------------------------------------------------------------- Stat tile -- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--sh-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.stat-label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-weight: var(--fw-medium);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.stat-label svg { width: 14px; height: 14px; color: var(--ink-muted); }
.stat-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semi);
  letter-spacing: -0.022em;
  line-height: 1.1;
  color: var(--ink);
}
.stat-value .unit { font-size: 0.6em; font-weight: var(--fw-medium); color: var(--ink-3); margin-left: 2px; }
.stat-meta { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--ink-3); flex-wrap: wrap; }
.stat-delta { display: inline-flex; align-items: center; gap: 3px; font-weight: var(--fw-semi); font-variant-numeric: tabular-nums; }
.stat-delta svg { width: 12px; height: 12px; }
.stat-delta.up { color: var(--delta-up); }
.stat-delta.down { color: var(--delta-down); }
.stat-delta.flat { color: var(--ink-3); }
.stat-spark { margin-top: auto; padding-top: var(--sp-2); }
.stat-accent { position: absolute; inset: 0 auto 0 0; width: 3px; }

/* --------------------------------------------------------------- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--neutral-ink);
  border: 1px solid transparent;
}
.badge svg { width: 11px; height: 11px; }
.badge-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.badge-good     { background: var(--good-bg); color: var(--good-ink); }
.badge-warning  { background: var(--warning-bg); color: var(--warning-ink); }
.badge-serious  { background: var(--serious-bg); color: var(--serious-ink); }
.badge-critical { background: var(--critical-bg); color: var(--critical-ink); }
.badge-info     { background: var(--info-bg); color: var(--info-ink); }
.badge-brand    { background: var(--brand-50); color: var(--brand-600); }
.badge-outline  { background: transparent; border-color: var(--border-strong); color: var(--ink-2); }
.badge-lg { height: 24px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }

.pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 26px; padding: 0 var(--sp-3);
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}

.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 26px; padding: 0 var(--sp-2) 0 var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--brand-50); color: var(--brand-600);
  border: 1px solid var(--brand-100);
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
}
.chip button { display: flex; color: inherit; opacity: 0.6; }
.chip button:hover { opacity: 1; }
.chip svg { width: 12px; height: 12px; }

/* --------------------------------------------------------------- Avatar --- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--r-full);
  background: var(--brand-100); color: var(--brand-700);
  font-size: var(--fs-xs); font-weight: var(--fw-semi);
  flex-shrink: 0; letter-spacing: 0.01em; text-transform: uppercase;
  border: 1px solid var(--surface);
}
.avatar-sm { width: 24px; height: 24px; font-size: var(--fs-2xs); }
.avatar-lg { width: 44px; height: 44px; font-size: var(--fs-md); }
.avatar-xl { width: 64px; height: 64px; font-size: var(--fs-lg); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------------------------------------------------------------- Forms --- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.field > label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--ink-2);
  display: flex; align-items: center; gap: var(--sp-2);
}
.field .hint { font-size: var(--fs-xs); color: var(--ink-muted); }
.field .err { font-size: var(--fs-xs); color: var(--critical-ink); }

.input, .select, .textarea {
  height: 34px;
  width: 100%;
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-md);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
  min-width: 0;
}
.textarea { height: auto; padding: var(--sp-3); resize: vertical; min-height: 76px; line-height: var(--lh-snug); }
.input::placeholder, .textarea::placeholder { color: var(--ink-muted); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--ring);
}
.input:disabled, .select:disabled { background: var(--surface-3); color: var(--ink-muted); cursor: not-allowed; }
.input-sm { height: 28px; font-size: var(--fs-sm); }

.select {
  appearance: none;
  padding-right: var(--sp-7);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b95a3' stroke-width='2.4' 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 var(--sp-3) center;
  cursor: pointer;
}

.input-group { position: relative; display: flex; align-items: center; min-width: 0; }
.input-group > svg {
  position: absolute; left: var(--sp-3); width: 15px; height: 15px;
  color: var(--ink-muted); pointer-events: none;
}
.input-group .input { padding-left: 32px; }
.input-group .suffix {
  position: absolute; right: var(--sp-3);
  font-size: var(--fs-xs); color: var(--ink-muted);
  pointer-events: none;
}

.check {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  font-size: var(--fs-md); cursor: pointer; user-select: none;
}
.check input[type="checkbox"], .check input[type="radio"] {
  appearance: none;
  width: 16px; height: 16px; flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-xs);
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: all var(--dur-1) var(--ease);
}
.check input[type="radio"] { border-radius: 50%; }
.check input:checked {
  background: var(--brand-500);
  border-color: var(--brand-500);
}
.check input[type="checkbox"]:checked::after {
  content: ""; position: absolute; inset: 0;
  background: 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/11px no-repeat;
}
.check input[type="radio"]:checked::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #fff;
}

.switch { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.switch input { appearance: none; margin: 0; }
.switch .track {
  width: 34px; height: 20px; border-radius: var(--r-full);
  background: var(--border-strong); position: relative;
  transition: background var(--dur-2) var(--ease);
  flex-shrink: 0;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--sh-xs);
  transition: transform var(--dur-2) var(--ease);
}
.switch input:checked + .track { background: var(--brand-500); }
.switch input:checked + .track::after { transform: translateX(14px); }

/* ---------------------------------------------------------------- Table --- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}
.table-wrap-scroll { max-height: 520px; overflow-y: auto; }

table.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-md);
}
table.tbl thead th {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
table.tbl thead th.sortable { cursor: pointer; }
table.tbl thead th.sortable:hover { color: var(--ink); background: var(--surface-3); }
table.tbl thead th .sort-ind {
  display: inline-block; margin-left: 4px; opacity: 0.35; font-size: 9px;
  vertical-align: 1px;
}
table.tbl thead th[aria-sort] .sort-ind { opacity: 1; color: var(--brand-500); }

table.tbl tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--ink-2);
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr { transition: background var(--dur-1) var(--ease); }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr.is-selected { background: var(--brand-50); }
table.tbl tbody tr.row-critical { background: color-mix(in srgb, var(--critical) 5%, transparent); }
table.tbl tbody tr.row-warning  { background: color-mix(in srgb, var(--warning) 7%, transparent); }

table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.strong { color: var(--ink); font-weight: var(--fw-medium); }
table.tbl tfoot td {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: var(--fw-semi);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
table.tbl.compact tbody td, table.tbl.compact thead th { padding: var(--sp-2) var(--sp-3); }
table.tbl .cell-main { color: var(--ink); font-weight: var(--fw-medium); }
table.tbl .cell-sub { font-size: var(--fs-xs); color: var(--ink-muted); }

.table-toolbar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.table-toolbar .input-group { max-width: 280px; }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-sm); color: var(--ink-3);
  background: var(--surface-2);
}
.pager-btns { display: flex; align-items: center; gap: var(--sp-1); }
.pager-btns button {
  min-width: 28px; height: 28px; padding: 0 var(--sp-2);
  border-radius: var(--r-sm); font-size: var(--fs-sm);
  color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.pager-btns button:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.pager-btns button[aria-current="page"] { background: var(--brand-500); color: var(--ink-on-brand); font-weight: var(--fw-semi); }
.pager-btns button:disabled { opacity: 0.35; cursor: default; }

/* ----------------------------------------------------------------- Tabs --- */
.tabs {
  display: flex; align-items: center; gap: var(--sp-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  position: relative;
  height: 38px; padding: 0 var(--sp-4);
  font-size: var(--fs-md); font-weight: var(--fw-medium);
  color: var(--ink-3); white-space: nowrap;
  transition: color var(--dur-1) var(--ease);
  display: inline-flex; align-items: center; gap: var(--sp-2);
}
.tabs button:hover { color: var(--ink); }
.tabs button::after {
  content: ""; position: absolute; left: var(--sp-3); right: var(--sp-3); bottom: -1px;
  height: 2px; background: transparent; border-radius: 2px 2px 0 0;
  transition: background var(--dur-2) var(--ease);
}
.tabs button[aria-selected="true"] { color: var(--brand-500); }
.tabs button[aria-selected="true"]::after { background: var(--brand-500); }
.tabs .count {
  font-size: var(--fs-2xs); background: var(--surface-3); color: var(--ink-3);
  padding: 1px 5px; border-radius: var(--r-full); font-weight: var(--fw-semi);
}

/* ----------------------------------------------------------- Empty state -- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3); padding: var(--sp-9) var(--sp-6); text-align: center;
  color: var(--ink-3);
}
.empty-icon {
  width: 44px; height: 44px; border-radius: var(--r-lg);
  background: var(--surface-3); display: grid; place-items: center;
  color: var(--ink-muted); margin-bottom: var(--sp-1);
}
.empty-icon svg { width: 20px; height: 20px; }
.empty h4 { font-size: var(--fs-md); font-weight: var(--fw-semi); color: var(--ink-2); }
.empty p { font-size: var(--fs-sm); max-width: 380px; }

/* ------------------------------------------------------------- Progress --- */
.meter {
  height: 6px; border-radius: var(--r-full);
  background: var(--surface-3); overflow: hidden; width: 100%;
}
.meter > span {
  display: block; height: 100%; border-radius: var(--r-full);
  background: var(--brand-500);
  transition: width var(--dur-4) var(--ease-out);
}
.meter.good > span     { background: var(--good); }
.meter.warning > span  { background: var(--warning); }
.meter.serious > span  { background: var(--serious); }
.meter.critical > span { background: var(--critical); }
.meter-lg { height: 9px; }
.meter-stack { display: flex; height: 9px; border-radius: var(--r-full); overflow: hidden; background: var(--surface-3); }
.meter-stack > span { display: block; height: 100%; }
.meter-stack > span + span { box-shadow: -2px 0 0 var(--surface); }

/* ---------------------------------------------------------------- Modal --- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10, 16, 22, 0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6);
  z-index: var(--z-modal);
  animation: fade var(--dur-2) var(--ease);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  width: 100%; max-width: 560px;
  max-height: min(86vh, 800px);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop var(--dur-3) var(--ease-out);
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 1080px; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
}
.modal-head h3 { font-size: var(--fs-lg); font-weight: var(--fw-semi); letter-spacing: -0.012em; }
.modal-head .sub { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; }
.modal-body { padding: var(--sp-6); overflow-y: auto; flex: 1; }
.modal-body-flush { padding: 0; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
}

/* --------------------------------------------------------------- Drawer --- */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 16, 22, 0.4);
  z-index: var(--z-drawer);
  animation: fade var(--dur-2) var(--ease);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--sh-xl);
  z-index: calc(var(--z-drawer) + 1);
  display: flex; flex-direction: column;
  animation: slide-in var(--dur-3) var(--ease-out);
}
.drawer-lg { width: min(760px, 96vw); }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
}
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-6); }
.drawer-body-flush { flex: 1; overflow-y: auto; }
.drawer-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
}

/* ---------------------------------------------------------------- Toast --- */
.toast-host {
  position: fixed; bottom: var(--sp-6); right: var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-3);
  z-index: var(--z-toast); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  min-width: 280px; max-width: 400px;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-500);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  pointer-events: auto;
  animation: slide-up var(--dur-3) var(--ease-out);
}
.toast.out { animation: fade-out var(--dur-2) var(--ease) forwards; }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast .title { font-size: var(--fs-md); font-weight: var(--fw-semi); color: var(--ink); }
.toast .msg { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; }
.toast-good     { border-left-color: var(--good); }
.toast-good svg { color: var(--good); }
.toast-warning     { border-left-color: var(--warning); }
.toast-warning svg { color: var(--warning-ink); }
.toast-critical     { border-left-color: var(--critical); }
.toast-critical svg { color: var(--critical); }
.toast-info     { border-left-color: var(--info); }
.toast-info svg { color: var(--info); }

/* -------------------------------------------------------------- Tooltip --- */
.tip {
  position: fixed;
  z-index: var(--z-toast);
  background: var(--surface-inv);
  color: var(--ink-inv);
  font-size: var(--fs-xs);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-lg);
  pointer-events: none;
  max-width: 300px;
  line-height: var(--lh-snug);
}
.tip-rich {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-4);
  min-width: 160px;
}
.tip-rich .tip-title {
  font-size: var(--fs-xs); font-weight: var(--fw-semi);
  color: var(--ink); margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border-subtle);
}
.tip-row {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--fs-xs); color: var(--ink-2);
  justify-content: space-between;
}
.tip-row + .tip-row { margin-top: 3px; }
.tip-row .key { display: flex; align-items: center; gap: var(--sp-2); }
.tip-row .val { font-weight: var(--fw-semi); color: var(--ink); font-variant-numeric: tabular-nums; }
.swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.swatch-line { width: 12px; height: 2px; border-radius: 2px; flex-shrink: 0; }

/* --------------------------------------------------------------- Legend --- */
.legend {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--fs-xs); color: var(--ink-2);
}
.legend-item { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: default; }
.legend-item.mutable { cursor: pointer; }
.legend-item.off { opacity: 0.4; }

/* ------------------------------------------------------------- Skeleton --- */
.skel {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--border-subtle) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
}

/* ------------------------------------------------------------- Timeline --- */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: var(--sp-4); position: relative; padding-bottom: var(--sp-5); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-rail { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.timeline-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-3);
  display: grid; place-items: center; flex-shrink: 0;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.timeline-dot svg { width: 11px; height: 11px; }
.timeline-dot.done { background: var(--brand-500); color: #fff; box-shadow: 0 0 0 1px var(--brand-500); }
.timeline-dot.active { background: var(--info); color: #fff; box-shadow: 0 0 0 1px var(--info), 0 0 0 4px var(--info-bg); }
.timeline-dot.fail { background: var(--critical); color: #fff; box-shadow: 0 0 0 1px var(--critical); }
.timeline-line { width: 2px; flex: 1; background: var(--border); margin: 3px 0; min-height: 12px; }
.timeline-item:last-child .timeline-line { display: none; }
.timeline-body { padding-top: 1px; min-width: 0; flex: 1; }
.timeline-body .ttl { font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--ink); }
.timeline-body .meta { font-size: var(--fs-xs); color: var(--ink-muted); margin-top: 2px; }

/* -------------------------------------------------------- Definition row -- */
.dl { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: var(--sp-3) var(--sp-4); font-size: var(--fs-md); }
.dl dt { color: var(--ink-3); font-size: var(--fs-sm); }
.dl dd { color: var(--ink); font-weight: var(--fw-medium); text-align: right; font-variant-numeric: tabular-nums; }
.dl-left dd { text-align: left; font-weight: var(--fw-normal); }

.kv-list { display: flex; flex-direction: column; }
.kv {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--border-subtle);
  font-size: var(--fs-md);
}
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-3); }
.kv .v { color: var(--ink); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; text-align: right; }

/* ---------------------------------------------------------------- Notes --- */
.note {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--info-bg);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  color: var(--info-ink);
  line-height: var(--lh-snug);
}
.note svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.note-good     { background: var(--good-bg); color: var(--good-ink); }
.note-warning  { background: var(--warning-bg); color: var(--warning-ink); }
.note-critical { background: var(--critical-bg); color: var(--critical-ink); }
.note-neutral  { background: var(--surface-2); color: var(--ink-2); border-color: var(--border); }
.note strong { font-weight: var(--fw-semi); }

/* ------------------------------------------------------------- Keycaps ---- */
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semi);
  color: var(--ink-3);
}

/* ------------------------------------------------------ Command palette --- */
.cmdk-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 16, 22, 0.42);
  backdrop-filter: blur(3px);
  z-index: var(--z-palette);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  animation: fade var(--dur-2) var(--ease);
}
.cmdk {
  width: min(620px, 92vw);
  max-height: 62vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop var(--dur-3) var(--ease-out);
}
.cmdk-input {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}
.cmdk-input svg { width: 17px; height: 17px; color: var(--ink-muted); flex-shrink: 0; }
.cmdk-input input {
  flex: 1; border: 0; background: none; outline: none;
  font-size: var(--fs-lg); color: var(--ink);
}
.cmdk-input input::placeholder { color: var(--ink-muted); }
.cmdk-list { overflow-y: auto; padding: var(--sp-2); }
.cmdk-group-label {
  font-size: var(--fs-2xs); font-weight: var(--fw-semi); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-muted);
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
}
.cmdk-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--r-md);
  cursor: pointer; font-size: var(--fs-md); color: var(--ink-2);
  width: 100%; text-align: left;
}
.cmdk-item svg { width: 15px; height: 15px; color: var(--ink-muted); flex-shrink: 0; }
.cmdk-item .sub { font-size: var(--fs-xs); color: var(--ink-muted); }
.cmdk-item[aria-selected="true"] { background: var(--brand-50); color: var(--brand-700); }
.cmdk-item[aria-selected="true"] svg { color: var(--brand-500); }
.cmdk-foot {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
  font-size: var(--fs-xs); color: var(--ink-muted);
}

/* -------------------------------------------------------------- Dropdown -- */
.menu {
  position: fixed;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  padding: var(--sp-2);
  z-index: var(--z-palette);
  animation: pop var(--dur-2) var(--ease-out);
  max-height: 60vh; overflow-y: auto;
}
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-md); color: var(--ink-2);
  text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-3); color: var(--ink); }
.menu-item svg { width: 14px; height: 14px; color: var(--ink-muted); flex-shrink: 0; }
.menu-item.danger { color: var(--critical-ink); }
.menu-item.danger svg { color: var(--critical); }
.menu-item[aria-checked="true"] { color: var(--brand-600); font-weight: var(--fw-medium); }
.menu-sep { height: 1px; background: var(--border-subtle); margin: var(--sp-2) 0; }
.menu-label {
  font-size: var(--fs-2xs); font-weight: var(--fw-semi); letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-muted);
  padding: var(--sp-2) var(--sp-3);
}

/* ------------------------------------------------------------ Animations -- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(4px); } }
@keyframes pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes slide-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--critical) 45%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }
