/* ============================================================
   RUNDECK · components
   define once, reuse everywhere.
   ============================================================ */

/* ============ BUTTONS ================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  height: 34px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-xs);
  font-weight: var(--fw-500);
  letter-spacing: var(--tr-ui);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-hover) var(--ease-out),
              border-color var(--dur-hover) var(--ease-out),
              transform var(--dur-press) var(--ease-out);
}
.btn:hover        { background: var(--n-25); }
.btn:active       { transform: scale(0.985); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5; cursor: not-allowed; transform: none;
}

.btn--primary {
  background: var(--primary); color: var(--primary-ink);
  border-color: var(--primary);
}
.btn--primary:hover  { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--primary:active { background: var(--primary-press); border-color: var(--primary-press); }

.btn--danger {
  background: var(--er); color: #fff; border-color: var(--er);
}
.btn--danger:hover { background: var(--er-ink); border-color: var(--er-ink); }

.btn--ghost {
  background: transparent; border-color: transparent; color: var(--ink-2);
}
.btn--ghost:hover { background: var(--n-100); color: var(--ink); }

.btn--accent {
  background: var(--v-500); color: var(--v-900); border-color: var(--v-500);
  font-weight: var(--fw-600);
}
.btn--accent:hover { background: var(--v-600); border-color: var(--v-600); }

.btn--sm { height: 28px; padding: 0 var(--sp-4); font-size: var(--fs-2xs); }
.btn--lg { height: 40px; padding: 0 var(--sp-6); font-size: var(--fs-sm); }
.btn--xl { height: 56px; padding: 0 var(--sp-7); font-size: var(--fs-md); font-weight: var(--fw-600); }
.btn--block { width: 100%; }

.btn--icon {
  width: 32px; height: 32px; padding: 0;
  border-radius: var(--r-sm);
  position: relative;
}
.btn--icon.btn--sm { width: 28px; height: 28px; }

.btn .icon { width: 16px; height: 16px; flex: 0 0 16px; }
.btn--lg .icon, .btn--xl .icon { width: 18px; height: 18px; flex-basis: 18px; }


/* ============ STATUS PILLS ============================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 2px var(--sp-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-500);
  line-height: 1.4;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  white-space: nowrap;
  letter-spacing: 0;
}
.pill .dot {
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
  flex: 0 0 6px;
}
.pill .dot--ring { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }

/* neutral (Quoted / Tendered / Invoiced / Cancelled) */
.pill--neutral    { background: var(--n-100); border-color: var(--n-200); color: var(--n-700); }
.pill--committed  { background: var(--n-200); border-color: var(--n-300); color: var(--n-800); }
.pill--cancelled  { background: var(--n-100); border-color: var(--n-200); color: var(--n-500);
                    text-decoration: line-through; }

/* live (En Route / At Shipper) */
.pill--live       { background: var(--h-100); border-color: var(--h-200); color: var(--h-700); }
.pill--live .dot  { background: var(--h-500); }
.pill--live .dot::after {
  content: ""; position: absolute; inset: -3px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--h-500);
  animation: pulse 2s var(--ease-out) infinite;
}
.pill--live .dot { position: relative; }

/* semantic */
.pill--ok    { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-ink); }
.pill--wa    { background: var(--wa-soft); border-color: var(--wa-line); color: var(--wa-ink); }
.pill--er    { background: var(--er-soft); border-color: var(--er-line); color: var(--er-ink); }
.pill--info  { background: var(--in-soft); border-color: var(--in-line); color: var(--in-ink); }

.pill--sm { padding: 1px var(--sp-2); font-size: 10px; }
.pill--lg { padding: 4px var(--sp-4); font-size: var(--fs-xs); }

/* dot-only compact form — uses ink tier for 3:1 non-text */
.pill--dot { padding: 0; width: 10px; height: 10px; border: 0; border-radius: var(--r-full); }
.pill--dot.pill--ok   { background: var(--ok-ink); }
.pill--dot.pill--wa   { background: var(--wa-ink); }
.pill--dot.pill--er   { background: var(--er-ink); }
.pill--dot.pill--info { background: var(--in-ink); }

@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.9; }
  70%  { transform: scale(2.2); opacity: 0;   }
  100% { transform: scale(2.2); opacity: 0;   }
}


