/* The app at /app/. Tokens, fonts and the two themes come from /ui/mivena.css (packages/ui), loaded
   first; this file styles the app's own class names with them. The look is the site's agent
   console at app density: a deep sidebar with an ion bar on the page you are on, hairline panels,
   the white button for the one thing to do, copper for what needs a person, green for done.
   Numbers and ids are set in Geist Mono. Motion: ease-out, short, and off with reduced motion. */
:root {
  --sidebar: 248px;
  font-size: 14.5px;
  line-height: 1.5;
}

[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); letter-spacing: -0.006em; }
h1, h2, h3, p { margin: 0; }
h1, h2 { text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ion); outline-offset: 2px; border-radius: var(--r-xs); }
.muted { color: var(--text-3); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Shell */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 18px;
  padding: 16px 12px 14px; background: var(--bg-deep); box-shadow: inset -1px 0 0 var(--line);
  overflow-y: auto; scrollbar-width: thin; scrollbar-color: transparent transparent; overscroll-behavior: contain;
}
.sidebar:hover, .sidebar:focus-within { scrollbar-color: var(--line-3) transparent; }
.sidebar-panel { display: flex; flex-direction: column; gap: 18px; flex: 1 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 1.28rem; padding: 4px 8px; color: var(--text); }
.brand .mv-mark { width: 22px; height: 22px; }
.sidebar nav { display: grid; gap: 1px; }
.nav-group { display: grid; gap: 1px; margin-top: 12px; }
/* A group whose every page is hidden for this person (Company, for most roles) takes no room. */
.nav-group:not(:has(.nav-item:not([hidden]))) { display: none; }
.nav-heading { padding: 0 10px 4px; font-size: 0.79rem; font-weight: 560; color: var(--text-4); letter-spacing: 0; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 10px; border-radius: 8px;
  color: var(--text-3); font-weight: 500; transition: background-color 150ms ease, color 150ms ease;
}
.nav-item .icon { width: 17px; height: 17px; opacity: 0.85; }
.nav-item[aria-current='page'] { background: var(--tint-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.nav-item[aria-current='page'] .icon { opacity: 1; }
/* The ion bar on the page you are on, as in the site's console. */
.nav-item[aria-current='page']::before { content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 2px; border-radius: 0 2px 2px 0; background: var(--ion); box-shadow: var(--glow-ion); }
.nav-item[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) {
  .nav-item:hover { background: var(--tint); color: var(--text); }
  .nav-item[aria-disabled='true']:hover { background: none; color: var(--text-3); }
}
/* The count of what waits for a person: copper, like everything that needs one. */
.badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--attention-bg); color: var(--attention-ink); box-shadow: inset 0 0 0 1px oklch(0.73 0.155 50 / 0.3); font: 500 0.76rem/1 var(--font-mono); display: grid; place-items: center; }
.nav-toggle { display: none; }

.sidebar-foot { margin-top: auto; display: grid; gap: 12px; padding: 14px 6px 0; box-shadow: 0 -1px 0 var(--line); }
.foot-title { font-size: 0.79rem; font-weight: 560; color: var(--text-4); }
.connections { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.86rem; color: var(--text-2); }
.connections li { display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-4); flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px oklch(0.82 0.13 163 / 0.14); }
.who { display: grid; gap: 4px; font-size: 0.8rem; color: var(--text-3); padding-top: 12px; border-top: 1px solid var(--line); }
.who input { font-size: 0.9rem; color: var(--text); background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r-xs); padding: 7px 9px; }
.who input:focus-visible { outline: none; box-shadow: var(--field-focus); }
.theme-pick { border: 0; margin: 0; padding: 12px 0 0; border-top: 1px solid var(--line); display: grid; gap: 6px; min-width: 0; }
.theme-pick legend { float: left; padding: 0; font-size: 0.8rem; color: var(--text-3); }
.theme-pick legend + * { clear: both; }
.theme-pick .segmented { display: grid; grid-template-columns: 1fr 1fr; justify-self: stretch; }
.theme-pick .seg span { text-align: center; }

/* Main */
.main { padding: 30px 40px 64px; max-width: 1320px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 1.85rem; font-weight: 580; font-stretch: 108%; letter-spacing: -0.04em; line-height: 1.1; }
.page-head .muted { margin-top: 6px; max-width: 72ch; }
.page-head > .btn { flex: none; white-space: nowrap; }

/* Buttons: hairline glass by default, the white (in light: ink) button for the one thing to do. */
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--tint); color: var(--text); font-weight: 540; cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, transform 160ms var(--ease-out), filter 150ms ease;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-primary { background: var(--cta); border-color: transparent; color: var(--on-cta); font-weight: 600; box-shadow: inset 0 -1px 0 oklch(0 0 0 / 0.12), 0 1px 2px oklch(0 0 0 / 0.25); }
:root:not([data-theme='light']) .btn-primary { box-shadow: inset 0 -1px 0 oklch(0 0 0 / 0.12), 0 1px 2px oklch(0 0 0 / 0.3), 0 6px 20px -8px oklch(0.8 0.105 228 / 0.5); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-sm { min-height: 30px; padding: 0 11px; font-size: 0.88rem; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); border: 0; background: transparent; cursor: pointer; color: var(--text-3); transition: background-color 150ms ease, color 150ms ease, transform 160ms var(--ease-out); }
.icon-btn:active { transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { background: var(--tint-2); border-color: var(--line-3); }
  .btn-primary:hover:not(:disabled) { background: var(--cta-hover); border-color: transparent; }
  .btn-ghost:hover:not(:disabled) { background: var(--tint); border-color: transparent; color: var(--text); }
  .icon-btn:hover { background: var(--tint-2); color: var(--text); }
}

/* Today: the figures, then the queue and the latest orders */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { position: relative; background: var(--glass), var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 14px 16px 15px; box-shadow: var(--shadow); }
.stat-label { font-size: 0.84rem; color: var(--text-3); }
.stat-value { font-size: 1.85rem; font-weight: 560; font-stretch: 108%; letter-spacing: -0.04em; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.attention { border-color: oklch(0.73 0.155 50 / 0.3); background: linear-gradient(180deg, oklch(0.73 0.155 50 / 0.08), transparent 70%), var(--surface); }
.stat.attention .stat-value { color: var(--attention); }
.stat.attention .stat-label::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; vertical-align: 1px; background: var(--copper); box-shadow: 0 0 8px oklch(0.73 0.155 50 / 0.8); }

.grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.panel { background: var(--glass), var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); min-height: 56px; }
.panel-head h2 { font-size: 1rem; font-weight: 580; letter-spacing: -0.015em; }

