:root {
  color-scheme: light;
  --canvas: #e3e6e5; --surface: #edf0ef; --raised: #f6f8f7; --input: #f9fbfa;
  --text: #222c2b; --muted: #56645e; --line: #cbd3d0; --accent: #226653;
  --accent-soft: #d3e7de; --button: #273c34; --button-text: #f6fffa;
  --shadow: 9px 9px 25px #283b3420, -7px -7px 22px #ffffffa3;
  --inset: inset 2px 2px 6px #283b3410, inset -2px -2px 6px #ffffffb0;
  --danger-bg: #f6e3e0; --danger: #982e28; --warn-bg: #f6ecd1; --warn: #755414;
  --rail: #26312e; --rail-text: #e6efeb;
  font-family: 'Segoe UI', Inter, system-ui, sans-serif;
  color: var(--text); background: var(--canvas);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #171d1c; --surface: #222a28; --raised: #2a3431; --input: #1c2421;
  --text: #ecf2ef; --muted: #b0beb7; --line: #3c4b44; --accent: #9dd6bc;
  --accent-soft: #314e40; --button: #b0ddc6; --button-text: #14271d;
  --shadow: 9px 9px 25px #00000035, -5px -5px 20px #ffffff03;
  --inset: inset 2px 2px 6px #00000035, inset -2px -2px 6px #ffffff04;
  --danger-bg: #462b2a; --danger: #ffb7b0; --warn-bg: #443a24; --warn: #f1cf83;
  --rail: #101713; --rail-text: #e6efeb;
}
body { min-height: 100dvh; background: radial-gradient(ellipse at top right, color-mix(in srgb, var(--accent-soft) 32%, transparent), transparent 65%), var(--canvas); }
button, input, select, textarea { font: inherit; }
button { min-height: 44px; border-radius: 12px; font-size: 13px; font-weight: 600; background: var(--button); color: var(--button-text); border: 1px solid transparent; padding: 11px 17px; transition: background .15s, transform .15s; }
button:hover:not(:disabled) { filter: brightness(1.06); }
button:active:not(:disabled) { transform: translateY(1px); }
button.secondary { background: var(--raised); color: var(--text); border-color: var(--line); }
button.danger { background: var(--danger-bg); color: var(--danger); }
input, select, textarea, #summaryText { background: var(--input); color: var(--text); border: 1px solid var(--line); border-radius: 11px; padding: 12px; box-shadow: var(--inset); min-height: 44px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
input:disabled, select:disabled { opacity: .6; }
input[type="checkbox"] { accent-color: var(--accent); min-height: 18px; width: 18px; height: 18px; box-shadow: none; }
label { color: var(--muted); font-size: 12px; line-height: 1.6; }
svg { width: 21px; height: 21px; flex: 0 0 auto; pointer-events: none; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.icon-rail { position: fixed; left: 20px; top: 20px; bottom: 20px; width: 72px; z-index: 30; padding: 10px; border-radius: 25px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); display: flex; align-items: center; flex-direction: column; gap: 13px; }
.rail-mark { width: 47px; height: 57px; display: grid; place-items: center; font-size: 29px; font-weight: 300; color: var(--text); }
.rail-links { width: 100%; border-radius: 17px; background: var(--rail); color: var(--rail-text); padding: 10px 5px; display: flex; flex-direction: column; gap: 12px; flex: 1; box-shadow: 3px 5px 10px #0002; }
.rail-links button { display: grid; place-items: center; padding: 0; min-height: 46px; background: transparent; color: inherit; border-radius: 12px; }
.rail-links button.active { background: #ffffff23; border-color: #ffffff25; }
.rail-links button:last-child { margin-top: auto; }
.rail-bottom { writing-mode: vertical-rl; font-size: 10px; color: var(--muted); letter-spacing: 2px; padding: 16px 0 6px; }
#nav { position: fixed; top: 20px; bottom: 20px; left: 110px; width: 254px; z-index: 40; margin: 0; padding: 22px 15px; display: flex; flex-flow: column nowrap; align-items: stretch; overflow-y: auto; overscroll-behavior: contain; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 25px; box-shadow: var(--shadow); scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.sidebar-brand { display: flex; gap: 10px; align-items: center; padding: 0 9px 18px; border-bottom: 1px solid var(--line); margin-bottom: 17px; }
.brand-emblem, .login-emblem { width: 37px; height: 37px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; background: var(--button); color: var(--button-text); font-weight: 800; font-size: 13px; letter-spacing: -1px; box-shadow: 2px 3px 7px #0002; }
.sidebar-brand strong { display: block; font-size: 13px; letter-spacing: 1.6px; }
.sidebar-brand small { font-size: 10px; color: var(--muted); }
.sidebar-profile { display: flex; align-items: center; gap: 10px; padding: 3px 9px 12px; }
.profile-avatar { display: grid; place-items: center; height: 38px; width: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--raised); box-shadow: var(--shadow); font-size: 12px; color: var(--accent); flex-shrink: 0; }
.sidebar-profile strong { display: block; font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.sidebar-profile small { color: var(--muted); font-size: 11px; }
.nav-group { margin: 15px 12px 6px; font-size: 9px; letter-spacing: 1.5px; color: var(--muted); font-weight: 650; }
#nav > button[data-tab] { background: transparent; color: var(--muted); border: 1px solid transparent; font-size: 12px; display: flex; align-items: center; gap: 11px; text-align: left; padding: 9px 12px; min-height: 42px; line-height: 1.4; flex-shrink: 0; }
#nav > button[data-tab] svg { width: 18px; height: 18px; }
#nav > button.active { color: var(--text); border-color: var(--line); background: linear-gradient(115deg, var(--raised), var(--accent-soft)); box-shadow: 3px 4px 9px #0000000d, inset 0 1px 0 #ffffff30; }
#nav > button:hover { background-color: var(--raised); color: var(--text); }
.sidebar-foot { margin: auto 10px 0; border-top: 1px solid var(--line); padding-top: 18px; font-size: 10px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; }
body > header { margin-left: 394px; margin-right: 30px; padding: 30px 0 22px; background: none; color: var(--text); border-bottom: 1px solid var(--line); min-height: 100px; }
.header-identity { display: flex; align-items: center; gap: 10px; }
.header-eyebrow { text-transform: uppercase; color: var(--muted); font-size: 10px; letter-spacing: 2px; }
header h1 { font-size: 14px; margin-top: 5px; font-weight: 550; }
.header-tools { display: flex; gap: 9px; align-items: center; }
#cloudStatus { color: var(--muted); font-size: 11px; margin: 0; max-width: 240px; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.theme-toggle svg { width: 18px; height: 18px; }
#logoutBtn { padding: 10px 15px; }
main { margin: 0 30px 0 394px; max-width: 1600px; padding: 0; min-width: 0; }
.page-heading { padding: 30px 0 27px; }
.page-heading .eyebrow { color: var(--accent); letter-spacing: 2px; font-size: 10px; font-weight: 650; text-transform: uppercase; margin: 0 0 10px; }
#pageTitle { font-size: clamp(26px, 3vw, 39px); font-weight: 450; letter-spacing: -1.5px; margin: 0 0 8px; outline: none; }
#pageDescription { color: var(--muted); font-size: 13px; margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 21px; padding: 25px; margin-bottom: 23px; box-shadow: var(--shadow); min-width: 0; }
.panel h2 { color: var(--text); font-size: 17px; font-weight: 550; letter-spacing: -.3px; margin-bottom: 21px; }
h3 { font-size: 14px; font-weight: 600; margin: 24px 0 15px; }
.grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
#stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { border: 1px solid var(--line); padding: 21px 18px; border-radius: 17px; background: linear-gradient(130deg, var(--raised), var(--surface)); box-shadow: 4px 5px 14px #00000008, inset 0 1px 0 #ffffff15; min-width: 0; }
.stat span { color: var(--muted); font-size: 11px; }
.stat strong { color: var(--text); font-size: clamp(19px, 2vw, 30px); letter-spacing: -1px; font-weight: 500; margin-top: 15px; overflow-wrap: anywhere; }
#stats .stat:first-child { background: linear-gradient(125deg, var(--accent-soft), var(--surface)); }
.muted, footer, #adminNotice, #passwordNotice { color: var(--muted); }
table { font-size: 13px; }
th { color: var(--muted); background: var(--raised); font-size: 11px; font-weight: 600; }
td, th { border-color: var(--line); padding: 15px 12px; }
tbody tr:hover { background: color-mix(in srgb, var(--raised) 65%, transparent); }
.tablewrap { border: 1px solid var(--line); border-radius: 13px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
td:last-child, th:last-child { padding-right: 16px; }
.actions button { min-height: 38px; font-size: 11px; padding: 7px 11px; }
.tag { background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.permission-grid { border-color: var(--line); border-radius: 13px; }
.permission-item { color: var(--text); font-weight: 450; }
#passwordHint { background: var(--warn-bg); border-color: var(--warn-bg); border-left: 3px solid var(--warn); color: var(--warn); font-size: 12px; box-shadow: none; padding: 12px 17px; }
#passwordHint button { padding: 5px 10px; min-height: 34px; background: transparent; border-color: currentColor; color: inherit; }
#syncActions { margin: 15px 30px 0 394px; max-width: none; border-color: var(--danger); }
#summaryModal { z-index: 100 !important; background: #091510a8 !important; backdrop-filter: blur(7px); }
#summaryText { border-color: var(--line) !important; }
.restore-button { background: var(--raised) !important; color: var(--text); border: 1px solid var(--line); min-height: 44px; justify-content: center; padding: 11px 17px !important; font-weight: 600; font-size: 13px; }
main > input[type="search"] { margin-top: 22px; }
#notice { background: var(--button); color: var(--button-text); z-index: 110; box-shadow: var(--shadow); max-width: min(420px, calc(100vw - 32px)); }
footer { margin-left: 394px; padding: 14px 25px 30px 0; text-align: left; font-size: 10px; }
#authGate { background: radial-gradient(ellipse at 80% 20%, var(--accent-soft), transparent 65%), var(--canvas); overflow-y: auto; }
#authGate .panel { width: min(450px, 100%); padding: 36px; border-radius: 28px; margin: auto; }
#authGate h2 { font-size: 29px; font-weight: 450; letter-spacing: -1px; margin: 20px 0 10px; }
#authGate p { color: var(--muted); font-size: 13px; line-height: 1.8; }
#authGate small { display: block; color: var(--muted); line-height: 1.7; font-size: 11px; }
#authGate label { color: var(--muted); font-size: 12px; }
#authGate input { margin-top: 7px; }
.login-top { display: flex; align-items: center; justify-content: space-between; }
#authGate .theme-toggle { width: auto; margin: 0; min-height: 40px; padding: 8px; background: var(--raised); color: var(--text); border-color: var(--line); }
#authGate .theme-toggle span { font-size: 11px; }
#loginError { color: var(--danger) !important; }
#menuToggle, #navClose, #navBackdrop { display: none; }
@media (min-width: 1750px) { main, body > header { margin-right: max(30px, calc((100vw - 1950px) / 2)); } }
@media (max-width: 1200px) and (min-width: 901px) {
  #nav { left: 96px; width: 222px; padding: 20px 10px; }
  .icon-rail { left: 14px; width: 66px; }
  main, body > header { margin-left: 342px; margin-right: 22px; }
  #syncActions { margin-left: 342px; }
  footer { margin-left: 342px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .line { grid-template-columns: minmax(0, 2fr) 75px 90px; }
  .line .line-total { display: block; grid-column: 1 / 3; }
}
@media (max-width: 900px) {
  .icon-rail { display: none; }
  body > header { margin: 0 22px; padding: 17px 0; min-height: 80px; }
  main { margin: 0 22px; }
  .header-tools { gap: 7px; }
  .header-tools .theme-toggle span { display: none; }
  .header-tools .theme-toggle { width: 44px; padding: 10px; }
  #cloudStatus { display: none; }
  #menuToggle, #navClose { display: inline-flex; background: var(--raised); color: var(--text); border: 1px solid var(--line); padding: 10px; }
  #menuToggle { width: 44px; }
  #nav { top: 10px; bottom: 10px; left: 10px; width: min(310px, calc(100vw - 30px)); transform: translateX(calc(-100% - 20px)); visibility: hidden; transition: transform .2s, visibility .2s; padding: 20px 15px; z-index: 81; }
  #navClose { margin-left: auto; min-height: 36px; padding: 6px; }
  #nav .sidebar-brand { gap: 8px; }
  .menu-open { overflow: hidden; }
  .menu-open #nav { transform: none; visibility: visible; }
  .menu-open #navBackdrop { display: block; position: fixed; inset: 0; background: #0a18136b; backdrop-filter: blur(4px); border-radius: 0; z-index: 80; width: 100%; height: 100%; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 20px; }
  .page-heading { padding: 25px 0; }
  footer { margin-left: 22px; }
  #syncActions { margin: 12px 22px; }
  .line { grid-template-columns: minmax(0, 2fr) 85px 90px; }
  .line .line-total { display: block; grid-column: 1 / 3; }
  .line button { grid-column: 3; }
}
@media (max-width: 550px) {
  body > header { margin: 0 16px; }
  main { margin: 0 16px; }
  .header-eyebrow { font-size: 8px; letter-spacing: 1.3px; }
  header h1 { font-size: 12px; }
  #logoutBtn { padding: 9px 11px; font-size: 12px; }
  .page-heading { padding: 23px 0; }
  #pageTitle { font-size: 27px; letter-spacing: -.9px; }
  #pageDescription { font-size: 12px; line-height: 1.7; }
  .panel { padding: 18px 15px; border-radius: 18px; margin-bottom: 20px; }
  .panel h2 { font-size: 15px; margin-bottom: 17px; }
  .row { gap: 13px; }
  .row > label, .row > .wide { flex-basis: 100%; min-width: 0; }
  .row > button { flex-grow: 1; }
  .spaced { align-items: stretch; }
  .spaced > label { width: 100%; }
  input, select, textarea { font-size: 16px; }
  .grid { gap: 10px; }
  .stat { padding: 16px 13px; border-radius: 13px; }
  .stat strong { font-size: 22px; letter-spacing: -.7px; margin-top: 10px; }
  .stat span { font-size: 10px; }
  .line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 9px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .line > label:first-child { grid-column: 1 / -1; }
  .line .line-total { display: block; grid-column: 1 / 3; grid-row: 3; }
  .line button { grid-column: 3; grid-row: 2; padding: 10px; }
  .actions button { min-height: 44px; }
  #productsTable .tablewrap { border: 0; overflow: visible; }
  #productsTable table, #productsTable tbody { display: block; }
  #productsTable thead { display: none; }
  #productsTable tbody { display: grid; gap: 12px; }
  #productsTable tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 15px 10px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--raised); }
  #productsTable td { padding: 0; border: 0; white-space: normal; align-self: center; }
  #productsTable td:first-child { font-weight: 550; }
  #productsTable td:nth-child(2) { font-weight: 600; color: var(--accent); }
  #productsTable td:last-child { grid-column: 1 / -1; }
  #productsTable .actions > button { flex: 1; }
  #summaryModal { padding: 10px !important; }
  #summaryModal .panel { padding: 19px 15px; max-height: calc(100dvh - 20px) !important; }
  #syncActions { margin: 12px 16px; }
  #authGate .panel { padding: 28px; }
  footer { margin-left: 16px; line-height: 1.7; }
  .permission-grid { padding: 12px; gap: 15px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  :root, :root[data-theme="dark"] { color-scheme: light; --text: #111; --muted: #444; --surface: #fff; --raised: #fff; --line: #ccc; }
  body { background: white; }
  .icon-rail, .page-heading, body > header, #navBackdrop { display: none !important; }
  main, footer, #syncActions { margin: 0; }
  .panel { box-shadow: none; break-inside: avoid; }
}

/* Transparent business identity, shared by both themes. */
.brand-logo { object-fit: contain; flex-shrink: 0; filter: drop-shadow(0 3px 4px #00000018); }
.sidebar-logo { width: 52px; height: 52px; }
.sidebar-brand { gap: 8px; padding-left: 3px; padding-right: 3px; }
.sidebar-brand strong { font-size: 11px; letter-spacing: 1.1px; }
.sidebar-brand small { font-size: 9px; }
.login-top { position: relative; justify-content: center; padding-top: 27px; }
.login-logo { width: 200px; height: 200px; max-width: 65vw; }
#authGate .login-top .theme-toggle { position: absolute; right: 0; top: 0; }
#authGate h2 { text-align: center; margin-top: 10px; }
#authGate h2 + p { text-align: center; }
.page-heading { position: relative; display: flex; align-items: center; min-height: 160px; gap: 18px; }
.page-heading-copy { position: relative; z-index: 1; flex: 1; min-width: 0; }
.heading-logo { object-fit: contain; width: 128px; height: 128px; margin: -12px 8px -12px 0; opacity: .15; pointer-events: none; flex-shrink: 0; filter: saturate(.8); }
:root[data-theme="dark"] .brand-logo { filter: drop-shadow(0 0 1px #ffffff65) drop-shadow(0 3px 6px #00000025); }
:root[data-theme="dark"] .heading-logo { opacity: .22; }
@media (max-width: 1200px) and (min-width: 901px) {
  .sidebar-logo { width: 44px; height: 44px; }
  .sidebar-brand strong { font-size: 10px; letter-spacing: .8px; }
  .sidebar-brand small { font-size: 8px; }
}
@media (max-width: 900px) {
  #nav .sidebar-brand { gap: 8px; }
  .heading-logo { width: 100px; height: 100px; margin-right: 0; }
  .page-heading { min-height: 145px; }
}
@media (max-width: 550px) {
  .heading-logo { position: absolute; width: 95px; height: 95px; right: 0; top: 10px; margin: 0; opacity: .07; }
  :root[data-theme="dark"] .heading-logo { opacity: .1; }
  .page-heading { min-height: 135px; }
  .login-logo { width: 170px; height: 170px; }
  .login-top { padding-top: 35px; }
}
@media print { .heading-logo { display: none; } }