/* ============ PANELS / CARDS ============================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line-faint);
  border-radius: var(--r-md);
}
.panel--pad { padding: var(--sp-6); }
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--line-faint);
  min-height: 48px;
}
.panel__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-600);
  letter-spacing: var(--tr-heading);
}
.panel__sub { color: var(--ink-3); font-size: var(--fs-2xs); margin-top: 2px; }
.panel__body { padding: var(--sp-6); }
.panel__foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--line-faint);
  background: var(--n-25);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line-faint);
  border-radius: var(--r-md);
  padding: var(--sp-5);
}
.card--hover { transition: border-color var(--dur-hover) var(--ease-out),
                          background var(--dur-hover) var(--ease-out); cursor: pointer; }
.card--hover:hover { border-color: var(--line-strong); background: var(--n-25); }


/* ============ KPI TILE ================================= */
.kpi {
  padding: var(--sp-5) var(--sp-6);
  border: 1px solid var(--line-faint);
  border-radius: var(--r-md);
  background: var(--surface);
  min-width: 0;
}
.kpi__label {
  font-size: var(--fs-3xs);
  color: var(--ink-3);
  font-weight: var(--fw-600);
  text-transform: uppercase;
  letter-spacing: var(--tr-micro);
  font-variation-settings: "wdth" var(--wd-condensed);
  margin-bottom: var(--sp-2);
}
.kpi__figure {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-700);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tr-heading);
  color: var(--ink);
}
.kpi__delta {
  display: inline-flex; align-items: center; gap: 2px;
  margin-left: var(--sp-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-500);
  color: var(--ink-3);
}
.kpi__delta--up   { color: var(--ok-ink); }
.kpi__delta--down { color: var(--er-ink); }
.kpi__foot {
  margin-top: var(--sp-3);
  font-size: var(--fs-2xs);
  color: var(--ink-3);
}
.kpi__spark { margin-top: var(--sp-3); height: 40px; }


/* ============ TABLES ==================================== */
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-faint);
  border-radius: var(--r-md);
  background: var(--surface);
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-xs);
}
.tbl thead th {
  position: sticky; top: 0;
  background: var(--n-100);
  color: var(--ink-3);
  font-size: var(--fs-3xs);
  text-transform: uppercase;
  letter-spacing: var(--tr-micro);
  font-weight: var(--fw-600);
  font-variation-settings: "wdth" var(--wd-condensed);
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl th.num, .tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.center, .tbl td.center { text-align: center; }
.tbl tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-faint);
  vertical-align: middle;
  height: 40px;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr {
  position: relative;
  transition: none; /* no hover transition on rows */
}
.tbl tbody tr:hover { background: var(--n-25); }
.tbl tbody tr.is-selected { background: var(--h-50); }
.tbl tbody tr.is-selected td:first-child::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--h-600);
}

/* row-health rail — the only place lifecycle rows get colour */
.tbl tbody tr.is-warn td:first-child::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--wa);
}
.tbl tbody tr.is-late td:first-child::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--er);
}
.tbl tbody tr.is-action td:first-child::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--h-600);
}
.tbl tbody tr.is-warn  td.eta { color: var(--wa-ink); font-weight: var(--fw-500); }
.tbl tbody tr.is-late  td.eta { color: var(--er-ink); font-weight: var(--fw-500); }

.tbl.tbl--dense tbody td { padding: var(--sp-2) var(--sp-4); height: 32px; }
.tbl.tbl--zebra tbody tr:nth-child(even) { background: var(--n-25); }

.tbl td .id { font-family: var(--font-mono); font-size: 0.95em; font-weight: 500;
              letter-spacing: var(--tr-mono); font-variant-numeric: slashed-zero tabular-nums;
              color: var(--ink); }

.tbl th .sort {
  display: inline-flex; align-items: center; gap: 2px;
  cursor: pointer;
}
.tbl th .sort .icon { width: 12px; height: 12px; opacity: 0.5; }
.tbl th .sort.is-asc  .icon,
.tbl th .sort.is-desc .icon { opacity: 1; color: var(--ink); }

.tbl-empty {
  padding: var(--sp-10);
  text-align: center;
  color: var(--ink-3);
}