/* Approval queue: one card per thing a person decides */
.queue { list-style: none; margin: 0; padding: 0; }
.queue > li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); }
.queue > li:last-child { border-bottom: 0; }
.q-icon { width: 34px; height: 34px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--attention-bg); color: var(--attention); box-shadow: inset 0 0 0 1px oklch(0.73 0.155 50 / 0.25); }
.q-icon .icon { width: 17px; height: 17px; }
.q-icon.review { background: var(--danger-bg); color: var(--danger); box-shadow: inset 0 0 0 1px oklch(0.72 0.16 25 / 0.28); }
.q-title { font-weight: 580; letter-spacing: -0.01em; }
.q-meta { color: var(--text-3); font-size: 0.88rem; margin-top: 1px; }
.q-lines { margin: 8px 0 10px; padding: 0; list-style: none; font-size: 0.9rem; color: var(--text-2); }
.q-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.q-lines strong { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.q-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* Order card: one approval per order (app.js orderCardItem) */
.card-lines { list-style: none; margin: 8px 0 10px; padding: 0; display: grid; gap: 8px; }
.card-line { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; background: var(--surface-2); }
.card-line.needs { border-color: var(--danger); background: var(--danger-bg); }
.card-line-head { display: flex; justify-content: space-between; gap: 12px; font-size: 0.92rem; }
.card-line-head strong { font-weight: 500; }
.card-why { list-style: none; margin: 4px 0 0; padding: 0; font-size: 0.84rem; color: var(--text-2); }
.card-why li { padding: 1px 0; }
.card-why.warn li { color: var(--attention); }
.card-options { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.card-needs { color: var(--danger); margin-top: 4px; }
.card-docs { list-style: none; margin: 0 0 10px; padding: 0; font-size: 0.86rem; display: grid; gap: 4px; }
.card-edit { margin-top: 8px; display: grid; gap: 8px; }
.card-field { display: flex; gap: 6px; align-items: center; font-size: 0.86rem; flex-wrap: wrap; }
.card-batches { border: 1px dashed var(--border); border-radius: var(--r-sm); padding: 6px 8px; margin: 0; display: grid; gap: 6px; }
.card-batches legend { font-size: 0.84rem; color: var(--text-2); padding: 0 4px; }
.card-batch-row { display: flex; gap: 6px; flex-wrap: wrap; }
.card-box { border-color: var(--attention); }
.queue > li.leaving { opacity: 0; transform: translateX(10px); }

.empty { padding: 36px 18px; text-align: center; color: var(--text-3); }
.empty .icon { width: 28px; height: 28px; color: var(--green); margin-bottom: 8px; }
.empty strong { display: block; color: var(--text); font-weight: 580; margin-bottom: 2px; }

/* Orders table */
.search { display: flex; align-items: center; gap: 8px; background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 0 10px; color: var(--text-4); transition: box-shadow 200ms ease, border-color 150ms ease; }
.search input { border: 0; background: transparent; color: var(--text); min-height: 34px; width: 14rem; outline: none; text-overflow: ellipsis; }
.search input::placeholder { color: var(--text-4); }
.search .icon { width: 16px; height: 16px; }
.search:focus-within { border-color: transparent; box-shadow: var(--field-focus); }
.table-wrap { overflow-x: auto; }
.orders { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.orders th { text-align: left; font-weight: 500; color: var(--text-4); font-size: 0.8rem; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.orders td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.orders td:nth-child(2) { white-space: nowrap; }
.orders tbody tr { cursor: pointer; transition: background-color 120ms ease; }
.orders tbody tr:last-child td { border-bottom: 0; }
@media (hover: hover) and (pointer: fine) { .orders tbody tr:hover { background: var(--tint); } }
/* Order, invoice and quote numbers and amounts in mono, as on the site's console. .o-num is the
   first cell of any table (a name as often as a number), so mono only where it is a number. */
.o-num { font-weight: 580; letter-spacing: -0.01em; }
#orders .o-num, #orders-all .o-num, #invoices .o-num, #quote-rows .o-num, .drawer-head h2 { font-family: var(--font-mono); font-size: 0.92em; font-weight: 500; letter-spacing: 0; }
.drawer-head h2 { font-size: 1.3rem; }
.o-sub { color: var(--text-3); font-size: 0.84rem; }
.orders td.num, .list td.num, .fin-kv dd { font-family: var(--font-mono); font-size: 0.88em; letter-spacing: 0; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 0.79rem; font-weight: 560; white-space: nowrap; background: var(--tint-2); color: var(--text-2); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.attention { background: var(--attention-bg); color: var(--attention-ink); }
.pill.attention::before { background: var(--copper); }
.pill.success { background: var(--success-bg); color: var(--success); }
.pill.danger { background: var(--danger-bg); color: var(--danger-ink); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.info::before { background: var(--ion); }

.progress { display: flex; gap: 3px; min-width: 84px; }
.progress span { flex: 1; height: 5px; border-radius: 3px; background: var(--tint-2); }
.progress span.on { background: var(--green); }
.progress span.now { background: var(--copper); box-shadow: 0 0 8px oklch(0.73 0.155 50 / 0.6); }
.progress-label { font-size: 0.8rem; color: var(--text-3); margin-top: 4px; }

/* Drawer */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; transition: opacity 200ms ease; }
@starting-style { .scrim { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; height: 100dvh; width: min(580px, 100vw); z-index: 30; transform: translateX(100%); visibility: hidden; transition: transform 220ms var(--ease-out), visibility 0s 220ms; }
.drawer.open { transform: none; visibility: visible; transition: transform 300ms var(--ease-drawer); }
.drawer-inner { height: 100%; background: var(--glass), var(--surface); box-shadow: inset 1px 0 0 var(--line-2), var(--shadow-lg); display: flex; flex-direction: column; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 22px 12px; }
.drawer-head h2 { font-size: 1.4rem; font-weight: 580; font-stretch: 106%; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; white-space: nowrap; border: 0; background: none; padding: 10px 8px; cursor: pointer; color: var(--text-3); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 150ms ease, border-color 150ms ease; }
.tabs button[aria-selected='true'] { color: var(--text); border-bottom-color: var(--ion); }
@media (hover: hover) and (pointer: fine) { .tabs button:hover, .tabs a:hover { color: var(--text); } }
.drawer-body { padding: 18px 22px 28px; overflow-y: auto; overscroll-behavior: contain; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin: 0 0 18px; }
.facts dt { font-size: 0.8rem; color: var(--text-3); }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.list { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.list th { text-align: left; color: var(--text-4); font-weight: 500; font-size: 0.8rem; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list td { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .num, .orders .num { text-align: right; }
.orders td.num, .orders td.nowrap { white-space: nowrap; }
.doc { border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 10px; background: var(--tint); }
.doc-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ''; position: absolute; left: 5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--ion); box-shadow: 0 0 0 3px oklch(0.8 0.105 228 / 0.14); }
.timeline li::after { content: ''; position: absolute; left: 8px; top: 19px; bottom: 0; width: 2px; background: var(--line-2); }
.timeline li:last-child::after { display: none; }
.timeline time { display: block; font: 400 0.78rem/1.6 var(--font-mono); color: var(--text-4); }

/* Dialog */
dialog { border: 0; border-radius: var(--r-xl); padding: 24px; width: min(620px, calc(100vw - 32px)); background: var(--glass), var(--surface); color: var(--text); box-shadow: var(--edge), var(--shadow-lg); }
dialog[open] { opacity: 1; transform: none; transition: opacity 180ms ease, transform 220ms var(--ease-out); }
@starting-style { dialog[open] { opacity: 0; transform: translateY(6px) scale(0.98); } }
dialog::backdrop { background: var(--scrim); }
dialog h2 { font-size: 1.25rem; font-weight: 580; letter-spacing: -0.025em; margin-bottom: 4px; }
.field-label { display: block; font-size: 0.86rem; font-weight: 540; color: var(--text-2); margin: 16px 0 6px; }
dialog textarea { width: 100%; font: 0.84rem/1.45 var(--font-mono); color: var(--text); background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 10px; resize: vertical; }
dialog textarea:focus-visible { outline: none; border-color: transparent; box-shadow: var(--field-focus); }
.field-error { color: var(--danger-ink); font-size: 0.88rem; min-height: 1.3em; margin-top: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* Toasts */
.toasts { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 40; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--surface-3); color: var(--text); padding: 10px 14px; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line-3), var(--shadow-lg); font-size: 0.92rem; transition: opacity 200ms ease, transform 240ms var(--ease-out); }
@starting-style { .toast { opacity: 0; transform: translateY(8px); } }
.toast .icon { color: var(--green); }
.toast.toast-warn .icon { color: var(--copper); }

/* Views, toolbar, chips */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 0; background: var(--tint); box-shadow: inset 0 0 0 1px var(--line-2); border-radius: 999px; padding: 5px 12px; font-size: 0.88rem; font-weight: 500; cursor: pointer; color: var(--text-2); transition: background-color 150ms ease, box-shadow 150ms ease, color 150ms ease, transform 160ms var(--ease-out); }
.chip:active { transform: scale(0.97); }
.chip[aria-pressed='true'] { background: oklch(0.8 0.105 228 / 0.14); color: var(--text); box-shadow: inset 0 0 0 1.5px oklch(0.8 0.105 228 / 0.75); }
:root[data-theme='light'] .chip[aria-pressed='true'] { background: oklch(0.5 0.12 240 / 0.1); box-shadow: inset 0 0 0 1.5px oklch(0.5 0.12 240 / 0.7); }
@media (hover: hover) and (pointer: fine) { .chip:hover { color: var(--text); } }
.tag { display: inline-block; font-size: 0.78rem; padding: 1px 7px; border-radius: var(--r-xs); background: var(--tint-2); border: 1px solid var(--line); color: var(--text-2); margin: 0 4px 2px 0; }

/* Import */
.tabs-inline { padding: 0; margin: 14px 0 4px; }
.drop-zone { display: grid; justify-items: center; gap: 4px; padding: 28px 16px; margin-top: 12px; border: 1.5px dashed var(--line-3); border-radius: var(--r-md); background: var(--tint); cursor: pointer; text-align: center; transition: border-color 150ms ease, background-color 150ms ease; }
.drop-zone:hover, .drop-zone.over { border-color: var(--ion); background: var(--info-bg); }
.drop-zone .icon { width: 24px; height: 24px; color: var(--ion); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
dialog textarea.mono, #edi { font-family: var(--font-mono); }
dialog textarea { font-family: inherit; font-size: 0.92rem; }
.field-note { font-size: 0.88rem; color: var(--attention-ink); background: var(--attention-bg); box-shadow: inset 0 0 0 1px oklch(0.73 0.155 50 / 0.22); padding: 8px 11px; border-radius: var(--r-sm); margin-top: 10px; }

/* Review */
.notes { list-style: none; margin: 0 0 16px; padding: 12px 14px; border-radius: var(--r-md); background: var(--attention-bg); box-shadow: inset 0 0 0 1px oklch(0.73 0.155 50 / 0.22); color: var(--text); font-size: 0.92rem; display: grid; gap: 4px; }
.notes li::before { content: '•'; color: var(--copper); margin-right: 8px; }
.review-select { font-size: 0.9rem; color: var(--text); background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r-xs); padding: 5px 8px; max-width: 100%; margin-top: 6px; }
.review-unit { font-size: 0.9rem; color: var(--text); background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r-xs); padding: 3px 6px; width: 5.5em; margin-left: 4px; text-transform: uppercase; }
.review-actions { display: flex; gap: 12px; margin-top: 16px; align-items: center; }
.review-actions .btn { white-space: nowrap; }

/* Queue reason */
.q-why { display: flex; gap: 6px; align-items: flex-start; font-size: 0.84rem; color: var(--text-3); margin: -2px 0 10px; }
.q-why .icon { width: 15px; height: 15px; margin-top: 2px; }

/* Stock reports and price lists: one row per article change, its concern and "apply anyway" under it */
.q-lines li.q-change { flex-wrap: wrap; }
.q-lines li.q-change strong { text-align: right; }
.q-lines li.q-change .q-why, .q-include, .q-sub { flex-basis: 100%; margin: 2px 0 4px; }
.q-sub { font-size: 0.84rem; color: var(--text-3); margin-top: -2px; }
.q-include { display: flex; gap: 6px; align-items: center; font-size: 0.84rem; color: var(--text-2); cursor: pointer; }
.q-more { margin: -4px 0 10px; font-size: 0.9rem; }
.q-more > summary { cursor: pointer; color: var(--text-2); }
.q-more > .q-lines { margin-top: 4px; }

/* Rules */
.rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.rule-body { padding: 18px 20px; display: grid; gap: 10px; }
.rule h2, .rule-body h2 { font-size: 1.05rem; font-weight: 580; letter-spacing: -0.015em; }
.segmented { display: inline-flex; background: var(--field); box-shadow: inset 0 0 0 1px var(--line-2); border-radius: var(--r-md); padding: 3px; gap: 2px; justify-self: start; flex-wrap: wrap; }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.seg span { display: block; padding: 6px 12px; border-radius: 7px; font-size: 0.9rem; font-weight: 500; color: var(--text-3); transition: background-color 150ms ease, color 150ms ease; }
.seg input:checked + span { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2), inset 0 1px 0 oklch(1 0 0 / 0.06); }
:root[data-theme='light'] .seg input:checked + span { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 2px oklch(0.2 0.02 262 / 0.08); }
.seg input:focus-visible + span { outline: 2px solid var(--ion); outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) { .seg input:not(:checked):hover + span { color: var(--text); } }
.rule-help { font-size: 0.88rem; color: var(--text-2); }
.limit { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text-2); }
.limit input, .input { font-size: 0.92rem; color: var(--text); background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 7px 10px; transition: box-shadow 200ms ease, border-color 150ms ease; }
.limit input:focus-visible, .input:focus-visible, .review-select:focus-visible, .review-unit:focus-visible, .qty:focus-visible { outline: none; border-color: transparent; box-shadow: var(--field-focus); }
.input::placeholder { color: var(--text-4); }
.limit input { width: 7rem; }
.input { width: 100%; }
select.input, .review-select, .lang-select { cursor: pointer; }
.routing-list { list-style: none; margin: 0; padding: 6px 18px 12px; }
.routing-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--text-2); }
.routing-list li:last-child { border-bottom: 0; }
.routing-list .icon { margin-top: 2px; color: var(--text-3); }
.routing-list strong { color: var(--text); font-weight: 580; }

