:root {
  --blue: #0072ce;
  --blue-dark: #005ca8;
  --pink: #ff8da1;
  --pink-soft: #fff0f3;
  --navy: #08254c;
  --navy-2: #143a68;
  --green: #16a66a;
  --green-soft: #e8fff5;
  --red: #c9364f;
  --amber: #a86600;
  --surface: #ffffff;
  --surface-2: #f3f6fa;
  --line: #dce4ee;
  --muted: #627086;
  --shadow: 0 14px 36px rgba(8, 37, 76, .10);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}

* { box-sizing: border-box; }
html { font-size: 16px; background: var(--surface-2); }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--navy); background: var(--surface-2); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.splash { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--navy); }
.splash-mark { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; background: var(--blue); color: white; font: 900 40px/1 Georgia, serif; box-shadow: 0 14px 30px rgba(0, 114, 206, .25); border: 7px solid var(--pink); }
.splash img { width: min(280px, 78vw); height: auto; border-radius: 15px; }
.splash strong { font-size: 22px; }
.splash span { color: var(--muted); }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, .9fr) minmax(420px, 1.1fr); background: var(--navy); }
.login-brand { position: relative; overflow: hidden; padding: clamp(28px, 6vw, 80px); display: flex; flex-direction: column; justify-content: space-between; color: white; background: linear-gradient(150deg, var(--blue) 0%, var(--navy) 74%); }
.login-brand::before { content: ""; position: absolute; width: 430px; height: 430px; border: 70px solid var(--pink); border-radius: 50%; right: -230px; top: -180px; opacity: .85; }
.login-brand::after { content: ""; position: absolute; width: 260px; height: 260px; border: 36px solid rgba(255,255,255,.12); border-radius: 50%; left: -150px; bottom: -110px; }
.login-brand > * { position: relative; z-index: 1; }
.brand-lockup { display: flex; align-items: center; gap: 14px; font-size: 24px; font-weight: 900; }
.brand-icon { width: 54px; height: 54px; border-radius: 17px; object-fit: cover; box-shadow: 0 10px 24px rgba(0,0,0,.18); }
.login-identity { width: min(100%, 560px); margin: auto; display: grid; justify-items: center; gap: 22px; text-align: center; }
.login-logo { display: block; width: min(100%, 500px); height: auto; border-radius: 24px; box-shadow: 0 22px 54px rgba(0,0,0,.22); }
.login-identity strong { font-size: clamp(30px, 4vw, 48px); line-height: 1; letter-spacing: -.035em; }
.app-brand { display: grid; justify-items: start; gap: 8px; font-size: 19px; line-height: 1.05; }
.brand-logo-small { width: 142px; height: auto; border-radius: 10px; }
.login-brand h1 { font-size: clamp(40px, 6vw, 76px); line-height: .98; letter-spacing: -.045em; margin: 0; max-width: 660px; }
.login-brand h1 em { display: block; color: var(--pink); font-style: normal; }
.login-brand p { font-size: 19px; line-height: 1.55; max-width: 570px; color: rgba(255,255,255,.82); }
.login-panel { background: var(--surface-2); display: grid; place-items: center; padding: 28px; }
.login-card { width: min(100%, 480px); background: white; padding: clamp(24px, 5vw, 46px); border-radius: 28px; box-shadow: var(--shadow); }
.login-card h2 { margin: 0 0 7px; font-size: 32px; letter-spacing: -.03em; }
.login-card > p { margin: 0 0 28px; color: var(--muted); font-size: 17px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; background: var(--navy); color: white; display: flex; flex-direction: column; gap: 24px; }
.sidebar .brand-lockup { padding: 2px 8px 12px; }
.nav-list { display: grid; gap: 7px; }
.nav-button { appearance: none; border: 0; width: 100%; min-height: 52px; border-radius: 14px; padding: 0 14px; display: flex; align-items: center; gap: 12px; background: transparent; color: rgba(255,255,255,.7); font-weight: 750; text-align: left; transition: background 160ms var(--ease-out), color 160ms var(--ease-out), transform 160ms var(--ease-out); }
.nav-button:hover, .nav-button.is-active { color: white; background: rgba(255,255,255,.12); }
.nav-button.is-active { box-shadow: inset 4px 0 var(--pink); }
.nav-button:active, .button:active, .icon-button:active { transform: scale(.97); }
.nav-icon { width: 23px; height: 23px; flex: 0 0 auto; }
.sidebar-footer { margin-top: auto; padding: 12px 8px; border-top: 1px solid rgba(255,255,255,.12); }
.user-chip strong, .user-chip span { display: block; }
.user-chip strong { font-size: 15px; }
.user-chip span { font-size: 13px; color: rgba(255,255,255,.62); text-transform: capitalize; margin-top: 3px; }

