/* InvoiceDesk — application styles. No build step, no external assets. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --text: #16191d;
  --text-2: #4a5059;
  --muted: #6b7280;
  --primary: #17693a;
  --primary-hover: #10512c;
  --primary-soft: #e6f2ea;
  --focus: #22964f;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warning: #9a5b00;
  --warning-soft: #fff4dd;
  --success: #12733f;
  --success-soft: #e3f4ea;
  --info: #17693a;
  --info-soft: #e6f2ea;
  --series-1: #17693a;
  --series-2: #eb6834;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --sidebar-w: 212px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.08rem; } h3 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .92em; }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex;
           flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; }
.brand a { display: flex; align-items: center; gap: .6rem; padding: 1.05rem 1.15rem; font-weight: 700; font-size: 1.05rem;
           color: var(--text); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; color: var(--primary); fill: none; stroke: none; }
.nav { display: flex; flex-direction: column; padding: .25rem .6rem; gap: 2px; flex: 1; overflow-y: auto; }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: var(--radius-sm);
            color: var(--text-2); font-weight: 500; text-decoration: none; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-cta { padding: .75rem; }
.sidebar-user { display: flex; align-items: center; gap: .25rem; padding: .7rem .75rem; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; color: var(--text); text-decoration: none; }
.user-chip:hover { text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
          display: grid; place-items: center; font-weight: 700; flex: none; }
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-meta strong, .user-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; min-height: 60px; padding: .6rem 1.6rem;
          background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.topbar-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.topbar-title h1 { margin: 0; font-size: 1.2rem; }
.topbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 1.4rem 1.6rem 3rem; max-width: 1360px; width: 100%; }
.btn-icon.nav-toggle { display: none; }
.sidebar-scrim { display: none; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .48rem .9rem;
       border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
       color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
       line-height: 1.3; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #f0c5c0; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: .3rem .6rem; font-size: .86rem; }
.btn-block { width: 100%; }
.btn-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--radius-sm);
            background: transparent; color: var(--text-2); cursor: pointer; padding: 0; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon:disabled { opacity: .35; cursor: default; }
.inline-form { display: inline; margin: 0; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 1.1rem 1.2rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.2rem;
             border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 1rem; }
.stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin: 0 0 .5rem; }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi { padding: 1rem 1.1rem; }
.kpi-label { color: var(--muted); font-size: .84rem; font-weight: 500; }
.kpi-value { font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: .15rem; white-space: nowrap; }
.kpi-sub { font-size: .82rem; color: var(--muted); }
.kpi.is-alert .kpi-value { color: var(--danger); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label { font-weight: 500; font-size: .88rem; color: var(--text-2); }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search],
input[type=tel], input[type=url], input:not([type]), select, textarea {
  width: 100%; padding: .48rem .65rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; line-height: 1.35; min-height: 36px; }
input[type=color] { width: 60px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(34, 150, 79, .18); }
.has-error input, .has-error select, .has-error textarea, input.invalid, select.invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .82rem; margin: 0; }
.help { color: var(--muted); font-size: .82rem; margin: 0; }
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 400 !important; color: var(--text) !important; }
.check input { width: 16px; height: 16px; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; padding-top: .5rem; }
.form-section + .form-section { border-top: 1px solid var(--border); margin-top: 1.1rem; padding-top: 1.1rem; }
fieldset { border: 0; padding: 0; margin: 0; }
.alert { padding: .7rem .9rem; border-radius: var(--radius-sm); border: 1px solid; margin-bottom: 1rem; }
.alert-error { background: var(--danger-soft); border-color: #f3c6c1; color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: #f2d9a6; color: var(--warning); }
.alert-info { background: var(--info-soft); border-color: #bfe0cb; color: var(--info); }
.alert-success { background: var(--success-soft); border-color: #b9e1c9; color: var(--success); }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; }
.toolbar .field { min-width: 140px; }
.toolbar .field-search { flex: 1 1 240px; }
.search-input { position: relative; }
.search-input .icon { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input input { padding-left: 2rem; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { padding: .3rem .7rem; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text-2);
        background: var(--surface); font-size: .86rem; text-decoration: none; }
.chip:hover { text-decoration: none; background: var(--surface-2); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
            background: var(--surface-2); white-space: nowrap; }
.table tbody tr:hover { background: #fafbfc; }
.table tbody tr[data-href] { cursor: pointer; }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-bottom: 0; }
.table tr.is-overdue td { background: #fff6f5; }
.table tr.is-overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table tr.is-cancelled td, .table tr.is-voided td { color: var(--muted); }
.table tr.is-voided td.num { text-decoration: line-through; }
.table .actions { text-align: right; white-space: nowrap; }
.table-compact th, .table-compact td { padding: .45rem .6rem; }
.sort-link { color: inherit; text-decoration: none; display: inline-flex; gap: .25rem; align-items: center; }
.sort-link:hover { color: var(--text); text-decoration: none; }
.sort-link.active { color: var(--text); }
.sort-link.active.asc .sort-ind::after { content: "▲"; font-size: .65em; }
.sort-link.active.desc .sort-ind::after { content: "▼"; font-size: .65em; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; padding: .75rem 1rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.cell-main { font-weight: 500; color: var(--text); }
.cell-sub { display: block; font-size: .82rem; color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: .14rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap;
         border: 1px solid transparent; }
.badge-draft { background: #eef0f3; color: #4a5059; }
.badge-issued { background: var(--warning-soft); color: var(--warning); }
.badge-partially_paid { background: var(--warning-soft); color: var(--warning); }
.badge-paid { background: var(--success-soft); color: var(--success); }
.badge-overdue { background: var(--danger-soft); color: var(--danger); border-color: #f3c6c1; }
.badge-cancelled { background: #f1f1f1; color: #7a7a7a; text-decoration: line-through; }
.badge-sent { background: var(--info-soft); color: var(--info); }
.badge-accepted { background: var(--success-soft); color: var(--success); }
.badge-declined { background: #f1f1f1; color: #7a7a7a; }
.badge-expired { background: var(--warning-soft); color: var(--warning); }
.badge-invoiced { background: var(--success-soft); color: var(--success); }
.badge-archived { background: #f1f1f1; color: #6b6b6b; }
.badge-neutral { background: #eef0f3; color: #4a5059; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 1rem; top: 4.2rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: 420px; }
.toast { background: #1f2329; color: #fff; padding: .7rem 2.2rem .7rem .95rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
         position: relative; border-left: 4px solid var(--success); }
.toast-error { border-left-color: #f06a5d; }
.toast-warning { border-left-color: #f0b44c; }
.toast-info { border-left-color: #6aa8f0; }
.toast-close { position: absolute; right: .4rem; top: .35rem; background: none; border: 0; color: #bbb; font-size: 1.1rem; cursor: pointer; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 20, 28, .45); }
.modal-panel { position: relative; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
               width: min(640px, 100%); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; }
.modal-panel.modal-sm { width: min(420px, 100%); }
.modal-panel.modal-lg { width: min(980px, 100%); height: calc(100vh - 2rem); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 1.1rem; overflow: auto; flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.pdf-frame { width: 100%; height: 100%; min-height: 60vh; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #525659; }

/* ---------- dropdown menu ---------- */
.menu { position: relative; display: inline-block; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); min-width: 200px; background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: .3rem; z-index: 50; display: none; }
.menu.open .menu-list { display: block; }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .45rem .6rem; border: 0;
                                  background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer;
                                  border-radius: 5px; text-decoration: none; }
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); text-decoration: none; }
.menu-list .danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: .3rem 0; }