/* Partner form */
.roles { border: 0; padding: 0; margin: 0; display: flex; gap: 16px; flex-wrap: wrap; }
.roles legend { padding: 0; }
.roles label { display: flex; align-items: center; gap: 6px; font-size: 0.92rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.three { grid-template-columns: 1fr 2fr 0.8fr; }
input[type='checkbox'], input[type='radio'] { accent-color: var(--ion); }
input[type='file'] { color: var(--text-3); font-size: 0.88rem; }
input[type='file']::file-selector-button { margin-right: 10px; padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--tint-2); color: var(--text); font: inherit; font-weight: 540; cursor: pointer; }

/* Ship */
.sub { font-size: 1rem; font-weight: 580; letter-spacing: -0.015em; margin: 18px 0 4px; }
.drawer-body textarea { width: 100%; margin-top: 10px; padding: 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--field); color: var(--text); font: 0.84rem/1.45 var(--font-mono); }
.list th, .list td { padding-right: 10px; }
.list th:last-child, .list td:last-child { padding-right: 0; }
.list td:first-child { font-variant-numeric: tabular-nums; font-size: 0.86rem; }
.qty { width: 4.2rem; text-align: right; padding: 4px 6px; border: 1px solid var(--line-2); border-radius: var(--r-xs); background: var(--field); color: var(--text); font-family: var(--font-mono); font-size: 0.88rem; }
label.btn { cursor: pointer; }

