:root {
  color-scheme: light;
  --ink: #071526;
  --navy: #123560;
  --muted: #44586c;
  --line: #d8e2ec;
  --paper: #f4f8fc;
  --blue: #1a5bd7;
  --blue-hover: #154bac;
  --blue-quiet: #eaf2ff;
  --white: #fff;
  --radius: .625rem;
  --sidebar: 14rem;
  font: 16px/1.5 'Segoe UI', Aptos, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
input:disabled, select:disabled, textarea:disabled { color: var(--muted); background: var(--paper); opacity: 1; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
h1:focus { outline: none; }
h1, h2, p, dl, dd { margin: 0; }
h1, h2 { overflow-wrap: anywhere; }
h1 { font-size: clamp(1.9rem, 4.1vw, 2.65rem); line-height: 1.13; letter-spacing: -.035em; }
h2 { font-size: 1.12rem; line-height: 1.35; letter-spacing: -.013em; }

.skip { position: fixed; z-index: 5; top: .5rem; left: .5rem; padding: .5rem 1rem; transform: translateY(-180%); background: var(--white); color: var(--blue); }
.skip:focus { transform: none; }
.loading { padding: 2rem; color: var(--muted); }
.eyebrow { color: var(--muted); font-size: .7rem; line-height: 1.35; font-weight: 750; letter-spacing: .12em; }
.intro { margin-top: .55rem; color: var(--muted); overflow-wrap: anywhere; }

.brand { display: flex; align-items: center; gap: .65rem; white-space: nowrap; }
.brand img { inline-size: 2.35rem; block-size: 2.35rem; object-fit: contain; }
.brand strong, .brand small { display: block; line-height: 1.3; }
.brand strong { font-size: 1.18rem; letter-spacing: -.04em; }
.brand small { color: var(--muted); font-size: .75rem; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; border: 1px solid transparent;
  border-radius: var(--radius); padding: .55rem .85rem; font-size: .875rem; font-weight: 650; line-height: 1.3; text-align: center; }
.primary { color: var(--white); background: var(--blue); }
.primary:hover:not(:disabled) { background: var(--blue-hover); }
.secondary { color: var(--navy); background: var(--white); border-color: var(--line); }
.secondary:hover:not(:disabled), .quiet:hover:not(:disabled) { background: var(--blue-quiet); color: var(--blue-hover); }
.quiet { color: var(--muted); background: transparent; }

.auth { max-width: 72rem; margin: auto; padding: 1.5rem clamp(1rem, 4vw, 3rem) 3rem; }
.auth-brand { padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.auth-panel { max-width: 30rem; margin: clamp(2rem, 8vh, 6rem) auto 0; background: var(--white);
  border: 1px solid var(--line); border-top: 3px solid var(--navy); border-radius: var(--radius); padding: clamp(1.25rem, 5vw, 2rem); }
.auth-panel h1 { margin-top: .65rem; font-size: clamp(1.65rem, 5vw, 2.1rem); }
.auth-panel > .button { margin-top: 1.35rem; }
.auth-form { display: grid; gap: 1rem; margin-top: 1.4rem; }

.workspace { display: grid; grid-template: 'sidebar topbar' auto 'sidebar content' 1fr / var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }
.sidebar { display: flex; flex-direction: column; align-self: start; position: sticky; top: 0;
  grid-area: sidebar; min-height: 100dvh; padding: 1rem .8rem; background: var(--white); border-right: 1px solid var(--line); }
.sidebar .brand { padding: .38rem .32rem 1.16rem; border-bottom: 1px solid var(--line); }
.sidebar nav { margin-top: 1.55rem; }
.sidebar nav .eyebrow { padding: 0 .55rem .65rem; }
.nav-current { color: var(--blue-hover); font-weight: 700; font-size: .88rem; min-height: 2.75rem; background: var(--blue-quiet);
  border: 0; border-radius: var(--radius); padding: .5rem .65rem; width: 100%; text-align: left; }
.nav-current:hover { background: #deeaff; }
.logout { margin-top: auto; text-align: left; align-self: start; }
.topbar { grid-area: topbar; min-height: 4rem; padding: .48rem clamp(1rem, 3.2vw, 2.85rem); display: flex; flex-wrap: wrap; align-items: center; gap: .6rem;
  border-bottom: 1px solid var(--line); background: var(--white); color: var(--muted); font-size: .84rem; }
.topbar strong { color: var(--navy); }
.topbar-divider { color: #6b7d90; }
.menu-toggle { display: none; }
.content { grid-area: content; width: 100%; max-width: 88rem; min-width: 0; margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.75rem) clamp(1rem, 3.2vw, 2.85rem) 3rem; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.45rem; }
.page-header > div:first-child { min-width: 0; }
.page-header .eyebrow { margin-bottom: .45rem; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.page-actions .badge { margin-right: .2rem; }
.back { padding-inline: 0; margin: -.4rem 0 .7rem; }

.message { background: #ffefef; color: #8c2632; }
.success { background: #e8f5ee; color: #235c3c; margin-bottom: 1rem; }
.message, .success { border-radius: var(--radius); padding: .65rem .8rem; font-size: .875rem; overflow-wrap: anywhere; }
.message:empty { padding: 0; }
.content > .message:not(:empty) { margin-bottom: .8rem; }
.auth-form .message:empty { display: none; }

.worklist, .editor-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.worklist { overflow: hidden; }
.filters { display: grid; grid-template-columns: minmax(12rem, 1fr) repeat(2, minmax(8rem, 11rem)); gap: .75rem; padding: 1rem 1.15rem; }
.field { display: grid; gap: .3rem; min-width: 0; align-content: start; }
.field > span { color: var(--muted); font-size: .77rem; font-weight: 700; }
.field input:not([type='checkbox']), .field select, .field textarea { width: 100%; min-width: 0; min-height: 2.75rem; padding: .47rem .65rem;
  border: 1px solid #aabbd0; border-radius: .4rem; color: var(--ink); background-color: var(--white); }
.field :is(input, select, textarea):disabled { color: var(--muted); background-color: var(--paper); border-color: var(--line); }
.field textarea { resize: vertical; }
.field input::placeholder { color: #596d83; opacity: 1; }
.count { color: var(--muted); padding: .02rem 1.15rem .65rem; font-size: .8rem; }
.count:first-child, .filters[hidden] + .count:not(:empty) { padding-top: 1rem; }
.count:empty { display: none; }
.empty { padding: 2.65rem 1rem 3.2rem; border-top: 1px solid var(--line); text-align: center; }
.empty-icon { display: inline-grid; place-items: center; width: 2.15rem; height: 2.15rem; border-radius: .45rem; margin-bottom: .6rem;
  color: var(--blue-hover); background: var(--blue-quiet); font-size: 1.15rem; }
.empty p { margin: .38rem 0 .85rem; color: var(--muted); font-size: .9rem; }
.quotes-table { width: 100%; table-layout: fixed; }
table { border-collapse: collapse; }
.quotes-table th, .quotes-table td { text-align: left; padding: .65rem .6rem; border-top: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
.quotes-table :is(th, td):first-child { padding-left: 1.15rem; }
.quotes-table :is(th, td):last-child { padding-right: 1.15rem; }
.quotes-table th { color: var(--muted); background: var(--paper); font-size: .77rem; font-weight: 750; }
.quotes-table th:nth-child(1) { width: 24%; }
.quotes-table th:nth-child(2) { width: 20%; }
.quotes-table th:nth-child(3) { width: 13%; }
.quotes-table th:nth-child(4) { width: 14%; }
.quotes-table th:nth-child(5) { width: 14%; }
.quotes-table td { font-size: .86rem; }
.quotes-table tr:hover td { background: #f8fbff; }
.row-link { border: 0; background: transparent; color: var(--blue-hover); font-size: .91rem; font-weight: 700; text-align: left;
  padding: 0; min-height: 2rem; max-width: 100%; overflow-wrap: anywhere; }
.row-link:hover { text-decoration: underline; }
.quote-cell small { display: block; color: var(--muted); font-size: .74rem; }
.money, .item-amount, .totals dd { font-variant-numeric: tabular-nums; }
.money { font-weight: 700; }
.last-updated { color: var(--muted); }
.mobile-label { display: none; }
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .19rem .47rem; border-radius: 1rem; background: #edf1f6;
  color: #3c5065; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge::before { content: ''; width: .34rem; height: .34rem; border-radius: 50%; background: currentColor; }
.badge.sent { background: #e7f0ff; color: #194b9c; }
.badge.accepted { background: #e4f4eb; color: #22613e; }
.badge.rejected { background: #ffeced; color: #9a3039; }

.editor-fields { margin: 0; border: 0; padding: 0; min-inline-size: 0; }
.editor-card { padding: clamp(1rem, 2.15vw, 1.4rem); margin-bottom: .9rem; }
.editor-card h2 { margin-bottom: .85rem; }
.form-grid, .settlement, .total-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.span-two { grid-column: span 2; }
.field-help { align-self: end; color: var(--muted); font-size: .8rem; padding-bottom: .2rem; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .65rem; margin-bottom: .75rem; flex-wrap: wrap; }
.section-heading h2 { margin-bottom: .12rem; }
.section-heading p { color: var(--muted); font-size: .83rem; }
.items-list { padding: 0; margin: 0; list-style: none; }
.item-row { display: grid; grid-template-columns: 1.6rem minmax(9rem, 2fr) minmax(4rem, .75fr) minmax(3.6rem, .65fr) minmax(6rem, 1fr) minmax(5rem, .85fr) auto;
  gap: .5rem; align-items: end; padding: .75rem 0; border-top: 1px solid var(--line); }
.item-index { align-self: end; padding-bottom: .8rem; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.item-amount { display: flex; align-items: center; min-height: 2.75rem; font-weight: 700; overflow-wrap: anywhere; }
.remove-item { color: #8c2632; padding-inline: .5rem; }
.settlement { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.2rem; }
.total-controls { align-items: end; margin: .25rem 0 .8rem; }
.checkbox-field { display: flex; min-height: 2.75rem; align-items: center; gap: .4rem; }
.checkbox-field input { order: -1; inline-size: 1.12rem; block-size: 1.12rem; accent-color: var(--blue); }
.totals { border-radius: var(--radius); background: var(--paper); padding: .65rem .85rem; }
.totals div { display: flex; justify-content: space-between; gap: .85rem; padding: .22rem 0; font-size: .87rem; }
.totals dt { color: var(--muted); }
.totals dd { text-align: right; font-weight: 650; overflow-wrap: anywhere; min-width: 0; }
.totals .total-row { border-top: 1px solid var(--line); margin-top: .35rem; padding: .5rem 0 .13rem; font-size: 1.04rem; }
.total-row dt, .total-row dd { color: var(--navy); font-weight: 750; }
.editor-footer { display: flex; gap: .75rem; justify-content: space-between; align-items: center; }
.editor-footer .button { flex: 0 0 auto; }
#print-quote { display: none; }

@media (max-width: 68rem) {
  .item-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .item-row .description-field { grid-column: 2 / -1; }
  .item-index { align-self: start; padding: 0; }
  .item-row .remove-item { justify-self: start; }
}

@media (max-width: 60rem) {
  .workspace { display: flex; flex-direction: column; }
  .sidebar { display: none; position: static; width: 100%; min-height: auto; border: 0; border-bottom: 1px solid var(--line); }
  .menu-open .sidebar { display: flex; }
  .sidebar nav { margin: .75rem 0 .45rem; }
  .menu-toggle { display: inline-flex; }
}

@media (max-width: 44rem) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-field { grid-column: 1 / -1; }
  .quotes-table, .quotes-table tbody { display: block; }
  .quotes-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .quotes-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; border-top: 1px solid var(--line); padding: .65rem 1.15rem .85rem; }
  .quotes-table tr:nth-of-type(even) { background: #fbfdff; }
  .quotes-table :is(td, td:first-child, td:last-child) { display: block; border: 0; padding: 0; }
  .quote-cell { grid-column: span 2; }
  .quotes-table .row-link { min-height: 2.75rem; }
  .mobile-label { display: block; margin-bottom: .15rem; color: var(--muted); font-size: .72rem; }
  .settlement { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 34rem) {
  .topbar > span { display: none; }
  .item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-row .description-field { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-two { grid-column: auto; }
  .editor-footer { flex-wrap: wrap; justify-content: flex-end; }
  .editor-footer .message:not(:empty) { width: 100%; }
}

@page { size: A4; margin: 15mm; }
@media print {
  :root, body { background: white; color: #071526; font-size: 12pt; }
  body:has(#print-quote:not([hidden])) #app, .skip { display: none !important; }
  #print-quote:not([hidden]) { display: block; overflow-wrap: anywhere; }
  .print-header { display: flex; align-items: center; gap: 1rem; border-bottom: 2px solid var(--navy); padding: 0 0 .6rem; margin: 0 0 .85rem; }
  .print-header img { width: 2.7rem; height: 2.7rem; object-fit: contain; }
  .print-header h1 { font-size: 22pt; }
  .print-header p { color: var(--muted); }
  .print-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem 1rem; margin: .65rem 0 .85rem; }
  .print-details dt { font-weight: 700; }
  .print-items { width: 100%; margin: 0 0 .7rem; }
  .print-items th, .print-items td { border-bottom: 1px solid #b5c1cf; padding: .3rem; text-align: left; }
  .print-items td:first-child { width: 38%; }
  .print-items :is(th, td):nth-child(n+4) { text-align: right; }
  .print-items tr { break-inside: avoid; }
  #print-quote .totals { width: 50%; margin-left: auto; border: 1px solid var(--line); break-inside: avoid; }
  #print-quote .totals div { font-size: 12pt; }
  .print-terms { margin-top: .8rem; }
  .print-terms h2 { break-after: avoid; }
  .print-terms p { white-space: pre-wrap; }
}
