/*
  Components for docs/UI-DESIGN-SYSTEM.md. Plain CSS on the tokens in tokens.css; no build step.
  Light throughout. Two weights (400, 500). Hairline borders, square-cornered status labels, no
  pills, no gradients, no glows.
*/

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
b, strong { font-weight: 500; }
img, svg { display: block; }
a { color: var(--primary-600); text-decoration: none; }
a:hover { color: var(--primary-700); text-decoration: underline; text-underline-offset: 2px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 0; }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-100); border-radius: var(--radius-sm); }
::placeholder { color: var(--text-subtle); opacity: 1; }
::selection { background: var(--primary-100); }

.icon { flex: none; }
.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;
}
.skip-link {
  position: absolute; left: 16px; top: -120px; z-index: 100;
  background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
}
.skip-link:focus { top: 12px; }
kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface); color: var(--text-muted);
  font-family: var(--font-sans); font-size: 11px; line-height: 1;
}

/* ---------- Text helpers ---------- */

.mono, .num, .amount { font-family: var(--font-mono); font-size: 13px; line-height: 20px; font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: 12px; line-height: 18px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.weight-500 { font-weight: 500; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.arabic { font-family: "Noto Sans Arabic", "Geeza Pro", Tahoma, var(--font-sans); }
.section-label {
  font-size: 11px; line-height: 16px; letter-spacing: .06em; text-transform: uppercase;
  font-weight: 500; color: var(--text-muted);
}
.section-heading { font-size: 18px; line-height: 26px; font-weight: 500; }
.negative { color: var(--danger); }

/* ---------- Layout primitives ---------- */

.stack { display: flex; flex-direction: column; gap: 24px; }
.stack-sm { display: flex; flex-direction: column; gap: 12px; }
.stack-xs { display: flex; flex-direction: column; gap: 4px; }
.cluster { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.cluster-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

/* ---------- Shell ---------- */

.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 0 12px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  --nav-accent: var(--primary-600);
  --nav-active-bg: var(--primary-50);
  --nav-active-text: var(--primary-700);
}
.sidebar--admin {
  background: var(--admin-50);
  border-right-color: var(--admin-100);
  --nav-accent: var(--admin-accent);
  --nav-active-bg: var(--admin-100);
  --nav-active-text: #5E4410;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: var(--text); }
.sidebar > .brand { flex: none; height: var(--topbar-height); margin: 0 -12px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.sidebar--admin > .brand { border-bottom-color: var(--admin-100); }
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--primary-600); color: #fff;
}
.sidebar--admin .brand-mark { background: var(--admin-accent); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 15px; line-height: 20px; font-weight: 500; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; line-height: 16px; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-label { padding: 14px 10px 4px; font-size: 11px; line-height: 16px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); font-weight: 500; }
.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: 32px; padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background-color .12s ease, color .12s ease;
}
.nav-link .icon { color: var(--text-subtle); transition: color .12s ease; }
.nav-link:hover .icon { color: var(--text-muted); }
.nav-link.is-active .icon { color: var(--nav-accent); }
.nav-link:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.sidebar--admin .nav-link:hover { background: rgba(138, 100, 32, .06); }
.nav-link.is-active { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 500; }
.nav-link.is-active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--nav-accent);
}
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 1px 0 6px; }
.nav-sub .nav-link { min-height: 30px; padding-left: 38px; font-size: 13px; }
.nav-sub .nav-link.is-active { background: transparent; }
.nav-sub .nav-link.is-active::before { display: none; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.sidebar-note { padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; line-height: 18px; color: var(--text-muted); background: var(--surface-alt); }
.sidebar--admin .sidebar-note { background: var(--surface); border-color: var(--admin-100); }

.avatar {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--primary-50); color: var(--primary-700);
  font-size: 12px; font-weight: 500;
}
.sidebar--admin .avatar { background: var(--admin-100); color: #5E4410; }

.main { display: flex; flex-direction: column; min-width: 0; }
.scrim { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-height);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--gutter);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-search { position: relative; width: 100%; max-width: 380px; }
.topbar-search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.topbar-spacer { flex: 1; }
.topbar .menu-toggle { display: none; }