/* Connections */
.systems { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.system { background: var(--glass), var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 14px 16px; display: grid; gap: 4px; align-content: start; box-shadow: var(--shadow); }
.system-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.system-caps { font-size: 0.82rem; color: var(--text-3); margin: 4px 0 8px; }
.conn-actions { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 0.9rem; }
.system .btn { justify-self: start; }

/* Planning */
.plan td.why { max-width: 34rem; font-size: 0.88rem; color: var(--text-2); }
.plan td.why details { margin-top: 4px; }
.plan td.why summary { cursor: pointer; color: var(--ion); font-weight: 500; }
.plan td.why details p { margin-top: 4px; }
.plan .warn { color: var(--attention); }
.plan tbody tr { cursor: default; }

/* Sign-in: the card on the site's signal field (a dot grid under an ion glow). */
.auth-screen {
  position: relative; isolation: isolate; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1100px 620px at 50% -12%, oklch(0.34 0.07 252 / 0.42), transparent 68%), radial-gradient(700px 480px at 85% 95%, oklch(0.73 0.155 50 / 0.06), transparent 70%), var(--bg);
}
.auth-screen::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, oklch(1 0 0 / 0.1) 1px, transparent 1.5px); background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(90% 60% at 50% 20%, #000 20%, transparent 75%); mask-image: radial-gradient(90% 60% at 50% 20%, #000 20%, transparent 75%);
}
:root[data-theme='light'] .auth-screen { background: radial-gradient(1100px 620px at 50% -12%, oklch(0.8 0.08 235 / 0.35), transparent 68%), var(--bg); }
:root[data-theme='light'] .auth-screen::before { background-image: radial-gradient(circle at 1px 1px, oklch(0.25 0.02 262 / 0.12) 1px, transparent 1.5px); }
.auth-card { width: min(410px, 100%); background: var(--glass), var(--surface); border-radius: var(--r-xl); box-shadow: var(--edge), var(--shadow-lg); padding: 30px 30px 26px; display: grid; }
.auth-card .brand { padding: 0; font-size: 1.4rem; }
.auth-card .brand .mv-mark { width: 26px; height: 26px; }
.auth-card h1 { font-size: 1.6rem; font-weight: 580; font-stretch: 108%; letter-spacing: -0.04em; line-height: 1.15; }
.auth-card h1 + .muted { margin-top: 4px; }
.auth-card .input { min-height: 40px; }
.auth-card code { display: inline-block; padding: 6px 8px; border-radius: var(--r-xs); background: var(--field); box-shadow: inset 0 0 0 1px var(--line-2); overflow-wrap: anywhere; }
.auth-submit { margin-top: 12px; justify-content: center; min-height: 42px; }
/* Two-step sign-in: the key, the link to the authenticator app, then the code. */
#auth-totp-setup { display: grid; gap: 8px; justify-items: start; }
#auth-totp-setup .field-label { margin: 8px 0 0; }
#auth-totp-setup .field-note { margin-top: 12px; justify-self: stretch; }
/* The QR code of the key: always dark on white with its own quiet zone, whatever the theme. */
#auth-totp-setup .totp-qr { margin: 4px 0 0; display: grid; gap: 6px; justify-items: start; }
#auth-totp-qr { display: block; width: 184px; height: 184px; background: #fff; border-radius: var(--r-xs); box-shadow: inset 0 0 0 1px var(--line-2); }
#a-totp, #a-setup-token { font-family: var(--font-mono); }
#who-user { display: grid; gap: 4px; }
#who-user strong { color: var(--text); font-weight: 540; overflow-wrap: anywhere; }
#who-user .btn { justify-self: start; padding: 0; min-height: auto; }
.shell[hidden] { display: none; }

/* Language picker */
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.brand-row .brand { white-space: nowrap; min-width: 0; }
.lang-select { font-size: 0.8rem; color: var(--text-3); background: var(--tint); border: 1px solid var(--line-2); border-radius: var(--r-xs); padding: 4px 6px; max-width: 7.5rem; }
.lang-select:focus-visible { outline: none; box-shadow: var(--field-focus); }
.auth-card .brand-row { margin-bottom: 22px; }
.auth-card .brand-row .brand { margin-bottom: 0; }

/* Responsive */
@media (max-width: 1100px) {
  .grid, .rules-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Phone: the sidebar is a top bar; the menu opens as a sheet under it (shell.js). */
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .sidebar {
    position: sticky; top: 0; z-index: 25; height: auto; overflow: visible; gap: 0;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px; background: transparent; box-shadow: 0 1px 0 var(--line);
  }
  /* The frosted bar is a layer of its own: a backdrop-filter on .sidebar itself would make it the
     containing block of the fixed menu sheet and clip it to the bar. */
  .sidebar::before { content: ''; position: absolute; inset: 0; z-index: -1; background: oklch(0.12 0.011 262 / 0.82); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%); }
  :root[data-theme='light'] .sidebar::before { background: oklch(0.955 0.006 255 / 0.85); }
  .sidebar .brand-row { width: 100%; gap: 8px; }
  .sidebar .brand-row .brand { margin-right: auto; padding-left: 0; }
  .nav-toggle { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text); cursor: pointer; transition: background-color 150ms ease, transform 160ms var(--ease-out); }
  .nav-toggle:active { transform: scale(0.94); }
  .nav-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
  .nav-toggle path { transition: transform 200ms var(--ease-out); transform-origin: 12px 12px; }
  .sidebar.open .nav-toggle { background: var(--tint-2); }
  .sidebar-panel { display: none; }
  .sidebar.open .sidebar-panel {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; top: calc(56px + env(safe-area-inset-top)); z-index: 24;
    overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); background: var(--bg-deep);
    box-shadow: 0 -1px 0 var(--line); opacity: 1; transform: none; transition: opacity 180ms ease, transform 220ms var(--ease-out);
  }
  @starting-style { .sidebar.open .sidebar-panel { opacity: 0; transform: translateY(-8px); } }
  .sidebar.open .sidebar-panel .nav-item { min-height: 44px; font-size: 1rem; }
  .nav-item[aria-current='page']::before { left: -16px; }
  .sidebar-foot { display: grid; }
  body.nav-open { overflow: hidden; }
  .main { padding: 20px 16px 48px; }
  .page-head { align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
  .page-head h1 { font-size: 1.55rem; }
  .panel-head { padding: 12px 14px; }
  .panel-head .btn { white-space: nowrap; }
  .search input { width: 8rem; }
  .orders th:nth-child(2), .orders td:nth-child(2) { display: none; }
  .stats { gap: 10px; }
  .stat-value { font-size: 1.5rem; }
  .drawer-head { padding: calc(16px + env(safe-area-inset-top)) 16px 10px; }
  .drawer-body { padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); }
  dialog { padding: 20px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Order confirmation editor and carrier booking */
.doc input[type="date"], .confirm-fields input { font: inherit; padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--text); }
.confirm-fields { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 10px 0; font-size: 0.9rem; }
.confirm-fields label { display: flex; align-items: center; gap: 8px; }
.confirm-fields input[type="text"] { min-width: 14rem; }
.booking { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; display: grid; gap: 4px; }
.booking .pill { margin-left: 6px; }
.weights { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 0.86rem; margin: 4px 0; }
.weight { display: flex; align-items: center; gap: 6px; font-family: var(--mono, ui-monospace, monospace); }
.doc-invoice { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; font-weight: 500; }
/* A pallet we label ourselves */
.own-pallet { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px; margin: 0 0 14px; display: grid; gap: 6px; }
.own-pallet h4 { margin: 0; font-size: 0.95rem; }
.own-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
.own-grid .own-wide { grid-column: 1 / -1; }
.own-grid .field-label { margin: 8px 0 4px; }
.own-grid .input, .own-grid .review-select { width: 100%; margin-top: 0; }
@media (max-width: 560px) { .own-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Team: members and invites */
.team-body { display: grid; gap: 16px; }
.team-body > .panel { margin: 0; }
.invite-link { border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); padding: 12px 14px; margin-top: 14px; display: grid; gap: 6px; }
.invite-copy { display: flex; gap: 8px; align-items: center; }
.invite-copy .input { flex: 1 1 auto; min-width: 0; }
@media (max-width: 560px) { .team-invite .field-row { grid-template-columns: minmax(0, 1fr); } }
/* Unit names with the unit code (DFP, PCE, ...) as a tooltip */
abbr.unit { text-decoration: none; cursor: help; }