/* ---------- combobox ---------- */
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 3px); background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 60; max-height: 290px; overflow-y: auto; padding: .25rem; min-width: 260px; }
.combo-item { padding: .45rem .6rem; border-radius: 5px; cursor: pointer; }
.combo-item small { display: block; color: var(--muted); }
.combo-item.active, .combo-item:hover { background: var(--primary-soft); }
.combo-empty { padding: .5rem .6rem; color: var(--muted); }
.combo-action { border-top: 1px solid var(--border); margin-top: .25rem; padding-top: .35rem; color: var(--primary); font-weight: 500; }

/* ---------- invoice editor ---------- */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; }
.buyer-card { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: .8rem .9rem; background: var(--surface-2); }
.lines-table { width: 100%; border-collapse: collapse; }
.lines-table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
                  text-align: left; padding: .5rem .35rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.lines-table td { padding: .45rem .35rem; vertical-align: top; border-bottom: 1px solid var(--border); }
.lines-table input, .lines-table select, .lines-table textarea { min-height: 34px; padding: .38rem .5rem; }
.lines-table .col-order { width: 34px; }
.lines-table .col-qty { width: 86px; }
.lines-table .col-unit { width: 96px; }
.lines-table .col-price { width: 110px; }
.lines-table .col-disc { width: 132px; }
.lines-table .col-vat { width: 165px; }
.lines-table .col-amt { width: 104px; text-align: right; }
.lines-table .col-del { width: 36px; }
.lines-table textarea.line-desc { min-height: 34px; height: 34px; margin-top: .3rem; font-size: .88rem; }
.lines-table .amount { padding-top: .5rem; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines-table .amount small { display: block; color: var(--muted); font-size: .78rem; }
.order-btns { display: flex; flex-direction: column; }
.order-btns .btn-icon { width: 26px; height: 18px; }
.order-btns .icon { width: 15px; height: 15px; }
.disc-wrap { display: flex; gap: .25rem; }
.disc-wrap select { width: 56px; flex: none; padding-left: .3rem; padding-right: .1rem; }
.line-row.drag-over td { border-top: 2px solid var(--focus); }
.totals { margin-left: auto; width: min(380px, 100%); }
.totals-row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; font-variant-numeric: tabular-nums; }
.totals-row.grand { border-top: 2px solid var(--text); margin-top: .35rem; padding-top: .55rem; font-size: 1.12rem; font-weight: 700; }
.editor-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 95%, transparent); padding: .8rem 0; margin-top: 1rem;
                  display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; border-top: 1px solid var(--border); z-index: 20; }
.saving-indicator { color: var(--muted); font-size: .85rem; margin-right: auto; align-self: center; }

