/* Shared visual theme. Business layout and state selectors remain in styles.css. */
:root {
  --ink: #202d3c; --muted: #738091; --line: #e3e8ed; --line-strong: #cbd3dc;
  --canvas: #f4f6f8; --soft: #f7f9fb; --nav: #172536; --nav-secondary: #23364b;
  --brand: #257985; --brand-dark: #185660; --brand-soft: #eaf5f4;
  --amber: #efa93d; --amber-strong: #bd7822; --amber-soft: #fff5e5;
  --yellow: #efb24d; --yellow-hover: #e7a338; --red: #be4852; --red-soft: #fff0f1;
  --green: #218568; --shadow: 0 8px 28px rgba(29,45,65,.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
body { line-height: 1.55; -webkit-font-smoothing: antialiased; }
button { transition: background .16s ease, border-color .16s ease, box-shadow .16s ease; }
.sidebar { background: linear-gradient(165deg,#1b2d41,#142231); padding-inline: 14px; }
.brand { height: 86px; border-color: #ffffff12; }
.brand-mark { border-radius: 11px; }
.brand strong { font-size: 16px; letter-spacing: -.3px; }
.brand small { color: #96a9bd; margin-top: 6px; letter-spacing: 1.5px; font-size: 10px; }
.main-nav { gap: 7px; padding-top: 28px; }
.nav-item { min-height: 46px; border-radius: 9px; color: #a9b8c9; font-weight: 500; }
.nav-item:hover { border-color: transparent; background: #ffffff09; }
.nav-item.active { color: #ffcf80; background: #ffffff0c; border-color: #ffffff0b; box-shadow: inset 3px 0 var(--amber); }
.sidebar-foot { border-color: #ffffff12; padding-block: 20px 5px; }
.sidebar-foot strong { color: #d7e3ed; font-size: 11px; }
.sidebar-foot small { color: #92a5b9; line-height: 1.7; }
.topbar { height: 80px; padding-inline: 30px; box-shadow: none; background: #ffffffed; backdrop-filter: blur(14px); }
.topbar h1 { font-size: 21px; letter-spacing: -.5px; }
.eyebrow { font-size: 10px; letter-spacing: 1px; margin-bottom: 6px; }
.analysis-month-badge { border: 0; border-radius: 6px; padding: 5px 9px; font-weight: 500; }
.view { padding: 24px 30px 48px; }
.profit-layout { gap: 24px; }
.input-rail, .results-area { gap: 16px; }
.form-group, .band, .scenario-section, .cost-section, .kpi-card { border-radius: 12px; box-shadow: 0 3px 14px #20304003; }
.form-group { padding: 18px; }
.form-group > h3 { margin: -18px -18px 18px; padding: 12px 14px 12px 18px; border-radius: 12px 12px 0 0; background: white; font-size: 13px; min-height: 49px; }
.module-actions { gap: 4px; }
.module-actions button { color: #8a98a6; border-radius: 6px; }
label { color: #4e5e6e; font-weight: 500; font-size: 12px; gap: 7px; }
input, select, .auth-form input, .admin-create-form input { min-height: 39px; border-color: var(--line-strong); border-radius: 7px; background: #fcfdfe; padding: 8px 10px; }
input:hover, select:hover { border-color: #91a2b3; }
input:focus, select:focus { background: white; border-color: var(--brand); box-shadow: 0 0 0 3px #25798516; }
.field-grid { gap: 15px 12px; }
.form-subheading { color: #7a8795; padding-bottom: 9px; margin-top: 19px; font-size: 11px; }
.fee-rule-note { border-left-width: 2px; border-radius: 0 6px 6px 0; background: #fffaf0; line-height: 1.7; }
.primary-button, .secondary-button, .update-button, .icon-button { border-radius: 7px; min-height: 37px; box-shadow: none; font-weight: 500; }
.primary-button { border-color: #e9ac45; color: #382a16; font-weight: 600; }
.primary-button:hover { border-color: #d79c37; }
.secondary-button, .update-button, .icon-button { background: white; border-color: var(--line); }
.secondary-button:hover, .update-button:hover, .icon-button:hover { border-color: #b8c7d3; background: #f5f8fb; }
.kpi-grid { gap: 12px; }
.kpi-card { padding: 18px; }
.kpi-card .kpi-head { color: #788696; font-weight: 500; }
.kpi-card .kpi-icon { border: 0; background: #f1f5f7; color: #718497; border-radius: 8px; }
.kpi-card strong { font-size: 25px; letter-spacing: -.7px; margin-top: 14px; }
.kpi-card small { line-height: 1.6; }
.kpi-card.positive { border-color: #cce2db; background: #f6fbf9; }
.kpi-card.positive .kpi-icon { background: #e5f2ec; color: var(--green); }
.scenario-section, .cost-section { padding: 20px; }
.section-heading { margin-bottom: 20px; }
.section-heading h3 { font-size: 15px; }
.scenario-grid { gap: 12px; border: 0; border-radius: 0; overflow: visible; }
.scenario, .scenario:last-child { border: 1px solid var(--line); border-radius: 10px; padding: 18px; background: white; }
.scenario-top { margin-bottom: 17px; }
.scenario-name { font-size: 14px; }
.transport-icon { width: 20px; height: 20px; }
.status-badge { border-radius: 20px; font-size: 10px; padding: 3px 9px; font-weight: 500; }
.scenario-profit-grid { gap: 10px; margin-bottom: 14px; }
.scenario-profit-grid > div { background: #f6f8fa; border: 0; border-radius: 8px; padding: 14px; }
.scenario-profit-grid strong { font-size: 20px; letter-spacing: -.4px; }
.metric-row { padding-block: 11px; border-color: #edf0f3; }
.metric-label small, .cost-formula { line-height: 1.6; }
.cost-plan { border-radius: 9px; padding: 16px; }
.cost-row { gap: 7px; margin-top: 15px; }
.bar-track { height: 5px; border-radius: 8px; background: #eef2f5; }
.band { padding: 22px; }
.table-wrap { border-radius: 9px; }
th { background: #f5f7fa; color: #6d7c8b; font-weight: 500; }
td { border-color: #edf0f3; }
tbody tr:hover { background: #f8fafc; }
.subtabs { gap: 8px; }
.subtabs button { border-radius: 7px; }
dialog { border-color: var(--line); border-radius: 14px; box-shadow: 0 24px 90px #16253626; }
dialog::backdrop { background: #13223670; backdrop-filter: blur(3px); }
.login-page { position: relative; display: grid; grid-template-columns: minmax(0,1fr) minmax(390px, .85fr); gap: 9vw; padding: 120px 9vw 90px; background: #f7f8fa; overflow: hidden; }
.login-page::before { content: ""; position: absolute; inset: 0 47% 0 0; background: #192b3e; }
.login-brand { z-index: 1; top: 42px; left: 6vw; color: white; gap: 13px; }
.login-brand img { background: white; border: 0; border-radius: 10px; padding: 7px; width: 42px; height: 42px; }
.login-story { position: relative; z-index: 1; color: white; padding-bottom: 80px; }
.login-kicker { color: #c8a66b; font-size: 10px; font-weight: 600; letter-spacing: 3px; }
.login-story h2 { font-size: clamp(34px,3.8vw,58px); line-height: 1.4; letter-spacing: -1.5px; margin: 23px 0; font-weight: 600; }
.login-story > p { color: #a8b8c8; line-height: 2; font-size: 14px; }
.login-capabilities { display: flex; gap: 24px; margin-top: 38px; flex-wrap: wrap; }
.login-capabilities span { display: flex; gap: 8px; align-items: center; color: #cfdae4; font-size: 12px; }
.login-capabilities svg { width: 17px; color: #edbd72; }
.login-story > small { position: absolute; bottom: -80px; color: #8295aa; font-size: 9px; letter-spacing: 2px; }
.login-orbit { position: absolute; width: 300px; height: 300px; left: -210px; bottom: -260px; opacity: .13; pointer-events: none; }
.login-orbit span { position: absolute; inset: 0; border: 1px solid #d9b67a; border-radius: 50%; }
.login-orbit span:nth-child(2) { inset: -45px; }
.login-orbit span:nth-child(3) { inset: -90px; }
.login-panel { position: relative; width: min(420px,100%); justify-self: center; border: 1px solid #e3e8ed; border-radius: 18px; padding: 14px; box-shadow: 0 20px 65px #1a30400a; }
.login-heading { padding: 24px 20px 5px; }
.login-heading h1 { font-size: 26px; margin-top: 12px; letter-spacing: -.7px; }
.auth-switch { border: 0; background: #f2f5f7; border-radius: 8px; }
.auth-switch button { border-radius: 6px; }
.auth-form { gap: 18px; padding-bottom: 24px; }
.auth-form input { min-height: 44px; }
.auth-form .primary-button { min-height: 44px; }
.form-message:empty { min-height: 0; margin: 0; }
.brand > div { min-width: 0; }
.brand strong, .login-brand strong { overflow-wrap: anywhere; }
.brand strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#siteSettingsForm, #turnstileSettingsForm { max-width: 680px; }
#turnstileStatus { color: var(--brand); font-size: 12px; }
.cloud-dialog { width: min(720px,calc(100vw - 24px)); max-height: 90vh; overflow-y: auto; padding: 0; }
.cloud-dialog .auth-form { grid-template-columns: minmax(0,1fr); }
.cloud-dialog .field-grid { min-width: 0; }
.cloud-dialog p, .cloud-dialog label > span { overflow-wrap: anywhere; }
.cloud-dialog h2 { margin: 0; font-size: 20px; }
.cloud-dialog p { margin: 0; color: var(--muted); font-size: 12px; }
.cloud-dialog .action-group { flex-wrap: wrap; }
.cloud-dialog .toggle-row { display: flex; }
.cloud-dialog .toggle-row input { min-height: 0; width: 1px; height: 1px; padding: 0; }

/* Data, labels and explanatory text have separate visual roles. */
.kpi-card .kpi-head { color: #34465a; font-size: 13px; font-weight: 650; }
.kpi-card > strong { font-size: 28px; font-weight: 750; }
.kpi-card > small { color: #77818d; font-size: 11px; font-weight: 400; margin-top: 12px; line-height: 1.7; }
.scenario-profit-grid > div > span { color: #34465a; font-size: 12px; font-weight: 650; }
.scenario-profit-grid .profit-rate { color: #36566b; font-size: 12px; font-weight: 650; margin-top: 10px; }
.scenario-profit-grid .profit-formula { display: block; color: #77818d; font-size: 10px; font-weight: 400; line-height: 1.7; margin-top: 9px; padding-top: 8px; border-top: 1px solid #e3e8ed; }
.metric-row > .metric-label { color: #34465a; font-size: 12px; font-weight: 600; gap: 6px; }
.metric-row > strong { color: #202d3c; font-size: 13px; font-variant-numeric: tabular-nums; }
.metric-label small { color: #77818d; font-size: 10px; font-weight: 400; line-height: 1.7; }
.metric-row strong .money-stack > span { color: inherit; }
.cost-meta span { color: #34465a; font-size: 12px; font-weight: 600; }
.cost-meta strong { font-size: 12px; }
.cost-formula { color: #77818d !important; font-size: 10px !important; font-weight: 400; padding-top: 3px; }
@media (max-width: 640px) { .kpi-card > strong { font-size: 23px; } .kpi-card .kpi-head { font-size: 12px; } }
@media (min-width: 1181px) { .profit-kpis { grid-template-columns: repeat(3,minmax(0,1fr)); } }
@media (max-width: 900px) {
  .sidebar { padding: 6px; background: #192b3e; }
  .main-nav { padding: 0; gap: 2px; }
  .nav-item { min-height: 50px; border-radius: 7px; }
  .nav-item.active { box-shadow: inset 0 2px var(--amber); }
  .login-page { grid-template-columns: 1fr; padding: 110px 24px 50px; }
  .login-page::before { inset: 0 0 auto; height: 240px; }
  .login-story { display: none; }
  .login-brand { top: 32px; left: 32px; }
}
@media (max-width: 640px) {
  .topbar { height: 68px; padding-inline: 12px; gap: 8px; }
  .topbar h1 { font-size: 18px; }
  .topbar-actions { gap: 5px; }
  .page-title-line { gap: 5px; }
  .analysis-month-badge { font-size: 9px; padding: 4px 6px; }
  .view { padding: 18px 12px 30px; }
  .form-group, .band, .scenario-section, .cost-section { border-radius: 10px; }
  .band, .scenario-section, .cost-section { padding: 16px; }
  .kpi-card { padding: 14px; }
  .kpi-card strong { font-size: 21px; }
  .login-panel { padding: 8px; }
  .scenario-profit-grid strong { font-size: 18px; }
  input, select { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

.appearance-select { width: 78px; min-height: 36px; padding: 6px 8px; font-size: 12px; }
.login-appearance { position: absolute; z-index: 2; right: 32px; top: 38px; }
#cloud-view .cloud-dialog { width: 100%; max-width: 1100px; max-height: none; overflow: visible; padding: 24px; }
#cloud-view .auth-form { padding: 0; }
#cloud-view .auth-form > p { max-width: 760px; }
#cloud-view .auth-form label:not(.toggle-row) { display: grid; grid-template-columns: 160px minmax(0,1fr); align-items: center; }
#cloud-view .auth-form label > span { grid-column: 2; }
#cloud-view #cloudS3Fields, #cloud-view #cloudDavFields { grid-template-columns: 1fr; }
#cloud-view #cloudParameters { border-top: 1px solid var(--line); padding-top: 22px; gap: 20px; }
#cloud-view .toggle-row { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 8px; }
#cloud-view .toggle-row > span:first-child { grid-column: auto; }
#cloud-view .auth-form .action-group button { width: auto; }

html[data-theme="dark"] {
  color-scheme: dark; --ink: #e2e9f2; --muted: #a2b0c1; --line: #344154; --line-strong: #506077;
  --canvas: #111923; --surface: #1b2634; --soft: #222f3f; --brand: #76c6ce; --brand-dark: #a3dee3;
  --brand-soft: #203e44; --amber-soft: #3e3323; --green: #75d2ac; --red: #ff939c; --red-soft: #40282e;
}
html[data-theme="dark"] .topbar { background: #17212eee; }
html[data-theme="dark"] :is(.band,.form-group,.kpi-card,.scenario-section,.cost-section,.scenario,.cost-plan,.warehouse-card,dialog,.login-panel) { background: var(--surface); border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] :is(.form-group > h3,.update-dialog-head,th,.scenario-profit-grid > div,.planner-hour,.auth-switch,.subtabs) { background: var(--soft); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] :is(input,select,.auth-form input,.admin-create-form input) { background: #15202c; color: var(--ink); border-color: var(--line-strong); }
html[data-theme="dark"] input:focus,html[data-theme="dark"] select:focus { background: #1b2b3b; }
html[data-theme="dark"] :is(.secondary-button,.update-button,.icon-button,.auth-switch button.active) { background: #263448; color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] :is(.secondary-button:hover,.update-button:hover,.icon-button:hover,.module-actions button:hover,tbody tr:hover) { background: #30435a; }
html[data-theme="dark"] :is(label,.form-subheading,.form-subheading-row h4,.kpi-card .kpi-head,.scenario-profit-grid > div > span,.metric-row > .metric-label,.cost-meta span) { color: #c9d7e7; }
html[data-theme="dark"] :is(.metric-row > strong,.metric-row strong .money-stack > span) { color: #edf3fa; }
html[data-theme="dark"] :is(.kpi-card > small,.metric-label small,.scenario-profit-grid .profit-formula,.cost-formula) { color: #9dabbc !important; }
html[data-theme="dark"] .scenario-profit-grid .profit-rate { color: #aadbdc; }
html[data-theme="dark"] :is(.metric-row,.scenario-profit-grid .profit-formula,.cost-plan > header,td) { border-color: var(--line); }
html[data-theme="dark"] .kpi-card.positive { background: #1b3431; border-color: #365f53; }
html[data-theme="dark"] .kpi-card .kpi-icon { background: #2b3b4c; color: #b4c9df; }
html[data-theme="dark"] .fee-rule-note { background: #352e23; color: #c8bdab; }
html[data-theme="dark"] .analysis-month-badge { color: #efc990; }
html[data-theme="dark"] .status-badge { background: #203a30; color: #92dab1; border-color: #456b56; }
html[data-theme="dark"] .status-badge.pending { background: var(--soft); color: var(--muted); border-color: var(--line); }
html[data-theme="dark"] .status-badge.no { background: var(--red-soft); color: var(--red); }
html[data-theme="dark"] .bar-track { background: #344154; }
html[data-theme="dark"] .login-page { background: #111923; }
html[data-theme="dark"] .cloud-dialog p { color: var(--muted); }
html[data-theme="dark"] .primary-button { color: #352815; }
html[data-theme="dark"] .danger-button { color: var(--red); }
html[data-theme="dark"] :is(tbody tr:nth-child(even),tfoot td,.segmented,.warehouse-suggestions) { background: var(--soft); }
html[data-theme="dark"] :is(.segmented button.active,.warehouse-suggestion:hover,.warehouse-suggestion.active) { background: #30435a; color: var(--ink); }
html[data-theme="dark"] .calculation-warning:not(.omitted-cost-warning):not(.dimensional-warning) { color: #efc990; }
@media (max-width: 900px) {
  .main-nav { grid-template-columns: repeat(6,minmax(0,1fr)); }
  .main-nav.admin-enabled { grid-template-columns: repeat(7,minmax(0,1fr)); }
}
@media (max-width: 640px) {
  .appearance-select { width: 65px; font-size: 11px; }
  .login-appearance { right: 18px; top: 34px; }
  .topbar #exportAll { display: none; }
  .main-nav .nav-item { font-size: 9px; }
  #cloud-view .cloud-dialog { padding: 16px; }
  #cloud-view .auth-form label:not(.toggle-row) { grid-template-columns: minmax(0,1fr); }
  #cloud-view .auth-form label > span { grid-column: auto; }
}
