:root {
  color-scheme: light;
  --navy: #061b3b;
  --navy-2: #0b2b55;
  --blue: #168de2;
  --blue-2: #0876ca;
  --ink: #1b2735;
  --muted: #718092;
  --line: #e5eaf0;
  --surface: #ffffff;
  --canvas: #f4f7fa;
  --mint: #e7f6f1;
  --mint-ink: #178466;
  --amber: #fff4df;
  --amber-ink: #9a650d;
  --red: #c74646;
  --shadow: 0 18px 55px rgba(15, 35, 61, .15);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(22,141,226,.24); outline-offset: 2px; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 252px; background: var(--navy); color: #fff; padding: 24px 16px 16px; display: flex; flex-direction: column; z-index: 20; }
.brand-lockup, .mobile-brand { display: flex; align-items: center; gap: 11px; }
.brand-lockup { padding: 0 8px 30px; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; background: #fff; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; overflow: hidden; }
.brand-mark img { width: 42px; height: 42px; object-fit: contain; }
.brand-lockup strong, .mobile-brand strong { display: block; font-size: 15px; letter-spacing: .01em; }
.brand-lockup small, .mobile-brand small { display: block; color: #9bb5d5; font-size: 9px; letter-spacing: .16em; margin-top: 3px; font-weight: 700; }
.workspace-label { color: #7992b2; font-size: 9px; font-weight: 800; letter-spacing: .17em; padding: 0 12px 12px; }
.side-nav { display: grid; gap: 5px; }
.nav-item { color: #b8c9dc; background: transparent; border: 0; border-radius: 10px; min-height: 44px; width: 100%; display: flex; gap: 13px; align-items: center; text-align: left; padding: 0 12px; font-size: 13px; font-weight: 600; transition: background .16s ease, color .16s ease; }
.nav-item:hover { background: rgba(255,255,255,.07); color: white; }
.nav-item.active { background: #123b6a; color: #fff; box-shadow: inset 3px 0 var(--blue); }
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-bottom { margin-top: auto; }
.local-badge { display: flex; gap: 8px; align-items: center; color: #90a8c4; padding: 12px 10px 18px; font-size: 10px; line-height: 1.35; }
.live-dot { width: 7px; height: 7px; background: #4dd6a2; border-radius: 50%; box-shadow: 0 0 0 3px rgba(77,214,162,.14); flex: 0 0 auto; }
.profile-button { display: flex; align-items: center; gap: 10px; color: #fff; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; width: 100%; padding: 10px; text-align: left; }
.profile-button strong, .profile-button small { display: block; }
.profile-button strong { font-size: 11px; }
.profile-button small { color: #9ab0cb; font-size: 10px; margin-top: 4px; }
.avatar { width: 31px; height: 31px; display: grid; place-items: center; background: #1e5c95; color: #fff; font-size: 10px; font-weight: 800; border-radius: 9px; }
.profile-more { margin-left: auto; letter-spacing: 2px; color: #9ab0cb; }
.workspace { margin-left: 252px; min-height: 100vh; }
.topbar { height: 72px; padding: 0 38px; display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-context { display: flex; align-items: center; gap: 10px; color: #334255; font-size: 12px; font-weight: 650; }
.crumb { color: #94a1af; font-weight: 500; }
.crumb-sep { color: #c5ced7; }
.topbar-actions { display: flex; align-items: center; gap: 22px; }
.secure-label { display: flex; align-items: center; gap: 7px; color: #778596; font-size: 11px; }
.secure-icon { font-size: 8px; color: #29aa81; }
.mobile-brand { display: none; }
.btn { min-height: 40px; border-radius: 9px; padding: 0 14px; border: 1px solid transparent; display: inline-flex; justify-content: center; align-items: center; gap: 8px; font-weight: 700; font-size: 12px; transition: transform .15s ease, background .15s ease, border .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { color: #fff; background: var(--blue); box-shadow: 0 5px 12px rgba(22,141,226,.17); }
.btn-primary:hover { background: var(--blue-2); }
.btn-secondary { background: #fff; color: #34465a; border-color: var(--line); }
.btn-secondary:hover { background: #f7fafc; border-color: #ccd7e2; }
.btn-quiet { background: transparent; color: var(--muted); border-color: transparent; }
.btn-danger { color: var(--red); background: #fff5f5; border-color: #f5dede; }
.btn-small { min-height: 33px; border-radius: 7px; padding: 0 10px; font-size: 11px; }
.btn-plus { font-size: 17px; line-height: 1; font-weight: 400; }
#view-root { max-width: 1460px; margin: 0 auto; padding: 33px 38px 58px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 25px; }
.eyebrow { font-size: 9px; letter-spacing: .15em; text-transform: uppercase; color: #8996a5; font-weight: 800; margin-bottom: 9px; }
h1, h2, h3, p { margin-top: 0; }
h1 { color: var(--navy); font-size: clamp(24px, 3vw, 31px); letter-spacing: -.045em; margin: 0; line-height: 1.13; }
.page-subtitle { margin: 8px 0 0; color: #7a8796; font-size: 12px; line-height: 1.55; }
.heading-actions { display: flex; gap: 9px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin: 0 0 22px; }
.stat-card { background: var(--surface); border: 1px solid #e9edf1; border-radius: 12px; padding: 17px 18px 15px; min-height: 119px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; width: 76px; height: 76px; border-radius: 50%; position: absolute; right: -28px; top: -30px; background: #f3f8fc; }
.stat-top { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
.stat-label { font-size: 10px; font-weight: 700; color: #7c8997; }
.stat-icon { height: 27px; width: 27px; display: grid; place-items: center; border-radius: 8px; background: #edf6fc; color: var(--blue); }
.stat-icon svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.stat-value { font-size: 23px; color: var(--navy); font-weight: 750; letter-spacing: -.04em; margin: 9px 0 5px; position: relative; z-index: 1; }
.stat-caption { font-size: 10px; color: #a1acb8; margin: 0; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(290px,.85fr); gap: 18px; align-items: start; }
.panel { border-radius: 13px; background: #fff; border: 1px solid #e8edf2; }
.panel-head { min-height: 58px; padding: 0 18px; border-bottom: 1px solid #eef1f4; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.panel-title { font-size: 13px; color: #172a40; font-weight: 750; margin: 0; }
.panel-subtitle { font-size: 10px; color: #96a1ad; margin: 4px 0 0; }
.text-link { border: 0; background: transparent; color: var(--blue-2); font-size: 10px; font-weight: 750; padding: 8px 0; }
.empty-state { padding: 31px 18px 35px; text-align: center; }
.empty-illustration { margin: 0 auto 13px; width: 58px; height: 58px; border-radius: 19px; display: grid; place-items: center; color: #187fc4; background: #eff7fc; }
.empty-illustration svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h3 { font-size: 13px; margin: 0 0 6px; color: #26384d; }
.empty-state p { color: #8996a4; font-size: 11px; max-width: 320px; line-height: 1.6; margin: 0 auto 15px; }
.quick-panel { padding: 18px; }
.quick-panel .panel-title { margin-bottom: 14px; }
.quick-action { width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: center; gap: 12px; padding: 12px; text-align: left; margin-bottom: 8px; transition: border .15s ease, transform .15s ease; }
.quick-action:hover { border-color: #b9d9ef; transform: translateY(-1px); }
.quick-action:last-child { margin-bottom: 0; }
.quick-action-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #eff7fc; color: #187fc4; flex: 0 0 auto; }
.quick-action-icon.green { background: #eef8f4; color: #188267; }
.quick-action-icon svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.quick-action strong { display: block; color: #23354a; font-size: 11px; }
.quick-action small { display: block; color: #8b97a4; font-size: 9px; margin-top: 4px; }
.quick-arrow { margin-left: auto; color: #a6b1bd; font-size: 16px; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 14px; }
.search-box { position: relative; width: min(100%,310px); }
.search-box svg { position: absolute; width: 15px; height: 15px; left: 11px; top: 50%; transform: translateY(-50%); stroke: #9ba7b4; fill: none; stroke-width: 1.8; }
.search-box input { width: 100%; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 0 12px 0 34px; color: var(--ink); font-size: 11px; }
.filter-select { height: 37px; border: 1px solid var(--line); border-radius: 8px; background: white; padding: 0 29px 0 10px; color: #536274; font-size: 10px; }
.content-panel { overflow: hidden; }
.document-row { display: grid; grid-template-columns: minmax(180px,1.5fr) minmax(120px,.85fr) minmax(100px,.7fr) minmax(100px,.7fr) 90px; gap: 12px; align-items: center; min-height: 64px; padding: 10px 18px; border-bottom: 1px solid #f0f3f6; cursor: pointer; }
.doc-status-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 0; }
.row-payment-action { border: 0; padding: 0; background: transparent; color: #147fc3; font-size: 9px; line-height: 1.2; font-weight: 750; }
.row-payment-action:hover { color: #0d5f99; text-decoration: underline; }
.document-row:last-child { border-bottom: 0; }
.document-row:hover { background: #fbfdff; }
.table-header { min-height: 39px; background: #fafbfd; color: #919eab; font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.doc-primary { min-width: 0; display: flex; align-items: center; gap: 10px; }
.doc-type-icon { width: 33px; height: 36px; border: 1px solid #dcebf6; background: #f2f8fc; color: #1685d2; border-radius: 7px; display: grid; place-items: center; flex: 0 0 auto; }
.doc-type-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.doc-primary strong { display: block; font-size: 11px; color: #25374b; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.doc-primary small { display: block; color: #99a4b0; font-size: 9px; margin-top: 4px; }
.cell-muted { font-size: 10px; color: #69798b; }
.cell-money { font-size: 11px; font-weight: 750; color: #263a51; }
.status-pill { display: inline-flex; align-items: center; justify-content: center; padding: 5px 8px; border-radius: 99px; font-size: 9px; font-weight: 750; white-space: nowrap; }
.status-paid { background: var(--mint); color: var(--mint-ink); }
.status-due { background: var(--amber); color: var(--amber-ink); }
.status-proforma { background: #edf4fc; color: #4875a2; }
.status-cancelled { background: #fff0ef; color: #a3423d; }
.catalog-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.catalog-card { background: #fff; border: 1px solid #e7edf2; border-radius: 11px; padding: 15px; min-width: 0; }
.catalog-card-top { display: flex; gap: 10px; align-items: flex-start; }
.catalog-icon { width: 35px; height: 35px; flex: 0 0 auto; border-radius: 10px; background: #eff7fc; color: #187fc4; display: grid; place-items: center; }
.catalog-icon svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.catalog-name { font-size: 11px; font-weight: 750; line-height: 1.4; color: #25384d; margin: 2px 0 4px; }
.catalog-category { font-size: 9px; color: #93a0ad; }
.catalog-price-row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 16px; border-top: 1px solid #f0f3f5; padding-top: 12px; }
.catalog-price { font-size: 16px; color: var(--navy); font-weight: 750; letter-spacing: -.03em; }
.catalog-unit { color: #929eaa; font-size: 9px; }
.catalog-actions { display: flex; gap: 6px; }
.catalog-actions button { background: none; border: 0; color: #8291a0; padding: 4px; font-size: 10px; }
.catalog-actions button:hover { color: var(--blue-2); }
.client-row { display: grid; grid-template-columns: minmax(190px,1.4fr) minmax(180px,1fr) minmax(150px,1fr) 90px; gap: 15px; align-items: center; min-height: 66px; padding: 10px 18px; border-bottom: 1px solid #f0f3f6; }
.client-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-initials { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: #eef5fb; color: #2b76ad; font-weight: 800; font-size: 10px; }
.client-person strong { display: block; color: #2b3d51; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-person small { display: block; color: #96a2ae; font-size: 9px; margin-top: 4px; }
.notice { background: #edf7fd; border: 1px solid #d8ebf8; border-radius: 10px; padding: 12px 14px; color: #45708f; font-size: 10px; line-height: 1.5; }
.workflow-hint { margin: 12px 2px 0; color: #6d7e90; line-height: 1.55; }
.workflow-linked { margin: 0 0 12px; }
.confirm-action { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; color: #526174; font-size: 10px; line-height: 1.5; }
.confirm-action input { margin-top: 1px; accent-color: var(--blue); flex: 0 0 auto; }
.settings-grid { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(280px,.9fr); gap: 18px; align-items: start; }
.settings-panel { padding: 19px; }
.user-admin-panel { margin-top:16px; overflow:hidden; }
.user-invite-form { display:grid; grid-template-columns:minmax(180px,1fr) minmax(150px,.7fr) auto; gap:12px; align-items:end; padding:16px 18px; border-bottom:1px solid #edf1f4; }
.user-admin-list,.audit-log-list { padding:0 18px; }
.user-admin-row,.audit-row { display:grid; grid-template-columns:minmax(0,1fr) 150px auto; gap:12px; align-items:center; min-height:61px; border-bottom:1px solid #f0f3f6; padding:9px 0; }
.user-admin-row:last-child,.audit-row:last-child { border-bottom:0; }
.user-admin-row strong,.audit-row strong { display:block; color:#263a50; font-size:10px; }
.user-admin-row small,.audit-row small { display:block; color:#93a0ad; font-size:9px; margin-top:4px; }
.audit-row { grid-template-columns:minmax(0,1fr) auto; }
.settings-panel h2 { font-size: 13px; color: #21354b; margin: 0 0 4px; }
.settings-panel > p { color: #8a97a5; font-size: 10px; margin: 0 0 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; }
.field { min-width: 0; }
.field.full { grid-column: 1/-1; }
.field label { display: block; font-size: 10px; font-weight: 700; color: #526174; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; min-height: 39px; padding: 9px 10px; border: 1px solid #dde5eb; border-radius: 8px; background: #fff; color: #2b3a4b; font-size: 11px; }
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { font-size: 9px; line-height: 1.4; color: #9aa5b0; margin: 6px 0 0; }
.settings-actions { display: flex; justify-content: flex-end; margin-top: 17px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(6,20,39,.5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade-in .16s ease; }
.modal { background: #fff; border-radius: 15px; box-shadow: var(--shadow); width: min(100%,780px); max-height: min(90vh,900px); display: flex; flex-direction: column; overflow: hidden; animation: modal-in .2s ease; }
.modal.modal-narrow { width: min(100%,500px); }
.modal.modal-preview { width: min(100%,960px); height: min(94vh,940px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 21px; border-bottom: 1px solid #edf0f3; }
.modal-head h2 { margin: 0; font-size: 16px; color: var(--navy); letter-spacing: -.02em; }
.modal-head p { margin: 5px 0 0; color: #8996a4; font-size: 10px; }
.icon-button { background: #f5f7f9; border: 0; width: 31px; height: 31px; border-radius: 8px; color: #718092; font-size: 18px; display: grid; place-items: center; flex: 0 0 auto; }
.modal-body { padding: 18px 21px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { padding: 13px 21px; border-top: 1px solid #edf0f3; display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff; }
.modal-foot-right { display: flex; gap: 8px; margin-left: auto; }
.document-type-switch { display: inline-flex; padding: 3px; background: #f0f4f7; border-radius: 9px; gap: 3px; margin-bottom: 15px; }
.document-type-switch button { background: transparent; border: 0; border-radius: 7px; padding: 8px 13px; color: #82909f; font-size: 10px; font-weight: 700; }
.document-type-switch button.active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(15,35,61,.1); }
.section-rule { margin: 17px 0 11px; display: flex; align-items: center; justify-content: space-between; color: #526174; font-size: 10px; font-weight: 800; }
.line-editor { border: 1px solid #e4eaf0; border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.line-editor-head { background: #f7f9fb; display: grid; grid-template-columns: minmax(160px,1.6fr) 74px 110px 100px 30px; gap: 7px; padding: 8px 9px; color: #8d99a6; font-size: 8px; font-weight: 800; text-transform: uppercase; }
.line-editor-row { display: grid; grid-template-columns: minmax(160px,1.6fr) 74px 110px 100px 30px; gap: 7px; padding: 8px 9px; align-items: center; border-top: 1px solid #edf1f4; }
.line-editor-row select, .line-editor-row input { min-width: 0; width: 100%; height: 34px; border: 1px solid #e0e6ec; background: white; border-radius: 6px; padding: 0 7px; font-size: 10px; color: #394b60; }
.line-editor-row select { overflow: hidden; text-overflow: ellipsis; }
.line-total { text-align: right; color: #2b4057; font-size: 10px; font-weight: 750; white-space: nowrap; }
.remove-line { border: 0; background: transparent; color: #a3aeb9; font-size: 16px; padding: 2px; }
.remove-line:hover { color: var(--red); }
.add-line { margin-top: 2px; }
.totals-box { width: min(100%,300px); margin: 14px 0 0 auto; border-top: 1px solid #e8edf1; padding-top: 10px; }
.total-line { display: flex; justify-content: space-between; color: #778493; font-size: 10px; padding: 4px 0; }
.total-line strong { color: #263b51; font-size: 11px; }
.total-line.grand { border-top: 1px solid #e8edf1; margin-top: 6px; padding-top: 9px; font-size: 11px; font-weight: 750; color: #25394e; }
.total-line.grand strong { font-size: 17px; color: var(--navy); }
.modal-summary { display: flex; justify-content: space-between; align-items: center; padding: 11px 13px; border-radius: 9px; background: #f2f8fc; color: #6e7e8e; font-size: 10px; margin-top: 13px; }
.modal-summary strong { color: var(--navy); font-size: 16px; }
.preview-toolbar { display: flex; align-items: center; gap: 8px; }
.preview-scroll { flex: 1; overflow: auto; background: #e8edf2; padding: 22px; display: grid; place-items: start center; }
.preview-page { width: min(100%,640px); background: white; box-shadow: 0 8px 25px rgba(10,30,55,.16); }
.preview-page img { display: block; width: 100%; height: auto; }
.preview-help { color: #8d99a6; font-size: 9px; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 22px; background: #102e50; color: #fff; box-shadow: 0 8px 24px rgba(5,24,47,.25); border-radius: 10px; padding: 12px 15px; display: flex; align-items: center; gap: 9px; font-size: 11px; animation: toast-in .2s ease; }
.toast-mark { color: #5ce0ae; font-size: 15px; }
.mobile-nav { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: .7; transform: translateY(6px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 1080px) {
  .sidebar { width: 218px; }
  .workspace { margin-left: 218px; }
  .topbar { padding: 0 25px; }
  #view-root { padding-left: 25px; padding-right: 25px; }
  .stats-grid { gap: 10px; }
  .stat-card { padding-left: 13px; padding-right: 13px; }
  .catalog-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .workspace { margin-left: 0; padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .topbar { height: 62px; padding: 0 17px; }
  .mobile-brand { display: flex; }
  .mobile-brand .brand-mark { width: 35px; height: 35px; border-radius: 10px; }
  .mobile-brand .brand-mark img { width: 35px; height: 35px; }
  .mobile-brand strong { font-size: 12px; color: var(--navy); }
  .mobile-brand small { font-size: 8px; color: #8a98a7; letter-spacing: .08em; }
  .topbar-context { display: none; }
  .topbar-actions { gap: 0; }
  .secure-label { display: none; }
  .btn-top { min-height: 36px; padding: 0 10px; font-size: 10px; }
  .btn-top .btn-plus { font-size: 15px; }
  #view-root { padding: 24px 16px 30px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 14px; margin-bottom: 20px; }
  .page-heading .heading-actions { width: 100%; }
  .page-heading .heading-actions .btn { flex: 1; }
  .page-heading h1 { font-size: 25px; }
  .page-subtitle { font-size: 11px; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; margin-bottom: 15px; }
  .stat-card { min-height: 105px; padding: 13px; border-radius: 10px; }
  .stat-label { font-size: 9px; }
  .stat-value { font-size: 20px; margin-top: 8px; }
  .stat-caption { font-size: 9px; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 13px; }
  .panel-head { padding: 0 14px; }
  .quick-panel { padding: 14px; }
  .empty-state { padding: 25px 13px 28px; }
  .mobile-nav { position: fixed; display: grid; grid-template-columns: repeat(5,1fr); inset: auto 0 0; z-index: 30; padding: 7px 5px calc(7px + env(safe-area-inset-bottom)); min-height: 64px; background: rgba(255,255,255,.96); border-top: 1px solid #e6ebef; backdrop-filter: blur(16px); }
  .mobile-nav .nav-item { min-height: 49px; padding: 4px 2px; border-radius: 8px; flex-direction: column; justify-content: center; gap: 3px; color: #8996a3; font-size: 8px; font-weight: 700; }
  .mobile-nav .nav-item svg { width: 17px; height: 17px; }
  .mobile-nav .nav-item.active { background: transparent; color: #087fc9; box-shadow: none; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .search-box { width: 100%; }
  .table-toolbar .filter-select { align-self: flex-start; }
  .document-row { grid-template-columns: minmax(0,1fr) auto; gap: 3px 10px; padding: 11px 13px; min-height: 66px; }
  .document-row.table-header { display: none; }
  .document-row .doc-primary { grid-column: 1; grid-row: 1 / span 2; }
  .document-row .doc-date { grid-column: 1; margin-left: 43px; grid-row: 3; font-size: 9px; }
  .document-row .doc-client { display: none; }
  .document-row .cell-money { grid-column: 2; grid-row: 1; text-align: right; }
  .document-row .status-pill { grid-column: 2; grid-row: 2; justify-self: end; }
  .document-row .doc-status-cell { grid-column: 2; grid-row: 2; justify-self: end; }
  .catalog-grid { grid-template-columns: 1fr; gap: 9px; }
  .catalog-card { padding: 12px; }
  .catalog-price-row { margin-top: 11px; padding-top: 10px; }
  .client-row { grid-template-columns: minmax(0,1fr) auto; padding: 11px 13px; gap: 5px; }
  .client-row .client-address { grid-column: 1; margin-left: 44px; font-size: 9px; }
  .client-row .client-phone { display: none; }
  .client-row .client-action { grid-column: 2; grid-row: 1; }
  .settings-grid { grid-template-columns: 1fr; }
  .user-invite-form { grid-template-columns:1fr; }
  .user-admin-row { grid-template-columns:minmax(0,1fr) auto; }
  .user-admin-row select { grid-column:1; grid-row:2; width:100%; }
  .user-admin-row button { grid-column:2; grid-row:1 / span 2; }
  .settings-panel { padding: 15px; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal.modal-narrow { border-radius: 17px 17px 0 0; width: 100%; max-height: min(94dvh,900px); padding-bottom: env(safe-area-inset-bottom); }
  .modal.modal-preview { height: 94dvh; max-height: 94dvh; border-radius: 17px 17px 0 0; }
  .modal-head { padding: 15px 16px; }
  .modal-body { padding: 15px 16px; }
  .modal-foot { padding: 11px 16px; }
  .form-grid { grid-template-columns: 1fr; gap: 11px; }
  .field.full { grid-column: auto; }
  .field input, .field select { min-height: 42px; font-size: 12px; }
  .line-editor { overflow: visible; border: 0; display: grid; gap: 8px; }
  .line-editor-head { display: none; }
  .line-editor-row { position: relative; grid-template-columns: 1fr 1fr; gap: 8px; border: 1px solid #e3e9ee; border-radius: 10px; padding: 10px; }
  .line-editor-row select { grid-column: 1/-1; height: 39px; font-size: 11px; padding-right: 28px; }
  .line-editor-row input { height: 38px; font-size: 12px; }
  .line-editor-row::before { content: "Qté"; position: absolute; left: 17px; top: 59px; color: #8b98a5; font-size: 8px; pointer-events: none; }
  .line-editor-row::after { content: "Prix unitaire"; position: absolute; left: calc(50% + 12px); top: 59px; color: #8b98a5; font-size: 8px; pointer-events: none; }
  .line-editor-row input[name="quantity"] { padding: 11px 6px 0; text-align: center; }
  .line-editor-row input[name="unitPrice"] { padding: 11px 8px 0; }
  .line-total { grid-column: 1; text-align: left; align-self: center; padding-left: 2px; }
  .line-total::before { content: "Ligne · "; color: #98a4b0; font-weight: 500; }
  .remove-line { grid-column: 2; justify-self: end; }
  .totals-box { width: 100%; }
  .modal-foot .btn { min-height: 42px; }
  .modal-foot-right { flex: 1; }
  .modal-foot-right .btn { flex: 1; }
  .preview-scroll { padding: 13px; }
  .preview-toolbar .btn { padding: 0 9px; }
  .preview-help { display: none; }
  .toast { left: 14px; right: 14px; bottom: calc(78px + env(safe-area-inset-bottom)); justify-content: center; }
}
@media (max-width: 390px) {
  #view-root { padding-left: 12px; padding-right: 12px; }
  .topbar { padding: 0 12px; }
  .stat-card { padding: 11px; }
  .stat-value { font-size: 18px; }
  .btn-top { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
