
/* MriaCRM — компоненти. Лише класи й змінні з tokens.css; жодних округлень, тіней і градієнтів. */

/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; border-radius: var(--radius-none); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/20px var(--font-sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wordmark { font: 700 26px/32px var(--font-sans); letter-spacing: -0.04em; color: var(--ink); }
.wordmark span { font-weight: 400; color: var(--muted); }
.page-eyebrow { margin: 0 0 var(--space-1); font: 600 11px/16px var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.page-title { margin: 0; font: 600 28px/34px var(--font-sans); letter-spacing: -0.02em; }

/* ---------- Button ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--control-h); padding: 0 var(--space-4); border: 1px solid var(--control); background: var(--surface); color: var(--ink); font-weight: 500; font-size: 14px; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--ink); text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--on-accent); }
.btn--quiet { background: transparent; border-color: transparent; color: var(--accent); padding: 0 var(--space-2); }
.btn--quiet:hover { border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn--danger { color: var(--error); border-color: var(--error); }
.btn--danger:hover { background: var(--error-soft); border-color: var(--error); }
.btn--sm { height: var(--control-h-sm); padding: 0 var(--space-3); font-size: 13px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::after { content: "…"; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* ---------- Field ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field__label { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink); }
.field__hint { font-size: 12px; line-height: 16px; color: var(--muted); }
.field__error { font-size: 12px; line-height: 16px; color: var(--error); }
.field__error::before { content: "✕ "; }
.input, .select, .textarea { width: 100%; min-width: 0; height: var(--control-h); padding: 0 var(--space-3); border: 1px solid var(--control); background: var(--surface); color: var(--ink); font-size: 14px; }
.textarea { height: auto; min-height: 72px; padding: var(--space-2) var(--space-3); resize: vertical; line-height: 20px; }
.select { appearance: none; padding-right: 32px; background-image: none; }
.select-wrap { position: relative; }
.select-wrap::after { content: "▾"; position: absolute; right: var(--space-3); top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); font-size: 12px; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.field--invalid .input, .field--invalid .select, .field--invalid .textarea { border-color: var(--error); }
.input[disabled], .select[disabled], .textarea[disabled] { background: var(--bg); color: var(--muted); cursor: not-allowed; }

/* ---------- FilterBar ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); padding: var(--space-4) 0; border-bottom: 1px solid var(--line); }
.filters .field { min-width: 180px; }
.filters .field--grow { flex: 1 1 240px; }
.filters__count { margin-left: auto; align-self: center; font-size: 12px; color: var(--muted); }

/* ---------- StageBadge ---------- */
.stage { --stage-c: var(--muted); display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 var(--space-2); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 12px; line-height: 16px; white-space: nowrap; }
.stage::before { content: ""; flex: none; width: var(--mark); height: var(--mark); border: 1.5px solid var(--stage-c); }
.stage--pay { --stage-c: var(--stage-pay); }
.stage--work { --stage-c: var(--stage-work); }
.stage--work::before { box-shadow: inset 2.5px 0 0 var(--stage-c); }
.stage--transit { --stage-c: var(--stage-transit); }
.stage--transit::before { background: var(--stage-c); }
.stage--done { --stage-c: var(--stage-done); }
.stage--done::before { background: var(--stage-c); outline: 1.5px solid var(--stage-c); outline-offset: 1.5px; width: 5px; height: 5px; margin: 0 1.5px; }
.stage--cancel { --stage-c: var(--stage-cancel); color: var(--muted); }
.stage--cancel::before { height: 2px; border: 0; background: var(--stage-c); }
.stage--plain { border-color: transparent; background: transparent; padding: 0; }

/* ---------- StageStepper ---------- */
.stepper { display: grid; grid-template-columns: repeat(var(--steps, 8), minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; counter-reset: step; }
.stepper li { position: relative; padding-top: 18px; padding-right: var(--space-2); font-size: 12px; line-height: 16px; color: var(--muted); }
.stepper li::before { content: ""; position: absolute; top: 0; left: 0; width: 10px; height: 10px; border: 1.5px solid var(--control); background: var(--surface); z-index: 1; }
.stepper li::after { content: ""; position: absolute; top: 4.5px; left: 10px; right: 0; height: 1px; background: var(--line); }
.stepper li:last-child::after { display: none; }
.stepper li[data-state="done"] { color: var(--ink); }
.stepper li[data-state="done"]::before { background: var(--accent); border-color: var(--accent); }
.stepper li[data-state="done"]::after { background: var(--accent); height: 2px; top: 4px; }
.stepper li[aria-current="step"] { color: var(--ink); font-weight: 600; }
.stepper li[aria-current="step"]::before { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 5px var(--accent); }

/* ---------- Notice ---------- */
.notice { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-3); align-items: start; padding: var(--space-3) var(--space-4); border: 1px solid currentColor; font-size: 13px; line-height: 18px; }
.notice__icon { font-family: var(--font-mono); font-weight: 500; }
.notice__body { color: var(--ink); }
.notice__body strong { display: block; font-weight: 600; }
.notice--error { color: var(--error); background: var(--error-soft); }
.notice--warning { color: var(--warning); background: var(--warning-soft); }
.notice--info { color: var(--info); background: var(--info-soft); }
.notice--success { color: var(--accent); background: var(--soft); }

/* ---------- SyncStatus ---------- */
.sync { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 12px; line-height: 16px; color: var(--muted); }
.sync::before { content: ""; width: 6px; height: 6px; background: var(--accent); flex: none; }
.sync--running::before { background: var(--info); animation: sync-blink 1s steps(2) infinite; }
.sync--stale::before { background: var(--warning); }
.sync--failed { color: var(--error); }
.sync--failed::before { background: var(--error); }
@keyframes sync-blink { 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .sync--running::before { animation: none; } }

/* ---------- DataTable ---------- */
.table-scroll { overflow-x: auto; }
.table-scroll > .data-table { min-width: 760px; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; line-height: 18px; }
.data-table th { padding: var(--space-2) var(--space-3); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.data-table td { padding: var(--space-3); border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th:first-child, .data-table td:first-child { padding-left: 0; }
.data-table th:last-child, .data-table td:last-child { padding-right: 0; }
.data-table tbody tr:hover { background: var(--soft); }
.data-table .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .cell-sub { display: block; margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--muted); }
.order-link { font-family: var(--font-mono); font-weight: 500; color: var(--ink); }
.order-link:hover { color: var(--accent); }
.data-table--dense td { padding-top: var(--space-2); padding-bottom: var(--space-2); }

/* ---------- Metrics ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric { display: grid; gap: 2px; padding: var(--space-4) var(--space-6) var(--space-4) 0; }
.metric + .metric { padding-left: var(--space-6); border-left: 1px solid var(--line); }
.metric__label { font-size: 12px; line-height: 16px; color: var(--muted); }
.metric__value { font-size: 36px; line-height: 40px; font-weight: 400; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.metric__note { font-size: 12px; line-height: 16px; color: var(--muted); }
.metric__note--alert { color: var(--error); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 112px 1fr; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 18px; }
.timeline time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline__who { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.timeline__kind { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-right: var(--space-2); }
.timeline li[data-kind="note"] .timeline__text { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline li[data-kind="refund"] .timeline__text { color: var(--warning); }

/* ---------- NextAction ---------- */
.next-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4); background: var(--soft); border-left: 0; }
.next-action__label { margin: 0; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.next-action__text { margin: 2px 0 0; font-size: 14px; line-height: 20px; font-weight: 600; }

/* ---------- EmptyState ---------- */
.empty { max-width: 560px; padding: var(--space-10) 0; border-top: 1px solid var(--line); }
.empty__mark { display: block; margin-bottom: var(--space-3); font-family: var(--font-mono); font-size: 24px; line-height: 1; color: var(--muted); }
.empty__title { margin: 0 0 var(--space-1); font-size: 15px; line-height: 20px; font-weight: 600; }
.empty__text { margin: 0 0 var(--space-4); color: var(--muted); }

/* ---------- AppShell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: var(--space-6) var(--space-3); background: var(--sidebar); border-right: 1px solid var(--line); }
.sidebar .wordmark { padding: 0 var(--space-3); }
.sidebar nav { display: grid; gap: 2px; margin-top: var(--space-8); }
.sidebar nav a { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); color: var(--muted); font-size: 14px; line-height: 20px; text-decoration: none; }
.sidebar nav a:hover { background: var(--soft); color: var(--ink); }
.sidebar nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: inset 2px 0 0 var(--accent); }
.sidebar__idx { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.sidebar__count { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.sidebar__foot { margin-top: auto; padding: var(--space-4) var(--space-3) 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); height: 56px; padding: 0 var(--space-10); border-bottom: 1px solid var(--line); font-size: 13px; }
.breadcrumb { color: var(--muted); }
.breadcrumb span { margin: 0 var(--space-2); color: var(--control); }
.breadcrumb [aria-current] { color: var(--ink); }
.topbar__account { display: flex; align-items: center; gap: var(--space-4); color: var(--muted); }
.content { max-width: var(--content-max); padding: var(--space-8) var(--space-10); }
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: var(--space-3) var(--space-4); border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .wordmark { padding: 0; }
  .sidebar nav { display: flex; overflow-x: auto; margin-top: var(--space-3); }
  .sidebar nav a { white-space: nowrap; }
  .sidebar__idx, .sidebar__foot, .sidebar__count { display: none; }
  .topbar { padding: 0 var(--space-4); height: 48px; }
  .topbar__account > span { display: none; }
  .content { padding: var(--space-6) var(--space-4); }
}

/* ---------- SidePanel ---------- */
.panel { width: var(--panel-w); max-width: 100vw; background: var(--surface); color: var(--ink); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
dialog.panel { position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; height: 100%; max-height: 100vh; border-top: 0; border-right: 0; border-bottom: 0; }
dialog.panel::backdrop { background: var(--overlay); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--line); }
.panel__head h2 { margin: 0; font-size: 18px; line-height: 24px; font-weight: 600; }
.panel__body { padding: var(--space-6); overflow-y: auto; display: grid; gap: var(--space-6); align-content: start; }
.panel__foot { margin-top: auto; display: flex; gap: var(--space-2); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--line); }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: var(--space-2) var(--space-3); margin: 0; font-size: 13px; line-height: 18px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