.banner { display: flex; align-items: center; gap: 12px; padding: 10px var(--gutter); border-bottom: 1px solid; font-size: 13px; line-height: 20px; }
.banner--warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.banner--danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.banner--info { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }

.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 28px var(--gutter) 64px; }

/* ---------- Switchers and menus ---------- */

.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
}
.dropdown-menu--left { left: 0; right: auto; }
.dropdown-header { padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-label { padding: 6px 10px 4px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); font-weight: 500; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.dropdown-item.is-current { color: var(--primary-700); font-weight: 500; }
.dropdown-item--danger, .dropdown-item--danger:hover { color: var(--danger); }
.dropdown-item--danger:hover { background: var(--danger-bg); }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 0; }

.switcher {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 10px 0 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  max-width: 320px;
}
.switcher:hover { border-color: var(--border-strong); }
.switcher-mark { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; background: var(--accent-50); color: var(--accent-700); flex: none; }
.switcher-text { display: flex; flex-direction: column; min-width: 0; line-height: 16px; }
.switcher-name { font-weight: 500; font-size: 13px; }
.switcher-meta { font-size: 11px; color: var(--text-muted); }

.user-button { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: var(--radius-sm); color: var(--text); }
.user-button:hover { background: var(--surface-alt); }

.row-menu > summary { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; color: var(--text-muted); }
.row-menu > summary:hover { background: var(--neutral-bg); color: var(--text); }