/* ============ BADGES ==================================== */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 2px var(--sp-3);
  font-size: var(--fs-3xs);
  font-weight: var(--fw-600);
  text-transform: uppercase;
  letter-spacing: var(--tr-micro);
  font-variation-settings: "wdth" var(--wd-condensed);
  background: var(--n-100);
  color: var(--ink-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--n-200);
}
.badge--live  { background: var(--v-500); color: var(--v-900); border-color: var(--v-500); }
.badge--demo  { background: var(--wa-soft); color: var(--wa-ink); border-color: var(--wa-line);
                font-family: var(--font-mono); text-transform: none; font-weight: 500; }
.badge--mocked { background: var(--n-1000); color: var(--v-500); border-color: var(--n-1000);
                font-family: var(--font-mono); text-transform: none; font-weight: 500; font-size: 10px; }

/* integration chip — cross-cutting demo convention */
.integ {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.01em;
  background: var(--n-100);
  color: var(--ink-3);
  border-radius: var(--r-xs);
  border: 1px solid var(--n-200);
  cursor: help;
}
.integ::before {
  content: ""; width: 6px; height: 6px; background: var(--v-500);
  border-radius: var(--r-full); flex: 0 0 6px;
}
html[data-show-integ="true"] .integ {
  background: var(--v-500); color: var(--v-900); border-color: var(--v-500);
}


/* ============ FORMS ===================================== */
.field {
  display: block;
  margin-bottom: var(--sp-5);
}
.field__label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-600);
  color: var(--ink);
  margin-bottom: var(--sp-2);
  letter-spacing: var(--tr-ui);
}
.field__hint {
  margin-top: var(--sp-2);
  font-size: var(--fs-2xs);
  color: var(--ink-3);
}
.field__error {
  margin-top: var(--sp-2);
  font-size: var(--fs-2xs);
  color: var(--er-ink);
  font-weight: var(--fw-500);
}
.field.is-error .input,
.field.is-error .select,
.field.is-error .textarea { border-color: var(--er); }

.input, .select, .textarea {
  width: 100%;
  height: 34px;
  padding: 0 var(--sp-4);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--n-500);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  transition: border-color var(--dur-hover) var(--ease-out);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--focus);
}
.input::placeholder { color: var(--n-500); }

.textarea { height: auto; min-height: 96px; padding: var(--sp-3) var(--sp-4); resize: vertical; }
.input--lg, .select--lg { height: 48px; font-size: var(--fs-base); padding: 0 var(--sp-5); }
.input--xl, .select--xl { height: 56px; font-size: var(--fs-md); padding: 0 var(--sp-6); }

.input-group {
  display: flex; align-items: center;
  border: 1px solid var(--n-500);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color var(--dur-hover) var(--ease-out);
}
.input-group:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--focus);
}
.input-group .input { border: 0; }
.input-group .input:focus { outline: 0; }
.input-group__addon {
  padding: 0 var(--sp-3);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  border-right: 1px solid var(--line);
  height: 100%; display: inline-flex; align-items: center;
}
.input-group__addon--right {
  border-right: 0; border-left: 1px solid var(--line);
}

.input-with-icon {
  position: relative;
}
.input-with-icon .icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-3); pointer-events: none;
}
.input-with-icon .input { padding-left: 36px; }

/* checkbox / radio / switch */
.check, .radio {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  cursor: pointer;
  font-size: var(--fs-sm);
  user-select: none;
}
.check input, .radio input {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  margin: 0;
  cursor: pointer;
}

.switch {
  display: inline-flex; align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  width: 32px; height: 18px;
  background: var(--n-300);
  border-radius: var(--r-full);
  position: relative;
  transition: background var(--dur-pop) var(--ease-out);
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: var(--r-full);
  transition: transform var(--dur-pop) var(--ease-out);
  box-shadow: 0 1px 2px rgb(0 0 0 / .2);
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--focus); outline-offset: 2px; }

.segmented {
  display: inline-flex;
  background: var(--n-100);
  border: 1px solid var(--n-200);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.segmented button {
  padding: 4px var(--sp-4);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-500);
  color: var(--ink-3);
  border-radius: var(--r-sm);
  transition: background var(--dur-hover) var(--ease-out),
              color var(--dur-hover) var(--ease-out);
}
.segmented button:hover { color: var(--ink); }
.segmented button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }


/* ============ ALERTS =================================== */
.alert {
  display: flex; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--fs-xs);
  align-items: flex-start;
}
.alert__icon { flex: 0 0 20px; margin-top: 1px; }
.alert__icon .icon { width: 20px; height: 20px; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: var(--fw-600); color: var(--ink); margin-bottom: 2px; }
.alert__msg   { color: var(--ink-2); line-height: var(--lh-body); }
.alert__actions { margin-top: var(--sp-3); display: flex; gap: var(--sp-3); }

.alert--ok   { background: var(--ok-soft); border-color: var(--ok-line); }
.alert--ok   .alert__icon { color: var(--ok); }
.alert--wa   { background: var(--wa-soft); border-color: var(--wa-line); }
.alert--wa   .alert__icon { color: var(--wa); }
.alert--er   { background: var(--er-soft); border-color: var(--er-line); }
.alert--er   .alert__icon { color: var(--er); }
.alert--info { background: var(--in-soft); border-color: var(--in-line); }
.alert--info .alert__icon { color: var(--in); }


/* ============ MODAL / DRAWER =========================== */
.overlay {
  position: fixed; inset: 0;
  background: rgb(5 8 12 / .55);
  z-index: var(--z-modal-backdrop);
  animation: fadeIn 160ms var(--ease-out);
}
.modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(var(--modal-w), calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-modal);
  display: flex; flex-direction: column;
  animation: modalIn var(--dur-modal) var(--ease-out);
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--line-faint);
}
.modal__title { font-size: var(--fs-lg); font-weight: var(--fw-600); }
.modal__close { color: var(--ink-3); }
.modal__body { padding: var(--sp-6); overflow-y: auto; flex: 1; }
.modal__foot {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--line-faint);
  display: flex; justify-content: flex-end; gap: var(--sp-3);
  background: var(--n-25);
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
}

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(var(--drawer-w), 92vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-drawer);
  display: flex; flex-direction: column;
  animation: drawerIn var(--dur-drawer) var(--ease-drawer);
}
.drawer__head { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--line-faint);
                display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--sp-6); }
.drawer__foot { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--line-faint);
                display: flex; gap: var(--sp-3); background: var(--n-25); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes drawerIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}


/* ============ TOAST ==================================== */
.toast-stack {
  position: fixed; right: var(--sp-6); bottom: var(--sp-6);
  z-index: var(--z-toast);
  display: flex; flex-direction: column-reverse; gap: var(--sp-3);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 320px; max-width: 400px;
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  display: flex; gap: var(--sp-3); align-items: flex-start;
  animation: toastIn 300ms var(--ease-out);
  font-size: var(--fs-xs);
}
.toast.is-out { animation: toastOut 180ms var(--ease-out) forwards; }
.toast__icon { flex: 0 0 18px; margin-top: 1px; }
.toast__icon .icon { width: 18px; height: 18px; }
.toast__body { flex: 1; }
.toast__title { font-weight: var(--fw-600); margin-bottom: 2px; }
.toast__msg { color: var(--ink-2); }
.toast--ok .toast__icon { color: var(--ok); }
.toast--wa .toast__icon { color: var(--wa); }
.toast--er .toast__icon { color: var(--er); }
.toast--info .toast__icon { color: var(--in); }

@keyframes toastIn  { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(20%); } }


/* ============ TOOLTIP ================================== */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--n-1000); color: var(--n-0);
  font-size: 11px; white-space: nowrap;
  border-radius: var(--r-sm);
  z-index: var(--z-tooltip);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-hover) var(--ease-out);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; }


/* ============ DROPDOWN MENU ============================ */
.menu {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  min-width: 200px;
  z-index: var(--z-dropdown);
  animation: menuIn var(--dur-pop) var(--ease-out);
  transform-origin: top left;
}
.menu__item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  color: var(--ink);
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.menu__item:hover { background: var(--n-100); }
.menu__item.is-danger { color: var(--er-ink); }
.menu__sep { height: 1px; background: var(--line-faint); margin: 4px 0; }
.menu__label {
  padding: var(--sp-2) var(--sp-4) 0;
  font-size: var(--fs-3xs);
  text-transform: uppercase;
  letter-spacing: var(--tr-micro);
  color: var(--ink-3);
  font-weight: var(--fw-600);
}

@keyframes menuIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}


