:root {
  --ink: #182137;
  --muted: #667085;
  --line: #d8deea;
  --soft: #f2f5fa;
  --paper: #ffffff;
  --blue: #172c78;
  --blue-2: #2448b4;
  --gold: #968d68;
  --green: #18794e;
  --red: #b42318;
  --shadow: 0 14px 40px rgba(25, 36, 70, .08);
}

* { box-sizing: border-box; }
body { margin: 0; background: #f6f7fb; color: var(--ink); font: 15px/1.5 Arial, Helvetica, sans-serif; }
a { color: var(--blue-2); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(30px, 4vw, 44px); letter-spacing: -.035em; }
h2 { margin-bottom: 10px; font-size: 21px; letter-spacing: -.02em; }
small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

.app-header { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 12px max(24px, calc((100vw - 1240px) / 2)); border-bottom: 1px solid rgba(216,222,234,.9); background: rgba(255,255,255,.93); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: baseline; gap: 14px; color: var(--ink); }
.brand-mark { color: var(--blue); font-size: 25px; font-weight: 900; letter-spacing: -.07em; }
.brand-copy { color: var(--muted); font-size: 13px; }
.app-header nav { display: flex; align-items: center; gap: 18px; }
.logout-form { margin: 0; }
.page-shell { width: min(1240px, calc(100% - 40px)); margin: 38px auto 90px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.eyebrow, .step-number { margin-bottom: 6px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); }
.card { border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); padding: 26px; }
.table-card { overflow: hidden; padding: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.section-heading h2 { margin-bottom: 0; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.button-primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.button-primary:hover { background: #0e205f; }
.button-secondary { border-color: var(--line); background: #fff; color: var(--blue); }
.button-danger { border-color: #f0b4ae; background: #fff; color: var(--red); }
.button-danger:hover { background: #fff0ee; }
.button-ghost { color: var(--muted); }
.button-wide { width: 100%; }

.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 16px; background: var(--soft); color: #4b556b; font-size: 11px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 15px 16px; border-top: 1px solid var(--line); vertical-align: top; }
td small { margin-top: 2px; }
.number { text-align: right; white-space: nowrap; }
.actions { text-align: right; }
.table-actions { display: flex; justify-content: flex-end; gap: 8px; }
.table-actions form { margin: 0; }
.status { display: inline-flex; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-draft { background: #fff6d8; color: #7a5200; }
.status-final { background: #e8f7ef; color: var(--green); }
.status-inactive { background: #f2f4f7; color: var(--muted); }
.empty-state { padding: 72px 24px; text-align: center; }

.detail-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; margin-bottom: 18px; }
.detail-grid.slim { grid-template-columns: 1fr 1fr; margin: 14px 0 0; }
.compact-details { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.compact-details div { display: flex; flex-direction: column; gap: 4px; }
.compact-details span { color: var(--muted); font-size: 12px; }
.totals-panel { width: min(440px, 100%); margin: 22px 22px 22px auto; }
.totals-panel div { display: flex; justify-content: space-between; gap: 18px; padding: 7px 4px; }
.totals-panel .grand-total { margin-top: 7px; padding-top: 14px; border-top: 2px solid var(--blue); font-size: 18px; }
.terms-card, .finalize-card, .vies-card { margin-top: 18px; }
.finalize-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; }

.quote-form { display: grid; gap: 22px; }
.form-section { padding: 28px; }
.directory-picker { display: flex; align-items: end; gap: 14px; margin-bottom: 22px; border-radius: 12px; background: var(--soft); padding: 16px; }
.directory-picker .field { flex: 1; }
.customer-search { position: relative; }
.customer-search-results { position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; left: 0; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 16px 36px rgba(25,36,70,.18); }
.customer-search-result { display: block; width: 100%; border: 0; border-top: 1px solid var(--line); background: #fff; color: var(--ink); padding: 11px 13px; text-align: left; cursor: pointer; }
.customer-search-result:first-child { border-top: 0; }
.customer-search-result:hover, .customer-search-result:focus { background: var(--soft); outline: none; }
.customer-search-result strong { display: block; }
.customer-search-message { padding: 12px 13px; color: var(--muted); }
.customer-search-message.error { color: var(--red); }
.directory-search { display: flex; align-items: end; gap: 12px; margin-bottom: 18px; }
.directory-table .button { white-space: nowrap; }
.form-grid { display: grid; gap: 17px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field.grow { flex: 1; }
.field label { color: #344054; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid #cbd2df; border-radius: 9px; background: #fff; color: var(--ink); font: inherit; padding: 9px 11px; outline: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(36,72,180,.12); }
.checkbox-field { justify-content: end; }
.checkbox-field label { display: flex; align-items: center; min-height: 42px; gap: 9px; }
.checkbox-field input { width: 18px; min-height: 18px; }
.section-divider { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.info-panel { margin-top: 16px; border-left: 3px solid var(--gold); border-radius: 6px; background: #faf8f1; color: #585239; padding: 12px 14px; font-size: 13px; }
.inline-status { margin-top: 16px; border-radius: 8px; padding: 11px 13px; font-weight: 700; }
.inline-status.loading { background: var(--soft); }
.inline-status.success { background: #e8f7ef; color: var(--green); }
.inline-status.error { background: #fff0ee; color: var(--red); }
.errorlist { margin: 2px 0 0; padding-left: 18px; color: var(--red); font-size: 12px; }

.items-stack { display: grid; gap: 18px; }
.item-card { border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 8px 24px rgba(25,36,70,.06); padding: 22px; }
.item-card-header { display: flex; align-items: end; gap: 16px; margin-bottom: 20px; }
.remove-item { border: 0; background: transparent; color: var(--red); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; padding: 11px 0; }
.delete-field { display: none; }
.subsection { margin: 18px 0 0; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.subsection legend { padding: 0 7px; color: var(--muted); font-size: 12px; font-weight: 800; }
.pricing-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 17px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.sticky-actions { position: sticky; z-index: 10; bottom: 16px; display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.94); box-shadow: 0 18px 50px rgba(20,29,58,.16); padding: 12px; backdrop-filter: blur(16px); }

.messages { display: grid; gap: 8px; margin-bottom: 20px; }
.message { border-radius: 10px; background: var(--soft); padding: 12px 14px; }
.message-success { background: #e8f7ef; color: var(--green); }
.message-error { background: #fff0ee; color: var(--red); }
.login-card { width: min(420px, 100%); margin: 80px auto; padding: 36px; }
.stack-form { display: grid; gap: 18px; }
.stack-form label { display: grid; gap: 7px; font-weight: 700; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.users-table-heading { padding: 24px 26px 12px; }
.users-table-heading h2 { margin-bottom: 6px; }
.users-table-heading p { max-width: 800px; margin-bottom: 0; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 18px; border-color: #f0b4ae; }
.danger-zone h2 { color: var(--red); }
.danger-zone p { margin-bottom: 0; }

[hidden] { display: none !important; }

@media (max-width: 850px) {
  .brand-copy, .app-header nav > a:first-child { display: none; }
  .page-shell { width: min(100% - 24px, 1240px); margin-top: 24px; }
  .page-heading, .finalize-card, .directory-picker, .directory-search { align-items: stretch; flex-direction: column; }
  .detail-grid, .detail-grid.slim, .form-grid.two, .form-grid.three, .form-grid.four, .pricing-grid, .admin-grid { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .compact-details { grid-template-columns: 1fr 1fr; }
  .card, .form-section { padding: 20px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .danger-zone { align-items: stretch; flex-direction: column; }
}
