:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #e5e9f0;
  --paper: #ffffff;
  --canvas: #f4f6f8;
  --nav: #111827;
  --nav-soft: #1f2937;
  --accent: #e4a23b;
  --accent-dark: #a45f0a;
  --accent-soft: #fff4de;
  --green: #08745b;
  --green-soft: #e8f7f1;
  --red: #b42318;
  --red-soft: #fff0ee;
  --blue: #275ea8;
  --blue-soft: #edf4ff;
  --radius: 18px;
  --shadow: 0 18px 46px rgba(16, 24, 40, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.loading-view { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.loader-mark, .brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; color: #201304; background: linear-gradient(145deg, #f7c66b, var(--accent)); font-weight: 900; box-shadow: 0 8px 20px rgba(228, 162, 59, .28); }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 620px) 1fr; background: var(--paper); }
.login-panel { padding: clamp(32px, 7vw, 90px); display: flex; flex-direction: column; justify-content: center; gap: 58px; }
.sales-brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.sales-brand > span:last-child { display: grid; line-height: 1.05; }
.sales-brand strong { font-size: 1.15rem; letter-spacing: -.025em; }
.sales-brand small { margin-top: 4px; color: var(--muted); }
.login-copy h1 { margin: 8px 0 16px; color: var(--nav); font-size: clamp(44px, 6vw, 76px); line-height: .96; letter-spacing: -.06em; }
.login-copy > p:last-child { max-width: 42ch; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }
.stack-form { display: grid; gap: 15px; max-width: 420px; }
.form-error { margin: 0; color: var(--red); }
.sales-visual { position: relative; overflow: hidden; background: radial-gradient(circle at 76% 22%, rgba(228,162,59,.28), transparent 24%), linear-gradient(145deg, #1b2638, #0b111c); }
.sales-visual::before { content: ""; position: absolute; width: 62%; height: 120%; right: -9%; top: -10%; transform: skewX(-16deg); background: linear-gradient(180deg, rgba(247,198,107,.88), rgba(164,95,10,.7)); }
.visual-ring { position: absolute; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; }
.visual-ring-one { width: 460px; height: 460px; right: -100px; top: 9%; box-shadow: 0 0 0 58px rgba(255,255,255,.035), 0 0 0 112px rgba(255,255,255,.02); }
.visual-ring-two { width: 180px; height: 180px; left: 13%; top: 13%; }
.visual-copy { position: absolute; left: 10%; bottom: 10%; display: grid; gap: 8px; color: white; }
.visual-copy span { font-size: .72rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.visual-copy strong { max-width: 9ch; font-size: clamp(36px, 4.5vw, 66px); line-height: .96; letter-spacing: -.05em; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: var(--nav); color: white; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; color: white; text-decoration: none; padding: 0 8px 24px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.12rem; }
.brand small { margin-top: 2px; color: #a9b2c3; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav button { width: 100%; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 12px; padding: 12px 13px; color: #bac3d1; background: transparent; text-align: left; }
.sidebar nav button span { width: 24px; color: #8e99aa; text-align: center; }
.sidebar nav button:hover, .sidebar nav button.is-active { color: white; background: var(--nav-soft); }
.sidebar nav button.is-active span { color: var(--accent); }
.sidebar-bottom { margin-top: auto; display: grid; gap: 18px; }
.back-link { color: #c9d1dc; text-decoration: none; padding: 10px 12px; border-radius: 10px; }
.back-link:hover { background: var(--nav-soft); color: white; }
.user { display: flex; align-items: center; gap: 10px; padding: 13px; border-radius: 14px; background: rgba(255,255,255,.06); }
.user > span { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #211609; background: var(--accent); font-weight: 800; }
.user strong, .user small { display: block; }
.user small { color: #aeb8c7; margin-top: 2px; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px clamp(20px, 4vw, 52px); background: rgba(244, 246, 248, .92); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(229,233,240,.85); }
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.35rem, 2vw, 1.8rem); }
.topbar-actions { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .9rem; }
.icon-button { border: 1px solid var(--line); border-radius: 11px; background: var(--paper); color: var(--ink); min-width: 40px; height: 40px; padding: 0 11px; font-size: 1.15rem; }
#menu-button { display: none; }
.page-content { padding: 28px clamp(20px, 4vw, 52px) 64px; outline: none; }
.eyebrow { margin: 0; color: var(--accent-dark); font-size: .72rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }

.hero { position: relative; overflow: hidden; display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; padding: clamp(24px, 4vw, 42px); border-radius: 24px; background: linear-gradient(125deg, #182131 0%, #283448 70%, #493318 140%); color: white; box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; right: -80px; bottom: -110px; width: 330px; height: 330px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 46px rgba(255,255,255,.035), 0 0 0 94px rgba(255,255,255,.025); }
.hero > * { position: relative; z-index: 1; }
.hero h2 { margin: 8px 0 12px; max-width: 660px; font-size: clamp(2rem, 4.5vw, 3.8rem); line-height: 1.02; letter-spacing: -.045em; }
.hero p { max-width: 620px; color: #ced5df; line-height: 1.65; }
.hero .eyebrow { color: #f5c56d; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero-metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; align-content: center; }
.hero-metric { padding: 18px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.07); border-radius: 16px; }
.hero-metric span, .hero-metric small, .metric span, .metric small { display: block; }
.hero-metric span { color: #c8d0dc; font-size: .82rem; }
.hero-metric strong { display: block; margin: 8px 0 4px; font-size: 1.55rem; }
.hero-metric small { color: #9ea9ba; }

.section { margin-top: 34px; }
.section-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 14px; }
.section-header h2 { margin: 5px 0 0; font-size: clamp(1.3rem, 2.2vw, 1.85rem); letter-spacing: -.02em; }
.section-header p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button { min-height: 42px; border-radius: 11px; padding: 9px 15px; border: 1px solid transparent; font-weight: 750; }
.button-primary { background: var(--accent); color: #281805; border-color: var(--accent); }
.button-primary:hover { background: #efb14e; }
.button-dark { color: white; background: var(--ink); }
.button-ghost { color: var(--ink); background: var(--paper); border-color: var(--line); }
.button-danger { color: var(--red); background: var(--red-soft); border-color: #ffd3cc; }
.button-sidebar { width: 100%; color: #eef1f5; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); }
.button-sidebar:hover { background: rgba(255,255,255,.14); }
.button-small { min-height: 34px; padding: 6px 10px; font-size: .83rem; }
.button:disabled { opacity: .5; cursor: not-allowed; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.metric, .surface, .vehicle-card, .investor-card, .deal-card, .action-card, .calculator { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 7px 24px rgba(16,24,40,.04); }
.metric { padding: 18px; }
.metric span { color: var(--muted); font-size: .82rem; }
.metric strong { display: block; margin: 8px 0 5px; font-size: clamp(1.35rem, 2.2vw, 1.9rem); letter-spacing: -.035em; }
.metric small { color: var(--muted); line-height: 1.4; }
.metric.good strong { color: var(--green); }
.metric.warn strong { color: var(--accent-dark); }
.metric.bad strong { color: var(--red); }
.surface { padding: 18px; }

.vehicle-grid, .deal-grid, .investor-grid, .action-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.vehicle-card, .deal-card, .investor-card, .action-card { padding: 19px; }
.vehicle-card header, .deal-card header, .investor-card header, .action-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.vehicle-card h3, .deal-card h3, .investor-card h3, .action-card h3 { margin: 5px 0 4px; font-size: 1.15rem; }
.vehicle-card p, .deal-card p, .investor-card p, .action-card p { color: var(--muted); }
.card-metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin: 16px 0; }
.card-metrics div { padding: 11px; background: var(--canvas); border-radius: 12px; }
.card-metrics span, .card-metrics strong { display: block; }
.card-metrics span { color: var(--muted); font-size: .72rem; }
.card-metrics strong { margin-top: 5px; font-size: .94rem; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: .72rem; font-weight: 800; background: var(--blue-soft); color: var(--blue); }
.status.available, .status.paid, .status.settled { color: var(--green); background: var(--green-soft); }
.status.defaulted, .status.overdue, .status.refund_due { color: var(--red); background: var(--red-soft); }
.status.sold, .status.active, .status.customer_owes { color: var(--accent-dark); background: var(--accent-soft); }

.action-card { border-left: 4px solid var(--accent); }
.action-card.priority-critical { border-left-color: var(--red); }
.action-card.priority-high { border-left-color: #df7c19; }
.action-card time { color: var(--muted); font-size: .8rem; }
.action-card p { margin: 8px 0; }
.action-card footer { margin-top: 14px; }

.table-wrap { overflow-x: auto; padding: 0; }
.data-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.data-table th, .data-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; background: #fafbfc; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table small { color: var(--muted); }
.money-positive { color: var(--green); font-weight: 800; }
.money-negative { color: var(--red); font-weight: 800; }

.calculator { padding: 20px; background: linear-gradient(135deg, #fff 0%, #fff8eb 100%); }
.calculator-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; align-items: end; }
.calculator-result { margin-top: 15px; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.calculator-result div { padding: 13px; border-radius: 12px; background: white; border: 1px solid #f1dfbe; }
.calculator-result span, .calculator-result strong { display: block; }
.calculator-result span { color: var(--muted); font-size: .75rem; }
.calculator-result strong { margin-top: 6px; }

label { display: grid; gap: 7px; color: #344054; font-size: .84rem; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cfd6e0; border-radius: 10px; padding: 11px 12px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(228,162,59,.18); }
textarea { resize: vertical; }
.hint { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.inline-note { margin: 0; padding: 12px 14px; border-radius: 11px; background: var(--blue-soft); color: #234e86; font-size: .84rem; line-height: 1.45; }
.settlement-preview { padding: 14px; border-radius: 12px; background: var(--accent-soft); border: 1px solid #f1d29b; }
.settlement-preview strong { display: block; margin-bottom: 4px; }

.empty { padding: 40px 22px; border: 1px dashed #cfd6e0; border-radius: var(--radius); text-align: center; color: var(--muted); background: rgba(255,255,255,.55); }
.empty h3 { margin: 0 0 7px; color: var(--ink); }

.modal { border: 0; padding: 0; background: transparent; width: min(820px, calc(100vw - 28px)); max-height: calc(100vh - 28px); }
.modal::backdrop { background: rgba(10, 17, 29, .62); backdrop-filter: blur(4px); }
.modal-card { margin: 0; max-height: calc(100vh - 28px); overflow-y: auto; padding: 0; border-radius: 20px; background: white; box-shadow: 0 28px 90px rgba(0,0,0,.3); }
.modal-card > header, .modal-card > footer { position: sticky; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 19px 22px; background: white; }
.modal-card > header { top: 0; border-bottom: 1px solid var(--line); }
.modal-card > footer { bottom: 0; justify-content: flex-end; border-top: 1px solid var(--line); }
.modal-card h2 { margin: 4px 0 0; }
#form-intro { padding: 18px 22px 0; }
.dialog-copy { margin: 0; padding: 18px 22px 0; color: var(--muted); }
.form-grid { padding: 20px 22px 24px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.span-two { grid-column: span 2; }
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 9px; font-weight: 600; }
.check input { width: auto; }

.toast-host { position: fixed; z-index: 100; top: 18px; right: 18px; display: grid; gap: 8px; pointer-events: none; }
.toast { transform: translateY(-10px); opacity: 0; max-width: min(420px, calc(100vw - 36px)); padding: 13px 16px; border-radius: 12px; color: white; background: var(--ink); box-shadow: var(--shadow); transition: .2s ease; }
.toast.is-visible { transform: none; opacity: 1; }
.toast-error { background: var(--red); }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .calculator-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .calculator-result { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .hero { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .login-view { grid-template-columns: 1fr; }
  .sales-visual { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: transform .2s ease; width: min(280px, 85vw); box-shadow: 20px 0 60px rgba(0,0,0,.25); }
  .app-shell.menu-open .sidebar { transform: none; }
  #menu-button { display: inline-grid; place-items: center; }
  .topbar { height: 74px; padding-inline: 16px; }
  .topbar-actions span { display: none; }
  .page-content { padding: 20px 14px 46px; }
  .vehicle-grid, .deal-grid, .investor-grid, .action-grid { grid-template-columns: 1fr; }
  .section-header { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .login-panel { padding: 28px 20px; gap: 42px; }
  .login-copy h1 { font-size: 48px; }
  .hero { padding: 24px 20px; border-radius: 20px; }
  .hero-metrics, .metric-grid, .card-metrics, .calculator-grid, .calculator-result, .form-grid { grid-template-columns: 1fr; }
  .span-two { grid-column: span 1; }
  .button-row, .hero-actions { width: 100%; }
  .button-row .button, .hero-actions .button { flex: 1; }
  .modal { width: calc(100vw - 14px); max-height: calc(100vh - 14px); }
  .modal-card { max-height: calc(100vh - 14px); border-radius: 16px; }
  .modal-card > header, .modal-card > footer, #form-intro, .form-grid { padding-left: 16px; padding-right: 16px; }
}