/* ---------- Page header ---------- */

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-heading { min-width: 0; }
.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px; }
.breadcrumb li { font-size: 12px; line-height: 18px; color: var(--text-muted); }
.breadcrumb li + li::before { content: "/"; margin-right: 6px; color: var(--text-subtle); }
.breadcrumb a { color: var(--text-muted); }
.page-title { font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: -.02em; }
.page-description { margin-top: 2px; color: var(--text-muted); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Card ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 16px; line-height: 24px; font-weight: 500; }
.card-subtitle { font-size: 13px; line-height: 20px; color: var(--text-muted); }
.card-link { font-size: 13px; font-weight: 500; white-space: nowrap; }
.card-body { padding: 24px; }
.card-body--flush { padding: 0; }
.card-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-alt);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; line-height: 20px; font-weight: 500;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { border-color: var(--primary-600); box-shadow: 0 0 0 3px var(--primary-100); }
.btn-primary { background: var(--primary-600); color: #fff; box-shadow: inset 0 -1px 0 rgba(8, 58, 49, .35), var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-700); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-alt); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--neutral-bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; color: #fff; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-block { width: 100%; }
.link-button { padding: 0; border: 0; background: none; font: inherit; color: var(--primary-600); cursor: pointer; }
.link-button:hover { text-decoration: underline; }

/* ---------- Status labels (square-cornered, never pills) ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; line-height: 20px; font-weight: 500;
  white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; flex: none; }
.badge--success { color: var(--success); }
.badge--warning { color: var(--warning); }
.badge--danger  { color: var(--danger); }
.badge--info    { color: var(--info); }
.badge--neutral { color: var(--neutral); }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-alt);
  font-size: 12px; line-height: 18px; color: var(--text);
}
.tag--off { color: var(--text-muted); text-decoration: line-through; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-alt); font-size: 12px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; line-height: 20px; }
.table th {
  position: sticky; top: 0; z-index: 1;
  height: 40px; padding: 0 16px;
  background: var(--surface-alt); border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap;
  font-size: 11px; line-height: 16px; letter-spacing: .06em; text-transform: uppercase;
  font-weight: 500; color: var(--text-muted);
}
.table td { height: 48px; padding: 6px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-alt); }
.table tr[data-href] { cursor: pointer; }
.table .num, .table .col-num { text-align: right; }
.table .col-actions { width: 1%; text-align: right; white-space: nowrap; }
.table tfoot td { height: 44px; background: var(--surface-alt); border-top: 1px solid var(--border); font-weight: 500; }
.table .row-title { color: var(--text); font-weight: 500; }
.table .row-title:hover { color: var(--primary-700); }
.table .row-sub { display: block; font-size: 12px; line-height: 18px; color: var(--text-muted); }
.table tr.is-highlight td, .table tr.is-highlight:hover td { background: var(--danger-bg); }
.table tr.is-muted td { color: var(--text-muted); }
.matrix th:not(:first-child), .matrix td:not(:first-child) { text-align: center; }
.matrix .icon { margin: 0 auto; }

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; }
.form-grid .span-2, .form-grid-3 .span-3 { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.fieldset legend { padding: 0; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; line-height: 20px; font-weight: 500; color: var(--text-muted); }
.optional { font-weight: 400; color: var(--text-muted); }
.help { font-size: 12px; line-height: 18px; color: var(--text-muted); }
.field-error { font-size: 12px; line-height: 18px; color: var(--danger); }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 14px; line-height: 22px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.textarea { height: auto; min-height: 88px; padding: 8px 12px; resize: vertical; }
.select {
  appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2356605B' stroke-width='2' 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 10px center;
}
.input:hover, .select:hover, .textarea:hover { border-color: #B9C1BB; }
.input:focus, .select:focus, .textarea:focus,
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--primary-600); box-shadow: 0 0 0 3px var(--primary-100); border-radius: var(--radius-sm); }
.input[readonly], .input:disabled, .select:disabled { background: var(--surface-alt); color: var(--text-muted); }
.input-amount, .input.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.input-validation-error, .has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); }
.input-validation-error:focus, .has-error .input:focus { box-shadow: 0 0 0 3px var(--danger-bg); border-color: var(--danger); }
.input-sm, .select-sm { height: 32px; font-size: 13px; }
.input-file { padding: 6px 12px; height: auto; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--primary-600); flex: none; }
.check-text { display: flex; flex-direction: column; }

.choice-list { display: grid; gap: 8px; }
.choice-list--cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); cursor: pointer;
}
.choice:hover { border-color: var(--border-strong); }
.choice:has(input:checked) { border-color: var(--primary-600); background: var(--primary-50); }
.choice:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--primary-100); }
.choice input { margin-top: 3px; accent-color: var(--primary-600); }
.choice-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.choice-title { font-weight: 500; }
.choice-meta { font-size: 13px; line-height: 20px; color: var(--text-muted); }

/* ---------- Alerts ---------- */

.alert { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border: 1px solid; border-radius: var(--radius-md); color: var(--text); }
.alert .icon { margin-top: 3px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 500; }
.alert-list { list-style: disc; padding-left: 18px; margin-top: 4px; }
.alert--success { background: var(--success-bg); border-color: var(--success-border); }
.alert--success .icon, .alert--success .alert-title { color: var(--success); }
.alert--warning { background: var(--warning-bg); border-color: var(--warning-border); }
.alert--warning .icon, .alert--warning .alert-title { color: var(--warning); }
.alert--danger { background: var(--danger-bg); border-color: var(--danger-border); }
.alert--danger .icon, .alert--danger .alert-title { color: var(--danger); }
.alert--info { background: var(--info-bg); border-color: var(--info-border); }
.alert--info .icon, .alert--info .alert-title { color: var(--info); }
.alert--neutral { background: var(--neutral-bg); border-color: var(--neutral-border); }
.alert--neutral .icon, .alert--neutral .alert-title { color: var(--neutral); }
.flash { margin-bottom: 24px; }

/* ---------- Empty state ---------- */

.empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 48px 24px; text-align: center; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 12px; background: var(--primary-50); color: var(--primary-600); }
.empty-title { font-size: 16px; line-height: 24px; font-weight: 500; }
.empty-text { max-width: 440px; color: var(--text-muted); }
.empty-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }

/* ---------- Toolbar and pagination ---------- */

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-box { position: relative; flex: 1 1 240px; max-width: 360px; }
.search-box > .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); pointer-events: none; }
.search-box .input { padding-left: 34px; }
.toolbar .select { width: auto; min-width: 150px; }
.toolbar .input[type="date"] { width: auto; }
.toolbar-spacer { flex: 1; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; line-height: 20px; color: var(--text-muted); }
.pager { display: flex; align-items: center; gap: 4px; }
.pager a, .pager span {
  min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-variant-numeric: tabular-nums;
}
.pager a:hover { background: var(--surface-alt); text-decoration: none; }
.pager .is-current { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-700); font-weight: 500; }
.pager .is-disabled { color: var(--text-subtle); background: var(--surface-alt); }
.pager .gap { border: 0; background: none; min-width: 16px; padding: 0; }
.page-size { display: flex; align-items: center; gap: 8px; }
.page-size .select { width: auto; height: 32px; font-size: 13px; }

/* ---------- Tabs (underline, no count pills) ---------- */

.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--primary-700); border-bottom-color: var(--primary-600); }
.tab-count { color: var(--text-muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.tab-count--danger { color: var(--danger); font-weight: 500; }

/* ---------- Timeline ---------- */

.timeline { display: flex; flex-direction: column; }
.timeline-item { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; left: 11px; top: 28px; bottom: 4px; width: 1px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--neutral-border); border-radius: 7px; background: var(--neutral-bg); color: var(--neutral); }
.timeline-dot--success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.timeline-dot--warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.timeline-dot--danger  { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger); }
.timeline-dot--info    { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info); }
.timeline-title { font-weight: 500; }
.timeline-meta { font-size: 12px; line-height: 18px; color: var(--text-muted); }
.timeline-detail { margin-top: 2px; font-size: 13px; line-height: 20px; color: var(--text-muted); overflow-wrap: anywhere; }

/* ---------- Seats ---------- */

.seats { display: flex; flex-direction: column; gap: 8px; }
.seats-line { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.seats-count { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter { height: 6px; overflow: hidden; border-radius: 3px; background: var(--neutral-bg); }
.meter-fill { height: 100%; border-radius: inherit; background: var(--primary-600); }
.seats.is-full .meter-fill { background: var(--danger); }
.seats.is-full .seats-count { color: var(--danger); }
.seat-ratio { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.seat-ratio.is-full { color: var(--danger); font-weight: 500; }

/* ---------- KPIs ---------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 4px; transition: border-color .15s ease, box-shadow .15s ease; }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.stat-icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--primary-50); color: var(--primary-700); }
.stat-icon--danger { background: var(--danger-bg); color: var(--danger); }
.stat-value { font-size: 26px; line-height: 34px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-value .currency { font-size: 13px; color: var(--text-muted); font-weight: 400; margin-right: 4px; }
.stat-foot { font-size: 12px; line-height: 18px; color: var(--text-muted); }
.stat-breakdown { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
a.stat { color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-md); }
a.stat:not([href]) { cursor: default; }
a.stat:not([href]):hover { border-color: var(--border); box-shadow: var(--shadow-sm); }

/* ---------- Dashboard: needs attention, e-invoice status, quick actions ---------- */

.attention { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 16px; }
.attention-item, .attention-clear {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
  --tone: var(--neutral); --tone-bg: var(--neutral-bg);
}
.attention-item--danger { --tone: var(--danger); --tone-bg: var(--danger-bg); }
.attention-item--warning { --tone: var(--warning); --tone-bg: var(--warning-bg); }
.attention-item--info { --tone: var(--info); --tone-bg: var(--info-bg); }
.attention-item:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.attention-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--tone-bg); color: var(--tone); }
.attention-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.attention-title { font-weight: 500; }
.attention-detail { font-size: 12px; line-height: 18px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attention-go { color: var(--text-subtle); transition: transform .12s ease, color .12s ease; }
.attention-item:hover .attention-go { color: var(--text-muted); transform: translateX(2px); }
.attention-clear { grid-column: 1 / -1; box-shadow: none; background: var(--surface-alt); --tone: var(--success); --tone-bg: var(--success-bg); }

.status-bar { display: flex; gap: 3px; height: 8px; }
.status-bar span { flex-basis: 0; min-width: 0; border-radius: 2px; background: var(--key); }
.status-bar span[style^="flex-grow: 0;"] { display: none; }
.status-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; line-height: 20px; }
.status-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.status-list .tabular { font-weight: 500; }
.status-list li.is-danger .tabular { color: var(--danger); }

.card-fill { display: flex; flex-direction: column; }
.card-fill > .card-body { flex: 1; display: flex; flex-direction: column; gap: 24px; }
.chart-totals { margin-top: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.chart-totals dt { font-size: 12px; line-height: 18px; color: var(--text-muted); }
.chart-totals dd { font-size: 16px; line-height: 24px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.chart-totals .currency { font-size: 12px; font-weight: 400; color: var(--text-muted); margin-right: 4px; }
.quick-actions { display: flex; flex-direction: column; padding: 6px; }
.quick-actions a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text); }
.quick-actions a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.quick-actions .icon { color: var(--primary-600); }

/* ---------- Charts (server-rendered SVG) ---------- */

.chart { width: 100%; height: auto; overflow: visible; }
.chart .axis { stroke: var(--border); }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 2 4; }
.chart .tick { fill: var(--text-muted); font-size: 11px; font-family: var(--font-sans); }
.chart .bar-a { fill: var(--primary-600); }
.chart .bar-b { fill: var(--accent-500); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); }
.legend-key { display: inline-flex; align-items: center; gap: 6px; }
.legend-key::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--key); }