/* Set up: choose files, review, confirm */
.steps { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-weight: 500; }
.step-no { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 0.84rem; border: 1.5px solid var(--border); background: var(--surface); }
.steps li[aria-current='step'] { color: var(--text); }
.steps li[aria-current='step'] .step-no { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.steps li.done .step-no { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.setup-body { display: grid; gap: 16px; }
.setup-body > .panel { margin: 0; }
.setup-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 14px 18px 16px; margin: 0; }
.setup-current .panel-head { flex-wrap: wrap; row-gap: 2px; padding-top: 10px; padding-bottom: 10px; }
.setup-current .panel-head h2 { white-space: nowrap; }
.setup-current .panel-head p { font-size: 0.86rem; }
.setup-facts dd { font-size: 1.25rem; font-weight: 600; }
.setup-kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.setup-kind { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px 18px; display: grid; gap: 6px; align-content: start; }
.setup-kind h2 { font-size: 1rem; font-weight: 600; }
.setup-kind .drop-zone { margin-top: 6px; padding: 18px 12px; }
.setup-files { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.setup-file { border: 1px solid var(--border); border-radius: var(--r-md); padding: 6px 6px 6px 10px; display: grid; gap: 4px; }
.setup-file-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.setup-file-name { font-weight: 500; overflow-wrap: anywhere; flex: 1; min-width: 0; }
.setup-roles { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 0.86rem; color: var(--text-2); padding-bottom: 4px; }
.setup-roles .review-select { margin-top: 0; }
.nowrap { white-space: nowrap; }
.setup-mode { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.setup-mode legend { padding: 0; margin-top: 0; }
.setup-choice { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; cursor: pointer; }
.setup-choice:has(input:checked) { border-color: var(--primary); background: var(--info-bg); }
.setup-choice input { margin-top: 4px; accent-color: var(--primary); }
.setup-choice > span { display: grid; gap: 2px; }
.setup-choice .muted { font-size: 0.88rem; }
.setup-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.setup-actions > p { margin-right: auto; }
.setup-actions.center { justify-content: center; margin-top: 16px; }
.setup-verdict { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); }
.setup-verdict .icon { width: 22px; height: 22px; margin-top: 1px; }
.setup-verdict p { color: var(--text-2); font-size: 0.92rem; margin-top: 2px; }
.setup-verdict.danger { background: var(--danger-bg); }
.setup-verdict.danger .icon { color: var(--danger); }
.setup-verdict.success { background: var(--success-bg); }
.setup-verdict.success .icon { color: var(--success); }
.setup-issues .panel-head { min-height: 52px; }
.setup-issues h2 { display: flex; align-items: center; gap: 8px; }
details.setup-issues > summary { cursor: pointer; list-style: none; }
details.setup-issues > summary::-webkit-details-marker { display: none; }
details.setup-issues:not([open]) > summary { border-bottom: 0; }
.issue-list { list-style: none; margin: 0; padding: 4px 18px 10px; }
.issue-list li { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.issue-list li:last-child { border-bottom: 0; }
.pill.neutral { background: var(--surface-2); color: var(--text-3); }
.setup-columns { display: grid; gap: 10px; }
.setup-columns .sub { margin: 4px 0 0; }
.setup-table tbody tr { cursor: default; }
.setup-table td { padding: 8px 14px; }
.setup-table td .pill { margin-top: 3px; }
.setup-table td:first-child { overflow-wrap: anywhere; }
.setup-table .review-select { margin-top: 0; min-width: 12rem; }
.orders.setup-table td:nth-child(2) { white-space: normal; }
.diff-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.diff-block { padding: 14px 18px; border-bottom: 1px solid var(--border); display: grid; gap: 6px; align-content: start; }
.diff-block:nth-child(odd) { border-right: 1px solid var(--border); }
.diff-block h3 { font-size: 0.92rem; font-weight: 600; }
.diff-tags .tag { font-size: 0.84rem; padding: 2px 8px; }
.diff-block summary { cursor: pointer; color: var(--primary); font-weight: 500; font-size: 0.9rem; }
.diff-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 0.9rem; max-height: 22rem; overflow-y: auto; }
.setup-confirm .facts { margin: 6px 0 4px; }
.setup-confirm textarea { resize: vertical; font: inherit; }
.setup-done .empty p { margin-bottom: 8px; }
.setup-done .setup-facts { max-width: 560px; margin: 8px auto 0; text-align: left; }
@media (max-width: 760px) {
  .setup-kinds, .setup-mode, .diff-grid { grid-template-columns: minmax(0, 1fr); }
  .diff-block:nth-child(odd) { border-right: 0; }
  .setup-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup-table .review-select { min-width: 9rem; }
  .orders.setup-table th:nth-child(2), .orders.setup-table td:nth-child(2) { display: table-cell; }
  .setup-actions { justify-content: stretch; }
  .setup-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* The chains a company delivers to: a tick per chain, its checklist under it. */
#chain-list li { display: grid; gap: 8px; }
.chain-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-left: 26px; }

/* Finance: ask the agent, tabs, panels of drafts, tables with sums, VAT boxes, settings forms */
.fin-ask { margin-bottom: 16px; }
.fin-ask-row { display: flex; gap: 8px; align-items: center; }
.fin-ask-input { flex: 1 1 auto; min-width: 0; }
.fin-ask-input input { width: 100%; }
.fin-answer { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); padding: 12px 14px; display: grid; gap: 8px; }
.fin-tabs { margin: 0 0 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; gap: 2px; }
.fin-tabs a { padding-inline: 7px; }
.tabs a { padding: 10px 8px; color: var(--text-3); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a { transition: color 150ms ease, border-color 150ms ease; }
.tabs a[aria-current='page'] { color: var(--text); border-bottom-color: var(--ion); }
.fin-body { display: grid; gap: 16px; }
.fin-body > .panel, .fin-grid > .panel { margin: 0; }
.fin-body .panel-head { flex-wrap: wrap; row-gap: 8px; }
.fin-body .panel-head > div { flex: 1 1 16rem; min-width: 0; }
.fin-body .panel-head .btn, .fin-body .panel-head .pill { flex: none; white-space: nowrap; }
.fin-body[aria-busy='true'] { opacity: 0.6; transition: opacity 150ms; }
.fin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.fin-grid-flat { gap: 0; border-top: 1px solid var(--border); }
.fin-grid-flat > * + * { border-left: 1px solid var(--border); }
.fin-docs { padding: 14px 18px 4px; }
.fin-reason { font-size: 0.92rem; color: var(--text-2); margin: 6px 0 8px; }
.fin-notes { margin: 8px 0; }
.fin-flag { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; font-size: 0.9rem; }
.fin-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 12px 18px; }
.fin-body .rule-body .fin-filter { padding: 0; }
.fin-field { display: grid; }
.fin-field .field-label { margin: 0 0 4px; }
.fin-field .input { min-width: 10rem; }
.fin-table tbody tr { cursor: default; }
.fin-table td:nth-child(2) { white-space: normal; }
.fin-table tfoot td, .fin-table tr.fin-sum td { font-weight: 600; border-top: 1px solid var(--border); }
.fin-table tr.strong td { font-weight: 600; }
.fin-statement tr.fin-heading td { font-weight: 600; color: var(--text-2); background: var(--surface-2); padding-top: 8px; padding-bottom: 8px; }
.fin-statement td.lvl3 { padding-left: 30px; }
.fin-rows { margin: 8px 0 10px; }
.fin-body .list td.num, .fin-body .list th.num { white-space: nowrap; }
.fin-sub { margin: 14px 18px 4px; }
.fin-late { color: var(--attention); }
.fin-boxes { list-style: none; margin: 0; padding: 4px 18px; }
.fin-box { border-bottom: 1px solid var(--border); }
.fin-box:last-child { border-bottom: 0; }
.fin-box-head { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 9px 0; font-size: 0.92rem; }
.fin-box details > summary { cursor: pointer; list-style: none; }
.fin-box details > summary::-webkit-details-marker { display: none; }
.fin-box details > summary .fin-box-no { color: var(--primary); }
.fin-box details[open] > summary { border-bottom: 1px dashed var(--border); }
.fin-box-no { font-weight: 600; color: var(--text-3); }
.fin-box.strong .fin-box-head { font-weight: 600; }
.fin-notice { margin: 12px 18px 0; }
.fin-payments { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.fin-payment { border-top: 1px solid var(--border); padding-top: 10px; }
.fin-picker { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); display: grid; gap: 8px; }
.fin-pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 16rem; overflow-y: auto; }
.fin-year { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; }
.fin-toolbar { margin-bottom: 0; align-items: flex-end; }
.fin-stats { margin: 12px 0 0; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fin-placeholders { margin: 0 0 12px; padding-left: 20px; font-size: 0.9rem; color: var(--text-2); display: grid; gap: 4px; }
.fin-inline { display: flex; gap: 4px; align-items: center; }
.fin-label-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.fin-label-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fin-label-row .input { width: auto; min-width: 9rem; flex: 1 1 9rem; }
.fin-body textarea.input { resize: vertical; font: inherit; }
@media (max-width: 1100px) {
  .fin-grid { grid-template-columns: minmax(0, 1fr); }
  .fin-grid-flat > * + * { border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 760px) {
  .fin-ask-row { flex-wrap: wrap; }
  .fin-ask-row .btn { flex: 1 1 auto; justify-content: center; }
  .fin-stats { grid-template-columns: minmax(0, 1fr); }
  .fin-body .field-row, .fin-body .field-row.three { grid-template-columns: minmax(0, 1fr); }
  .fin-table th:nth-child(2), .fin-table td:nth-child(2) { display: table-cell; }
  .fin-field .input { min-width: 0; }
}

/* Switch to Mivena: the cancellation checklist */
.sw-cancels { list-style: none; margin: 0; padding: 0 18px 12px; }
.sw-cancel { padding: 12px 0; border-bottom: 1px solid var(--border); }
.sw-cancel:last-child { border-bottom: 0; }
.sw-cancel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.sw-cancel-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 12px; }
.sw-field { display: flex; flex-direction: column; gap: 4px; }
.sw-cancel .notes { margin-top: 8px; }
.sw-dates { display: grid; gap: 6px; max-width: 420px; }
/* Kundportal (the tenant's side of the customer portal) */
.tag.tag-portal { background: var(--info-bg); color: var(--primary); border-color: transparent; }
.pa-check { display: inline-flex; align-items: center; gap: 6px; margin: 4px 14px 4px 0; cursor: pointer; }
.pa-weekdays { border: 0; padding: 0; margin: 0; }
.pa-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.pa-group .input { flex: 1 1 220px; min-width: 0; }
.pa-num { width: 6.5em; }
.pa-articles td.num, .pa-articles th.num { text-align: center; }
@media (max-width: 560px) { .pa-fields { grid-template-columns: minmax(0, 1fr); } }
/* Receipts, expense claims and the accounting firm (expenses.js). The capture button is large and
   first on a phone: it opens the camera straight away. */
.exp-body { display: grid; gap: 16px; }
.exp-capture-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 16px 18px 4px; }
.exp-camera { min-height: 48px; padding-inline: 20px; font-size: 1rem; }
.exp-archive { padding: 4px 18px 16px; }
.exp-form { padding: 4px 0 0; }
.exp-body .panel > .exp-form { padding: 12px 18px 16px; }
.exp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 10px; }
.exp-grid .field-label { margin-top: 8px; }
.exp-vat .input { max-width: 9rem; }
.exp-reason { max-width: 16rem; }
.exp-thread { margin-top: 10px; }
.exp-thread > summary { cursor: pointer; color: var(--text-3); font-size: 0.86rem; }
.exp-entries { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.exp-entries p { margin: 0; }
@media (max-width: 640px) {
  .exp-camera { width: 100%; justify-content: center; }
  .exp-grid { grid-template-columns: minmax(0, 1fr); }
  .exp-vat .input, .exp-reason { max-width: none; }
}
/* Sales: price lists, quotes, credit on the partner page */
.sales-panel { margin-top: 16px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
table.compact td, table.compact th { padding: 6px 8px; }
table.compact .input { min-width: 5rem; }
.price-customers { border: 0; padding: 0; margin: 0; }
.price-customers .check { display: inline-flex; align-items: center; gap: 6px; margin: 4px 14px 4px 0; font-size: 0.9rem; }
.credit-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 14px 0; }
.credit-facts dt { color: var(--text-3); }
.credit-facts dd { margin: 0; }
.quote-mail { margin-top: 12px; }
@media (max-width: 560px) { .credit-facts { grid-template-columns: minmax(0, 1fr); } }
/* Closing (bokslut): the add forms fold away, the tax calculation reads as label and amount. */
.fin-details { padding: 0 18px 12px; }
.fin-details > summary { cursor: pointer; padding: 8px 0; font-weight: 600; }
.fin-details .fin-filter { padding: 8px 0; }
.fin-kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 18px; margin: 0; }
.fin-kv dt { margin: 0; }
.fin-body .panel > .rule-help, .fin-body .panel > .o-sub, .fin-body .panel > .muted { padding: 0 18px; }
.fin-kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* Bank lines to book and the tax account (Finance, Bankhändelser) */
.fin-account { width: 7.5rem; flex: 0 0 auto; }
.fin-handled { margin-top: 12px; }
.fin-handled > summary { cursor: pointer; color: var(--text-2); font-size: 0.92rem; padding: 6px 0; }
.fin-payment .q-actions { flex-wrap: wrap; }
.fin-payment .q-actions select.input { width: auto; flex: 0 0 auto; }

