:root {
  color-scheme: light;
  --brand: #111111;
  --brand-deep: #050505;
  --accent: #e7a72e;
  --accent-soft: #fbf1dc;
  --paper: #f5f4f1;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --ink: #211f1b;
  --muted: #6b675f;
  --line: #e1ded7;
  --shadow: 0 14px 36px rgba(17, 17, 17, .09);
  --focus: rgba(231, 167, 46, .38);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #090909;
  --brand-deep: #000000;
  --accent: #efb33f;
  --accent-soft: #3a2d18;
  --paper: #111111;
  --surface: #232323;
  --surface-raised: #303030;
  --ink: #f7f5f0;
  --muted: #b7b2aa;
  --line: #45413b;
  --shadow: 0 14px 36px rgba(0, 0, 0, .28);
  --focus: rgba(239, 179, 63, .42);
}
* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { background: var(--paper); color: var(--ink); font: 15px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overflow-x: hidden; }
a { color: #815808; }
:root[data-theme="dark"] a { color: #efb33f; }
button, input, select, textarea { font: inherit; }
button, .button { min-height: 42px; border-radius: 10px; font-weight: 650; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button:hover, .button:hover { transform: translateY(-1px); }
img, svg { max-width: 100%; }
.layout { min-height: 100vh; grid-template-columns: 264px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; overflow-y: auto; padding: 25px 15px 18px; background: linear-gradient(165deg, var(--brand), var(--brand-deep)); }
.brand { min-height: 58px; padding: 0 10px; gap: 12px; letter-spacing: .11em; font-size: 13px; }
.brand img { width: 48px; height: 48px; border-radius: 12px; padding: 3px; object-fit: contain; background: transparent; }
.brand small { margin-top: 3px; font-size: 9px; letter-spacing: .18em; }
.side-nav { display: grid; gap: 4px; }
.side-nav a { display: flex; align-items: center; gap: 11px; min-height: 43px; padding: 10px 12px; color: #cad8df; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 550; transition: background .16s ease, color .16s ease; }
.side-nav a:hover, .side-nav a[aria-current="page"] { background: rgba(255,255,255,.11); color: #fff; text-decoration: none; }
.side-nav a[aria-current="page"] { border-color: rgba(231,167,46,.42); box-shadow: inset 3px 0 var(--accent); }
.side-nav a[aria-current="page"] .nav-icon, .legacy-nav a[aria-current="page"] .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-caption { margin: 17px 12px 5px; color: #91a8b5; font-size: 10px; font-weight: 750; letter-spacing: .14em; }
.side-foot { border-top-color: rgba(255,255,255,.13); line-height: 1.7; }
.main { min-width: 0; padding: 30px clamp(20px, 4vw, 56px) 52px; }
.topbar { min-height: 54px; align-items: center; margin: -3px 0 27px; color: var(--muted); }
.topbar .topbar-title { color: var(--ink); font-size: 13px; font-weight: 650; }
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.theme-toggle, .menu-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 42px; min-height: 42px; padding: 8px 11px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 11px; cursor: pointer; }
.theme-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
.menu-toggle { display: none; }
.account-chip { color: var(--ink); font-size: 13px; font-weight: 650; padding: 0 8px; }
.logout-form { display: inline-flex; margin: 0; }
.logout-form button { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 7px 11px; }
.main h1, .main h2, .main h3 { color: var(--ink); }
.main h1 { font-size: clamp(26px, 2.4vw, 34px); letter-spacing: -.035em; }
.main h2 { letter-spacing: -.025em; }
.card, .panel, .metric, .metric-card, .insight-card, .task-card { background: var(--surface); color: var(--ink); border-color: var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.card-grid .card:hover { border-color: var(--accent); }
.metric { min-height: 112px; }
.metric strong { letter-spacing: -.035em; }
.badge { background: var(--accent-soft); color: #70500f; font-weight: 700; }
:root[data-theme="dark"] .badge { color: #f3ca7a; }
.main input, .main textarea, .main select { border-color: var(--line); background: var(--surface-raised); color: var(--ink); border-radius: 10px; }
.main button, .main .button { background: var(--brand); color: #fff; border-radius: 10px; }
.main button:hover, .main .button:hover { background: #28231a; }
.main .button.secondary { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); }
.main .notice { background: #fff7df; color: #604b15; border-color: #f0dfaa; }
.main .good { background: #eaf7f0; color: #185b40; border-color: #cbe9d9; }
:root[data-theme="dark"] .main .notice { background: #3a301b; color: #f1d895; border-color: #5f4d28; }
:root[data-theme="dark"] .main .good { background: #19372c; color: #a9e3c3; border-color: #2c614b; }
.main table { border-color: var(--line); background: var(--surface); color: var(--ink); }
.main th { background: color-mix(in srgb, var(--surface-raised) 88%, var(--accent-soft)); color: var(--muted); }
.main td, .main th { border-color: var(--line); }
.muted, .small { color: var(--muted); }
.section-title { margin-top: 30px; }
.dashboard-hero { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 25px 28px; margin-bottom: 18px; background: linear-gradient(125deg, #080808, #242424 70%, #392a15); color: #fff; border-radius: 20px; box-shadow: var(--shadow); }
.dashboard-hero h1, .dashboard-hero p { color: #fff; }
.dashboard-hero p { opacity: .82; margin: 8px 0 0; }
.dashboard-hero .button { background: var(--accent); color: #17120a; white-space: nowrap; }
.dashboard-hero .button:hover { background: #f0bc55; }
.dashboard-section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dashboard-section-head h2 { margin: 0; }
.dashboard-chart { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: end; gap: 12px; min-height: 170px; padding: 18px 6px 0; }
.chart-column { display: flex; min-width: 0; height: 145px; flex-direction: column; align-items: center; justify-content: end; gap: 7px; }
.chart-bar-track { display: flex; align-items: end; width: min(100%, 44px); height: 112px; background: var(--paper); border-radius: 10px; overflow: hidden; }
.chart-bar { width: 100%; min-height: 3px; background: linear-gradient(180deg, var(--accent), #a66c12); border-radius: 10px 10px 3px 3px; }
.chart-count { color: var(--ink); font-size: 12px; font-weight: 750; }
.chart-label { color: var(--muted); font-size: 11px; }
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); gap: 18px; align-items: start; }
.dashboard-list { list-style: none; margin: 12px 0 0; padding: 0; }
.dashboard-list li { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.dashboard-list li:first-child { border-top: 0; }
.dashboard-list .list-main { min-width: 0; overflow-wrap: anywhere; }
.dashboard-list .list-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.recommendation { display: flex; gap: 12px; align-items: flex-start; padding: 13px 0; border-top: 1px solid var(--line); }
.recommendation:first-of-type { border-top: 0; }
.recommendation-dot { width: 9px; height: 9px; flex: 0 0 9px; margin-top: 7px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 5px var(--accent-soft); }
.drawer-backdrop { display: none; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: clamp(16px, 4vw, 42px); background: radial-gradient(ellipse at 12% 12%, rgba(231,167,46,.13), transparent 35%), var(--paper); }
.auth-shell { width: min(100%, 470px); }
.auth-header { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 0 auto 18px; }
.auth-brand { display: flex; align-items: center; justify-content: center; width: 100%; color: var(--ink); font-weight: 800; letter-spacing: .13em; }
.auth-brand img { display: block; width: min(100%, 430px); height: auto; padding: 0; object-fit: contain; background: #fff; border: 0; border-radius: 0; }
.auth-brand small { display: none; }
.auth-card { padding: clamp(22px, 5vw, 36px); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 70px rgba(15, 43, 61, .13); }
.auth-card h1 { margin: 0 0 7px; font-size: 27px; letter-spacing: -.03em; }
.auth-card .muted { margin-top: 0; }
.auth-card input, .auth-card select { width: 100%; min-height: 46px; background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; }
.auth-card button { width: 100%; min-height: 48px; margin-top: 18px; background: var(--brand); color: #fff; border-radius: 11px; }
.auth-card .pill { margin-bottom: 18px; }
.auth-card pre { max-width: 100%; overflow-x: auto; }
.legacy-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0,1fr); }
.legacy-sidebar { display: flex; flex-direction: column; gap: 20px; padding: 23px 15px; background: linear-gradient(165deg, var(--brand), var(--brand-deep)); }
.legacy-sidebar .brand { color: #fff; }
.legacy-nav { display: grid; gap: 5px; }
.legacy-nav a { display: flex; align-items: center; gap: 10px; min-height: 42px; margin: 0; padding: 9px 11px; color: #d2dfe5; border-radius: 10px; font-size: 13px; }
.legacy-nav a:hover, .legacy-nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.11); text-decoration: none; }
.legacy-main { width: 100%; max-width: none; min-width: 0; margin: 0; padding: 28px clamp(16px, 4vw, 52px) 50px; }
.legacy-main > h1 { margin-top: 0; color: var(--ink); }
.legacy-main nav { display: none; }
.legacy-main section { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.legacy-main input, .legacy-main textarea, .legacy-main select { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); border-radius: 9px; }
.legacy-main button { background: var(--brand); color: #fff; border-radius: 9px; }
.legacy-main table { display: block; max-width: 100%; overflow-x: auto; background: var(--surface); color: var(--ink); }
.legacy-main td, .legacy-main th { border-color: var(--line); }
.legacy-main th { background: var(--surface-raised); color: var(--muted); }
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar, .legacy-sidebar { position: fixed; z-index: 50; inset: 0 auto 0 0; width: min(84vw, 310px); height: 100dvh; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 20px 0 50px rgba(0,0,0,.18); }
  .sidebar.is-open, .legacy-sidebar.is-open { transform: translateX(0); }
  .drawer-backdrop.is-open { display: block; position: fixed; z-index: 40; inset: 0; border: 0; border-radius: 0; background: rgba(5,16,24,.48); }
  .main, .legacy-main { padding: 16px 16px 32px; }
  .topbar { margin: 0 0 18px; }
  .menu-toggle { display: inline-flex; }
  .dashboard-columns { grid-template-columns: 1fr; }
  .legacy-shell { display: block; }
}
@media (max-width: 600px) {
  .main, .legacy-main { padding: 12px 12px 28px; }
  .topbar { align-items: center; gap: 8px; }
  .topbar-title { display: none; }
  .topbar-tools { gap: 5px; }
  .account-chip { max-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .logout-form button { min-height: 40px; padding: 6px 8px; font-size: 12px; }
  .dashboard-hero { display: grid; gap: 16px; padding: 20px 18px; border-radius: 16px; }
  .dashboard-hero .button { width: 100%; }
  .metric-grid, .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-width: 0; padding: 12px; }
  .metric strong { font-size: 19px; overflow-wrap: anywhere; }
  .metric span { font-size: 12px; }
  .card, .panel { min-width: 0; padding: 14px; border-radius: 13px; }
  .dashboard-chart { gap: 6px; }
  .chart-label { font-size: 10px; }
  .dashboard-list li { gap: 8px; }
  .dashboard-list .list-meta { white-space: normal; text-align: right; }
  .actions > * { flex: 1 1 100%; }
  .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .main table { min-width: 580px; }
  .auth-page { padding: 14px; }
  .auth-card { border-radius: 18px; }
  .legacy-main > nav { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
@media print {
  .theme-toggle, .menu-toggle, .drawer-backdrop { display: none !important; }
}
:root[data-theme="dark"] {
  --navy: #090909;
  --navy2: #111111;
  --teal: #efb33f;
  --paper: #111111;
  --white: #232323;
  --ink: #f7f5f0;
  --muted: #b7b2aa;
  --line: #45413b;
  --shadow: 0 14px 36px rgba(0,0,0,.28);
}
:root[data-theme="dark"] body { background: var(--paper) !important; color: var(--ink) !important; }
:root[data-theme="dark"] .main .badge { background: var(--accent-soft); color: #f3ca7a; }
:root[data-theme="dark"] .offer { background: var(--surface); color: var(--ink); }

:root { --navy: #111111; --navy2: #111111; --teal: #e7a72e; --white: #ffffff; }
.badge { color: #70500f; }
:root[data-theme="dark"] .badge { color: #f3ca7a; }
.main button, .main .button, .legacy-main button, .auth-card button { background: var(--brand); }
.main button:hover, .main .button:hover, .legacy-main button:hover, .auth-card button:hover { background: #28231a; }
.main .button:not(.secondary), .dashboard-hero .button { background: var(--accent); color: #17120a; }
.main .button:not(.secondary):hover, .dashboard-hero .button:hover { background: #f0bc55; }
.offer-logo { display:block; width:min(100%, 220px); height:auto; max-height:110px; object-fit:contain; background:#fff; }
.brand-preview-logo { display:block; width:min(100%, 300px); height:auto; max-height:190px; object-fit:contain; background:#fff; }
.document-brand { display:block; width:min(100%, 280px); height:auto; max-height:180px; object-fit:contain; background:#fff; margin:0 0 18px; }
.estimate-document { background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:clamp(18px,3vw,32px); }
:root[data-theme="dark"] .estimate-document { background:var(--surface); color:var(--ink); }
@media print {
  body { background:#fff !important; color:#111 !important; }
  .estimate-document, .offer { color:#111 !important; background:#fff !important; }
  .estimate-document { border:0; box-shadow:none; padding:0; }
  .estimate-document .metric, .estimate-document .panel { color:#111 !important; background:#fff !important; }
  .estimate-document .muted { color:#444 !important; }
}
