/* Toimari – ulkoasu. Raikas valko-sininen paletti (D-005), järjestelmäfontit (toimii ilman verkkoa). */

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f0f4fa;
  --border: #dde5ef;
  --text: #16202e;
  --text-2: #5b6b80;
  --brand: #1f63d1;
  --brand-strong: #164ea8;
  --brand-soft: #e7f0fd;
  --accent: #1f63d1;
  --ok: #2f8a5b;
  --warn: #b7791f;
  --bad: #c0392b;
  --sidebar-bg: #ffffff;
  --sidebar-border: #e3e9f2;
  --sidebar-text: #2a3a50;
  --sidebar-muted: #8796aa;
  --sidebar-active: #e7f0fd;
  --sidebar-active-text: #164ea8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(22, 32, 46, .05), 0 2px 8px rgba(22, 32, 46, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1620; --surface: #16202c; --surface-2: #1b2633; --border: #283546;
    --text: #e6edf6; --text-2: #93a3b8; --brand: #6aa7ff; --brand-strong: #8fbcff;
    --brand-soft: #1a2d47; --accent: #6aa7ff; --sidebar-bg: #121b26; --sidebar-border: #223043;
    --sidebar-text: #d5deea; --sidebar-muted: #7f90a6; --sidebar-active: #1a2d47;
    --sidebar-active-text: #ffffff; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1620; --surface: #16202c; --surface-2: #1b2633; --border: #283546;
  --text: #e6edf6; --text-2: #93a3b8; --brand: #6aa7ff; --brand-strong: #8fbcff;
  --brand-soft: #1a2d47; --accent: #6aa7ff; --sidebar-bg: #121b26; --sidebar-border: #223043;
  --sidebar-text: #d5deea; --sidebar-muted: #7f90a6; --sidebar-active: #1a2d47;
  --sidebar-active-text: #ffffff; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.35rem; font-weight: 650; }
h2 { font-size: 1rem; font-weight: 620; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }

.icon { width: 20px; height: 20px; flex: none; }
.icon-lg { width: 32px; height: 32px; }
.icon-xl { width: 44px; height: 44px; }