/* ---------- Wizard steps and progress ---------- */

.steps { display: flex; align-items: center; margin-bottom: 24px; overflow-x: auto; }
.step { display: flex; align-items: center; gap: 10px; flex: 1 1 0; min-width: max-content; color: var(--text-muted); font-size: 13px; }
.step:not(:last-child)::after { content: ""; flex: 1; min-width: 16px; height: 1px; margin: 0 12px; background: var(--border-strong); }
.step-marker { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font-size: 13px; font-weight: 500; }
.step.is-done .step-marker { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.step.is-current { color: var(--text); font-weight: 500; }
.step.is-current .step-marker { border-color: var(--primary-600); color: var(--primary-700); box-shadow: 0 0 0 3px var(--primary-100); }
.wizard-footer .wizard-primary { order: 2; }
.wizard-footer .wizard-cancel { order: 1; }
.wizard-footer .wizard-back { order: -1; margin-right: auto; }
.review { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }

.progress-steps { display: flex; flex-direction: column; gap: 4px; }
.progress-step { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); }
.progress-step .state { width: 24px; height: 24px; display: grid; place-items: center; flex: none; }
.progress-step .state .icon { display: none; }
.progress-step.is-done .i-done, .progress-step.is-running .i-running, .progress-step.is-failed .i-failed, .progress-step.is-pending .i-pending { display: block; }
.progress-step.is-pending { color: var(--text-muted); }
.progress-step.is-pending .state { color: var(--text-subtle); }
.progress-step.is-running { background: var(--info-bg); }
.progress-step.is-running .state { color: var(--info); }
.progress-step.is-done .state { color: var(--success); }
.progress-step.is-failed { background: var(--danger-bg); }
.progress-step.is-failed .state { color: var(--danger); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ---------- Definition lists ---------- */

.dl { display: grid; grid-template-columns: minmax(120px, 180px) minmax(0, 1fr); gap: 10px 16px; }
.dl dt { color: var(--text-muted); font-size: 13px; line-height: 22px; }
.dl dd { min-width: 0; overflow-wrap: anywhere; }

/* ---------- Document editor and document view ---------- */

.doc-head { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 24px; }
.doc-head .span-2 { grid-column: span 2; }
.lines { width: 100%; border-collapse: separate; border-spacing: 0; }
.lines th { padding: 0 8px 8px; text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.lines td { padding: 4px; vertical-align: top; }
.lines td:first-child { padding-left: 0; }
.lines .input, .lines .select { height: 34px; font-size: 13px; }
.lines .col-item { width: 22%; }
.lines .col-qty { width: 9%; }
.lines .col-price { width: 13%; }
.lines .col-tax { width: 14%; }
.lines .col-total { width: 14%; }
.lines .col-remove { width: 36px; }
.line-total { height: 34px; display: flex; align-items: center; justify-content: flex-end; padding: 0 8px; font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.totals { margin-left: auto; width: min(360px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--text-muted); }
.totals dd { text-align: right; font-family: var(--font-mono); font-size: 13px; }
.totals .grand { padding-top: 10px; border-top: 1px solid var(--border); font-weight: 500; color: var(--text); font-size: 15px; }
.totals dd.grand { font-size: 15px; }
.editor-bar { position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 12px 24px; border-top: 1px solid var(--border); background: rgba(255,255,255,.95); backdrop-filter: blur(6px); border-radius: 0 0 var(--radius-md) var(--radius-md); }
.editor-bar .hint { margin-right: auto; font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

.paper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 32px 36px; }
.paper-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.paper-title { font-size: 20px; line-height: 28px; font-weight: 500; }
.paper-parties { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-bottom: 24px; }

/* ---------- Modal ---------- */

dialog.modal { width: min(480px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); color: var(--text); }
dialog.modal::backdrop { background: rgba(16, 24, 20, .4); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-title { font-size: 16px; line-height: 24px; font-weight: 500; }
.modal-text { color: var(--text-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-alt); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- Auth ---------- */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-aside {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: 40px 56px; background: var(--admin-50); border-right: 1px solid var(--admin-100);
}
/* The landing page's eight-point star, faded towards the copy. */
.auth-aside::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23B7892F' stroke-opacity='.16'%3E%3Crect x='20' y='20' width='24' height='24'/%3E%3Crect x='20' y='20' width='24' height='24' transform='rotate(45 32 32)'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 70% 60%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 60% at 70% 60%, #000 20%, transparent 75%);
}
.auth-aside > * { position: relative; }
.auth-aside .brand { padding: 0; }
.auth-pitch { display: flex; flex-direction: column; gap: 28px; max-width: 460px; }
.auth-aside-quote { font-size: 32px; line-height: 40px; font-weight: 500; letter-spacing: -.03em; color: var(--text); text-wrap: balance; }
.auth-card { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.auth-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.auth-card-head .mono { font-size: 14px; font-weight: 500; }
.auth-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding-top: 14px; font-size: 12px; line-height: 16px; color: var(--text-muted); }
.auth-steps li { position: relative; display: flex; flex-direction: column; gap: 8px; }
.auth-steps li::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--primary-600); position: relative; z-index: 1; }
.auth-steps li:not(:last-child)::after { content: ""; position: absolute; left: 10px; right: -8px; top: 4px; height: 2px; background: var(--primary-100); }
.auth-aside-list { display: flex; flex-direction: column; gap: 10px; color: var(--text); }
.auth-aside-list li { display: flex; gap: 10px; align-items: center; }
.auth-aside-list .icon { color: var(--primary-600); }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-panel { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 24px; }
.auth-title { font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: -.02em; }
.auth-panel .card-body { display: flex; flex-direction: column; gap: 24px; padding: 32px; }
@media (max-width: 640px) { .auth-panel .card-body { padding: 24px 20px; } }
.auth-foot { text-align: center; font-size: 12px; line-height: 18px; color: var(--text-muted); }

/* ---------- Notices ---------- */

.notice { max-width: 560px; margin: 48px auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.notice-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 14px; margin-bottom: 12px; }
.notice-icon--danger { background: var(--danger-bg); color: var(--danger); }
.notice-icon--warning { background: var(--warning-bg); color: var(--warning); }
.notice-icon--info { background: var(--info-bg); color: var(--info); }

/* ---------- Print ---------- */

@media print {
  .sidebar, .topbar, .page-actions, .editor-bar, .tabs, .flash, .banner { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .card, .paper { border: 0; box-shadow: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1280px) {
  .shell { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }
  .sidebar .brand { padding: 0; justify-content: center; }
  .sidebar .brand-text, .sidebar .nav-text, .sidebar .nav-label, .sidebar .nav-sub, .sidebar .sidebar-note, .sidebar .sidebar-user-text { display: none; }
  .sidebar .nav-link { justify-content: center; padding: 0; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-head { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  :root { --gutter: 16px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: var(--sidebar-width); transform: translateX(-100%); transition: transform .2s ease; }
  .nav-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  .sidebar .brand { padding: 0 20px; justify-content: flex-start; }
  .sidebar .brand-text, .sidebar .nav-text { display: flex; }
  .sidebar .nav-label, .sidebar .sidebar-note { display: block; }
  .sidebar .nav-sub { display: flex; }
  .sidebar .nav-link { justify-content: flex-start; padding: 0 10px; }
  .sidebar .nav-sub .nav-link { padding-left: 38px; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(16, 24, 20, .4); }
  .topbar .menu-toggle { display: inline-flex; }
  .grid-2, .grid-3, .grid-main, .form-grid, .form-grid-3, .review, .paper-parties, .choice-list--cols { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .topbar-search { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .lines thead { display: none; }
  .lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .lines td { padding: 0; }
  .lines td.col-desc, .lines td.col-item { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .stats, .doc-head { grid-template-columns: minmax(0, 1fr); }
  .stat { padding: 16px; }
  .stat-value { font-size: 22px; line-height: 30px; }
  .chart-totals { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .doc-head .span-2 { grid-column: auto; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .dl dd { margin-bottom: 10px; }
  .steps .step-label { display: none; }
  .card-header, .card-body, .card-footer { padding-left: 16px; padding-right: 16px; }
  .paper { padding: 20px; }
  .switcher-text { display: none; }
}

/* ---------- Module screens (Phases 2-6) ---------- */
.strong { font-weight: 500; color: var(--text); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row-gap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-pad { padding: 16px 20px; }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 24px; }
.stats-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 24px; }
.dl-compact { grid-template-columns: minmax(96px, 120px) minmax(0, 1fr); gap: 6px 12px; font-size: 13px; }

button.dropdown-item { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.dropdown-item.is-disabled, .dropdown-item.is-disabled:hover { color: var(--text-subtle); background: none; cursor: not-allowed; }
.dropdown-note { padding: 2px 10px 8px 34px; font-size: 12px; line-height: 18px; color: var(--text-muted); max-width: 260px; }

.input.is-invalid, .select.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }

/* Document editor */
.editor .lines-wrap { overflow-x: auto; margin: 0 -4px; }
.editor .lines { min-width: 760px; }
.lines .line-total { padding-top: 11px; font-size: 13px; color: var(--text); }
.lines .num, .lines .input.num { text-align: right; }
.editor-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); gap: 32px; align-items: start; padding-top: 16px; border-top: 1px solid var(--border); }
.editor-foot .totals { width: 100%; }

/* Document preview */
.paper-meta { display: grid; grid-template-columns: auto auto; gap: 4px 16px; font-size: 13px; text-align: right; }
.paper-meta dt { color: var(--text-muted); }
.paper-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 340px); gap: 24px; padding-top: 20px; margin-top: 4px; border-top: 1px solid var(--border); }
.paper-foot .totals { width: 100%; }
.table-paper th:first-child, .table-paper td:first-child { padding-left: 0; }
.table-paper th:last-child, .table-paper td:last-child { padding-right: 0; }
.table-paper tbody tr:hover td { background: none; }
.table-paper .col-no { width: 32px; }

@media (max-width: 1024px) {
  .stats-3 { grid-template-columns: 1fr; }
  .editor-foot, .paper-foot { grid-template-columns: 1fr; }
  .paper { padding: 20px; }
  .paper-head { flex-direction: column; }
  .paper-meta { text-align: left; }
  .paper-parties { grid-template-columns: 1fr; }
}
.subsection { display: flex; flex-direction: column; gap: 12px; padding-top: 20px; border-top: 1px solid var(--border); }
.subsection .table-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table .input-amount { width: 140px; margin-left: auto; height: 34px; text-align: right; }
.form-narrow { max-width: 720px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.tile-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--primary-50); color: var(--primary-700); }
a.tile { color: inherit; transition: border-color .15s, box-shadow .15s; }
a.tile:hover { text-decoration: none; border-color: var(--primary-100); box-shadow: var(--shadow-md); }
.tile-link { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--primary-700); }
.label-inline { font-size: 13px; color: var(--text-muted); }
.table .row-section td { height: 36px; background: var(--surface-alt); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); font-weight: 500; }
.table .row-total td { font-weight: 500; background: var(--surface-alt); border-top: 1px solid var(--border-strong); }
.table-report tbody tr:hover td { background: inherit; }
.table tr.row-section:hover td, .table tr.row-total:hover td { background: var(--surface-alt); }
.cell-wrap { white-space: normal; min-width: 220px; max-width: 420px; }
.person { display: flex; align-items: center; gap: 10px; }
.person .row-title { display: block; }
.seat-card { margin-bottom: 24px; display: flex; flex-direction: column; gap: 8px; }
fieldset.plain { border: 0; margin: 0; min-width: 0; }
fieldset.plain[disabled] { opacity: .6; }
.auth-brand { display: none; align-items: center; gap: 10px; color: var(--text); }
@media (max-width: 1024px) { .auth-brand { display: flex; } }
.callout { margin-top: 20px; padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-alt); display: flex; flex-direction: column; gap: 4px; }
.copyable { user-select: all; overflow-wrap: anywhere; color: var(--text); }
.totals { column-gap: 0; }
.totals dd { padding-left: 24px; }
.lines th.col-total { padding-right: 8px; }
@media (max-width: 1024px) {
  .editor .lines-wrap { overflow: visible; margin: 0; }
  .editor .lines { min-width: 0; }
  .lines td.col-item, .lines td.col-desc { width: auto; }
  .lines .line-total { padding-top: 9px; }
  .editor-bar { flex-wrap: wrap; padding: 12px 16px; }
  .editor-bar .hint { display: none; }
  .editor-bar .btn { flex: 1 1 auto; }
}

/* ---------- Phase 7 modules ---------- */
.catch-up { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; border-left: 3px solid var(--warning); }
.btn-danger-text, .btn-danger-text:hover { color: var(--danger); }

/* Journal and expense editors */
.lines .col-account { width: 26%; }
.lines .col-category { width: 15%; }
.lines .col-date { width: 13%; }
.lines .col-trn { width: 14%; }
.lines .col-desc { min-width: 160px; }
.select.is-muted-control { color: var(--text-subtle); border-style: dashed; }

/* Reconciliation matching */
.table tr.is-highlight-soft td { background: var(--warning-bg); }
.table tr.is-highlight-soft:hover td { background: var(--warning-bg); }
.row-expand td { background: var(--surface-alt); padding: 0; }
.match { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px; border-left: 3px solid var(--primary-600); }
.match-list { display: flex; flex-direction: column; gap: 8px; }
.match-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 16px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.match-list .mono { font-variant-numeric: tabular-nums; }
.match-aside { display: flex; gap: 8px; align-items: center; padding-top: 4px; border-top: 1px dashed var(--border); }
.match-aside .input { max-width: 340px; }

@media (max-width: 1024px) {
  .match-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .match-list li form { grid-column: 1 / -1; }
  .match-aside { flex-direction: column; align-items: stretch; }
  .match-aside .input { max-width: none; }
}