/* Likviditet (Finance): the cash-flow chart. Three scenario colours in a fixed order (validated for
   colour vision deficiency, light and dark stepped separately) plus a line style each, so colour is
   never the only cue; the threshold in the critical status colour; a hairline grid. */
.cf-chart {
  --cf-1: #2a78d6; --cf-2: #eb6834; --cf-3: #1baf7a; --cf-crit: #d03b3b;
  --cf-grid: var(--line-2); --cf-ink: var(--text-3);
  margin: 12px 0;
}
/* Dark is the default theme, so the dark steps apply unless light is chosen. */
:root:not([data-theme='light']) .cf-chart { --cf-1: #3987e5; --cf-2: #d95926; --cf-3: #199e70; --cf-crit: #e66767; }
.cf-plot { position: relative; }
.cf-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.cf-grid { stroke: var(--cf-grid); stroke-width: 1; shape-rendering: crispEdges; }
.cf-zero { stroke: var(--text-3); }
.cf-axis, .cf-label { fill: var(--cf-ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.cf-label { fill: var(--text-2); }
.cf-line, .cf-key { fill: none; stroke-width: 2; stroke-linejoin: round; }
.cf-s1 { stroke: var(--cf-1); }
.cf-s2 { stroke: var(--cf-2); stroke-dasharray: 6 4; }
.cf-s3 { stroke: var(--cf-3); stroke-dasharray: 2 3 8 3; }
.cf-threshold { stroke: var(--cf-crit); stroke-width: 1.5; }
.cf-cross { stroke: var(--text-3); stroke-width: 1; }
.cf-hit { fill: transparent; pointer-events: all; }
.cf-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; margin: 0 0 8px; padding: 0; font-size: 0.86rem; color: var(--text-2); }
.cf-legend li { display: inline-flex; align-items: center; gap: 6px; }
.cf-tip { position: absolute; top: 8px; display: grid; gap: 2px; min-width: 180px; max-width: 220px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: var(--shadow-lg); font-size: 0.84rem; pointer-events: none; }
.cf-dot { display: inline-block; width: 10px; height: 2px; margin-right: 6px; vertical-align: middle; background: var(--cf-1); }
.cf-dot.cf-s2 { background: var(--cf-2); }
.cf-dot.cf-s3 { background: var(--cf-3); }
.cf-lows { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.cf-below td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.cf-item-list { list-style: none; margin: 0; padding: 4px 0; display: grid; gap: 6px; }
.cf-item-list li { display: grid; grid-template-columns: 7rem 12rem 8rem minmax(0, 1fr); gap: 4px 12px; align-items: baseline; }
.cf-recurring { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.cf-amount { width: 8rem; flex: 0 0 auto; }
.cf-trend-label { padding: 12px 18px 4px; }
@media (max-width: 640px) {
  .cf-item-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .cf-item-list .o-sub { grid-column: 1 / -1; }
}
.cf-toggle { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.fin-table [data-cf="items"] { white-space: nowrap; }
/* Returns and back-orders (returns.js) */
.today-backorders { margin-top: 18px; }
.order-extras { margin-top: 14px; display: grid; gap: 10px; }
#returns-root { display: grid; gap: 18px; }
#returns-root .field-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }

/* The agent's learning (learning.js): the page's panels, Flagga fel in the order panel, the autopilot switch on Rules */
#learning-root { display: grid; gap: 16px; }
.learning-body { padding: 14px 18px; display: grid; gap: 10px; }
.learning-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
#autopilot-panel:not(:empty) { margin-bottom: 16px; }
.order-extras details.doc > summary { cursor: pointer; }
/* Sign-in extras and the first steps of a new workspace (welcome.js) */
.auth-link { justify-self: center; margin-top: 8px; }
.welcome-step h2 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; font-weight: 600; margin: 0; }
.welcome-step.done h2 .icon { color: var(--success); }
.welcome-step .setup-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.welcome-warehouse { border: 0; padding: 0; margin: 12px 0 0; }
.welcome-warehouse legend { padding: 0; margin-bottom: 8px; }
.welcome-warehouse-steps { margin-top: 12px; }
.welcome-mail { width: 100%; font: inherit; white-space: pre-wrap; resize: vertical; }
.welcome-invite .input[type="email"] { flex: 1 1 16rem; min-width: 0; }
.welcome-invite .input { width: auto; }
.welcome-invite-title { font-size: 0.95rem; font-weight: 600; margin: 16px 0 8px; }
.welcome-invites { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.welcome-invites li { overflow-wrap: anywhere; }
.welcome-invites .setup-actions { margin-top: 6px; }
.welcome-manual { margin-top: 16px; }
.welcome-manual summary { cursor: pointer; font-weight: 600; }
.welcome-invite + .muted { margin-top: 8px; }
.welcome-invite-detail { font-size: 0.82rem; margin: 4px 0 0; }
/* First steps: dark or light, chosen from two small pictures of the app. The pictures keep their
   own colours whatever the theme is, so each shows what it will look like. */
.theme-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 12rem)); gap: 12px; margin-top: 4px; }
.theme-card { position: relative; display: grid; gap: 8px; padding: 8px 8px 10px; border-radius: var(--r-lg); background: var(--tint); box-shadow: inset 0 0 0 1px var(--line-2); cursor: pointer; transition: box-shadow 150ms ease, transform 160ms var(--ease-out); }
.theme-card:active { transform: scale(0.98); }
.theme-card input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.theme-card:has(input:checked) { box-shadow: inset 0 0 0 1.5px var(--ion), 0 0 0 4px oklch(0.8 0.105 228 / 0.12); }
.theme-card:has(input:focus-visible) { outline: 2px solid var(--ion); outline-offset: 2px; }
.theme-shot { display: grid; grid-template-columns: 28% 1fr; grid-template-rows: repeat(3, 10px); gap: 6px 8px; align-content: start; height: 76px; padding: 10px; border-radius: var(--r-md); }
.theme-shot i { grid-row: 1 / -1; border-radius: 5px; }
.theme-shot b { border-radius: 4px; }
.theme-shot b:first-of-type { width: 60%; }
.theme-card-dark .theme-shot { background: oklch(0.145 0.012 262); box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.08); }
.theme-card-dark .theme-shot i { background: oklch(0.12 0.011 262); box-shadow: inset -1px 0 0 oklch(1 0 0 / 0.07), inset 2px 0 0 oklch(0.8 0.105 228); }
.theme-card-dark .theme-shot b { background: oklch(1 0 0 / 0.12); }
.theme-card-dark .theme-shot b:last-of-type { background: oklch(0.73 0.155 50 / 0.5); width: 40%; }
.theme-card-light .theme-shot { background: oklch(0.972 0.004 255); box-shadow: inset 0 0 0 1px oklch(0.25 0.02 262 / 0.12); }
.theme-card-light .theme-shot i { background: oklch(0.955 0.006 255); box-shadow: inset -1px 0 0 oklch(0.25 0.02 262 / 0.08), inset 2px 0 0 oklch(0.5 0.12 240); }
.theme-card-light .theme-shot b { background: oklch(0.25 0.02 262 / 0.14); }
.theme-card-light .theme-shot b:last-of-type { background: oklch(0.68 0.16 50 / 0.55); width: 40%; }
.theme-name { padding: 0 4px; font-weight: 540; font-size: 0.92rem; }
@media (max-width: 560px) { .theme-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Learned cases and the AI model (learning.js) */
.model-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; padding: 12px 16px; border-radius: var(--r-md); background: var(--attention-bg); color: var(--attention); border: 1px solid var(--attention); }
.model-banner p { margin: 0; font-weight: 500; }
.case-item .doc-head > span { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.case-why { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--border); }
.case-used { margin: 4px 0; font-size: 0.875rem; }
.case-edit { margin: 6px 0; }
.case-edit > summary, .case-old > summary { cursor: pointer; }
.case-scope { display: flex; align-items: center; gap: 8px; }
.case-old { margin-top: 12px; }
.case-forgotten, .case-superseded { opacity: 0.75; }
#ai-model h3 { margin: 16px 0 6px; font-size: 1rem; }

/* ---------------------------------------------------------------------------------------------
   The assistant on every page (assistant.js): the button bottom right, a panel on a desktop, a
   sheet on a phone. Colours are the theme's tokens, so dark and light follow the app's choice.
   --------------------------------------------------------------------------------------------- */
.asst-fab {
  position: fixed; right: calc(20px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 35;
  width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--cta); color: var(--on-cta); box-shadow: inset 0 -1px 0 oklch(0 0 0 / 0.12), var(--shadow-lg);
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.asst-fab .icon { width: 22px; height: 22px; }
.asst-fab:hover { background: var(--cta-hover); }
.asst-fab:active { transform: scale(0.94); }
.asst-fab:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.asst-fab[aria-expanded="true"] { transform: scale(0.92); }
.asst-scrim { display: none; }
.asst-panel {
  position: fixed; right: calc(20px + env(safe-area-inset-right)); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 36;
  width: min(420px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--text); border-radius: var(--r-xl); box-shadow: var(--edge), var(--shadow-lg);
  transform-origin: bottom right;
}
.asst-panel[hidden] { display: none; }
.asst-panel.asst-in { animation: asst-in 200ms var(--ease-out); }
@keyframes asst-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.asst-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--line); background: var(--glass); }
.asst-head h2 { font-size: 1rem; font-weight: 640; margin: 0; flex: 1; }
.asst-mark { color: var(--primary); display: inline-grid; }
.asst-mark .icon { width: 18px; height: 18px; }
.asst-kbd { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-3); padding: 2px 6px; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line-2); }
.asst-icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; }
.asst-icon-btn:hover { background: var(--tint); color: var(--text); }
.asst-icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.asst-icon-btn .icon { width: 17px; height: 17px; }
.asst-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 6px; }
.asst-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.asst-turn { display: grid; gap: 8px; }
.asst-q { justify-self: end; max-width: 85%; padding: 8px 12px; border-radius: 14px 14px 4px 14px; background: var(--surface-3); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.asst-a { display: grid; gap: 8px; max-width: 100%; }
.asst-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.asst-refused .asst-text { color: var(--attention-ink); }
.asst-links { display: flex; flex-wrap: wrap; gap: 6px; }
.asst-source { margin: 0; font-size: 0.8rem; color: var(--text-3); overflow-wrap: anywhere; }
.asst-note { margin: 0; font-size: 0.82rem; color: var(--text-3); }
.asst-later { visibility: hidden; }
.asst-proposal { display: grid; gap: 8px; padding: 10px 12px; border-radius: var(--r-md); background: var(--info-bg); box-shadow: inset 0 0 0 1px var(--line-2); }
.asst-proposal p { margin: 0; }
.asst-proposal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.asst-proposal-done, .asst-proposal-dismissed, .asst-proposal-failed { background: var(--tint); }
.asst-proposal .pill { justify-self: start; }
.asst-email { display: grid; gap: 8px; padding: 10px 12px; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line-2); }
.asst-email dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 0.88rem; }
.asst-email dt { color: var(--text-3); }
.asst-email dd { margin: 0; overflow-wrap: anywhere; }
.asst-email-body { margin: 0; font: inherit; font-size: 0.92rem; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); max-height: 220px; overflow-y: auto; }
.asst-empty { display: grid; gap: 12px; padding: 18px 2px 6px; color: var(--text-2); }
.asst-empty p { margin: 0; }
.asst-empty-mark { color: var(--primary); }
.asst-empty-mark .icon { width: 26px; height: 26px; }
.asst-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.asst-chip { border: 0; cursor: pointer; text-align: left; font: inherit; font-size: 0.88rem; padding: 7px 11px; border-radius: 999px; background: var(--tint); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); transition: background-color 140ms ease; }
.asst-chip:hover { background: var(--info-bg); }
.asst-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.asst-topics { font-size: 0.85rem; color: var(--text-3); }
.asst-topics summary { cursor: pointer; width: max-content; }
.asst-topics p { margin: 6px 0 0; }
.asst-thinking { display: inline-flex; gap: 5px; margin: 4px 0; }
.asst-thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: asst-dot 1.1s infinite ease-in-out; }
.asst-thinking span:nth-child(2) { animation-delay: 0.15s; }
.asst-thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes asst-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.asst-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.asst-input { flex: 1; resize: none; min-height: 40px; max-height: 160px; padding: 9px 12px; border: 0; border-radius: 12px; background: var(--field); color: var(--text); font: inherit; font-size: 16px; line-height: 1.4; box-shadow: inset 0 0 0 1px var(--line-2); }
.asst-input:focus { outline: none; box-shadow: var(--field-focus); }
.asst-send { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 0; border-radius: 12px; cursor: pointer; background: var(--cta); color: var(--on-cta); }
.asst-send:hover { background: var(--cta-hover); }
.asst-send:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.asst-send .icon { width: 18px; height: 18px; }
.asst-panel .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) {
  .asst-fab { right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
  body.asst-open .asst-fab { visibility: hidden; }
  .asst-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--scrim); }
  .asst-scrim[hidden] { display: none; }
  .asst-panel { left: 0; right: 0; bottom: 0; width: 100%; height: min(88dvh, 100dvh - 24px); border-radius: var(--r-xl) var(--r-xl) 0 0; transform-origin: bottom center; }
  .asst-panel.asst-in { animation-name: asst-sheet; animation-duration: 260ms; animation-timing-function: var(--ease-drawer); }
  .asst-form { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .asst-kbd { display: none; }
}
@keyframes asst-sheet { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .asst-panel.asst-in { animation: none; }
  .asst-thinking span { animation: none; opacity: 0.6; }
  .asst-fab { transition: none; }
}
@media print { .asst-fab, .asst-panel, .asst-scrim { display: none !important; } }