/* ---------- invoice view ---------- */
.doc { padding: 1.4rem 1.5rem; }
.doc-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.2rem; }
.doc-total { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .45rem 0 .45rem 1.1rem; border-left: 2px solid var(--border); position: relative; font-size: .88rem; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .85rem; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.timeline li small { display: block; }

/* ---------- charts ---------- */
.chart-wrap { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar { transition: opacity .1s; }
.chart .bar-0 { fill: var(--series-1); }
.chart .bar-1 { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .hover-band, .chart .hover-band { fill: transparent; }
.legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--text-2); margin-bottom: .5rem; flex-wrap: wrap; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.chart-tip { position: absolute; pointer-events: none; background: #1f2329; color: #fff; padding: .45rem .6rem; border-radius: 6px;
             font-size: .8rem; box-shadow: var(--shadow-lg); white-space: nowrap; z-index: 5; }
.chart-tip strong { display: block; margin-bottom: .15rem; }
.chart-tip .row { display: flex; gap: .8rem; justify-content: space-between; }
details.table-view summary { cursor: pointer; color: var(--primary); font-size: .86rem; margin-top: .5rem; }

/* ---------- settings ---------- */
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 80px; }
.subnav a { padding: .5rem .7rem; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; }
.subnav a:hover { background: var(--surface); text-decoration: none; }
.subnav a.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.logo-preview { max-height: 64px; max-width: 220px; border: 1px solid var(--border); border-radius: 6px; padding: 4px; background: #fff; }
code.token { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 .3rem; font-size: .85em; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(440px, 100%); }
.auth-card.wide { width: min(620px, 100%); }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; font-weight: 700; font-size: 1.25rem; margin-bottom: 1.2rem; }
.auth-brand .brand-mark { color: var(--primary); width: 32px; height: 32px; }
.lang-switch { text-align: center; margin-top: 1rem; font-size: .88rem; }
.lang-switch a { margin: 0 .35rem; }

/* ---------- print view ---------- */
.print-page { height: 100vh; margin: 0; }
.print-page iframe { width: 100%; height: 100vh; border: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .editor-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-layout { grid-template-columns: 1fr; }
  .subnav { flex-direction: row; overflow-x: auto; position: static; }
  .subnav a { white-space: nowrap; }
  /* invoice lines become cards */
  .lines-table thead { display: none; }
  .lines-table, .lines-table tbody, .lines-table tr, .lines-table td { display: block; width: 100% !important; }
  .lines-table tr { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem; margin-bottom: .7rem; position: relative;
                    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem .6rem; background: var(--surface); }
  .lines-table td { border: 0; padding: 0; }
  .lines-table td[data-label]::before { content: attr(data-label); display: block; font-size: .74rem; color: var(--muted);
                                        text-transform: uppercase; letter-spacing: .04em; margin-bottom: .15rem; }
  .lines-table td.col-item { grid-column: 1 / -1; }
  .lines-table td.col-order { position: absolute; right: 44px; top: .45rem; width: auto !important; }
  .lines-table td.col-order .order-btns { flex-direction: row; gap: .2rem; }
  .lines-table td.col-del { position: absolute; right: .4rem; top: .4rem; width: auto !important; }
  .lines-table td.col-item { padding-right: 96px; }
  .lines-table .amount { text-align: left; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .18s ease; box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(15, 20, 28, .4); z-index: 35; }
  .main { margin-left: 0; }
  .btn-icon.nav-toggle { display: inline-grid; }
  .topbar { padding: .5rem .8rem; }
  .content { padding: 1rem .8rem 3rem; }
  .kpis, .grid-2, .grid-3, .grid-4, .form-grid, .doc-parties { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-responsive thead { display: none; }
  .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td { display: block; width: 100%; }
  .table-responsive tr { padding: .6rem .8rem; border-bottom: 1px solid var(--border); display: grid;
                         grid-template-columns: 1fr auto; gap: .1rem .8rem; }
  .table-responsive td { border: 0; padding: 0; text-align: left; }
  .table-responsive td.num { text-align: right; }
  .table-responsive td.hide-sm { display: none; }
  .table-responsive tr.is-overdue { background: #fff6f5; box-shadow: inset 3px 0 0 var(--danger); }
  .table-responsive tr.is-overdue td { background: transparent; box-shadow: none !important; }
  .table-responsive tfoot tr { background: var(--surface-2); }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { padding: .48rem .6rem; }
  .toolbar .field { flex: 1 1 140px; }
}
@media print {
  .sidebar, .topbar, .toasts, .editor-actions, .no-print { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
}

/* ---------- company logo in the sidebar ---------- */
.brand-logo { display: block; max-width: 100%; max-height: 54px; object-fit: contain; }
.brand a.has-logo { padding: .9rem 1.1rem; }
.avatar img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; background: #fff; }
.avatar.has-img { background: #fff; border: 1px solid var(--border); overflow: hidden; }
.kpi-value.is-red, .num.is-red, .is-red { color: var(--danger); }
.pdf-preview { width: 100%; height: 1150px; border: 1px solid var(--border); border-radius: var(--radius); background: #525659; display: block; }
.summary-bar { display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem; align-items: flex-end; }
.summary-bar .item small { display: block; color: var(--muted); font-size: .8rem; }
.summary-bar .item strong { font-size: 1.05rem; }
.summary-bar .total strong { font-size: 1.5rem; }

/* users page */
.inline-details { display: inline-block; vertical-align: middle; }
.inline-details > summary { list-style: none; cursor: pointer; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] form { min-width: 14rem; }

/* Ladu, Hinnakirjad, Logid */
.kpis.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stock-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
.is-green { color: var(--success, #1f7a4d); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--muted, #6b7280); }
.dl dd { margin: 0; }
.qty-form { display: inline-flex; gap: .25rem; align-items: center; margin: 0; }
.qty-form input[type=number] { width: 4.2rem; padding: .3rem .4rem; }
.price-table input.price-input { width: 7.5rem; text-align: right; padding: .3rem .45rem; }
.price-table input.price-input.changed { border-color: var(--primary, #1f6f43); background: #f1f8f3; font-weight: 600; }
.price-table td.diff { font-size: .85em; }
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: .75rem; align-items: center; justify-content: flex-end;
  padding: .75rem 1rem; background: var(--surface, #fff); border-top: 1px solid var(--border, #e5e7eb); }
.log-details { color: var(--muted, #6b7280); font-size: .88em; }
@media (max-width: 900px) {
  .kpis.kpis-4, .stock-layout { grid-template-columns: 1fr; }
}
.nav-sep { height: 1px; background: var(--border); margin: .5rem .75rem; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .2rem .9rem .3rem; }
.avatar.has-photo { padding: 0; overflow: hidden; background: var(--surface-2); }
.avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-lg { width: 96px; height: 96px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 2.2rem; font-weight: 700;
  background: var(--primary-soft); color: var(--primary); overflow: hidden; flex: none; }
.avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.profile-photo { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.auth-logo { max-height: 56px; max-width: 220px; object-fit: contain; display: block; margin: 0 auto .4rem; }
.auth-brand:has(.auth-logo) { flex-direction: column; }
.tag-list { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.tag { font-size: .7rem; padding: .08rem .45rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 600; letter-spacing: .02em; }
.col-check { width: 2.2rem; }
.col-check input { width: 1.05rem; height: 1.05rem; }
.bulkbar { position: sticky; bottom: 0; display: flex; gap: .8rem; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; background: var(--surface); border-top: 1px solid var(--border); z-index: 5; }
.danger-row { margin-top: 1rem; display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.maker-card { display: flex; gap: .9rem; padding: 1rem; text-decoration: none; color: inherit; align-items: flex-start; transition: box-shadow .15s, border-color .15s; }
.maker-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg, 0 6px 20px rgba(0,0,0,.08)); text-decoration: none; }
.maker-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; font-size: .92rem; }
.maker-body .tag { align-self: flex-start; margin-top: .3rem; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.maker-logo { width: 72px; height: 72px; flex: none; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  display: grid; place-items: center; overflow: hidden; }
.maker-logo img { max-width: 90%; max-height: 90%; object-fit: contain; }
.maker-logo span { font-weight: 700; color: var(--primary); font-size: 1.3rem; }
.maker-logo-sm { width: 120px; height: 60px; margin-bottom: .5rem; }
.maker-logo-lg { width: 100%; height: 120px; }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li + li { border-top: 1px solid var(--border); }
.file-list a { display: flex; gap: .8rem; align-items: center; padding: .75rem 1rem; color: inherit; text-decoration: none; }
.file-list a:hover { background: var(--surface-2); }
.file-list a > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.file-ext { flex: none; width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; font-size: .72rem; font-weight: 700;
  background: var(--primary-soft); color: var(--primary); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.pricelist-meta { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; }
.pricelist-actions { margin-left: auto; display: inline-flex; gap: .4rem; }
.pricelist-pdf { height: calc(100vh - 210px); min-height: 520px; }
.pricelist-img { max-width: 100%; height: auto; border-radius: 6px; }
.sheet-wrap { max-height: calc(100vh - 260px); overflow: auto; }
.sheet-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); }
.sheet-table td, .sheet-table th { white-space: nowrap; }
.mobile-only { display: none; }

/* ---------- phones: everything works one-handed on a ~360-430px screen ---------- */
.kpis.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .kpis.kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: block; }
  .btn.mobile-only { display: inline-flex; }
  .pdf-open { justify-content: center; padding: .9rem 1rem; margin-top: .5rem; }
  html { -webkit-text-size-adjust: 100%; }
  input, select, textarea { font-size: 16px; }          /* stops iPhone from zooming into fields */
  .btn, .btn-sm { min-height: 40px; }

  /* header: title on its own line, buttons (with their text) in a scrollable row underneath */
  .topbar { flex-wrap: wrap; row-gap: .45rem; position: sticky; top: 0; z-index: 30; }
  .topbar-title { flex: 1 1 calc(100% - 56px); }
  .topbar-title h1 { font-size: 1.1rem; line-height: 1.25; }
  .topbar-actions { flex: 1 1 100%; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto;
                    -webkit-overflow-scrolling: touch; padding-bottom: 2px; scrollbar-width: none; }
  .topbar-actions:empty { display: none; }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions .btn { padding: .45rem .7rem; white-space: nowrap; flex: none; }
  .topbar-actions .btn span { display: inline; }
  .topbar-actions .menu-list { right: auto; left: 0; }

  .kpis, .kpis.kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: .6rem; }
  .kpi { padding: .8rem .9rem; min-width: 0; }
  .kpi-value { font-size: 1.2rem; overflow-wrap: anywhere; }
  .kpi-label, .kpi-sub { font-size: .78rem; }
  .stock-layout { grid-template-columns: 1fr; }
  .toolbar { gap: .6rem; }
  .toolbar .field-search { flex: 1 1 100%; }
  .card-grid { grid-template-columns: 1fr; }
  .pricelist-actions { margin-left: 0; }
  .sheet-wrap { max-height: 70vh; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 auto; justify-content: center; }
  .settings-layout .subnav { margin: 0 -.8rem; padding: 0 .8rem; scrollbar-width: none; }

  /* lists shown as cards: everything left-aligned and readable */
  .contacts-table tr, .log-table tr { display: block; position: relative; padding: .75rem .9rem; }
  .contacts-table td, .log-table td { display: block; text-align: left !important; padding: .05rem 0; }
  .contacts-table td.col-check { position: absolute; right: .8rem; top: .8rem; width: auto; }
  .contacts-table td.col-main { padding-right: 2.2rem; }
  .contacts-table td:empty { display: none; }
  .log-table td:first-child { font-size: .8rem; color: var(--muted); }
  .log-table td.hide-sm { display: block; }
  .table-responsive .actions { justify-self: end; }
}
@media (max-width: 380px) {
  .kpis, .kpis.kpis-4 { grid-template-columns: 1fr !important; }
}
@media (max-width: 760px) {
  .log-table td:nth-child(2), .log-table td:nth-child(3) { display: inline; }
  .log-table td:nth-child(2)::after { content: " · "; color: var(--muted); }
  .log-table td:nth-child(4) { margin-top: .2rem; }
}
.creator { display: inline-flex; align-items: center; gap: .45rem; }
.creator .avatar { width: 26px; height: 26px; font-size: .75rem; }
.show-sm { display: none !important; }
@media (max-width: 760px) { .show-sm { display: block !important; } }
.doc-contact-preview { margin-top: 1rem; padding: .8rem 1rem; border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); display: flex; flex-direction: column; gap: .1rem; font-size: .9rem; }

/* ---------- alert bars (KMD, majandusaasta aruanne, calendar alerts) ---------- */
.alert-bars { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.alert-bar { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border-radius: var(--radius);
  color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.12); animation: alertIn .35s ease-out; }
.alert-bar .icon { flex: none; width: 22px; height: 22px; }
.alert-bar-red { background: #c62828; }
.alert-bar-orange { background: #c2410c; }
.alert-bar-blue { background: #1d4ed8; }
.alert-bar-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.alert-bar-text span { opacity: .92; font-size: .88rem; }
.alert-bar-count { flex: none; display: flex; flex-direction: column; align-items: center; line-height: 1; padding: .3rem .6rem;
  border-radius: 8px; background: rgba(255,255,255,.18); }
.alert-bar-count b { font-size: 1.35rem; }
.alert-bar-count small { font-size: .65rem; text-transform: uppercase; letter-spacing: .05em; }
.alert-bar .btn { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.35); }
.alert-bar .btn-icon { color: #fff; }
.alert-bar form { margin: 0; }
@keyframes alertIn { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
.alert-preview { padding: .8rem 1rem; border-radius: var(--radius); background: #fdecea; color: #7f1d1d; display: flex; flex-direction: column; gap: .25rem; }
h3.form-section { font-size: 1rem; margin: .4rem 0 0; }
.tag-red { background: #fdecea; color: #b91c1c; } .tag-orange { background: #fff1e6; color: #c2410c; } .tag-blue { background: #e8efff; color: #1d4ed8; }
.icon-xs { width: 13px; height: 13px; vertical-align: -2px; }

/* ---------- Kalender ---------- */
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 1rem; margin-bottom: 1rem; }
.cal-nav { display: flex; align-items: center; gap: .35rem; }
.cal-title { margin: 0 0 0 .5rem; font-size: 1.2rem; }
.cal-views { display: flex; gap: .3rem; }
.cal-search { margin-left: auto; min-width: 220px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: .5rem; font-size: .75rem; font-weight: 700; color: var(--muted); text-align: center; border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 112px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: .3rem .35rem; display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.cal-grid .cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.is-out { background: var(--surface-2); }
.cal-cell.is-out .cal-daynum { color: var(--muted); }
.cal-cell.is-weekend { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.cal-cell.is-holiday .cal-daynum { color: #c62828; }
.cal-cell-head { display: flex; justify-content: space-between; align-items: center; }
.cal-daynum { font-weight: 700; font-size: .85rem; width: 1.8rem; height: 1.8rem; display: grid; place-items: center; border-radius: 50%; color: inherit; text-decoration: none; }
.cal-cell.is-today .cal-daynum { background: var(--primary); color: #fff; }
.cal-add { opacity: 0; text-decoration: none; font-weight: 700; color: var(--primary); width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 6px; }
.cal-cell:hover .cal-add, .cal-weekday-head .cal-add { opacity: 1; }
.cal-add:hover { background: var(--primary-soft); }
.cal-holiday { font-size: .68rem; color: #c62828; line-height: 1.2; }
.cal-events { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ev { display: flex; align-items: center; gap: .25rem; font-size: .74rem; line-height: 1.25; padding: .12rem .35rem; border-radius: 4px; min-width: 0;
  color: var(--text); text-decoration: none; background: color-mix(in srgb, var(--c) 14%, transparent); border-left: 3px solid var(--c); }
.ev span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.ev-allday { background: var(--c); color: #fff; border-left-color: var(--c); }
.ev.ev-system { background: #c62828; color: #fff; border-left-color: #7f1d1d; font-weight: 600; }
.ev:hover { filter: brightness(.95); text-decoration: none; }
.ev-more { font-size: .72rem; color: var(--muted); padding-left: .3rem; }
.cal-dots { display: none; }
.cal-month-agenda { display: none; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.cal-weekday { min-height: 220px; }
.cal-weekday.is-today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.cal-weekday-head { display: flex; justify-content: space-between; align-items: center; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.cal-weekday-head a { text-decoration: none; color: inherit; }
.cal-weekday .cal-holiday { padding: .3rem .6rem 0; }
.cal-daylist { display: flex; flex-direction: column; }
.cal-row { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem .7rem; color: inherit; text-decoration: none; border-left: 4px solid var(--c); margin: .3rem .4rem; border-radius: 6px;
  background: color-mix(in srgb, var(--c) 8%, transparent); }
.cal-row:hover { background: color-mix(in srgb, var(--c) 15%, transparent); text-decoration: none; }
.cal-row > div { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cal-row small { color: var(--muted); font-size: .8rem; }
.cal-row .cal-desc { white-space: pre-line; color: var(--text); opacity: .8; }
.cal-row-time { flex: none; width: 3.2rem; font-weight: 700; font-size: .82rem; line-height: 1.2; }
.cal-row-system { background: #fdecea; border-left-color: #c62828; color: #7f1d1d; }
.cal-row-system small { color: #7f1d1d; }
.cal-week .cal-row { flex-direction: column; gap: .15rem; margin: .25rem; padding: .4rem .5rem; }
.cal-week .cal-row-time { width: auto; }
.cal-week .cal-row .tag { align-self: flex-start; }
.cal-empty { padding: .6rem .8rem; margin: 0; font-size: .85rem; }
.cal-agenda-day + .cal-agenda-day { border-top: 1px solid var(--border); }
.cal-agenda-day h3 { font-size: .9rem; margin: 0; padding: .7rem .9rem .2rem; }
.cal-agenda-day.is-today h3 { color: var(--primary); }
.cal-hours { border-top: 1px solid var(--border); display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cal-hours a { display: flex; justify-content: space-between; padding: .55rem .9rem; border-bottom: 1px solid var(--border); color: var(--muted); text-decoration: none; font-size: .85rem; }
.cal-hours a em { font-style: normal; opacity: 0; color: var(--primary); }
.cal-hours a:hover em { opacity: 1; }
.cal-fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem 1rem; margin: 0; }
.cal-fieldset legend { font-weight: 700; padding: 0 .4rem; display: flex; gap: .35rem; align-items: center; }
.cal-form:has(input[name=all_day]:checked) .time-field { display: none; }
.cal-form:has(select[name=recurrence] option[value=none]:checked) .rec-field { display: none; }
.cal-form:not(:has(input[name=alert_enabled]:checked)) .alert-fields { display: none; }
.color-pick { display: flex; gap: .45rem; flex-wrap: wrap; padding-top: .2rem; }
.color-pick input { position: absolute; opacity: 0; pointer-events: none; }
.color-pick span { display: block; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; box-shadow: 0 0 0 1px var(--border); }
.color-pick input:checked + span { border-color: #fff; box-shadow: 0 0 0 2px var(--text); }
.color-pick input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.howto { border: 1px solid var(--border); border-radius: var(--radius); padding: .55rem .8rem; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto ol { margin: .5rem 0 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: .3rem; }
.btn-block { width: 100%; justify-content: center; }
.device { display: flex; gap: .7rem; align-items: center; padding: .6rem .2rem; }
.device > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; }
.phone-layout { grid-template-columns: 1fr 1fr; }

@media (max-width: 1100px) {
  .cal-week { grid-template-columns: 1fr; }
  .cal-weekday { min-height: 0; }
}
@media (max-width: 760px) {
  .cal-toolbar { gap: .5rem; }
  .cal-title { font-size: 1.05rem; margin-left: .3rem; }
  .cal-views { width: 100%; }
  .cal-views .chip { flex: 1; text-align: center; justify-content: center; }
  .cal-search { margin-left: 0; width: 100%; min-width: 0; }
  .cal-cell { min-height: 54px; padding: .15rem; align-items: center; }
  .cal-cell-head { justify-content: center; }
  .cal-add, .cal-events, .cal-holiday { display: none; }
  .cal-daynum { font-size: .8rem; width: 1.7rem; height: 1.7rem; }
  .cal-dots { display: flex; gap: 2px; justify-content: center; flex-wrap: wrap; min-height: 6px; }
  .cal-dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }
  .cal-month-agenda { display: block; margin-top: .8rem; }
  .cal-head div { padding: .35rem 0; }
  .phone-layout { grid-template-columns: 1fr; }
  .alert-bar { flex-wrap: wrap; padding: .6rem .7rem; gap: .5rem; }
  .alert-bar-text { flex: 1 1 calc(100% - 110px); }
  .alert-bar .btn { order: 5; }
}
.alert-bar-count small, .alert-bar-count b { color: #fff; }
@media (max-width: 760px) {
  .alert-bar { flex-wrap: wrap; row-gap: .35rem; }
  .alert-bar-text { flex: 1 1 calc(100% - 150px); font-size: .9rem; }
  .alert-bar form { order: 3; }
  .alert-bar .btn { order: 4; margin-left: 2.2rem; }
  .alert-bar-count { padding: .2rem .45rem; }
  .alert-bar-count b { font-size: 1.1rem; }
}
.combo-tag { display: inline-block; font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .05rem .4rem; border-radius: 999px; margin-right: .4rem; vertical-align: 1px; }
.combo-tag-stock { background: #e6f4ec; color: #17693a; }
.combo-tag-product { background: var(--surface-2); color: var(--muted); }
.stock-badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; font-weight: 600; color: #17693a;
  background: #e6f4ec; border-radius: 999px; padding: .05rem .5rem; margin-top: .2rem; }
.stock-badge.is-short { background: #fdecea; color: #b91c1c; }
.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1280px) { .kpis.kpis-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .kpis.kpis-3 { grid-template-columns: 1fr !important; } }
.badge-credited, .badge-credit_note { background: #f3e8ff; color: #6b21a8; }
.badge-superseded { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.line-serial { margin-top: .25rem; font-family: var(--mono, monospace); font-size: .85rem; }
.versions { margin-bottom: 1rem; }
.versions .card-body { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.red-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: #dc2626; margin-right: .4rem; vertical-align: middle; }
.low-list { list-style: none; margin: .5rem 0 0; padding: 0; font-size: .85rem; max-height: 9rem; overflow-y: auto; }
.low-list li { padding: .1rem 0; }
.tag-activity { background: #e8f5e9; color: #1b5e20; }
.kpis.kpis-7 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis.kpis-7 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.online-card { margin-top: 1rem; }
.online-list { list-style: none; margin: 0; padding: .25rem 0; }
.online-list li { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; border-top: 1px solid var(--border); }
.online-list li:first-child { border-top: 0; }
.online-avatar { position: relative; display: inline-flex; }
.online-dot { position: absolute; right: -2px; bottom: -2px; width: .7rem; height: .7rem; border-radius: 50%; background: #9ca3af; border: 2px solid var(--surface, #fff); }
.online-dot.is-on { background: #16a34a; }
.online-name { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.online-name small { color: var(--muted); }
.online-state { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.online-state.is-on { color: #15803d; font-weight: 600; }
.deal-chain .card-body { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .7rem 1rem; }
.chain-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chain { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; margin: 0; padding: 0; counter-reset: step; }
.chain li { display: flex; align-items: center; }
.chain li + li::before { content: "→"; color: var(--muted); margin-right: .4rem; }
.chain a, .chain button, .chain li > span { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .7rem; border-radius: 999px;
  border: 1px dashed var(--border); background: transparent; color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer; text-decoration: none; }
.chain li.done a { border-style: solid; border-color: #16a34a; color: #15803d; background: rgba(22,163,74,.07); font-weight: 600; }
.chain li.skip > span { opacity: .5; cursor: default; }
.chain button:hover { border-color: var(--primary, #15803d); color: var(--primary, #15803d); }
.chain form { margin: 0; }
.static-value { padding: .55rem 0; }
.steps-list { margin: 0; padding-left: 1.3rem; display: grid; gap: .5rem; }
.steps-list .btn { margin-left: .4rem; vertical-align: middle; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2::after { content: " ▾"; color: var(--muted); }

/* ===================== round 9: sidebar, logo, dashboard, phone + button, dark theme ===================== */
.brand { position: relative; display: flex; align-items: center; }
.brand > a { flex: 1; min-width: 0; }
.brand a.has-logo { padding: .55rem .7rem .55rem .85rem; }
.brand-logo { display: block; width: 100%; max-width: 100%; max-height: 64px; object-fit: contain; object-position: left center;
              image-rendering: auto; }
.brand-icon { display: none; width: 36px; height: 36px; border-radius: 8px; }
.sb-toggle-form { margin: 0; padding-right: .35rem; }
.sb-toggle { width: 28px; height: 28px; color: var(--muted); border-radius: 6px; }
.sb-toggle .icon { width: 16px; height: 16px; transition: transform .15s; }
.nav-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar { box-shadow: 0 1px 0 var(--border), 0 4px 14px rgba(16, 24, 40, .04); }

@media (min-width: 981px) {
  body.sb-collapsed { --sidebar-w: 68px; }
  body.sb-collapsed .brand { flex-direction: column; gap: .3rem; padding: .45rem 0; }
  body.sb-collapsed .brand a.has-logo, body.sb-collapsed .brand > a { padding: .2rem; justify-content: center; }
  body.sb-collapsed .brand-logo, body.sb-collapsed .brand > a > span { display: none; }
  body.sb-collapsed .brand-icon { display: block; }
  body.sb-collapsed .sb-toggle-form { padding: 0; }
  body.sb-collapsed .sb-toggle .icon { transform: rotate(180deg); }
  body.sb-collapsed .nav { padding: .25rem .45rem; }
  body.sb-collapsed .nav-link { justify-content: center; padding: .6rem 0; }
  body.sb-collapsed .nav-link span, body.sb-collapsed .nav-label, body.sb-collapsed .user-meta { display: none; }
  body.sb-collapsed .sidebar-user { flex-direction: column; gap: .35rem; padding: .6rem .3rem; }
  body.sb-collapsed .user-chip { justify-content: center; flex: none; }
  .sidebar, .main { transition: width .15s ease, margin-left .15s ease; }
}
@media (max-width: 980px) { .sb-toggle-form { display: none; } }

/* greeting next to the title */
.greeting { display: inline-flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; margin-left: .35rem; padding-left: .8rem;
            border-left: 1px solid var(--border); }
.greet-hi { font-weight: 600; color: var(--text); }
.greet-date { color: var(--muted); font-size: .9rem; }
@media (max-width: 760px) { .greeting { margin-left: 0; padding-left: 0; border-left: 0; width: 100%; } .greet-date { font-size: .8rem; } }

/* eight equal cards: two rows of four */
.kpis.kpis-8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis.kpis-8 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpis-8 .kpi { border-color: var(--border); }
.kpi-label { display: flex; align-items: center; gap: .45rem; }
.kpi-label .icon { width: 16px; height: 16px; color: var(--muted); vertical-align: 0; }
.kpi-value.is-zero { color: var(--muted); }
.kpi-value.is-red { color: #c62828; }
.kpi-value.is-orange { color: #c2410c; }
.kpi-value.is-green { color: #15803d; }

/* Täna / Tulekul + Kes on võrgus */
.dash-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 1rem; margin: 0 0 1rem; align-items: start; }
.dash-row .online-card { margin-top: 0; }
@media (max-width: 980px) { .dash-row { grid-template-columns: 1fr; } }
.upcoming { list-style: none; margin: 0; padding: .25rem 0; }
.upcoming li a { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.1rem; color: var(--text); text-decoration: none;
                 border-top: 1px solid var(--border); }
.upcoming li:first-child a { border-top: 0; }
.upcoming li a:hover { background: var(--surface-2); }
.up-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none;
           background: var(--surface-2); color: var(--c, var(--text-2)); }
.up-red .up-icon { background: rgba(198, 40, 40, .1); color: #c62828; }
.up-orange .up-icon { background: rgba(194, 65, 12, .1); color: #c2410c; }
.up-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.up-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-text small { color: var(--muted); }
.up-when { text-align: right; font-weight: 600; font-size: .88rem; white-space: nowrap; display: flex; flex-direction: column; }
.up-when small { color: var(--muted); font-weight: 400; }
.up-red .up-when { color: #c62828; }

/* phone: floating + button */
.fab { display: none; }
@media (max-width: 760px) {
  .fab { display: block; position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 60; }
  .fab-btn { width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--primary); color: #fff;
             box-shadow: 0 6px 20px rgba(23, 105, 58, .45); display: grid; place-items: center; cursor: pointer; }
  .fab-btn .icon { width: 26px; height: 26px; stroke-width: 2.4; transition: transform .15s; }
  .fab.open .fab-btn .icon { transform: rotate(45deg); }
  .fab-menu { position: absolute; right: 0; bottom: 70px; display: flex; flex-direction: column; gap: .45rem; align-items: flex-end; }
  .fab-menu a { display: inline-flex; align-items: center; gap: .55rem; padding: .6rem .95rem; border-radius: 999px;
                background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); font-weight: 600;
                white-space: nowrap; text-decoration: none; border: 1px solid var(--border); }
  .fab-menu a .icon { color: var(--primary); }
  .fab-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 59; }
  .content { padding-bottom: 6rem; }
}

/* ===================== dark theme ===================== */
[data-theme="dark"] {
  --bg: #0f1215; --surface: #171b20; --surface-2: #1d2228; --border: #2a3038; --border-strong: #39414b;
  --text: #e7eaee; --text-2: #c2c8d0; --muted: #8b949e;
  --primary: #3fb46f; --primary-hover: #57c583; --primary-soft: rgba(63, 180, 111, .14); --focus: #57c583;
  --danger: #f27b70; --danger-soft: rgba(242, 123, 112, .12); --warning: #f0b45a; --warning-soft: rgba(240, 180, 90, .12);
  --success: #5fd08f; --success-soft: rgba(95, 208, 143, .12); --info: #57c583; --info-soft: rgba(63, 180, 111, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

[data-theme="dark"] .btn-primary { color: #0b1a10; }
[data-theme="dark"] .table tbody tr:hover { background: #1b2026; }
[data-theme="dark"] .table tr.is-overdue td, [data-theme="dark"] .table-responsive tr.is-overdue { background: rgba(198, 40, 40, .1); }
[data-theme="dark"] .badge-draft, [data-theme="dark"] .badge-neutral { background: #262c33; color: #c2c8d0; }
[data-theme="dark"] .badge-cancelled, [data-theme="dark"] .badge-declined, [data-theme="dark"] .badge-archived { background: #262c33; color: #8b949e; }
[data-theme="dark"] .badge-credited, [data-theme="dark"] .badge-credit_note { background: rgba(168, 85, 247, .16); color: #d8b4fe; }
[data-theme="dark"] .alert-error { border-color: rgba(242, 123, 112, .35); } [data-theme="dark"] .alert-warning { border-color: rgba(240, 180, 90, .35); }
[data-theme="dark"] .alert-info, [data-theme="dark"] .alert-success { border-color: rgba(63, 180, 111, .35); }
[data-theme="dark"] .alert-preview, [data-theme="dark"] .cal-row-system { background: rgba(198, 40, 40, .14); color: #fecaca; }
[data-theme="dark"] .cal-row-system small { color: #fecaca; }
[data-theme="dark"] .tag-red { background: rgba(198,40,40,.16); color: #fca5a5; } [data-theme="dark"] .tag-orange { background: rgba(194,65,12,.18); color: #fdba74; }
[data-theme="dark"] .tag-blue { background: rgba(29,78,216,.2); color: #93c5fd; } [data-theme="dark"] .tag-activity, [data-theme="dark"] .combo-tag-stock, [data-theme="dark"] .stock-badge { background: rgba(63,180,111,.14); color: #86efac; }
[data-theme="dark"] .stock-badge.is-short { background: rgba(198,40,40,.16); color: #fca5a5; }
[data-theme="dark"] .price-table input.price-input.changed { background: rgba(63,180,111,.12); }
[data-theme="dark"] .kpi-value.is-red, [data-theme="dark"] .up-red .up-when { color: #f87171; } [data-theme="dark"] .kpi-value.is-orange { color: #fb923c; } [data-theme="dark"] .kpi-value.is-green { color: #4ade80; }
[data-theme="dark"] .online-state.is-on { color: #4ade80; } [data-theme="dark"] .chain li.done a { color: #4ade80; border-color: #22c55e; }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
[data-theme="dark"] .logo-preview, [data-theme="dark"] .avatar.has-img, [data-theme="dark"] .avatar img { background: #fff; border-radius: 6px; }
[data-theme="dark"] .maker-logo:not(:has(img)) { background: var(--surface-2); }
[data-theme="dark"] .logo-light { display: none !important; } [data-theme="dark"] .logo-dark { display: block; }
[data-theme="dark"] .pdf-preview { border-color: var(--border); }
[data-theme="dark"] .cal-cell.is-holiday .cal-daynum, [data-theme="dark"] .cal-holiday { color: #f87171; }
[data-theme="dark"] .fab-btn { color: #0b1a10; }
@media (prefers-color-scheme: dark) {
[data-theme="auto"] {
  --bg: #0f1215; --surface: #171b20; --surface-2: #1d2228; --border: #2a3038; --border-strong: #39414b;
  --text: #e7eaee; --text-2: #c2c8d0; --muted: #8b949e;
  --primary: #3fb46f; --primary-hover: #57c583; --primary-soft: rgba(63, 180, 111, .14); --focus: #57c583;
  --danger: #f27b70; --danger-soft: rgba(242, 123, 112, .12); --warning: #f0b45a; --warning-soft: rgba(240, 180, 90, .12);
  --success: #5fd08f; --success-soft: rgba(95, 208, 143, .12); --info: #57c583; --info-soft: rgba(63, 180, 111, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

[data-theme="auto"] .btn-primary { color: #0b1a10; }
[data-theme="auto"] .table tbody tr:hover { background: #1b2026; }
[data-theme="auto"] .table tr.is-overdue td, [data-theme="auto"] .table-responsive tr.is-overdue { background: rgba(198, 40, 40, .1); }
[data-theme="auto"] .badge-draft, [data-theme="auto"] .badge-neutral { background: #262c33; color: #c2c8d0; }
[data-theme="auto"] .badge-cancelled, [data-theme="auto"] .badge-declined, [data-theme="auto"] .badge-archived { background: #262c33; color: #8b949e; }
[data-theme="auto"] .badge-credited, [data-theme="auto"] .badge-credit_note { background: rgba(168, 85, 247, .16); color: #d8b4fe; }
[data-theme="auto"] .alert-error { border-color: rgba(242, 123, 112, .35); } [data-theme="auto"] .alert-warning { border-color: rgba(240, 180, 90, .35); }
[data-theme="auto"] .alert-info, [data-theme="auto"] .alert-success { border-color: rgba(63, 180, 111, .35); }
[data-theme="auto"] .alert-preview, [data-theme="auto"] .cal-row-system { background: rgba(198, 40, 40, .14); color: #fecaca; }
[data-theme="auto"] .cal-row-system small { color: #fecaca; }
[data-theme="auto"] .tag-red { background: rgba(198,40,40,.16); color: #fca5a5; } [data-theme="auto"] .tag-orange { background: rgba(194,65,12,.18); color: #fdba74; }
[data-theme="auto"] .tag-blue { background: rgba(29,78,216,.2); color: #93c5fd; } [data-theme="auto"] .tag-activity, [data-theme="auto"] .combo-tag-stock, [data-theme="auto"] .stock-badge { background: rgba(63,180,111,.14); color: #86efac; }
[data-theme="auto"] .stock-badge.is-short { background: rgba(198,40,40,.16); color: #fca5a5; }
[data-theme="auto"] .price-table input.price-input.changed { background: rgba(63,180,111,.12); }
[data-theme="auto"] .kpi-value.is-red, [data-theme="auto"] .up-red .up-when { color: #f87171; } [data-theme="auto"] .kpi-value.is-orange { color: #fb923c; } [data-theme="auto"] .kpi-value.is-green { color: #4ade80; }
[data-theme="auto"] .online-state.is-on { color: #4ade80; } [data-theme="auto"] .chain li.done a { color: #4ade80; border-color: #22c55e; }
[data-theme="auto"] input, [data-theme="auto"] select, [data-theme="auto"] textarea { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
[data-theme="auto"] .logo-preview, [data-theme="auto"] .avatar.has-img, [data-theme="auto"] .avatar img { background: #fff; border-radius: 6px; }
[data-theme="auto"] .maker-logo:not(:has(img)) { background: var(--surface-2); }
[data-theme="auto"] .logo-light { display: none !important; } [data-theme="auto"] .logo-dark { display: block; }
[data-theme="auto"] .pdf-preview { border-color: var(--border); }
[data-theme="auto"] .cal-cell.is-holiday .cal-daynum, [data-theme="auto"] .cal-holiday { color: #f87171; }
[data-theme="auto"] .fab-btn { color: #0b1a10; }
}
.logo-dark { display: none !important; }
[data-theme="dark"] .logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) { [data-theme="auto"] .logo-dark { display: block !important; } }
body.sb-collapsed .brand-logo.logo-dark, body:not(.sb-collapsed) .brand-icon.logo-dark { display: none !important; }
@media (max-width: 980px) { .brand-icon.logo-dark { display: none !important; } }
/* Tootjad ja hinnakirjad (one section) */
.card-grid:has(.maker-files) { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.maker-card { flex-direction: column; gap: 0; padding: 0; align-items: stretch; }
.maker-head { display: flex; gap: .9rem; padding: 1rem; color: inherit; text-decoration: none; align-items: flex-start; }
.maker-head:hover { text-decoration: none; }
.maker-head:hover strong { color: var(--primary); }
.maker-files { border-top: 1px solid var(--border); padding: .45rem .6rem .6rem; display: flex; flex-direction: column; gap: 2px; }
.maker-file { display: flex; align-items: center; gap: .55rem; padding: .35rem .4rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.maker-file:hover { background: var(--surface-2); text-decoration: none; }
.maker-file .file-ext { width: 34px; height: 30px; font-size: .62rem; border-radius: 6px; }
.maker-file-name { display: flex; flex-direction: column; min-width: 0; font-size: .9rem; line-height: 1.25; }
.maker-file-name small { color: var(--muted); font-size: .76rem; }
.maker-more, .maker-add { font-size: .84rem; padding: .3rem .4rem; }
.maker-add { display: inline-flex; align-items: center; gap: .35rem; color: var(--primary); margin-top: .15rem; }
.maker-add .icon { width: 15px; height: 15px; }
.maker-nofiles { font-size: .85rem; padding: .3rem .4rem; }
.badge-pria { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; font-size: .7rem; vertical-align: 1px; margin-left: .3rem; }
[data-theme="dark"] .badge-pria { background: rgba(56,189,248,.14); color: #7dd3fc; border-color: rgba(56,189,248,.3); }
@media (prefers-color-scheme: dark) { [data-theme="auto"] .badge-pria { background: rgba(56,189,248,.14); color: #7dd3fc; border-color: rgba(56,189,248,.3); } }
.pria-check { align-items: flex-start !important; }
.pria-check span { display: flex; flex-direction: column; }
.combo-tag-pria { background: #e0f2fe; color: #075985; }
[data-theme="dark"] .combo-tag-pria { background: rgba(56,189,248,.14); color: #7dd3fc; }
.einv-alert ul { margin: .35rem 0 0; padding-left: 1.2rem; }
/* Kliendid: what each client has */
.chip-list { display: flex; flex-wrap: wrap; gap: .25rem; }
.chip { display: inline-block; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
        font-size: .8rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-more { color: var(--muted); }
.park-count { display: inline-flex; align-items: center; gap: .3rem; font-weight: 700; color: var(--primary); }
.park-count .icon { width: 16px; height: 16px; }
/* Masinapark */
.park-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 980px) { .park-layout { grid-template-columns: 1fr; } }
.park-client-list { list-style: none; margin: 0; padding: .3rem; max-height: 70vh; overflow-y: auto; }
.park-client-list a { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem .6rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.park-client-list a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.park-client-list a strong { color: var(--primary); }
.park-client-list a:hover { background: var(--surface-2); }
.park-client-list li.active a { background: var(--primary-soft); font-weight: 600; }
/* Kliendibaas: KLIENT label */
.badge-client { background: #15803d; color: #fff; font-size: .68rem; letter-spacing: .04em; padding: .12rem .45rem; border-radius: 4px; text-decoration: none; margin-left: .35rem; vertical-align: 1px; }
.badge-client:hover { background: #166534; text-decoration: none; color: #fff; }
.quiet-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.quiet-row input[type=number] { width: 4.5rem; }
.list-intro { margin: .7rem 1.25rem .5rem; }
.badge-kind { background: var(--surface-2); color: var(--muted); font-size: .68rem; }
.row-actions { width: 1%; white-space: nowrap; text-align: right; }
.row-actions .btn-icon { color: var(--muted); }
.row-actions .btn-icon:hover { color: var(--danger); }
/* Toetused */
.grant-list { list-style: none; margin: 0; padding: 0; }
.grant { display: flex; align-items: center; gap: .9rem; padding: .8rem 1.1rem; border-top: 1px solid var(--border); }
.grant:first-child { border-top: 0; }
.grant-src { flex: none; min-width: 58px; text-align: center; font-size: .72rem; font-weight: 700; letter-spacing: .04em;
             padding: .25rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }
.grant-open .grant-src { background: #15803d; color: #fff; }
.grant-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.grant-title { font-weight: 600; color: var(--text); }
.grant-title:hover { color: var(--primary); }
.grant-note { color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.grant-when { flex: none; text-align: right; display: flex; flex-direction: column; min-width: 120px; }
.grant-status { font-weight: 700; font-size: .85rem; }
.grant-when small { color: var(--muted); }
.grant-open .grant-status { color: #15803d; } .grant-upcoming .grant-status { color: #c2410c; }
.grant-closed .grant-status, .grant-unknown .grant-status { color: var(--muted); }
.grant-closed .grant-title { color: var(--text-2); font-weight: 500; }
.badge-new { background: #fde68a; color: #78350f; font-size: .66rem; align-self: flex-start; }
.star { font-size: 1.15rem; color: var(--border-strong); background: none; border: 0; cursor: pointer; }
.star.on { color: #eab308; }
@media (max-width: 760px) { .grant { flex-wrap: wrap; } .grant-when { text-align: left; min-width: 0; } }
[data-theme="dark"] .grant-open .grant-status { color: #4ade80; } [data-theme="dark"] .badge-new { background: rgba(234,179,8,.2); color: #fde68a; }