/* ============ TIMELINE ================================= */
.timeline {
  position: relative;
  padding-left: var(--sp-6);
}
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.timeline__item {
  position: relative;
  padding: 2px 0 var(--sp-4);
}
.timeline__item::before {
  content: ""; position: absolute;
  left: calc(-1 * var(--sp-6) + 1px);
  top: 5px;
  width: 10px; height: 10px;
  background: var(--surface);
  border: 2px solid var(--ink-3);
  border-radius: var(--r-full);
}
.timeline__item.is-live::before  { border-color: var(--h-600); background: var(--h-600); }
.timeline__item.is-done::before  { border-color: var(--ok); background: var(--ok); }
.timeline__item.is-warn::before  { border-color: var(--wa); background: var(--wa); }
.timeline__item.is-er::before    { border-color: var(--er); background: var(--er); }

.timeline__head { display: flex; gap: var(--sp-3); align-items: baseline; flex-wrap: wrap; }
.timeline__title { font-size: var(--fs-xs); font-weight: var(--fw-500); color: var(--ink); }
.timeline__time { font-size: var(--fs-2xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.timeline__body { font-size: var(--fs-2xs); color: var(--ink-2); margin-top: 2px; line-height: var(--lh-body); }


/* ============ CHAT / MESSAGE LOG ======================= */
.chat { display: flex; flex-direction: column; gap: var(--sp-3); }
.chat__day {
  align-self: center;
  padding: 2px var(--sp-4);
  background: var(--n-100); color: var(--ink-3);
  font-size: var(--fs-3xs);
  text-transform: uppercase;
  letter-spacing: var(--tr-micro);
  font-weight: var(--fw-600);
  border-radius: var(--r-full);
}
.chat__msg {
  max-width: 78%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
}
.chat__msg--in  { align-self: flex-start; background: var(--n-100); color: var(--ink); }
.chat__msg--out { align-self: flex-end;   background: var(--h-50); color: var(--h-900); }
.chat__msg--note{ align-self: stretch; background: var(--wa-soft); color: var(--wa-ink);
                  border-left: 3px solid var(--wa); border-radius: var(--r-sm); }
.chat__meta {
  font-size: var(--fs-3xs);
  color: var(--ink-3);
  margin-top: 2px;
  display: flex; gap: var(--sp-2);
}


/* ============ DOCUMENT / UPLOAD CARD ==================== */
.doc {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--line-faint);
  border-radius: var(--r-md);
  background: var(--surface);
}
.doc__glyph {
  width: 40px; height: 40px;
  background: var(--n-100);
  color: var(--ink-3);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 40px;
}
.doc__glyph .icon { width: 20px; height: 20px; }
.doc__meta { flex: 1; min-width: 0; }
.doc__name { font-weight: var(--fw-500); font-size: var(--fs-sm); color: var(--ink); }
.doc__sub  { font-size: var(--fs-2xs); color: var(--ink-3); margin-top: 2px; }
.doc.is-uploaded .doc__glyph { background: var(--ok-soft); color: var(--ok-ink); }
.doc.is-error    .doc__glyph { background: var(--er-soft); color: var(--er-ink); }
.doc.is-warn     .doc__glyph { background: var(--wa-soft); color: var(--wa-ink); }

.dropzone {
  padding: var(--sp-8);
  border: 2px dashed var(--line);
  border-radius: var(--r-md);
  background: var(--n-25);
  text-align: center;
  color: var(--ink-3);
  cursor: pointer;
}
.dropzone:hover { border-color: var(--primary); background: var(--h-50); color: var(--h-700); }
.dropzone .icon { width: 24px; height: 24px; margin: 0 auto var(--sp-3); }


/* ============ AVATAR ==================================== */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--n-200); color: var(--ink-2);
  border-radius: var(--r-full);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-600);
  flex: 0 0 32px;
}
.avatar--sm { width: 24px; height: 24px; flex-basis: 24px; font-size: 10px; }
.avatar--lg { width: 40px; height: 40px; flex-basis: 40px; font-size: var(--fs-sm); }
.avatar--xl { width: 56px; height: 56px; flex-basis: 56px; font-size: var(--fs-md); }
.avatar-group { display: inline-flex; }
.avatar-group .avatar + .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }


/* ============ TABS ===================================== */
.tabs {
  display: flex;
  gap: var(--sp-2);
  border-bottom: 1px solid var(--line-faint);
  padding: 0 var(--sp-2);
}
.tabs__item {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-xs);
  font-weight: var(--fw-500);
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--sp-2);
}
.tabs__item:hover { color: var(--ink); }
.tabs__item.is-active {
  color: var(--ink); border-bottom-color: var(--primary); font-weight: var(--fw-600);
}
.tabs__count {
  padding: 0 6px; min-width: 18px; height: 18px;
  background: var(--n-100); color: var(--ink-3);
  font-size: 10px; font-weight: var(--fw-600);
  border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
}


/* ============ PROGRESS / SKELETON ====================== */
.progress {
  height: 6px;
  background: var(--n-200);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress__bar {
  height: 100%; background: var(--primary);
  border-radius: var(--r-full);
  transition: width 300ms var(--ease-out);
}
.progress--warn .progress__bar { background: var(--wa); }
.progress--er   .progress__bar { background: var(--er); }
.progress--ok   .progress__bar { background: var(--ok); }

.skeleton {
  background: linear-gradient(90deg, var(--n-100) 0%, var(--n-200) 50%, var(--n-100) 100%);
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  animation: shimmer 1.2s linear infinite;
  height: 12px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ============ PAGINATION =============================== */
.pager { display: inline-flex; gap: 2px; }
.pager__btn {
  min-width: 32px; height: 32px; padding: 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  font-size: var(--fs-xs);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.pager__btn:hover { background: var(--n-25); }
.pager__btn.is-active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }


/* ============ FILTER CHIP ============================== */
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 2px var(--sp-3) 2px var(--sp-2);
  background: var(--n-100); color: var(--ink-2);
  border: 1px solid var(--n-200);
  border-radius: var(--r-full);
  font-size: var(--fs-2xs);
  cursor: pointer;
}
.chip:hover { background: var(--n-200); }
.chip__close { display: inline-flex; align-items: center; justify-content: center;
               width: 14px; height: 14px; color: var(--ink-3); }
.chip__close:hover { color: var(--er); }


/* ============ KBD ====================================== */
kbd, .kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--n-100); color: var(--ink-2);
  border: 1px solid var(--n-300);
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  box-shadow: 0 1px 0 var(--n-300);
}


/* ============ EMPTY STATE ============================== */
.empty {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--ink-3);
}
.empty__icon {
  width: 40px; height: 40px;
  margin: 0 auto var(--sp-5);
  color: var(--ink-3);
  opacity: 0.8;
}
.empty__title { font-size: var(--fs-lg); color: var(--ink); font-weight: var(--fw-600); margin-bottom: var(--sp-2); }
.empty__msg { max-width: 40ch; margin: 0 auto var(--sp-5); line-height: var(--lh-body); }


/* ============ PAGE HEADER ============================== */
.pagehead {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-6); padding: var(--sp-6) 0 var(--sp-5);
  flex-wrap: wrap;
}
.pagehead__title { font-size: var(--fs-xl); font-weight: var(--fw-700); letter-spacing: var(--tr-heading); }
.pagehead__sub   { color: var(--ink-3); margin-top: 2px; font-size: var(--fs-sm); }
.pagehead__actions { display: flex; gap: var(--sp-3); }

.crumb {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-2xs);
  color: var(--ink-3);
  margin-bottom: var(--sp-3);
}
.crumb a { color: var(--ink-3); }
.crumb a:hover { color: var(--ink); }
.crumb__sep { color: var(--n-400); }
.crumb__cur { color: var(--ink); font-weight: var(--fw-500); }


/* ============ DASHBOARD GRIDS ========================== */
.grid-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-5);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-6); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-5); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}


/* ============ STACK / CLUSTER UTILITIES ================ */
.stack   > * + * { margin-top: var(--sp-4); }
.stack-2 > * + * { margin-top: var(--sp-2); }
.stack-3 > * + * { margin-top: var(--sp-3); }
.stack-5 > * + * { margin-top: var(--sp-5); }
.stack-6 > * + * { margin-top: var(--sp-6); }
.stack-8 > * + * { margin-top: var(--sp-8); }
.row     { display: flex; gap: var(--sp-4); align-items: center; flex-wrap: wrap; }
.row-6   { display: flex; gap: var(--sp-6); align-items: center; }
.row-3   { display: flex; gap: var(--sp-3); align-items: center; }
.row--between { justify-content: space-between; }
.row--start   { align-items: flex-start; }
.row--stretch { align-items: stretch; }
.row--wrap    { flex-wrap: wrap; }
.spacer  { flex: 1; }
