:root {
  --navy: #10233f;
  --blue: #135aa0;
  --blue-dark: #0d477f;
  --blue-soft: #eaf3fb;
  --green: #0a8a59;
  --green-soft: #e7f7f0;
  --amber: #a85c00;
  --amber-soft: #fff5df;
  --red: #b42318;
  --red-soft: #feeceb;
  --ink: #182536;
  --muted: #5f6e7d;
  --line: #d8e0e8;
  --surface: #ffffff;
  --canvas: #f4f7fa;
  --shadow: 0 8px 28px rgba(16, 35, 63, .08);
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 20; padding: 10px 14px; color: white; background: var(--navy); border-radius: 6px; }
.skip-link:focus { top: 12px; }

.topbar { min-height: 86px; display: grid; grid-template-columns: 240px 1fr 240px; align-items: center; gap: 24px; padding: 8px max(24px, calc((100vw - 1440px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; color: #1c2e2c; }
.brand-logo { position: relative; display: block; overflow: hidden; width: 220px; height: 90px; }
.brand-logo img { position: absolute; top: -54px; left: 0; display: block; width: 220px; height: 220px; max-width: none; }
.user-badge strong, .user-badge small { display: block; }
.title-wrap { text-align: center; }
.title-wrap h1 { margin: 2px 0 0; font-size: clamp(22px, 3vw, 32px); letter-spacing: -.025em; }
.eyebrow { margin: 0; color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.user-badge { justify-self: end; display: flex; align-items: center; gap: 10px; max-width: 240px; }
.user-badge .avatar { display: grid; flex: 0 0 auto; place-items: center; width: 38px; height: 38px; color: white; font-weight: 700; background: var(--navy); border-radius: 50%; }
.user-badge strong, .user-badge small { max-width: 185px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-badge small { margin-top: 2px; color: var(--muted); }

.main-nav { position: sticky; top: 0; z-index: 10; display: flex; justify-content: center; gap: 8px; padding: 8px 20px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.nav-button { padding: 10px 18px; color: var(--muted); font-weight: 600; background: transparent; border: 0; border-radius: 7px; }
.nav-button:hover { color: var(--blue); background: var(--blue-soft); }
.nav-button.active { color: white; background: var(--navy); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 5px; padding: 0 5px; color: var(--navy); font-size: 11px; background: white; border-radius: 999px; }
.environment-banner { padding: 9px 24px; color: #6d3c00; text-align: center; background: var(--amber-soft); border-bottom: 1px solid #f0d59a; }

main { max-width: 1440px; min-height: calc(100vh - 140px); margin: 0 auto; padding: 28px 24px 60px; }
.view { display: none; }
.view.active { display: block; }
.form-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; gap: 20px; }
.form-workspace > form { min-width: 0; }
.completion-panel { position: sticky; top: 74px; padding: 20px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.completion-summary { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 13px; margin: 10px 0 14px; }
.completion-summary h3 { margin: 0 0 4px; color: var(--navy); font-size: 17px; }
.completion-summary p { margin: 0; color: var(--muted); font-size: 12px; }
.completion-ring { --progress: 0; display: grid; place-items: center; width: 70px; height: 70px; background: conic-gradient(var(--green) calc(var(--progress) * 1%), #e6edf3 0); border-radius: 50%; }
.completion-ring::before { content: ""; grid-area: 1 / 1; width: 54px; height: 54px; background: white; border-radius: 50%; }
.completion-ring strong { z-index: 1; grid-area: 1 / 1; color: var(--navy); font-size: 17px; }
.completion-bar { height: 7px; overflow: hidden; background: #e6edf3; border-radius: 99px; }
.completion-bar span { display: block; width: 0; height: 100%; background: var(--green); border-radius: inherit; transition: width .2s ease; }
.required-progress { margin: 9px 0 16px; color: var(--muted); font-size: 11px; }
.section-progress { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.section-progress li { display: grid; grid-template-columns: 25px 1fr auto; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.section-progress li > span { display: grid; place-items: center; width: 24px; height: 24px; color: var(--blue); font-weight: 700; background: var(--blue-soft); border-radius: 50%; }
.section-progress li strong { color: var(--ink); font-size: 11px; }
.section-progress li.complete > span { color: white; background: var(--green); }
.section-progress li.complete small { color: var(--green); font-weight: 700; }
.completion-pending { margin-top: 16px; padding: 11px; color: #754000; background: var(--amber-soft); border-radius: 7px; }
.completion-pending strong, .completion-pending p { display: block; margin: 0; font-size: 11px; }
.completion-pending p { margin-top: 4px; line-height: 1.35; }
.completion-pending.complete { color: #075e3d; background: var(--green-soft); }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 18px; }
.page-heading h2 { margin: 4px 0 0; font-size: 27px; letter-spacing: -.02em; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.card { margin-bottom: 18px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 22px; }
.section-heading.compact { margin-bottom: 18px; }
.section-heading h3 { margin: 0; font-size: 19px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.section-number { display: grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; color: var(--blue); font-size: 12px; font-weight: 800; background: var(--blue-soft); border-radius: 50%; }

.field-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 20px; }
.field-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; min-width: 0; gap: 7px; }
.field.span-2 { grid-column: span 2; }
.field.span-4 { grid-column: 1 / -1; }
.field label, .toolbar label > span { color: #2c3e50; font-size: 13px; font-weight: 650; }
.required { color: var(--red); }
.field input, .field select, .field textarea, .toolbar input, .toolbar select { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); background: white; border: 1px solid #b9c5d2; border-radius: 6px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .toolbar select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(19,90,160,.13); }
.field select[multiple] { min-height: 104px; }
.field input[readonly] { color: #465465; background: #f0f3f6; border-color: #dde3e9; }
.field-help { margin: -2px 0 0; color: var(--muted); font-size: 11px; }
.form-note { margin: 20px 0 0; padding: 10px 12px; color: #344659; font-size: 13px; background: #f7f9fb; border-left: 3px solid var(--blue); }
.split-card { display: grid; grid-template-columns: 1fr 1.25fr; gap: 32px; }
.subsection + .subsection { padding-left: 32px; border-left: 1px solid var(--line); }

.signature-pad { display: grid; grid-template-columns: minmax(280px, 620px) 1fr; gap: 18px; align-items: start; }
.signature-upload-wrap { position: relative; display: grid; place-items: center; overflow: hidden; width: 100%; height: 180px; min-height: 0; padding: 12px; background: #fff; border: 1px dashed #8da0b3; border-radius: 8px; }
.signature-placeholder { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: #748394; font-size: 13px; }
.signature-controls { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; }
.signature-preview { display: block; width: 100%; height: 156px; min-width: 0; padding: 6px; object-fit: contain; background: white; border-radius: 6px; }
.signature-preview[hidden] { display: none; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; opacity: 0; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding: 18px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 22px rgba(16,35,63,.08); }
.button { min-height: 42px; padding: 9px 16px; font-weight: 700; border: 1px solid transparent; border-radius: 6px; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { color: white; background: var(--blue); }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); }
.button-secondary { color: var(--navy); background: white; border-color: #aebbc8; }
.button-secondary:hover { background: #f2f5f8; }
.button-ghost { color: var(--blue); background: var(--blue-soft); }
.button-danger { color: var(--red); background: var(--red-soft); }
.button-approve { color: #145c3d; background: #dff4e8; border-color: #9ed0b7; }
.button-approve:hover:not(:disabled) { color: #0d4a30; background: #ccebd9; border-color: #79bd99; }
.icon-button { width: 38px; height: 38px; color: var(--muted); font-size: 27px; line-height: 1; background: transparent; border: 0; border-radius: 50%; }
.icon-button:hover { background: #eef2f6; }

.status { display: inline-flex; align-items: center; width: fit-content; padding: 5px 9px; font-size: 11px; font-weight: 750; border-radius: 999px; }
.status-draft { color: #4c5966; background: #e9edf1; }
.status-commercial { color: #805000; background: #fff1cc; }
.status-manager { color: #714b8a; background: #f3eafa; }
.status-projects { color: #075a76; background: #dff4fb; }
.status-development { color: #805000; background: #fff1cc; }
.status-director { color: #334f8a; background: #e6edff; }
.status-done { color: #087047; background: #ddf6eb; }
.status-rejected { color: #9b1c1c; background: var(--red-soft); }

.toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) 260px; gap: 16px; box-shadow: none; }
.toolbar label { display: flex; flex-direction: column; gap: 6px; }
.toolbar-note { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 4px 0; }
.toolbar-note strong { color: var(--navy); font-size: 13px; }
.toolbar-note span { color: var(--muted); font-size: 12px; }
.records-content { min-height: 220px; }
.consultation-table-wrap, .consultation-details { padding: 0; overflow: hidden; box-shadow: none; }
.consultation-detail-row > td { padding: 0 !important; background: #f8fafc; border-bottom: 2px solid #9eb7ce !important; }
.consultation-details { margin: 12px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.table-title { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.table-title h3 { margin: 0; color: var(--navy); font-size: 17px; font-weight: 650; }
.table-scroll { overflow-x: auto; }
.consultation-table, .details-table { width: 100%; border-collapse: collapse; }
.consultation-table th, .consultation-table td, .details-table th, .details-table td { padding: 13px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.consultation-table th { color: #38506a; font-size: 12px; background: #eef3f7; white-space: nowrap; }
.consultation-table td { font-size: 13px; }
.consultation-table tbody tr:last-child td, .details-table tbody tr:last-child th, .details-table tbody tr:last-child td { border-bottom: 0; }
.consultation-table tbody tr.selected { background: #f0f6ff; }
.consultation-table .rfq-group-row > td { padding: 10px 14px; color: var(--navy); background: #dfeaf4; border-top: 2px solid #b8cada; border-bottom: 1px solid #b8cada; }
.consultation-table .rfq-group-row:first-child > td { border-top: 0; }
.rfq-group-row strong { margin-right: 10px; font-size: 14px; }
.rfq-group-row span { color: #536b82; font-size: 11px; font-weight: 650; }
.consultation-table .rfq-revision-row > td:first-child { padding-left: 24px; }
.consultation-table td:nth-child(7) { min-width: 240px; overflow-wrap: anywhere; }
.consultation-table .button { white-space: nowrap; }
.details-table th { width: 15%; color: var(--muted); font-size: 11px; font-weight: 650; background: #f7f9fb; }
.details-table td { width: 35%; color: var(--ink); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.development-table-wrap { padding: 0; overflow-x: auto; box-shadow: none; }
.development-table { width: 100%; min-width: 980px; border-collapse: collapse; }
.development-table th, .development-table td { padding: 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.development-table th { color: #38506a; font-size: 12px; background: #eef3f7; white-space: nowrap; }
.development-table td { font-size: 13px; }
.development-table tbody tr:last-child td { border-bottom: 0; }
.development-table td:first-child strong, .development-table td:first-child small { display: block; }
.development-table td:first-child small { margin-top: 4px; color: var(--muted); }
.development-table select { min-width: 170px; height: 42px; padding: 8px 34px 8px 10px; background: white; border: 1px solid #afbdca; border-radius: 6px; }
.development-table tr.release-locked { background: #f2faf6; }
.development-table .development-group-row > td { padding: 9px 14px; color: var(--navy); background: #dfeaf4; border-top: 2px solid #b8cada; border-bottom: 1px solid #b8cada; }
.development-table .development-group-row:first-child > td { border-top: 0; }
.development-group-row strong { margin-right: 10px; font-size: 14px; }
.development-group-row span { color: #536b82; font-size: 11px; font-weight: 650; }
.development-table select:disabled { color: #245c43; font-weight: 700; background: #e6f5ed; border-color: #b8dac8; opacity: 1; }
.development-final-approvals { display: grid; gap: 10px; margin-top: 20px; }
.print-report { display: none; }
.record-list { display: grid; gap: 10px; }
.record-group-list { display: grid; gap: 16px; }
.record-group { overflow: hidden; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; }
.record-group-header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: var(--navy); background: #dfeaf4; border-bottom: 1px solid #b8cada; }
.record-group-header strong { font-size: 14px; }
.record-group-header span { color: #536b82; font-size: 11px; font-weight: 650; }
.record-group .record-list { gap: 0; }
.record-group .record-card { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.record-group .record-card:last-child { border-bottom: 0; }
.record-card { display: grid; grid-template-columns: 1.3fr 1.1fr 1fr auto; align-items: center; gap: 18px; padding: 17px 19px; background: white; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 3px 12px rgba(16,35,63,.04); }
.record-card:hover { border-color: #9eb7ce; }
.record-main strong, .record-meta strong { display: block; }
.record-main span, .record-meta span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.record-actions { display: flex; gap: 8px; }
.empty-state { display: grid; place-items: center; padding: 60px 20px; color: var(--muted); text-align: center; background: white; border: 1px dashed #b8c4d0; border-radius: 10px; }
.empty-state > span { color: #8aa2b8; font-size: 40px; }
.empty-state h3 { margin: 8px 0 3px; color: var(--ink); }
.empty-state p { margin: 0; }
.loading { padding: 50px; color: var(--muted); text-align: center; }

.dialog { width: min(920px, calc(100vw - 30px)); height: calc(100dvh - 30px); max-height: calc(100vh - 30px); padding: 0; overflow: clip; border: 0; border-radius: 13px; box-shadow: 0 30px 80px rgba(2,15,31,.35); }
.dialog::backdrop { background: rgba(10,25,43,.64); backdrop-filter: blur(2px); }
.dialog-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; height: 100%; min-height: 0; }
.dialog-header, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; background: white; }
.dialog-header { min-height: 0; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 3px 0 0; }
.dialog-content { min-height: 0; overflow: auto; padding: 22px; background: var(--canvas); }
.dialog-actions { align-self: auto; justify-content: flex-end; min-height: 0; max-height: 92px; overflow-x: auto; overflow-y: hidden; border-top: 1px solid var(--line); }
.detail-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.detail-summary div, .detail-grid div { padding: 12px; background: white; border: 1px solid var(--line); border-radius: 7px; }
.detail-summary small, .detail-grid dt { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; }
.detail-summary strong { overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0; }
.detail-grid dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.approval-box { margin-top: 18px; padding: 18px; background: white; border: 1px solid #b8cee1; border-radius: 8px; }
.approval-box h3 { margin-top: 0; }

.toast-region { position: fixed; right: 18px; top: 105px; z-index: 100; display: grid; gap: 9px; width: min(390px, calc(100vw - 36px)); }
.toast { padding: 13px 15px; color: white; background: var(--navy); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: slide-in .2s ease-out; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes slide-in { from { opacity: 0; transform: translateX(15px); } }

.submission-overlay { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 20px; background: rgba(10,25,43,.58); backdrop-filter: blur(2px); }
.submission-overlay[hidden] { display: none; }
.submission-popover { display: flex; align-items: center; gap: 18px; width: min(470px, 100%); padding: 25px 27px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 24px 70px rgba(2,15,31,.32); }
.submission-popover strong { display: block; color: var(--navy); font-size: 18px; }
.submission-popover p { margin: 5px 0 0; color: var(--muted); line-height: 1.45; }
.submission-spinner { flex: 0 0 42px; width: 42px; height: 42px; border: 5px solid #dce9e4; border-top-color: var(--green); border-radius: 50%; animation: submission-spin .8s linear infinite; }
@keyframes submission-spin { to { transform: rotate(360deg); } }

@media (max-width: 1000px) {
  .topbar { grid-template-columns: 1fr auto; }
  .title-wrap { grid-column: 1 / -1; grid-row: 2; text-align: left; }
  .field-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split-card { grid-template-columns: 1fr; }
  .subsection + .subsection { padding: 26px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .record-card { grid-template-columns: 1fr 1fr; }
  .record-actions { justify-content: flex-end; }
}

@media (max-width: 1180px) {
  .form-workspace { grid-template-columns: 1fr; }
  .form-workspace > form { grid-row: 2; }
  .completion-panel { position: static; grid-row: 1; }
  .section-progress { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
  .topbar { padding: 12px 16px; }
  .brand-logo { width: 150px; height: 64px; }
  .brand-logo img { top: -38px; width: 150px; height: 150px; }
  .user-badge small { display: none; }
  .main-nav { justify-content: stretch; overflow-x: auto; }
  .nav-button { flex: 1 0 auto; }
  main { padding: 20px 12px 50px; }
  .card { padding: 18px 15px; }
  .field-grid, .field-grid.two-columns, .toolbar, .detail-summary, .detail-grid { grid-template-columns: 1fr; }
  .field.span-2, .field.span-4 { grid-column: auto; }
  .signature-pad { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; padding: 12px; }
  .form-actions .button { flex: 1 1 100%; }
  .record-card { grid-template-columns: 1fr; }
  .record-actions { justify-content: stretch; }
  .record-actions .button { flex: 1; }
  .section-progress { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
  .main-nav, .environment-banner, .form-actions, .button, .user-badge, .completion-panel { display: none !important; }
  body, :root { background: white; }
  main { max-width: none; padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
  body.print-query > .topbar, body.print-query > .main-nav, body.print-query > .environment-banner, body.print-query > main, body.print-query > dialog, body.print-query > .toast-region { display: none !important; }
  body.print-query .print-report { display: block !important; padding: 0; color: #111; font-family: Arial, sans-serif; }
  .print-report header { margin-bottom: 18px; border-bottom: 2px solid #111; }
  .print-report header p { margin: 0 0 5px; font-size: 11px; font-weight: 700; letter-spacing: .12em; }
  .print-report header h1 { margin: 0 0 6px; font-size: 22px; }
  .print-report header span, .print-filters { font-size: 10px; }
  .print-record-full { break-before: page; }
  .print-record-full:first-of-type { break-before: auto; }
  .print-record-full h2 { margin: 18px 0 8px; font-size: 16px; }
  .print-record-full table { width: 100%; border-collapse: collapse; font-size: 8px; }
  .print-record-full th, .print-record-full td { padding: 4px 5px; text-align: left; vertical-align: top; border: 1px solid #bbb; overflow-wrap: anywhere; }
  .print-record-full th { width: 16%; background: #eee; }
  .print-record-full td { width: 34%; }
  .print-signature { display: block; width: auto; max-width: 180px; max-height: 70px; object-fit: contain; }
  .print-filters { margin: 0 0 12px; }
  .print-report table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 9px; }
  .print-report th, .print-report td { padding: 6px 5px; text-align: left; vertical-align: top; overflow-wrap: anywhere; border: 1px solid #999; }
  .print-report th { background: #e8edf2; }
  .print-report tr { break-inside: avoid; }
}