/* Abonnemang (subscriptions.js), Budget and Månadsrapporter (budget.js) */
.input-sm { padding: 4px 8px; font-size: 0.875rem; min-height: 32px; }
.subs-line { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1.3fr) 5em 4.5em minmax(0, 1.3fr) minmax(0, 1.6fr) auto; gap: 6px; margin: 0 0 6px; }
.subs-forms { display: grid; gap: 8px; margin: 12px 0 0; }
.subs-inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 4px; }
.subs-inline .input { width: auto; flex: 0 1 11em; min-width: 7em; }
.subs-inline select.input { flex-basis: 16em; }
.subs-forms .field-label { min-width: 9em; margin: 0; }
.row-attention td:first-child { box-shadow: inset 3px 0 0 var(--warning, #b54708); }
.bud-table .good, .bud-months .good { color: var(--success, #067647); }
.bud-table .bad { color: var(--danger, #b42318); }
.bud-grid input.num { text-align: right; }
.bud-tools { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; margin: 0 0 8px; }
.bud-tools .fin-field { margin: 0; }
.bud-group { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.bud-group .input { width: auto; min-width: 6em; }
.bud-tools > .fin-field select { min-width: 14em; }
.pkg-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; }
.pkg-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.pkg-item p { margin: 0 0 4px; }
@media (max-width: 720px) {
  .subs-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .subs-line input[name="description"] { grid-column: 1 / -1; }
}

/* The customer agreement (agreement.js): the acceptance screen before a workspace is used, and
   Företaget > Avtal. The legal texts come rendered from the server (packages/legal); here they get a
   readable column inside a scrolling box, tables that scroll sideways on a phone. */
.agreement-screen { place-items: start center; padding-top: clamp(16px, 5vh, 56px); }
.agreement-card { width: min(780px, 100%); gap: 4px; }
.agreement-card h1 { margin-top: 18px; }
.ag-lead { color: var(--text-2); margin: 6px 0 4px; max-width: 68ch; }
.ag-draft { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 0.88rem; }
.ag-lang { border: 0; padding: 0; margin: 16px 0 4px; min-width: 0; }
.ag-lang legend { font-size: 0.86rem; font-weight: 540; color: var(--text-2); padding: 0; margin-bottom: 6px; }
.ag-lang .segmented { display: inline-grid; grid-template-columns: auto auto; }
.ag-lang p { margin: 6px 0 0; font-size: 0.84rem; }
.ag-docs { display: grid; gap: 12px; margin-top: 14px; }
.ag-doc, .ag-pending { border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 14px 16px; background: var(--tint); min-width: 0; }
.ag-pending + .ag-pending { margin-top: 12px; }
.ag-doc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.ag-doc-head h3 { font-size: 1.02rem; font-weight: 600; margin: 0; }
.ag-doc-head .muted { font-size: 0.85rem; }
.ag-summary, .ag-change { margin: 8px 0 0; color: var(--text-2); }
.ag-change { color: var(--attention-ink); }
.ag-text { margin-top: 10px; }
.ag-text summary { cursor: pointer; color: var(--info); font-weight: 540; width: fit-content; }
.ag-text-body { margin-top: 10px; max-height: min(52vh, 460px); overflow: auto; overscroll-behavior: contain; padding: 4px 14px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-deep); }
.ag-text-body:focus-visible { outline: 2px solid var(--ion); outline-offset: 2px; }
.ag-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 10px 0 0; font-size: 0.86rem; }
.ag-links a { color: var(--info); }
.ag-links .mono { font-size: 0.76rem; overflow-wrap: anywhere; }
.ag-form { display: grid; margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.ag-pending .ag-form { border-top: 0; margin-top: 8px; }
.ag-check { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; font-weight: 540; line-height: 1.45; cursor: pointer; }
.ag-check input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--ion); }
.ag-evidence { font-size: 0.84rem; margin: 10px 0 0; }
.ag-form .btn-primary { justify-self: start; margin-top: 4px; }
.ag-foot { margin: 14px 0 0; }
.ag-panel { margin-top: 16px; }
.ag-panel-body { padding: 14px 18px; }
.ag-list { list-style: none; margin: 0; padding: 0; }
.ag-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 18px; border-top: 1px solid var(--line); }
.ag-list li:first-child { border-top: 0; }
.ag-row-end { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.legal-text h2 { font-size: 1.3rem; font-weight: 600; margin: 16px 0 8px; letter-spacing: -0.02em; }
.legal-text h3 { font-size: 1.05rem; font-weight: 600; margin: 18px 0 6px; }
.legal-text h4 { font-size: 0.98rem; font-weight: 600; margin: 14px 0 4px; }
.legal-text p, .legal-text li { color: var(--text-2); line-height: 1.55; overflow-wrap: anywhere; }
.legal-text p { margin: 0 0 10px; }
.legal-text ul { margin: 0 0 10px; padding-left: 20px; }
.legal-text strong { color: var(--text); }
.legal-text a { color: var(--info); }
.legal-text code { font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.85em; background: var(--tint-2); padding: 0 4px; border-radius: 4px; }
.legal-text blockquote { margin: 10px 0; padding: 4px 12px; border-left: 3px solid var(--copper); background: var(--attention-bg); border-radius: 4px; }
.legal-text hr { border: 0; border-top: 1px solid var(--line-2); margin: 18px 0; }
.legal-table { overflow-x: auto; margin: 8px 0 14px; }
.legal-table table { border-collapse: collapse; min-width: 100%; font-size: 0.86rem; }
.legal-table th, .legal-table td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.legal-table td { color: var(--text-2); min-width: 7rem; }
@media (max-width: 560px) {
  .agreement-card { padding: 22px 16px 20px; }
  .ag-text-body { max-height: 60vh; padding: 4px 10px 10px; }
}
