:root {
  --hf-space-1: 4px;
  --hf-space-2: 8px;
  --hf-space-3: 12px;
  --hf-space-4: 16px;
  --hf-space-5: 24px;
  --hf-space-6: 32px;
  --hf-control-sm: 32px;
  --hf-control: 40px;
  --hf-control-lg: 44px;
  --hf-z-sticky: 10;
  --hf-z-menu: 100;
  --hf-z-dialog: 300;
  --hf-z-toast: 400;
  --ink: #18221e;
  --muted: #6f7c75;
  --paper: #f4f1ea;
  --surface: #fffdf8;
  --line: #ddd8cd;
  --forest: #1f4b3b;
  --forest-deep: #15362b;
  --sage: #bfd3c5;
  --clay: #c76d45;
  --gold: #d3aa55;
  --shadow: 0 16px 40px rgba(28, 42, 35, .08);
  /* Backwards-compatible semantic aliases used by shared components. */
  --green: var(--forest);
  --cream: #f8f6f0;
  --line-strong: #b7c7c0;
  --accent: var(--clay);
  --panel-soft: #f4f8f5;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "Segoe UI", Arial, sans-serif; }
.preview-page { min-height: 100vh; }
.preview-topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px clamp(18px, 4vw, 56px); color: white; background: var(--forest-deep); }
.preview-topbar .brand { padding: 0; }
.preview-topbar .secondary { color: white; border-color: rgba(255, 255, 255, .55); background: transparent; }
.preview-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.preview-main { width: min(1180px, calc(100% - 32px)); margin: 28px auto 54px; }
.preview-hero { display: flex; align-items: end; justify-content: space-between; gap: 28px; }
.preview-hero h1 { margin: 6px 0 12px; color: white; font: 700 clamp(30px, 5vw, 54px)/1.05 Georgia, serif; }
.preview-hero .primary { flex: 0 0 auto; text-decoration: none; }
.preview-page .stat-card { display: grid; align-content: start; gap: 5px; min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 24px rgba(28, 42, 35, .05); }
.preview-page .stat-card small, .preview-page .stat-card span { display: block; color: var(--muted); }
.preview-page .stat-card strong { display: block; color: var(--forest-deep); font: 700 28px/1 Georgia, serif; }
.preview-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; margin-top: 18px; }
.preview-kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.preview-kanban > div { display: grid; align-content: start; gap: 9px; min-width: 0; padding: 12px; border-radius: 10px; background: var(--panel-soft); }
.preview-kanban article { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.preview-kanban span, .preview-kanban small, .preview-steps span { color: var(--muted); }
.preview-steps { display: grid; gap: 14px; padding-left: 22px; }
.preview-steps li { padding-left: 6px; }
.preview-steps b, .preview-steps span { display: block; }
.preview-steps span { margin-top: 3px; font-size: 13px; }
.preview-cta { margin-top: 18px; padding: 28px; border-radius: 18px; text-align: center; background: white; box-shadow: var(--shadow); }
.preview-cta .primary { display: inline-block; margin-top: 8px; text-decoration: none; }
@media (max-width: 800px) { .preview-grid { grid-template-columns: 1fr; } .preview-kanban { grid-template-columns: 1fr; } .preview-hero { align-items: stretch; flex-direction: column; } }
@media (max-width: 540px) { .preview-topbar { align-items: stretch; flex-direction: column; } .preview-actions { align-items: stretch; flex-direction: column; } .preview-main { width: min(100% - 20px, 1180px); margin-top: 12px; } .login-card { padding: 24px 20px; } }
.login-gate { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: rgba(21,54,43,.96); }
.login-gate[hidden] { display: none; }
.login-card { width: min(100%, 430px); display: grid; gap: 14px; padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 25px 70px rgba(0,0,0,.25); }
.login-card .brand-mark { justify-self: start; background: var(--forest-deep); }
.login-card h1 { margin: 0; font-size: 30px; }
.login-card label { display: grid; gap: 6px; font-weight: 650; }
.login-card form { display: grid; gap: 14px; }
.login-card form[hidden] { display: none; }
.login-card input { width: 100%; min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.password-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
.password-control input { border-radius: 8px 0 0 8px; }
.password-control button { padding: 0 11px; border: 1px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0; color: var(--forest); background: var(--panel-soft); font-size: 12px; }
.login-card .primary { width: 100%; }
.text-button { padding: 5px; border: 0; color: var(--forest); background: transparent; text-decoration: underline; }
.login-preview { display: grid; gap: 8px; padding-top: 15px; border-top: 1px solid var(--line); text-align: center; }
.login-preview span { font-weight: 650; }
.login-preview small { color: var(--muted); line-height: 1.45; }
.preview-link { display: block; text-decoration: none; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.user-badge { color: var(--forest); font-size: 12px; font-weight: 650; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #2f7d5a;
  outline-offset: 2px;
}
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px; background: var(--forest-deep); color: white; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.35); border-radius: 13px; color: var(--gold); font-family: Georgia, serif; font-weight: 700; }
.brand strong, .brand span { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 20px; }
.brand span { margin-top: 3px; color: #b7c7c0; font-size: 11px; letter-spacing: .04em; }
nav { display: grid; gap: 3px; overflow-y: auto; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 13px; padding: 11px 12px; border: 0; border-radius: 9px; color: #d8e1dd; background: transparent; text-align: left; font-size: 13px; }
.nav-item span { color: #7fa08f; font: 11px Georgia, serif; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.1); }
.stage-badge { margin-left:auto; padding:2px 5px; border:1px solid #ffffff45; border-radius:6px; color:#d7e3db; font-size:9px; font-weight:500; }
.sidebar-foot { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 18px 10px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot small { margin-top: 3px; color: #9eb3aa; font-size: 10px; }
.sidebar-support { margin-top: 18px; padding: 14px 10px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; background: rgba(255,255,255,.06); }
.sidebar-support .eyebrow { margin-bottom: 7px; color: #d8b56e; font-size: 9px; }
.support-phone { display: block; overflow: hidden; color: #fff; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.support-phone[href="#/settings"] { color: #c6d4cc; font-size: 11px; font-weight: 500; white-space: normal; }
.sidebar-support small { display: block; margin-top: 5px; color: #9eb3aa; font-size: 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #7ac49c; box-shadow: 0 0 0 5px rgba(122,196,156,.12); }
main { min-width: 0; padding: 28px 38px 50px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 6px; color: var(--clay); text-transform: uppercase; letter-spacing: .15em; font-size: 10px; font-weight: 700; }
.eyebrow.light { color: #e8c886; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font: 34px/1.1 Georgia, serif; }
h2 { font: 42px/1.05 Georgia, serif; }
h3 { font: 22px/1.2 Georgia, serif; }
.security-badge { padding: 9px 13px; border: 1px solid #b8ccb9; border-radius: 999px; color: var(--forest); background: #edf5ee; font-size: 12px; }
.security-badge.warn { color: #8a3b26; background: #fff0e9; border-color: #efbca8; }
.view { display: none; }
.view.active { display: block; }
.hero-card { min-height: 260px; display: flex; align-items: end; justify-content: space-between; gap: 30px; padding: 42px; border-radius: 22px; overflow: hidden; color: white; background: radial-gradient(circle at 90% 0, rgba(211,170,85,.28), transparent 34%), linear-gradient(120deg, var(--forest-deep), var(--forest)); box-shadow: var(--shadow); }
.hero-card h2 { margin-bottom: 16px; }
.hero-card p:not(.eyebrow) { max-width: 590px; margin-bottom: 0; color: #c9d8d1; }
.primary, .secondary { padding: 11px 17px; border-radius: 9px; border: 1px solid transparent; font-weight: 650; }
.primary { color: white; background: var(--clay); box-shadow: 0 8px 18px rgba(151,71,37,.18); }
.primary:hover { background: #b95d38; }
.hero-card .primary { white-space: nowrap; background: var(--gold); color: #2b2a20; }
.secondary { color: var(--ink); background: transparent; border-color: var(--line); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 20px 0; }
.stat { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 7px; font: 30px Georgia, serif; }
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.panel { padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.accent-panel { background: #e8dfcf; }
.accent-panel p:last-child { color: #655c4d; line-height: 1.6; }
.flow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.flow div { position: relative; padding: 16px 12px; border-left: 2px solid var(--sage); }
.flow b, .flow span, .flow small { display: block; }
.flow b { color: var(--clay); font-size: 10px; }
.flow span { margin: 9px 0 5px; font-weight: 700; }
.flow small { color: var(--muted); }
.section-toolbar { min-height: 54px; display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 14px; }
.section-toolbar p { margin: 0; color: var(--muted); }
.section-title { margin-bottom: 6px; font: 28px/1.1 Georgia, serif; }
.finance-subnav { position: sticky; top: 10px; z-index: var(--hf-z-sticky); display: flex; gap: 6px; overflow-x: auto; margin: 0 0 18px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.98); box-shadow: 0 8px 22px rgba(28,42,35,.05); }
.finance-subnav button { flex: 0 0 auto; padding: 9px 12px; border: 0; border-radius: 9px; color: var(--ink); background: transparent; font-weight: 650; white-space: nowrap; }
.finance-subnav button:hover, .finance-subnav button:focus-visible, .finance-subnav button.active { color: white; background: var(--forest); }
.finance-tab-panel { min-width: 0; }
.finance-filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.finance-filters label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.finance-filters input, .finance-filters select { min-width: 150px; max-width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.finance-filters input[type="search"] { width: min(310px, 100%); }
.finance-filter-disclosure { margin-top: 12px; }
.finance-filter-trigger { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--forest); background: #faf8f2; font-weight: 700; text-align: left; }
.finance-filter-trigger small { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 500; }
.finance-filter-trigger[aria-expanded="true"] > span:last-child { transform: rotate(180deg); }
.finance-secondary-filters { margin-top: 10px; background: #faf8f2; }
.finance-journal-panel { margin-top: 16px; }
.finance-report-panel, .finance-accounts-panel { min-height: 180px; }
.expense-details > summary { cursor: pointer; color: var(--forest); font-weight: 700; }
.expense-details > summary::-webkit-details-marker { display: none; }
.expense-details small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.amount-cell { text-align: right; white-space: nowrap; }
.money-in { color: #1b7250; font-weight: 700; }
.money-out { color: #9b3e2a; font-weight: 700; }
.danger-button { color: #9b3e2a; }
.finance-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.finance-breakdown { margin: 18px 0; }
.finance-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.finance-line small { grid-column: 1 / -1; color: var(--muted); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.search { width: min(420px, 100%); padding: 11px 14px; border: 1px solid var(--line); border-radius: 9px; background: white; outline: none; }
.search:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(31,75,59,.09); }
.muted { color: var(--muted); font-size: 12px; }
.table-card { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 10px 30px rgba(28,42,35,.04); }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 13px 15px; border-bottom: 1px solid #ebe7df; text-align: left; vertical-align: middle; font-size: 13px; }
th { position: sticky; top: 0; color: #657168; background: #f8f6f0; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
tbody tr:hover { background: #faf8f2; }
tbody tr:last-child td { border-bottom: 0; }
.clickable-row { cursor: pointer; }
.table-link { padding: 0; border: 0; color: var(--forest); background: transparent; font-weight: 700; text-align: left; }
.table-link:hover { color: var(--clay); text-decoration: underline; }
.pill { display: inline-flex; padding: 5px 8px; border-radius: 999px; color: var(--forest); background: #e2eee6; font-size: 10px; font-weight: 700; }
.empty { padding: 42px !important; color: var(--muted); text-align: center; }
dialog { width: min(690px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow-y: auto; overflow-x: hidden; padding: 0; border: 0; border-radius: 18px; background: var(--surface); box-shadow: 0 30px 90px rgba(15,30,23,.32); }
.wide-dialog { width: min(1180px, calc(100vw - 28px)); }
.wide-dialog form, .form-grid > .field { min-width: 0; }
dialog::backdrop { background: rgba(15,27,22,.55); backdrop-filter: blur(3px); }
#modal-form, #quote-form, #expense-form, .detail-shell { padding: 26px; }
#technical-spec-form { padding: 0 26px 26px; }
#technical-spec-form > .modal-head { position: sticky; top: 0; z-index: 1; padding: 26px 0 14px; background: var(--surface); }
#technical-spec-form > .modal-actions { position: sticky; bottom: 0; z-index: 1; padding: 14px 0 2px; margin-bottom: 0; background: var(--surface); }
.modal-head { display: flex; justify-content: space-between; align-items: start; }
.modal-head h2 { margin-bottom: 20px; font-size: 30px; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 11px; font-weight: 650; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: white; outline: none; }
.field textarea { min-height: 88px; resize: vertical; }
.modal-actions { display: flex; justify-content: end; gap: 10px; margin-top: 22px; }
.expense-primary-fields, .expense-extra-fields { gap: 20px 16px; }
#expense-form .modal-head { margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
#expense-form .modal-head h2 { margin-bottom: 0; }
#expense-form .field { gap: 7px; }
#expense-form .expense-details { margin-top: 24px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #faf8f2; }
#expense-form .expense-details[open] > summary { margin-bottom: 18px; }
#expense-form .modal-actions { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-error { min-height: 18px; margin: 12px 0 0; color: #a33c27; font-size: 12px; }
.form-success { min-height: 18px; margin: 12px 0 0; color: var(--forest); font-size: 12px; }
.calculator-add { margin: 20px 0 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #f8f6f0; }
.calculator-tabs { display: flex; gap: 8px; margin-bottom: 13px; }
.calculator-tabs .active { color: white; border-color: var(--forest); background: var(--forest); }
.catalog-search-row { display: grid; grid-template-columns: 180px 1fr; gap: 10px; }
.catalog-search-row select, .manual-grid input, .manual-grid select { min-width: 0; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.catalog-results { display: grid; gap: 6px; max-height: 210px; margin-top: 10px; overflow: auto; }
.catalog-result, .related-record { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; text-align: left; }
.catalog-result:hover, .related-record:hover { border-color: var(--sage); background: #f2f7f3; }
.catalog-result span, .catalog-result small, .related-record span { display: block; }
.catalog-result small { margin-top: 4px; color: var(--muted); }
.manual-grid { display: grid; grid-template-columns: 130px 2fr 100px 130px 130px auto; gap: 8px; }
.calculation-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; max-width: 100%; max-height: 55vh; }
.calculation-table { min-width: 1080px; }
.calculation-table-wrap .order-item-table { min-width: 900px; }
.order-item-table td.item-description { max-width: 220px; word-break: break-word; }
.order-item-table td.item-description strong, .order-item-table td.item-description small { display: block; }
.order-item-table td.item-description small { color: var(--muted); font-size: 11px; }
.calculation-table { min-width: 1080px; }
.calculation-table input { width: 88px; padding: 7px; border: 1px solid var(--line); border-radius: 6px; }
.calculation-table td:first-child { min-width: 250px; }
.line-name small, .print-lines small { display: block; margin-top: 6px; }
.line-name .pill { margin-right: 4px; }
.remove-line { width: 28px; height: 28px; border: 0; border-radius: 50%; color: #9b3e2a; background: #f8e7e1; font-size: 18px; }
.calculation-footer { display: grid; grid-template-columns: 1fr 360px; gap: 22px; margin-top: 18px; }
.notes-field textarea { min-height: 130px; }
.calculation-summary, .quote-totals { display: grid; gap: 8px; align-content: start; }
.calculation-summary div, .quote-totals div { display: flex; justify-content: space-between; gap: 20px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.calculation-summary .grand-total, .quote-totals .grand-total { padding: 12px; border: 0; border-radius: 9px; color: white; background: var(--forest); }
.detail-actions { display: flex; justify-content: end; gap: 8px; margin: -8px 0 22px; }
.detail-grid, .print-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.detail-grid div, .print-meta div { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #faf8f2; }
.detail-grid span, .print-meta span, .detail-note span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.detail-note { margin: 18px 0; padding: 16px; border-left: 3px solid var(--gold); background: #f8f3e8; }
.detail-note p { margin: 0; white-space: pre-wrap; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 24px; }
.mini-stats div { padding: 15px; border-radius: 10px; color: white; background: var(--forest); text-align: center; }
.mini-stats b, .mini-stats span { display: block; }
.mini-stats b { font: 24px Georgia, serif; }
.mini-stats span { margin-top: 4px; color: #c9d8d1; font-size: 11px; }
.print-lines { min-width: 940px; }
.quote-totals { width: min(420px, 100%); margin: 20px 0 20px auto; }
.comments-section { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.comment-list { display: grid; gap: 8px; margin-bottom: 12px; }
.comment { padding: 12px; border-radius: 9px; background: #f4f1ea; }
.comment strong, .comment time { margin-right: 8px; font-size: 11px; }
.comment time { color: var(--muted); }
.comment p { margin: 7px 0 0; white-space: pre-wrap; }
.comment-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.comment-form textarea { min-height: 70px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: var(--hf-z-toast); padding: 12px 17px; border-radius: 10px; color: white; background: var(--forest-deep); box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 1120px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand div:last-child, .nav-item:not(.active) { font-size: 0; }
  .nav-item { justify-content: center; }
  .nav-item span { font-size: 11px; }
  .sidebar-foot div, .sidebar-support { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; }
  .brand, .sidebar-foot { display: none; }
  nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; overflow: visible; }
  .nav-item, .nav-item:not(.active) { min-width: 0; width: 100%; justify-content: center; padding: 9px 5px; font-size: 11px !important; line-height: 1.15; text-align: center; white-space: normal; }
  .nav-item span { display: none; }
  main { padding: 20px 14px 40px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  h1 { font-size: 28px; }
  .security-badge { width: max-content; max-width: 100%; }
  .hero-card { min-height: 320px; display: grid; padding: 28px; }
  .hero-card h2 { font-size: 34px; }
  .hero-card .primary { white-space: normal; width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .flow { grid-template-columns: 1fr 1fr; }
  .section-toolbar { align-items: stretch; flex-direction: column; }
  .orders-filters { align-items: stretch; flex-direction: column; }
  .orders-filters .search { max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  #technical-spec-form { padding-inline: 16px; }
  #technical-spec-form > .modal-head { padding-top: 16px; }
  .order-fields { grid-template-columns: 1fr; }
  .order-fields .wide { grid-column: 1 / -1; }
  .manual-grid, .catalog-search-row, .calculation-footer, .detail-grid, .print-meta { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; align-items: stretch; }
  .modal-actions > * { width: 100%; }
  .inline-form { display: grid; grid-template-columns: 1fr; }
  .inline-form > * { min-width: 0; width: 100%; }
  .opening-grid, .document-builder { grid-template-columns: 1fr; }
  .order-summary-grid { grid-template-columns: 1fr; }
  .orders-toolbar .toolbar-actions { width: 100%; }
  .orders-toolbar .toolbar-actions > button { flex: 1; }
  .comment-form { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  main { padding-inline: 10px; }
  .panel { padding: 18px 14px; }
  .hero-card { padding: 22px 18px; }
  .hero-card h2 { font-size: 29px; }
  .modal-head h2 { font-size: 23px; }
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-actions, .export-actions, .storage-actions { display: grid; grid-template-columns: 1fr; }
  .detail-actions > *, .export-actions > *, .storage-actions > * { width: 100%; }
}
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: white; }
  body.printing-detail .app-shell, body.printing-detail .toast { display: none !important; }
  body.printing-detail #detail-modal { position: static; display: block; width: auto; max-height: none; overflow: visible; border-radius: 0; box-shadow: none; }
  body.printing-detail #detail-modal::backdrop, .no-print { display: none !important; }
  body.printing-detail .detail-shell { padding: 0; }
  body.printing-detail .calculation-table-wrap { overflow: visible; border: 0; }
  body.printing-detail .print-lines { min-width: 0; font-size: 10px; }
  body.printing-detail th, body.printing-detail td { padding: 6px; }
  body.printing-detail .quote-totals { break-inside: avoid; }
  body.printing-order .sidebar, body.printing-order .topbar, body.printing-order .order-toolbar,
  body.printing-order .item-toolbar, body.printing-order .export-actions, body.printing-order .comment-form,
  body.printing-order .history-list, body.printing-order .order-section:nth-last-child(-n+3) { display: none !important; }
  body.printing-order .app-shell { display: block; }
  body.printing-order main { padding: 0; }
  body.printing-order .view { display: none !important; }
  body.printing-order #view-order-card { display: block !important; }
  body.printing-order .order-card-head, body.printing-order .order-section, body.printing-order .order-summary-sticky { border: 0; padding: 8px 0; box-shadow: none; break-inside: avoid; }
  body.printing-order .order-item-table { min-width: 0; font-size: 9px; }
  body.printing-order .calculation-table-wrap { overflow: visible; }
  body.printing-spec > *:not(#technical-spec-modal) { visibility: hidden !important; }
  body.printing-spec #technical-spec-modal, body.printing-spec #technical-spec-modal * { visibility: visible !important; }
  body.printing-spec #technical-spec-modal { position: static; width: auto; max-width: none; max-height: none; overflow: visible; box-shadow: none; }
  body.printing-spec #technical-spec-modal .modal-head button, body.printing-spec #technical-spec-modal .modal-actions, body.printing-spec #technical-spec-error { display: none !important; }
}

.order-subnav { position: sticky; top: 0; z-index: var(--hf-z-sticky); display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.98); }
.order-subnav button { white-space: nowrap; border: 0; background: transparent; color: var(--ink); padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.order-subnav button:hover, .order-subnav button:focus, .order-subnav button.active { background: var(--forest); color: white; }
.order-summary-sticky { position: sticky; bottom: 0; z-index: 5; padding: 12px 0; background: var(--surface); border-top: 2px solid var(--forest); }
.toolbar-more { position: relative; display: inline-block; }
.more-dropdown { position: absolute; right: 0; top: 100%; z-index: var(--hf-z-menu); display: grid; gap: 2px; min-width: 180px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 12px 30px rgba(0,0,0,.15); }
.more-dropdown[hidden] { display: none; }
.more-dropdown button { width: 100%; text-align: left; }

/* Settings tabs */
.settings-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.settings-tabs button { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; }
.settings-tabs button.active { border-color: var(--forest); background: var(--forest); color: white; }
.export-links { display: flex; gap: 10px; flex-wrap: wrap; }
.button-link { display: inline-flex; align-items: center; text-decoration: none; cursor: pointer; }

/* Spec T3 type-specific sections */
.spec-type-section { margin-top: 14px; }
.spec-params-set { padding: 14px 16px; border: 1px solid var(--forest); border-radius: 14px; background: #f4f8f5; }
.spec-params-set legend { padding: 0 8px; color: var(--forest); font-weight: 700; font-size: 13px; }
.spec-params-set .form-grid { margin-top: 8px; }
.spec-show-formula { margin: 8px 0 0; padding: 10px 14px; border-radius: 10px; background: #eaf3ed; font: 12px monospace; color: var(--forest); white-space: pre-wrap; line-height: 1.7; max-height: 300px; overflow-y: auto; }
.order-hierarchy { display: grid; gap: 14px; }
.room-card { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfb; }
.room-card > header, .opening-card > header, .product-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.room-card h4 { margin: 2px 0 0; font-size: 19px; }
.opening-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.opening-card { border-left: 4px solid var(--green); border-radius: 10px; background: white; padding: 12px; box-shadow: 0 3px 14px rgba(31,55,40,.06); }
.opening-card header small, .product-card span { display: block; color: var(--muted); margin-top: 4px; font-size: 12px; }
.product-list { display: grid; gap: 8px; margin-top: 10px; }
.product-card { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--cream); }
.empty-hierarchy { text-align: center; padding: 24px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.document-builder { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end; padding: 14px; background: var(--cream); border-radius: 12px; }
.document-builder label { display: grid; gap: 6px; }
.document-builder label:has(input[type="checkbox"]) { display: flex; align-items: center; }
.document-history { margin-top: 14px; }

@media (max-width: 760px) {
  .room-card > header, .opening-card > header, .product-card { flex-direction: column; }
  .order-subnav { width: 100%; min-width: 0; margin-left: 0; margin-right: 0; border-radius: 0; }
  .wide-dialog .form-grid { grid-template-columns: minmax(0, 1fr); }
  .wide-dialog .modal-head h2 { font-size: 24px; }
}

.order-card { display: grid; gap: 18px; padding-bottom: 42px; }
.order-card-head, .order-section, .order-summary-sticky { min-width: 0; max-width: 100%; background: var(--surface, #fff); border: 1px solid #dce5df; border-radius: 18px; padding: 20px; }
.order-card-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.order-card-head > * { min-width: 0; }
.order-title-line { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.order-toolbar, .item-toolbar, .export-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.order-section h3 { margin: 0 0 14px; }
.order-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.order-fields .wide { grid-column: span 2; }
.order-fields .full { grid-column: 1 / -1; }
.order-fields label, .order-item-table label { display: grid; gap: 6px; color: #52625a; font-size: 12px; }
.order-fields input, .order-fields select, .order-fields textarea { width: 100%; }
.order-item-table { width: 100%; min-width: 0; }
.order-item-table th, .order-item-table td { padding: 10px 8px; font-size: 12px; }
.order-item-table .item-description { min-width: 140px; max-width: 220px; }
.order-item-table .item-description strong { font-size: 13px; word-break: break-word; }
.order-item-table .item-description small { display: block; font-size: 10px; color: var(--muted); }
.order-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.order-item-actions button { padding: 5px 8px; font-size: 12px; white-space: nowrap; }
.order-item-table th:nth-child(3), .order-item-table td:nth-child(3),
.order-item-table th:nth-child(4), .order-item-table td:nth-child(4) { text-align: right; }
.order-item-table th:nth-child(5), .order-item-table td:nth-child(5) { text-align: right; }
.order-item-table th:nth-child(9), .order-item-table td:nth-child(9) { text-align: right; white-space: nowrap; }
.order-summary-grid { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; }
.order-summary-grid div { padding: 12px; border-radius: 12px; background: #f4f7f4; display: grid; gap: 5px; }
.order-summary-grid .total { background: #193c31; color: white; }
.order-summary-grid span { font-size: 12px; opacity: .72; }
.spec-preview { padding: 14px; background: #f6f4ec; border-radius: 12px; white-space: pre-wrap; }
.spec-measurements { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.spec-measurements div { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #f9f8f4; }
.spec-measurements span { display: block; color: var(--muted); font-size: 10px; }
.spec-measurements strong { display: block; margin-top: 3px; font: 16px Georgia, serif; }
.spec-calculations { margin: 12px 0; padding: 14px; border: 1px solid var(--sage); border-radius: 10px; background: #f2f7f3; }
.spec-calculations h4 { margin: 0 0 8px; font: 15px Georgia, serif; color: var(--forest); }
.spec-calculations p { margin: 4px 0; font-size: 12px; line-height: 1.6; }
.spec-calculations b { color: var(--clay); }
.spec-requirements { margin: 12px 0; }
.spec-requirements h4 { margin: 0 0 6px; font: 14px Georgia, serif; }
.spec-requirements p { margin: 0; white-space: pre-wrap; font-size: 12px; color: var(--ink); }
.spec-params-set { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 8px; margin: 4px 0; background: #fafaf9; }
.spec-params-set legend { font: 13px Georgia, serif; color: var(--muted); padding: 0 6px; }
.upload-zone { padding: 28px 20px; border: 2px dashed var(--line-strong); border-radius: 14px; text-align: center; cursor: pointer; background: #fafcfb; transition: .18s; }
.upload-zone:hover, .upload-zone-active { border-color: var(--forest); background: #f0f6f2; }
.upload-zone p { margin: 0 0 6px; font-size: 15px; color: var(--ink); }
.upload-zone small { display: block; margin-bottom: 12px; color: var(--muted); }
.upload-zone button { margin: 4px; }
.upload-zone #upload-file-name { display: block; margin-top: 8px; font-size: 13px; }
.history-list { display: grid; gap: 8px; }
.history-entry { border-left: 3px solid #8da898; padding: 7px 12px; }
.history-entry time { color: #6b7871; font-size: 12px; }
.inline-fields { display: grid; grid-template-columns: 72px 1fr; gap: 6px; }
.curtain-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.catalog-result { align-items: center; }
.catalog-result img { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; background: #edf1ee; }
.catalog-result .stock { color: #617067; font-size: 12px; }
.catalog-meta { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-bottom:12px; }
.catalog-meta > div, .catalog-meta > p { margin:0; padding:12px; border:1px solid var(--line); border-radius:11px; background:#f6f8f6; }
.catalog-meta span, td small { display:block; margin-bottom:4px; color:var(--muted); font-size:11px; }
.catalog-meta p { grid-column:1/-1; color:var(--muted); }
.order-readonly input, .order-readonly select, .order-readonly textarea { border-color: transparent; background: transparent; pointer-events: none; padding-left: 0; }
.unsaved-badge { color: #9c5e16; font-weight: 700; }
.autosave-status { color: #38745b; font-size: .82rem; font-weight: 600; }
.autosave-status.important { color: #a33f35; }
.storage-panel { display: grid; gap: 18px; }
.storage-panel > * { min-width: 0; }
.account-security-card { display: grid; gap: 14px; margin-top: 8px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--surface) 88%, var(--accent) 12%); }
.account-security-card h3, .account-security-card p { margin: 0; }
.account-security-card .form-grid { margin-top: 2px; }
.storage-path { display: grid; gap: 7px; padding: 14px; border-radius: 12px; background: #f2f6f3; }
.storage-path span { color: var(--muted); font-size: 12px; }
.storage-path code { overflow-wrap: anywhere; color: var(--forest-deep); font: 600 13px Consolas, monospace; }
.diagnostic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; margin-top: 12px; }
.diagnostic-grid div { display: grid; gap: 5px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.diagnostic-grid span { color: var(--muted); font-size: 12px; }
.storage-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.storage-detail { min-height: 42px; min-width: 0; padding: 12px; border-radius: 10px; background: #17251f; color: #e8f0eb; white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: auto; font: 12px/1.5 Consolas, monospace; }
.import-mapping-grid { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr); gap: 6px 10px; margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #f7faf8; color: var(--ink); }
.import-mapping-grid label { display: contents; }
.import-mapping-grid label select { width: 100%; min-width: 0; }
.import-mapping-field { grid-column: 1 / -1; }
.import-mapping-field > .muted { margin: 0; }
.price-review-dialog { width: min(680px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); }
.price-review-dialog::backdrop { background: rgba(17, 35, 27, .58); }
.danger-eyebrow { color: #a33f35; }
.danger-button { border: 1px solid #8f3029; border-radius: 9px; padding: 9px 14px; background: #a33f35; color: white; font: inherit; font-weight: 700; cursor: pointer; }
.danger-button:hover, .danger-button:focus-visible { background: #7f2722; outline: 3px solid #e7c0bc; outline-offset: 2px; }
.price-review-examples { display: grid; gap: 8px; margin: 16px 0; }
.price-review-examples > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid #e7c0bc; border-radius: 10px; background: #fff6f4; }
.price-review-examples strong { overflow-wrap: anywhere; }
.price-review-examples span { color: #8f3029; font-weight: 700; white-space: nowrap; }
.import-confidence { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-left: 4px solid var(--accent); padding: 10px 12px; background: var(--panel-soft); border-radius: 8px; }
.confidence-high { border-color: #248a57; }
.confidence-medium { border-color: #b77800; }
.confidence-review { border-color: #bd4d2f; }
.import-warning, .import-errors { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 12px 0; }
.import-warning { background: #fff8e8; border-color: #e7c77e; }
.import-errors ul { margin: 8px 0; padding-left: 20px; }
.import-preview { max-height: 300px; overflow: auto; font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; }
.button-link { display: inline-flex; align-items: center; text-decoration: none; }
#confirm-modal { max-width: 480px; }
#confirm-message { line-height: 1.55; white-space: pre-wrap; }
.section-title { margin: 0 0 4px; }
.orders-toolbar { justify-content: space-between; margin-top: -10px; }
.orders-filters { display: flex; align-items: center; gap: 8px; flex: 1; }
.orders-filters select { min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: white; }

@media (max-width: 760px) {
  dialog .form-grid, dialog .split-grid, dialog .inline-form { grid-template-columns: 1fr; }
  dialog .form-grid > *, dialog .split-grid > * { grid-column: 1 / -1; min-width: 0; }
  .finance-filters { align-items: stretch; flex-direction: column; }
  .finance-filters input, .finance-filters select, .finance-filters button { width: 100%; }
  .finance-subnav { position: static; width: 100%; margin-inline: 0; border-radius: 12px; }
  .finance-filter-trigger { align-items: flex-start; flex-wrap: wrap; }
  .finance-filter-trigger small { width: calc(100% - 24px); margin-left: 0; }
  #expense-form { padding: 20px 16px 18px; }
  #expense-form .expense-details { margin-top: 20px; padding: 16px; }
  #expense-form .modal-actions { margin-top: 20px; padding-top: 16px; }
  .finance-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-breakdown { grid-template-columns: 1fr; }
  .order-card-head { flex-direction: column; padding: 14px; }
  .order-toolbar { align-items: stretch; }
  .order-toolbar > * { min-width: 0; }
  .toolbar-more { align-self: stretch; }
  .more-dropdown { right: 0; left: auto; max-width: calc(100vw - 24px); }
}
.orders-filters .search { max-width: 360px; }
.orders-toolbar .toolbar-actions { display: flex; gap: 8px; }
.orders-toolbar button.active { background: var(--forest); color: white; }
.orders-kanban { display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 12px; overflow-x: auto; }
.kanban-column { min-height: 220px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #f5f8f5; }
.kanban-column > header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; color: var(--forest-deep); }
.kanban-column > header span { color: var(--muted); }
.kanban-card { display: grid; gap: 5px; margin-bottom: 8px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; }
.kanban-card:hover, .kanban-card:focus { border-color: var(--forest); outline: none; box-shadow: 0 2px 8px #193c3120; }
.kanban-card span, .kanban-card small, .kanban-card time { overflow-wrap: anywhere; }
.kanban-card small, .kanban-card time { color: var(--muted); font-size: 11px; }
@media (max-width: 1000px) {
  .order-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-summary-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .orders-kanban { grid-template-columns: repeat(5, minmax(160px, 1fr)); }
}
@media (max-width: 680px) {
  .order-fields { grid-template-columns: minmax(0, 1fr); }
  .order-fields .wide { grid-column: 1 / -1; }
}