/* ---------- Rakenne ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex: none; background: var(--sidebar-bg); color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2f7cf6, #164ea8); color: #fff; font-weight: 800; font-size: 1.1rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.05rem; }
.brand-text small { color: var(--sidebar-muted); font-size: .78rem; }

.nav { padding: 4px 12px 16px; flex: 1; }
.nav-section { margin-top: 14px; }
.nav-heading {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--sidebar-muted); padding: 0 10px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--sidebar-text); font-size: .92rem;
}
.nav-link:hover { background: var(--sidebar-active); text-decoration: none; }
.nav-link.is-active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 600; }
.nav-future .nav-link { color: var(--sidebar-muted); }
.nav-badge {
  margin-left: auto; font-size: .68rem; padding: 1px 6px; border-radius: 99px;
  border: 1px solid var(--sidebar-border); color: var(--sidebar-muted);
}
.sidebar-foot { padding: 12px 22px 18px; color: var(--sidebar-muted); font-size: .75rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px;
  border-bottom: 1px solid var(--border); background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.topbar-right { margin-left: auto; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: .9rem; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; font-size: .85rem;
}
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer;
}
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; }

/* ---------- Komponentit ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; margin-bottom: 20px;
  border-radius: var(--radius); background: var(--brand-soft); color: var(--text);
  border: 1px solid var(--border);
}
.notice .icon { color: var(--brand); margin-top: 2px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { font-size: .82rem; color: var(--text-2); }
.kpi-value { font-size: 1.75rem; font-weight: 680; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table thead th { font-size: .78rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.table tfoot th { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg-btn {
  border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: .82rem;
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
}
.seg-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.empty { display: grid; place-items: center; text-align: center; padding: 28px 12px; color: var(--text-2); }
.empty .icon { color: var(--border); margin-bottom: 6px; }
.empty p { margin: 0; max-width: 32ch; font-size: .9rem; }

.pill { font-size: .75rem; padding: 2px 9px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.pill-muted { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

.placeholder { max-width: 640px; padding: 32px; }
.placeholder-icon { color: var(--brand); margin-bottom: 12px; }
.placeholder h2 { font-size: 1.15rem; margin-bottom: 6px; }
.checklist { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: center; }
.checklist .icon { color: var(--ok); width: 18px; height: 18px; }

/* ---------- Painikkeet, työkalurivi, lomakkeet ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: .9rem; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); }
.back { font-size: .85rem; color: var(--text-2); }
.back::before { content: "← "; }
.topbar-title .back { flex-basis: 100%; }

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 1; min-width: 0; }
.filters .search { flex: 1; min-width: 180px; max-width: 360px; }

input[type=text], input[type=search], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], select, textarea {
  font: inherit; font-size: .92rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
.filters input, .filters select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: .88rem; color: var(--text-2); cursor: pointer; }

.card-flush { padding: 4px 0; }
.card-flush .table th:first-child, .card-flush .table td:first-child { padding-left: 20px; }
.card-flush .table th:last-child, .card-flush .table td:last-child { padding-right: 20px; }
.table-click tbody tr { cursor: pointer; }
.table-click tbody tr:hover td { background: var(--surface-2); }
.table td .pill { margin-left: 6px; }

.flash {
  display: flex; gap: 8px; align-items: center; padding: 10px 14px; margin-bottom: 16px;
  border-radius: 10px; background: #e8f6ee; color: #1f6b43; border: 1px solid #cfe9da; font-size: .9rem;
}
.flash .icon { width: 18px; height: 18px; }

.form-card { max-width: 760px; padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: .84rem; font-weight: 600; color: var(--text); }
.req { color: var(--bad); }
.field-hint { font-size: .78rem; color: var(--text-2); }
.field-error { font-size: .8rem; color: var(--bad); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--bad); }
.field-check { justify-content: flex-end; padding-bottom: 8px; }
.form-alert { padding: 10px 12px; margin-bottom: 16px; border-radius: 8px; background: #fdecea; color: var(--bad); font-size: .9rem; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

.form-section { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 8px 0 -4px; padding-top: 12px; border-top: 1px solid var(--border); }
.table-wrap { overflow-x: auto; }
.col-code { width: 1%; white-space: nowrap; }
.row-count td { border-bottom: none; cursor: default; }
.warn-text { color: var(--warn); font-size: .85rem; }
.type { font-size: .78rem; padding: 2px 8px; border-radius: 99px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.type-own { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.type-fee { background: #fff4e0; color: #8a5a10; border-color: transparent; }

/* Järjestettävät otsikot */
th.sortable a { color: inherit; display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
th.sortable a:hover { color: var(--text); text-decoration: none; }
th.num.sortable a { justify-content: flex-end; }
.sort-ind { font-size: .7rem; opacity: .35; }
th.is-sorted { color: var(--brand); }
th.is-sorted .sort-ind { opacity: 1; }

/* Kategorian pikavalinta listassa */
.col-category { width: 1%; }
.inline-select { width: auto; min-width: 150px; padding: 4px 8px; font-size: .86rem; background: transparent; border-color: transparent; cursor: pointer; }
.inline-select:hover, .inline-select:focus { border-color: var(--border); background: var(--surface); }
.inline-select.is-empty { color: var(--warn); border-color: var(--border); border-style: dashed; }
.inline-select.is-saved { animation: saved 1.2s ease; }
.inline-select.is-failed { border-color: var(--bad); border-style: solid; color: var(--bad); background: #fdecea; }
@keyframes saved { 0% { box-shadow: 0 0 0 3px rgba(47,138,91,.45); border-color: var(--ok); } 100% { box-shadow: none; } }

.col-pull { width: 1%; text-align: center; }
th.col-pull a { justify-content: center; }
.pull-check { display: inline-grid; place-items: center; width: 34px; height: 30px; border-radius: 6px; cursor: pointer; }
.pull-check:hover { background: var(--brand-soft); }
.pull-check input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); }
.pull-check.is-saved { animation: saved 1.2s ease; }
.pull-check.is-failed { background: #fdecea; outline: 2px solid var(--bad); }
.field-check { gap: 8px; }

/* Poistopainike ja ilmoitusrivi */
.col-del { width: 1%; text-align: center; padding-left: 0 !important; }
.del-btn {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid transparent; background: transparent;
  color: var(--bad); font-size: 1rem; font-weight: 700; line-height: 1; cursor: pointer; opacity: .55;
}
tr:hover .del-btn { opacity: 1; }
.del-btn:hover, .del-btn:focus-visible { opacity: 1; background: #fdecea; border-color: #f5c6c0; }
.row-notice td { font-size: .88rem; padding: 10px 20px !important; cursor: default; }
.row-notice-deleted td { background: #e8f6ee; color: #1f6b43; }
.row-notice-deactivated td { background: #fff4e0; color: #8a5a10; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Varmistusikkuna */
.confirm-dialog { border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px 18px; max-width: 420px; width: calc(100% - 32px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.confirm-dialog::backdrop { background: rgba(15, 22, 32, .45); }
.confirm-msg { margin: 0 0 20px; font-size: 1rem; line-height: 1.45; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.confirm-actions .btn { min-width: 84px; justify-content: center; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #a3301f; }

/* ---------- Tilaukset ---------- */
.new-order { margin-bottom: 16px; }
.new-order select { max-width: 360px; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab { padding: 8px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: .92rem; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.status { font-size: .78rem; padding: 2px 9px; border-radius: 99px; white-space: nowrap; font-weight: 600; }
.status-draft { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.status-confirmed { background: var(--brand-soft); color: var(--brand-strong); }
.status-in_production { background: #fff4e0; color: #8a5a10; }
.status-delivered, .status-invoiced { background: #e8f6ee; color: #1f6b43; }
.status-cancelled { background: #fdecea; color: var(--bad); text-decoration: line-through; }
.pill-warn { background: #fff4e0; color: #8a5a10; }

.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.order-main { display: grid; gap: 16px; min-width: 0; }
.order-head-row { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-end; }
.order-orderer { min-width: 260px; flex: 1; }
.order-status, .order-delivery { display: flex; flex-direction: column; gap: 6px; }
.order-delivery { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
.order-delivery .field-label { flex-basis: 100%; }
.delivery-date { font-size: 1.05rem; }
.internal-note { margin: 12px 0 0; }
.order-head p { margin: 8px 0 0; }

.add-line { display: flex; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.add-line-search { position: relative; flex: 1; }
.qty-input { width: 80px !important; text-align: right; }
.qty-line { padding: 5px 8px; }
.suggestions { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; }
.sugg-list { list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 22, 32, .15); max-height: 340px; overflow-y: auto; }
.sugg-item { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; width: 100%; text-align: left; padding: 8px 10px;
  border: 0; background: transparent; border-radius: 6px; cursor: pointer; font: inherit; font-size: .9rem; color: var(--text); }
.sugg-item:hover, .sugg-item:focus { background: var(--brand-soft); outline: none; }
.sugg-code { color: var(--text-2); font-size: .82rem; }
.sugg-price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sugg-price em { font-style: normal; font-size: .72rem; color: var(--ok); }
.sugg-empty { padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.add-line-search:not(:focus-within) .suggestions:not(:hover) { display: none; }
.add-line { flex-wrap: wrap; }
.add-preview { flex-basis: 100%; min-height: 1.2em; font-size: .86rem; }
.add-preview:empty { display: none; }
.preview-ok { color: var(--ok); font-weight: 600; }
.preview-warn { color: var(--warn); }
.preview-bad { color: var(--bad); font-weight: 600; }
.kbd-help { padding: 0 20px 10px; margin-top: -6px; }
kbd { font-family: inherit; font-size: .75rem; padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; background: var(--surface); color: var(--text); }
.sugg-item:focus { background: var(--brand); color: #fff; }
.sugg-item:focus .sugg-code, .sugg-item:focus em { color: #fff; }
.price-source { font-size: .72rem; color: var(--text-2); }
.src-customer { color: var(--ok); font-weight: 600; }
.src-none { color: var(--bad); }

.order-totals { padding: 12px 20px 16px; display: grid; gap: 4px; justify-items: end; border-top: 1px solid var(--border); }
.tot-row { display: flex; gap: 24px; justify-content: flex-end; min-width: 300px; font-variant-numeric: tabular-nums; font-size: .9rem; }
.tot-row span:last-child { min-width: 90px; text-align: right; }
.tot-grand { font-size: 1.1rem; font-weight: 700; padding-top: 6px; }
.order-actions { align-items: center; flex-wrap: wrap; }
.order-actions form { margin: 0; }
.push-right { margin-left: auto !important; }
.saved-note { color: var(--ok); font-weight: 500; font-size: .8rem; }

/* Kalenteri */
.order-calendar { position: sticky; top: 76px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { font-size: 1rem; }
.cal-head .icon-btn { width: 32px; height: 32px; font-size: 1.2rem; }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { font-size: .72rem; font-weight: 600; color: var(--text-2); padding: 4px 0; text-transform: uppercase; }
.cal td { padding: 2px; text-align: center; }
.cal-wk { width: 26px; font-size: .7rem; color: var(--text-2); }
.cal-day { width: 100%; aspect-ratio: 1; border: 1px solid transparent; border-radius: 8px; background: transparent;
  font: inherit; font-size: .9rem; color: var(--text); cursor: pointer; font-variant-numeric: tabular-nums; }
.cal-day:hover:not(:disabled) { background: var(--brand-soft); }
.cal-day.is-other { color: var(--text-2); opacity: .45; }
.cal-day.is-weekend { color: var(--text-2); }
.cal-day.is-past { opacity: .45; }
.cal-day.is-holiday { color: var(--bad); font-weight: 700; }
.cal-day.is-eve { color: #b7791f; font-weight: 600; }
.cal-day.is-today { border-color: var(--brand); }
.cal-day.is-selected { background: var(--brand); color: #fff; opacity: 1; font-weight: 700; }
.cal-day:disabled { cursor: default; }
.cal-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-today { border: 1.5px solid var(--brand); }
.lg-sel { background: var(--brand); }
.lg-hol { background: var(--bad); opacity: .8; }
.customer-prices-card { margin-top: 16px; }
.customer-prices-card h2 { margin-bottom: 8px; }
.price-add { margin: 8px 0 12px; }
.price-add input[name=q] { max-width: 220px; }

@media (max-width: 1000px) {
  .order-layout { grid-template-columns: 1fr; }
  .order-calendar { position: static; order: -1; }
}

.toolbar-actions { display: flex; gap: 8px; }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--bad); background: #fdecea; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input[type=text] { flex: 1; min-width: 180px; width: auto; }
.inline-form select { width: auto; }
.cat-new { margin-bottom: 16px; }
.cat-new p { margin: 10px 0 0; }
.cat-row input[type=text] { max-width: 320px; }

/* ---------- Responsiivisuus ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .menu-btn { display: grid; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar-backdrop { display: none; }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 15; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }
  .user-name { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-card { padding: 18px; }
  .filters .search { max-width: none; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 1.35rem; }
}

/* Tilausrivien kategoriaotsikot (D-039) */
.table tr.group-row td { background: var(--brand-soft); color: var(--brand-strong); font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; padding: 5px 8px; }
/* Kategorioiden järjestysnapit */
.cat-move { display: inline-flex; gap: 2px; }
.cat-move button { min-width: 28px; }

/* Myyntirajaus (D-040) */
.pill-bad { background: #fde8e6; color: var(--bad); }
.table tr.row-bad td { background: rgba(192, 57, 43, .06); }
.perm-card { margin-top: 16px; max-width: 760px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong); font-size: .88rem; }
.chip-group { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.chip-x { border: 0; background: transparent; color: var(--bad); cursor: pointer; font-size: .85rem; padding: 0 6px; border-radius: 999px; }
.chip-x:hover { background: rgba(192, 57, 43, .12); }
.perm-add select { max-width: 460px; }
.check-inline { display: inline-flex; align-items: center; gap: 4px; font-size: .88rem; white-space: nowrap; }
.saved-tick { color: var(--ok); font-size: .8rem; font-weight: 500; margin-left: 8px; }

/* Tilaajan muut kuin toimituspäivät (D-042) */
.cal-day.is-nodelivery { opacity: .45; text-decoration: line-through; }
.weekday-checks, .chip-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.weekday-check, .chip-choice { position: relative; }
.weekday-check input, .chip-choice input { position: absolute; opacity: 0; }
.chip-choice span { display: inline-block; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; }
.chip-choice input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-choice input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.weekday-check span { display: inline-block; min-width: 42px; text-align: center; padding: 7px 0; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; }
.weekday-check input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.weekday-check input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Noutomyymälä näkyy vain, kun valittu nouto (D-044) */
.chip-choice input:disabled + span { opacity: .4; cursor: not-allowed; background: var(--surface-2); }
.chip-choice input:disabled:checked + span { background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand-strong); opacity: 1; }

/* Tuotantolista (D-047) */
.prod-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prod-nav .icon-btn { text-decoration: none; font-size: 1.2rem; }
.prod-date-form input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.prod-drafts { margin: 12px 0 0; }
.prod-head { padding: 16px 20px 6px; }
.prod-head h2 { margin: 0 0 4px; font-size: 1.25rem; }
.prod-table .prod-qty { white-space: nowrap; font-size: 1.05rem; }
.prod-shares { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-2); }
.prod-shares strong { color: var(--text); }
.col-tick { width: 36px; text-align: center; }
.tick-box { display: inline-block; width: 16px; height: 16px; border: 1.5px solid var(--text-2); border-radius: 3px; }
.pull-mark { color: var(--brand); }
.print-only { display: none; }
@media print {
  body, .content, .main { background: #fff !important; color: #000; }
  .sidebar, .sidebar-backdrop, .topbar, .no-print { display: none !important; }
  .shell, .main, .content { display: block; padding: 0 !important; margin: 0 !important; }
  .card { box-shadow: none !important; border: 0 !important; }
  .prod-head { padding: 0 0 6px; }
  .table th, .table td { padding: 4px 6px; border-bottom: 1px solid #bbb; color: #000; }
  .table tr.group-row td { background: #eee !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table tr { break-inside: avoid; }
  .prod-shares, .muted { color: #333 !important; }
  .print-only { display: block; padding-top: 8px; }
  .table-wrap { overflow: visible !important; }
}

/* Lähetteet (D-049): korkeat rivit kynällä rastimiseen, yksi lähete per A4 */
.note { padding: 24px 28px; margin-bottom: 18px; }
.note-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 2px solid var(--text); padding-bottom: 10px; }
.note-title { font-size: 1.5rem; font-weight: 800; letter-spacing: .06em; }
.note-meta { display: grid; grid-template-columns: auto auto; gap: 2px 12px; margin: 0; font-size: .92rem; }
.note-meta dt { color: var(--text-2); }
.note-meta dd { margin: 0; text-align: right; }
.note-parties { display: flex; justify-content: space-between; gap: 20px; padding: 14px 0; }
.note-recipient { font-size: 1.15rem; font-weight: 700; }
.note-fulfillment { font-size: 1.05rem; align-self: center; border: 2px solid var(--text); border-radius: 8px; padding: 8px 14px; }
.note-notes { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.note-table { width: 100%; border-collapse: collapse; }
.note-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); border-bottom: 2px solid var(--text); padding: 6px 8px; }
.note-table td { height: 46px; padding: 4px 8px; border-bottom: 1px solid #9aa6b5; vertical-align: middle; font-size: 1rem; }
.note-table .num { text-align: right; white-space: nowrap; }
.note-tick { width: 64px; text-align: center !important; padding-left: 14px !important; }
.note-box { display: inline-block; width: 24px; height: 24px; border: 2px solid var(--text); border-radius: 4px; }
.note-qty { font-size: 1.15rem; }
.note-totals { text-align: right; padding-top: 10px; }
.note-grand { font-size: 1.1rem; font-weight: 700; margin-top: 4px; }
.note-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 36px; }
.note-sign div { border-top: 1px solid var(--text); padding-top: 4px; font-size: .8rem; color: var(--text-2); }
@media print {
  .note { padding: 0 !important; margin: 0 !important; break-after: page; }
  .note:last-of-type { break-after: auto; }
  .note-table td { height: 11mm; border-bottom: 1px solid #777; color: #000; }
  .note-table th, .note-head, .note-box, .note-fulfillment { border-color: #000 !important; color: #000; }
  .note-notes { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .note-table tr { break-inside: avoid; }
}
/* Suoratulostus (D-050) */
.print-day { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.print-day input[type=date] { width: auto; flex: 0 0 auto; }
.btn .icon, .print-btn .icon { width: 18px; height: 18px; vertical-align: -3px; }
.print-day input[type=date] { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.print-btn { text-decoration: none; }
/* Lähetteen tuoteryhmäotsikot (D-051): matalat välirivit */
.note-table tr.note-group td { height: auto; padding: 8px 8px 3px; border-bottom: 1px solid var(--text);
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
@media print {
  .note-table tr.note-group td { height: auto; padding: 2.5mm 2mm .8mm; border-bottom: 1px solid #000; color: #333; }
  .note-table tr.note-group { break-after: avoid; }
}

/* Kuormat (D-052) */
.note-parties { align-items: center; }
.note-load { margin-left: auto; font-size: 1.1rem; letter-spacing: .08em; border: 3px solid var(--text); border-radius: 8px; padding: 6px 14px; text-align: center; }
.note-load strong { display: block; font-size: 2.2rem; line-height: 1; letter-spacing: 0; }
.load-filter { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; margin-top: 10px; }
.chip-link { padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 500; background: var(--surface); }
.chip-link.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.order-load input { width: 80px; }
@media print { .note-load { border-color: #000 !important; color: #000; } }
/* Toistuva asiakasrivi lähetteen jokaisella tulostesivulla (D-052) */
.note-table tr.note-repeat th { display: none; }
@media print {
  .note-table thead { display: table-header-group; }
  .note-table tr.note-repeat th { display: table-cell; text-transform: none; letter-spacing: 0; font-size: 9.5pt; color: #000;
    border-bottom: 1px solid #000; padding: 0 0 2mm; }
  .note-repeat th > span { display: inline-block; }
  .note-repeat-who { font-weight: 700; font-size: 11pt; margin-right: 6mm; }
}
.store-load { display: inline-flex; align-items: center; gap: 6px; font-size: .92rem; }
.store-load input { width: 56px !important; min-width: 0 !important; flex: 0 0 auto !important; text-align: center; }
/* Noutomerkintä yhtä isona kuin kuorma (D-053) */
.note-pickup strong { font-size: 1.7rem; text-transform: uppercase; }
.note-load + .note-pickup { margin-left: 12px; }
/* Kuormat-sivu (D-055) */
.load-num { width: 64px !important; min-width: 0 !important; flex: 0 0 auto !important; text-align: center; }
.note-load-name { display: block; font-size: .75rem; letter-spacing: 0; margin-top: 2px; }

/* Tilaajan historia (D-057) */
.link-btn { border: 0; background: none; padding: 0; color: var(--brand); cursor: pointer; font: inherit; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.hist-actions { white-space: nowrap; }
.hist-actions form { display: inline; }
.hist-actions > * { margin-left: 4px; vertical-align: middle; }
.hist-order + .hist-order tr:first-child td { border-top: 1px solid var(--border); }
.hist-lines td { background: var(--surface-2); }
.mini-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.mini-table td { padding: 3px 8px; border-bottom: 1px dashed var(--border); }
.mini-table .num { text-align: right; white-space: nowrap; }
.hist-more { padding: 10px 16px; margin: 0; }
.heading-action { margin-left: 14px; }
.hist-btns { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: nowrap; }
.hist-btns form { margin: 0; }
/* Maksu noudettaessa (D-058) */
.note-pay { border: 3px solid var(--text); border-radius: 8px; padding: 8px 14px; margin-bottom: 10px; font-weight: 800; font-size: 1.1rem; letter-spacing: .04em; text-align: center; }
@media print { .note-pay { border-color: #000; color: #000; } }

/* Laskutus (D-062) */
.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 8px; }
.card-head-row .card-title, .card-pad { margin: 0; }
.card-pad { padding: 16px 20px 8px; }
.date-input { width: auto !important; flex: 0 0 auto !important; }
.inv-notice-form { margin-top: 12px; }
.inv-notice-form input { flex: 1; }
.invoice { padding: 28px 32px; }
.inv-head { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.inv-company-name { font-weight: 800; font-size: 1.1rem; margin-bottom: 28px; }
.inv-recipient { display: flex; flex-direction: column; gap: 2px; }
.inv-ytunnus { margin-top: 14px; }
.inv-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }
.inv-box dl { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--text); margin: 0; }
.inv-box dl > div { border: 1px solid var(--border); padding: 3px 8px; }
.inv-box dt { font-size: .7rem; color: var(--text-2); }
.inv-box dd { margin: 0; font-weight: 700; min-height: 1.2em; }
.inv-notice { border: 1px solid var(--text); padding: 8px 12px; margin: 18px 0 6px; font-weight: 600; }
.inv-table { width: 100%; border-collapse: collapse; margin-top: 18px; }
.inv-table th { font-size: .75rem; color: var(--text-2); text-align: left; border-bottom: 1px solid var(--text); padding: 6px; }
.inv-table td { padding: 6px; border-bottom: 1px solid var(--border); }
.inv-table .num { text-align: right; white-space: nowrap; }
.inv-table tfoot td { border-bottom: 0; }
.inv-vat td { color: var(--text-2); font-size: .9rem; }
.inv-total td { font-weight: 800; border-top: 2px solid var(--text) !important; font-size: 1.05rem; }
.inv-pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px; border: 2px solid var(--text); border-radius: 6px; padding: 12px 14px; margin-top: 22px; }
.inv-pay span { display: block; font-size: .7rem; color: var(--text-2); }
.inv-foot { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; border-top: 1px solid var(--text); margin-top: 24px; padding-top: 6px; color: var(--text-2); }
.journal { padding: 24px 28px; }
.journal-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline; }
.journal-head h2 { margin: 0; font-size: 1.4rem; }
.journal-period { text-align: center; margin: 4px 0 18px; }
.journal-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.journal-table th { text-align: left; border-bottom: 1px solid var(--text); padding: 4px 6px; font-size: .8rem; }
.journal-table td { padding: 3px 6px; vertical-align: top; }
.journal-table .num { text-align: right; white-space: nowrap; }
.journal-sum td { font-weight: 700; padding-bottom: 12px; }
.journal-total td { font-weight: 700; }
.journal-grand td { border-top: 1px solid var(--text); border-bottom: 1px solid var(--text); }
@media print {
  .invoice, .journal { padding: 0 !important; }
  .inv-box dl, .inv-notice, .inv-pay, .inv-table th, .inv-total td, .inv-foot { border-color: #000 !important; }
  .no-print-link { color: #000; text-decoration: none; }
  .journal-inv { break-inside: avoid; }
}
/* Laskutusajo (D-063) */
.run-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.run-row .icon-btn { text-decoration: none; font-size: 1.2rem; }
.run-month { min-width: 150px; text-align: center; }
.run-chips { width: auto; margin: 0 0 0 12px; }
.run-dates { margin-bottom: 6px; }
/* Suoritukset (D-064) */
.pay-form input { width: auto; }
.pay-inv { width: 170px !important; flex: 0 0 auto !important; }
.pay-amount { width: 210px !important; flex: 0 0 auto !important; }
.inv-payments { margin-top: 18px; padding-top: 10px; border-top: 1px dashed var(--border); }
.inv-payments h3 { font-size: 1rem; margin: 0 0 6px; display: flex; gap: 10px; align-items: center; }
.inv-payments form { margin-top: 8px; }
.status-paid { background: #1f6b43; color: #fff; }
.mail-to { width: 260px !important; flex: 0 0 auto !important; }

/* Laskun sivutus (D-066): maksutiedot viimeisen sivun alareunaan alatunnisteen yläpuolelle */
.inv-page { display: flex; flex-direction: column; margin-bottom: 18px; }
.inv-spacer { flex: 1 1 auto; min-height: 16px; }
.inv-pageno { float: right; font-size: .85rem; font-weight: 600; }
.inv-head-compact { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--text); padding-bottom: 6px; font-size: .9rem; }
.inv-head-compact .inv-pageno { float: none; margin-left: 14px; }
.inv-payments { padding: 16px 20px; margin-top: 0; border-top: 0; }
@media print {
  .inv-page { height: 270mm; overflow: hidden; margin: 0 !important; break-after: page; box-shadow: none; }
  .inv-page:last-of-type { break-after: auto; }
  .inv-table td { height: 6.6mm; padding: 0 6px; white-space: nowrap; vertical-align: middle; }
  .inv-table th { padding: 4px 6px; }
  .inv-pay { margin-top: 0; }
  .inv-foot { margin-top: 4mm; }
}
.inv-credit-note { grid-template-columns: 1fr; }
.credit-free input[name=free_desc] { flex: 1; min-width: 260px; }
/* Erillinen nimihaku (D-068) */
.search-panel { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: min(520px, 90vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 8px; }
.search-panel input { width: 100%; }
.search-panel .suggestions { position: static; box-shadow: none; border: 0; margin-top: 6px; }
.add-line-search { position: relative; }

/* Myynti (D-070) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; margin: 0; }
.kpi-label { font-size: .8rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi-value { font-size: 1.6rem; font-weight: 800; margin: 4px 0; }
.chg { font-weight: 700; }
.chg-up { color: var(--ok); }
.chg-down { color: var(--bad); }
.sales-table tr.is-weekend td { background: var(--surface-2); }
.sales-table tr.is-closed td { color: var(--text-2); }
.entry-table input { width: 110px; }
.entry-table td:last-child input { width: 100%; }

/* Kaaviot (D-072) – dataviz-paletti, validoitu (light #ffffff / dark #16202c) */
:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4;
  --viz-grid: #e8edf3; --viz-axis: #c3c9d2; --viz-muted: #7d8794;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
    --viz-grid: #232f3d; --viz-axis: #3a4757; --viz-muted: #8a97a8;
  }
}
:root[data-theme="dark"] {
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
  --viz-grid: #232f3d; --viz-axis: #3a4757; --viz-muted: #8a97a8;
}
.viz-card { padding: 18px 20px; }
.viz-head { padding: 0; margin-bottom: 6px; flex-wrap: wrap; }
.viz-head .load-filter { width: auto; margin: 0; }
.viz-root { position: relative; margin-top: 8px; }
.viz svg { display: block; overflow: visible; }
.viz-gridline { stroke: var(--viz-grid); stroke-width: 1; }
.viz-base { stroke: var(--viz-axis); stroke-width: 1; }
.viz-tick { fill: var(--viz-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-dot { stroke: var(--surface); stroke-width: 2; }
.viz-endlabel { fill: var(--text-2); font-size: 11.5px; font-weight: 600; }
.viz-cross { stroke: var(--viz-axis); stroke-width: 1; }
.viz-bar:focus { outline: none; stroke: var(--text); stroke-width: 1; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 6px; }
.viz-key { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 2px 0; font: inherit;
  font-size: .86rem; color: var(--text); cursor: pointer; }
.viz-key[disabled] { cursor: default; }
.viz-key.is-off { color: var(--text-2); text-decoration: line-through; }
.viz-key.is-off .viz-swatch { opacity: .3; }
.viz-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.viz-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: .82rem; min-width: 170px; }
.viz-tip div { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.viz-tip b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.viz-table { margin-top: 12px; }
.viz-filter { width: auto; margin: 4px 0 2px; }

/* Kirjautuminen ja käyttäjät (D-074) */
.login-body { background: var(--bg); min-height: 100vh; }
.login-shell { max-width: 400px; margin: 0 auto; padding: 12vh 16px 40px; }
.login-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 20px; }
.login-card { padding: 24px; }
.login-title { font-size: 1.3rem; margin: 0 0 14px; }
.login-form { display: grid; gap: 14px; }
.login-form input { font-size: 1rem; padding: 10px 12px; }
.login-btn { width: 100%; justify-content: center; padding: 11px; font-size: 1rem; margin-top: 4px; }
.login-help { text-align: center; margin: 16px 0 0; }
a.user-chip { text-decoration: none; color: inherit; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-right form { margin: 0; }
.orderer-bar { position: sticky; top: 0; z-index: 10; gap: 16px; padding-left: 20px; }
.orderer-bar .brand { padding: 0; margin: 0; }
.orderer-content { max-width: 1000px; margin: 0 auto; }
.account-card { max-width: 640px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.row-muted td { color: var(--text-2); }
@media (max-width: 640px) { .logout-btn { display: none; } }

/* Tilaajan tilaussivu (D-075) – tabletti edellä, isot kosketusalueet */
.portal-card { margin-bottom: 16px; }
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.day-grid form { margin: 0; }
.day-btn { width: 100%; min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; padding: 8px; }
.day-btn:hover, .day-btn:focus-visible { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft, rgba(42,120,214,.15)); }
.day-btn.has-order { border-color: var(--accent); background: var(--accent-soft, rgba(42,120,214,.08)); }
.day-wd { font-size: .85rem; color: var(--text-2); }
.day-date { font-size: 1.3rem; font-weight: 700; }
.day-note { font-size: .75rem; color: var(--accent); }
.day-holiday { color: #b45309; }
.order-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px;
  border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
a.order-row:hover, .order-row a.order-row-day:hover strong { color: var(--accent); }
.order-row-day, .order-row-status { display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; }
.order-row-status { align-items: flex-end; text-align: right; }
.status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--surface-2, #eef2f6); color: var(--text); }
.status-pill.status-draft { background: #fff4e0; color: #8a5300; }
.status-pill.status-confirmed { background: #e3f6ec; color: #0b6b3a; }
.status-pill.status-cancelled { background: #fde8e8; color: #9b1c1c; }
.portal-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 20px; }
.portal-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 16px; position: sticky; top: 64px; z-index: 4; }
.portal-tools input[type=search] { flex: 1 1 260px; font-size: 1rem; padding: 10px 12px; }
.portal-tools .load-filter { width: auto; margin: 0; }
.portal-tools .chip-link { font: inherit; cursor: pointer; }
.portal-group { margin-bottom: 12px; }
.portal-group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2);
  margin: 0; padding: 10px 16px 6px; }
.pitem { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px;
  border-top: 1px solid var(--border); }
.pitem.has-qty { background: var(--accent-soft, rgba(42,120,214,.06)); }
.pitem.has-qty .pitem-name { font-weight: 600; }
.pitem-name { flex: 1; cursor: pointer; }
.pitem-code { color: var(--text-2); font-variant-numeric: tabular-nums; margin-right: 4px; }
.qty-ctl { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.qty-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--text); touch-action: manipulation; }
.qty-btn:active { background: var(--surface-2, #eef2f6); }
.qty-input { width: 64px; height: 44px; text-align: center; font-size: 1.15rem; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.pitem.has-qty .qty-input { border-color: var(--accent); font-weight: 700; }
.pitem-unit { width: 28px; color: var(--text-2); font-size: .85rem; }
.portal-bar { position: sticky; bottom: 0; z-index: 6; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 10px; padding: 12px 16px; margin: 16px -4px 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px 12px 0 0; box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
.portal-actions { display: flex; gap: 8px; align-items: center; }
.portal-actions form { margin: 0; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }
.save-state { margin-left: 8px; font-size: .85rem; color: var(--text-2); }
.save-state.is-ok { color: #0b6b3a; }
.save-state.is-error { color: #9b1c1c; font-weight: 600; }
@media (max-width: 560px) {
  .pitem { flex-wrap: wrap; }
  .qty-ctl { margin-left: auto; }
  .portal-tools { top: 56px; }
  .order-row { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .orderer-bar { gap: 10px; padding-left: 12px; }
  .orderer-bar .brand-text, .orderer-bar .user-name { display: none; }
  .orderer-bar .topbar-title { min-width: 0; flex: 1; }
  .orderer-bar .topbar-title h1 { font-size: 1.15rem; white-space: normal; }
  .orderer-content { padding: 12px; }
  .day-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .day-btn { min-height: 64px; }
  .day-date { font-size: 1.1rem; }
}