.workspace { min-width: 0; }
.topbar { height: 78px; position: sticky; top: 0; z-index: 20; background: rgba(243,246,250,.93); backdrop-filter: blur(16px); display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(18px, 4vw, 48px); border-bottom: 1px solid rgba(8,37,76,.08); }
.topbar h1 { margin: 0; font-size: clamp(22px, 3vw, 31px); letter-spacing: -.03em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.page { max-width: 1260px; margin: 0 auto; padding: 30px clamp(18px, 4vw, 48px) 110px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-heading h2 { font-size: clamp(28px, 4vw, 44px); letter-spacing: -.04em; line-height: 1; margin: 0 0 8px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 17px; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: white; border: 1px solid rgba(8,37,76,.08); border-radius: var(--radius); padding: 22px; box-shadow: 0 8px 24px rgba(8,37,76,.055); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-header h3 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.card-header p { margin: 6px 0 0; color: var(--muted); }
.stat-card { min-height: 142px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; }
.stat-card::after { content: ""; position: absolute; width: 90px; height: 90px; border-radius: 50%; right: -36px; bottom: -38px; background: var(--pink); opacity: .22; }
.stat-card.blue::after { background: var(--blue); }.stat-card.green::after { background: var(--green); }
.stat-label { color: var(--muted); font-size: 14px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: clamp(28px, 4vw, 42px); font-weight: 900; letter-spacing: -.045em; }

.form-section { margin-bottom: 20px; }
.form-section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 7px; grid-column: span 4; min-width: 0; }
.field.span-6 { grid-column: span 6; }.field.span-8 { grid-column: span 8; }.field.span-12 { grid-column: span 12; }.field.span-3 { grid-column: span 3; }
.field label, .field-label { font-size: 14px; font-weight: 800; color: var(--navy-2); }
.field small { color: var(--muted); line-height: 1.35; }
.input, .select, .textarea { width: 100%; min-height: 54px; border: 2px solid var(--line); border-radius: 13px; background: white; color: var(--navy); padding: 12px 14px; font-size: 18px; font-weight: 620; transition: border 160ms var(--ease-out), box-shadow 160ms var(--ease-out); }
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,114,206,.13); }
.input[readonly] { background: #eef3f8; color: var(--muted); }
.input-invalid { border-color: var(--red) !important; }
.input-prefix { position: relative; }.input-prefix .input { padding-left: 43px; }.input-prefix > span { position: absolute; left: 14px; bottom: 17px; font-weight: 850; color: var(--muted); }
.checkbox-row { min-height: 50px; display: flex; align-items: center; gap: 10px; font-weight: 750; }
.checkbox-row input { width: 22px; height: 22px; accent-color: var(--blue); }

.button { appearance: none; border: 0; min-height: 50px; padding: 0 18px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; background: var(--blue); color: white; font-weight: 850; text-decoration: none; transition: transform 160ms var(--ease-out), background 160ms var(--ease-out), opacity 160ms var(--ease-out); }
.button:hover { background: var(--blue-dark); }.button:disabled { opacity: .55; cursor: not-allowed; }
.button.secondary { background: var(--navy); }.button.white { color: var(--navy); background: white; border: 2px solid var(--line); }.button.pink { background: var(--pink); color: var(--navy); }.button.green { background: var(--green); }.button.danger { background: var(--red); }.button.small { min-height: 40px; padding: 0 13px; font-size: 14px; }
.icon-button { width: 46px; height: 46px; border: 0; border-radius: 13px; display: grid; place-items: center; background: white; color: var(--navy); box-shadow: 0 5px 18px rgba(8,37,76,.08); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions.end { justify-content: flex-end; }

.summary-card { background: linear-gradient(145deg, var(--navy), #0e477e); color: white; border: 0; }
.summary-card .muted { color: rgba(255,255,255,.68); }
.summary-total { font-size: clamp(36px, 7vw, 66px); font-weight: 950; letter-spacing: -.055em; margin: 4px 0 18px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.summary-item { background: rgba(255,255,255,.09); border-radius: 13px; padding: 13px; }
.summary-item span, .summary-item strong { display: block; }.summary-item span { font-size: 12px; color: rgba(255,255,255,.67); margin-bottom: 4px; }.summary-item strong { font-size: 17px; }
.cost-breakdown { display: grid; gap: 9px; margin-top: 16px; }.cost-row { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.11); }.cost-row:last-child { border: 0; }.cost-row span { color: rgba(255,255,255,.7); }
.cost-row.financial-row { border-bottom-style: dashed; }
.cost-row.contribution-row { margin-top: 3px; padding: 12px; border: 1px solid rgba(255,141,161,.48); border-radius: 12px; background: rgba(255,141,161,.12); }
.cost-row.contribution-row span { color: white; font-weight: 800; }

.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: white; }
th, td { padding: 14px 15px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; background: #f8fafc; position: sticky; top: 0; }
td { font-size: 15px; } tr:last-child td { border-bottom: 0; }
.list-cards { display: none; gap: 12px; }
.list-card { padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.list-card-top { display: flex; justify-content: space-between; gap: 12px; }
.list-card strong { font-size: 17px; }.list-card p { color: var(--muted); margin: 7px 0 13px; }

.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; background: #e9f3ff; color: #00579c; font-size: 12px; font-weight: 850; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: #087448; }.badge.pink { background: var(--pink-soft); color: #a2243b; }.badge.gray { background: #edf1f5; color: #5c6878; }.badge.amber { background: #fff2d8; color: var(--amber); }
.notice { border-radius: 14px; padding: 14px 16px; line-height: 1.45; background: #e9f3ff; border-left: 5px solid var(--blue); }
.notice.success { background: var(--green-soft); border-color: var(--green); }.notice.error { background: #fff0f2; color: #9d2037; border-color: var(--red); }.notice.warning { background: #fff6df; border-color: #e2a11c; }
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }.empty strong { display: block; color: var(--navy); font-size: 20px; margin-bottom: 5px; }

.segmented { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; }
.segment-button { border: 1px solid var(--line); background: white; color: var(--navy); min-height: 44px; padding: 0 15px; border-radius: 999px; font-weight: 800; white-space: nowrap; }
.segment-button.is-active { color: white; background: var(--navy); border-color: var(--navy); }

.ribbon-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(180px, .8fr) 110px 46px; gap: 10px; margin-bottom: 12px; align-items: end; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.ribbon-row:last-child { border-bottom: 0; padding-bottom: 0; }
.label-item { margin-bottom: 14px; padding: 18px; border: 2px solid var(--line); border-radius: 16px; background: #f8fafc; }
.label-item:last-child { margin-bottom: 0; }
.label-item-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.label-item-header strong { font-size: 18px; }
.selection-help { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.item-summary-list { display: grid; gap: 10px; margin: 18px 0; }
.summary-section-title { margin-top: 20px; font-size: 15px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; color: rgba(255,255,255,.74); }
.item-summary { padding: 14px; border: 1px solid rgba(255,255,255,.16); border-radius: 13px; background: rgba(255,255,255,.07); }
.item-summary-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.item-summary p { margin: 3px 0; color: rgba(255,255,255,.72); }
.search-bar { display: flex; gap: 10px; margin-bottom: 18px; }.search-bar .input { flex: 1; }
.builder-subsection { margin-top: 18px; padding: 16px; background: #f7faff; border: 1px solid #cbd9e8; border-radius: 14px; }
.builder-subsection h4 { margin: 0 0 4px; color: var(--navy); }
.builder-subsection p { margin: 0 0 14px; }
.quote-items-box { display: grid; gap: 10px; margin-top: 18px; padding: 12px; background: #f3f6fa; border: 1px dashed #b8c8da; border-radius: 16px; }
.draft-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; background: white; border: 1px solid #d7e1eb; border-radius: 12px; padding: 12px 14px; }
.draft-item p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.draft-item small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.danger-text { color: #a4203a !important; }
.payment-summary { margin: 14px 0; padding: 11px 13px; background: #f4f8fc; color: var(--navy); border-left: 4px solid var(--pink); border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(8,37,76,.08); }.payment-summary strong { color: var(--navy); }

.modal { position: fixed; inset: 0; z-index: 80; background: rgba(8,37,76,.52); display: grid; place-items: end center; padding: 20px; }
.modal-panel { width: min(100%, 720px); max-height: calc(100vh - 40px); overflow: auto; background: white; border-radius: 24px; padding: 24px; box-shadow: 0 30px 80px rgba(8,37,76,.3); animation: modal-in 230ms var(--ease-out); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }.modal-header h2 { margin: 0; }
.toast-region { position: fixed; z-index: 120; right: 18px; top: 18px; display: grid; gap: 9px; width: min(380px, calc(100% - 36px)); }
.toast { background: var(--navy); color: white; padding: 15px 17px; border-radius: 14px; box-shadow: var(--shadow); animation: toast-in 220ms var(--ease-out); }.toast.error { background: #9d2037; }.toast.success { background: #087448; }
.loading { min-height: 260px; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 4px solid #dce4ee; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
.mobile-nav { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 86px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }.sidebar .brand-lockup span, .nav-button span, .sidebar-footer { display: none; }.sidebar .brand-lockup { justify-content: center; padding-inline: 0; }.brand-logo-small { width: 62px; border-radius: 8px; }.nav-button { justify-content: center; padding: 0; }.nav-button.is-active { box-shadow: inset 0 -4px var(--pink); }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .login-page { display: block; background: var(--surface-2); }.login-brand { min-height: 290px; padding: 28px 22px 44px; }.login-logo { width: min(100%, 330px); border-radius: 18px; }.login-identity { gap: 15px; }.login-identity strong { font-size: 29px; }.login-panel { padding: 0 14px 28px; }.login-card { margin-top: -22px; position: relative; padding: 24px 20px; }
  .login-brand::after { display: none; }
  .app-shell { display: block; }.sidebar { display: none; }.topbar { height: 68px; padding: 0 16px; }.topbar h1 { font-size: 22px; }.page { padding: 22px 14px calc(98px + var(--safe-bottom)); }
  .page-heading { align-items: stretch; flex-direction: column; }.page-heading .button { width: 100%; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }.grid.cols-4.stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }.stat-card { min-height: 118px; padding: 17px; }
  .form-grid { grid-template-columns: 1fr; }.field, .field.span-3, .field.span-6, .field.span-8, .field.span-12 { grid-column: auto; }.input, .select, .textarea { font-size: 18px; min-height: 58px; }.card { padding: 18px; border-radius: 17px; }
  .label-item { padding: 14px; }.label-item-header { align-items: flex-start; }.label-item-header .button { min-width: 44px; padding-inline: 11px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }.summary-total { font-size: 44px; }.ribbon-row { grid-template-columns: minmax(0, 1fr) 46px; }.ribbon-row .field:first-child, .ribbon-row .field:nth-child(2) { grid-column: 1 / -1; }.draft-item { grid-template-columns: minmax(0, 1fr) auto; }.draft-item .badge { grid-column: 1; grid-row: 2; justify-self: start; }
  .table-wrap { display: none; }.list-cards { display: grid; }
  .mobile-nav { position: fixed; z-index: 60; left: 8px; right: 8px; bottom: calc(8px + var(--safe-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--navy); color: white; border-radius: 20px; padding: 7px; box-shadow: 0 20px 45px rgba(8,37,76,.3); }
  .mobile-nav .nav-button { min-height: 58px; display: grid; place-items: center; align-content: center; gap: 3px; padding: 4px; border-radius: 14px; font-size: 10px; text-align: center; }.mobile-nav .nav-button span { display: block; }.mobile-nav .nav-button.is-active { background: var(--blue); box-shadow: none; }
  .mobile-nav .nav-icon { width: 22px; height: 22px; }
  .modal { padding: 0; align-items: end; }.modal-panel { max-height: 93vh; border-radius: 24px 24px 0 0; padding: 20px 16px calc(20px + var(--safe-bottom)); }
  .search-bar { display: grid; }.search-bar .button { width: 100%; }
}

@media (max-width: 420px) {
  .grid.cols-4.stats-grid { grid-template-columns: 1fr; }.summary-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
