:root {
  --bg: #f3f6fa;
  --surface: #fff;
  --surface-2: #f7f9fc;
  --ink: #172538;
  --muted: #728096;
  --line: #e5eaf1;
  --navy: #152b47;
  --navy2: #244466;
  --green: #158568;
  --red: #c64d4d;
  --amber: #a96b17;
  --gold: #d6b66f;
  --accent: #c9a653;
  --accent-strong: #a8802a;
  --accent-soft: #f8f1df;
  --shadow: 0 14px 36px rgba(28, 45, 70, .07);
  color-scheme: light;
}

body[data-theme="warm"] {
  --bg: #f3eee6;
  --surface: #fffdf9;
  --surface-2: #f8f3eb;
  --ink: #302b25;
  --muted: #81786c;
  --line: #e8dfd2;
  color-scheme: light;
}

body[data-theme="dark"] {
  --bg: #101820;
  --surface: #19232d;
  --surface-2: #202d38;
  --ink: #eef3f8;
  --muted: #a3b0bf;
  --line: #2e3d4a;
  --navy: #101923;
  --navy2: #1a2938;
  --green: #5bc59c;
  --red: #f27d7d;
  --amber: #e8b969;
  --accent-soft: #3d3523;
  --shadow: 0 18px 44px rgba(0, 0, 0, .2);
  color-scheme: dark;
}

body[data-accent="teal"] { --accent: #218b83; --accent-strong: #176b66; --accent-soft: #e3f4f1; --gold: #56bcb0; }
body[data-accent="blue"] { --accent: #4778bd; --accent-strong: #315e9c; --accent-soft: #eaf1fb; --gold: #82a9dd; }
body[data-accent="wine"] { --accent: #a4445a; --accent-strong: #803448; --accent-soft: #f8eaf0; --gold: #d28a9b; }
body[data-theme="dark"][data-accent="teal"],
body[data-theme="dark"][data-accent="blue"],
body[data-theme="dark"][data-accent="wine"] { --accent-soft: #2b3540; }

body { background: var(--bg); color: var(--ink); transition: background-color .2s, color .2s; }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.app-shell { min-height: 100vh; min-height: 100dvh; }
.sidebar { background: linear-gradient(180deg, #142a45 0%, #10233b 100%); padding: 26px 16px 18px; }
.brand { gap: 12px; padding: 4px 8px 30px; }
.brand-mark { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 14px; background: var(--accent); color: #152b47; box-shadow: 0 7px 18px rgba(0,0,0,.16); font-family: Georgia, serif; font-weight: 800; }
.brand b { color: #fff; letter-spacing: .075em; }
.brand small { color: #d4c293; font-family: inherit; font-size: 11px; letter-spacing: .02em; }
.sidebar nav { gap: 5px; }
.nav-item { min-height: 46px; border-radius: 12px; padding: 11px 13px; transition: background-color .18s, transform .18s; }
.nav-item span { font-weight: 550; letter-spacing: .01em; }
.nav-item:hover { transform: translateX(2px); background: rgba(255,255,255,.08); }
.nav-item.active { background: linear-gradient(110deg, rgba(214,182,111,.22), rgba(255,255,255,.06)); box-shadow: inset 3px 0 var(--gold); }
.side-foot { border-color: rgba(255,255,255,.13); }
.avatar { background: var(--accent); color: #152b47; }
.main { min-height: 100vh; min-height: 100dvh; }
.topbar { height: 78px; padding: 0 32px; background: var(--surface); border-color: var(--line); box-shadow: 0 2px 14px rgba(26,45,71,.035); }
.topbar strong { color: var(--ink); letter-spacing: -.02em; }
.topbar small { color: var(--muted); }
.sync-pill { background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; }
.content { max-width: 1480px; padding: 30px 32px 34px; }
.page-heading { align-items: center; margin-bottom: 22px; }
.page-eyebrow, .panel-kicker { display: block; color: var(--accent-strong); font-size: 9px; font-weight: 800; letter-spacing: .16em; margin-bottom: 6px; }
.page-heading h1 { color: var(--ink); font-size: clamp(23px, 2vw, 30px); letter-spacing: -.04em; }
.page-heading p, .panel-intro { color: var(--muted); font-size: 13px; }
.panel-intro { margin: -7px 0 17px; }
.grid { gap: 16px; }
.stats { gap: 14px; margin-bottom: 18px; }
.stat, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); }
.stat { padding: 19px 20px; position: relative; overflow: hidden; min-height: 122px; }
.stat::after { content: ""; position: absolute; width: 72px; height: 72px; right: -24px; bottom: -34px; border-radius: 50%; background: var(--accent-soft); opacity: .9; }
.stat label { color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .02em; }
.stat strong { color: var(--ink); font-size: 29px; letter-spacing: -.035em; }
.stat .hint { color: var(--muted); }
.panel { padding: 19px; margin-bottom: 16px; }
.panel h3 { color: var(--ink); font-size: 15px; letter-spacing: -.015em; }
.warehouse-row { border-color: var(--line); padding: 13px 0; }
.warehouse-row b { color: var(--ink); }
.warehouse-row small, .warehouse-row strong { color: var(--muted); }
.warehouse-icon { width: 39px; height: 39px; border-radius: 13px; background: var(--accent-soft); color: var(--accent-strong); }
.table-wrap { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { color: var(--ink); }
th { background: var(--surface-2); color: var(--muted); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
td, th { border-color: var(--line); }
tr:last-child td { border-bottom: 0; }
.field, select, textarea { border-color: var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); min-height: 44px; }
.field:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--accent) 19%, transparent); border-color: var(--accent); }
label.form-label { color: var(--muted); font-size: 11px; font-weight: 700; }
.btn { border-radius: 11px; min-height: 42px; padding: 10px 15px; transition: transform .16s, box-shadow .16s, filter .16s; }
.btn:active { transform: scale(.98); }
.primary { background: linear-gradient(135deg, var(--navy), var(--navy2)); box-shadow: 0 7px 18px rgba(21,43,71,.16); }
.gold { background: var(--accent); color: #172538; }
.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.secondary:hover { background: var(--surface-2); }
.danger { background: color-mix(in srgb, var(--red) 9%, var(--surface)); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, var(--line)); }
.toolbar { gap: 10px; }
.toolbar .field { min-height: 44px; }
.badge { background: var(--surface-2); color: var(--muted); }
.badge.green { background: color-mix(in srgb, var(--green) 12%, var(--surface)); color: var(--green); }
.badge.amber { background: color-mix(in srgb, var(--amber) 12%, var(--surface)); color: var(--amber); }
.badge.red { background: color-mix(in srgb, var(--red) 12%, var(--surface)); color: var(--red); }
.notice { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 28%, var(--line)); color: var(--accent-strong); border-radius: 12px; line-height: 1.6; }
.pill-tabs button { min-height: 40px; background: var(--surface); color: var(--ink); border-color: var(--line); }
.pill-tabs button.active { background: var(--navy); color: #fff; }
footer { background: var(--surface); border-color: var(--line); color: var(--muted); padding: 15px 32px; }
footer span { color: var(--accent); }
.empty { color: var(--muted); }
dialog { background: var(--surface); color: var(--ink); }
dialog .field, dialog select, dialog textarea { font-size: 14px; }
.modal-head { border-color: var(--line); }
.modal-head h3 { color: var(--ink); }
.icon-btn { color: var(--muted); width: 40px; height: 40px; border-radius: 10px; }
.icon-btn:hover { background: var(--surface-2); }
.toast { background: #142d4c; box-shadow: 0 12px 30px rgba(10,26,47,.2); padding: 13px 17px; border-radius: 13px; }

.appearance-panel { padding: 22px; }
#content[data-page="settings"] { display: flex; flex-direction: column; }
#content[data-page="settings"] > .page-heading { order: 0; width: 100%; }
#content[data-page="settings"] > .appearance-panel { order: 1; width: 100%; }
#content[data-page="settings"] > .cloud-panel { order: 2; width: 100%; }
#content[data-page="settings"] > .grid.two-col { order: 3; width: 100%; }
.appearance-panel h3 { font-size: 18px; margin-bottom: 12px; }
.directory-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.directory-heading h3 { margin: 0; }
.directory-heading .hint { margin: 0; }
.appearance-grid { gap: 0 16px; }
.appearance-preview { margin-top: 19px; padding: 14px; border-radius: 15px; display: flex; align-items: center; gap: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.appearance-preview .brand-mark { width: 42px; height: 42px; font-size: 21px; display: grid; place-items: center; }
.appearance-preview > div:nth-child(2) { min-width: 0; display: grid; gap: 2px; }
.appearance-preview small { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.appearance-preview b { color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.preview-chip { margin-left: auto; padding: 7px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 10px; font-weight: 750; white-space: nowrap; }
.save-appearance { margin-top: 16px; min-width: 170px; }
.logo-upload-row { display: flex; align-items: center; gap: 8px; }
.logo-upload-row .field { min-width: 0; flex: 1; }
.remove-logo-btn { white-space: nowrap; }
.brand-logo-image { display: block; width: 100%; height: 100%; padding: 4px; object-fit: contain; border-radius: inherit; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.cloud-panel { background: linear-gradient(135deg, var(--surface), var(--surface-2)); }
.stat > *, .panel > * { position: relative; z-index: 1; }
.stat::after { pointer-events: none; }
body[data-density="compact"] .content { padding-top: 20px; }
body[data-density="compact"] .panel { padding: 14px; margin-bottom: 11px; }
body[data-density="compact"] .stat { min-height: 100px; padding: 14px 16px; }
body[data-density="compact"] .warehouse-row { padding-top: 8px; padding-bottom: 8px; }
body[data-density="compact"] .grid { gap: 10px; }
.nav-item:focus-visible, .dock-item:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 48%, white); outline-offset: 2px; }

.mobile-dock, .mobile-scrim { display: none; }

@media (max-width: 900px) {
  .content { padding: 24px 22px 28px; }
  .topbar { padding: 0 22px; }
  .sidebar { width: 215px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  html { scroll-padding-top: 75px; }
  body { padding-bottom: env(safe-area-inset-bottom); }
  body.menu-open { overflow: hidden; }
  .app-shell { display: block; min-height: 100dvh; }
  .sidebar { position: fixed; z-index: 21; inset: 0 auto 0 0; width: min(84vw, 320px); padding: calc(18px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); transform: translateX(-105%); transition: transform .24s cubic-bezier(.2,.8,.2,1); box-shadow: none; }
  .sidebar.open { left: 0; transform: translateX(0); box-shadow: 22px 0 60px rgba(6,18,32,.28); }
  .sidebar nav { overflow: auto; }
  .nav-item { min-height: 50px; font-size: 18px; }
  .nav-item span { font-size: 14px; }
  .side-foot { margin-top: auto; }
  .mobile-scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(9,20,34,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .menu-open .mobile-scrim { opacity: 1; pointer-events: auto; }
  .main { min-height: 100dvh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .topbar { position: sticky; z-index: 10; top: 0; height: calc(64px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0; gap: 10px; }
  .mobile-menu { display: none; }
  .topbar > div:first-of-type { min-width: 0; flex: 1; }
  .topbar strong { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar small { display: none; }
  .top-right { gap: 0; }
  .top-right .avatar { display: none; }
  .sync-pill { width: 10px; height: 10px; min-width: 10px; padding: 0; overflow: hidden; font-size: 0; border-radius: 99px; box-shadow: 0 0 0 4px var(--accent-soft); }
  .content { padding: 21px 15px 25px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 17px; }
  .page-heading h1 { font-size: 25px; margin-bottom: 5px; }
  .page-heading p { font-size: 12px; line-height: 1.5; }
  .page-heading > .btn { width: 100%; min-height: 46px; }
  .grid { gap: 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 13px; }
  .stat { min-height: 112px; padding: 14px 13px; border-radius: 15px; }
  .stat label { font-size: 10px; line-height: 1.35; display: block; max-width: 120px; }
  .stat strong { font-size: clamp(22px, 7vw, 28px); margin-top: 7px; }
  .stat .hint { font-size: 10px; line-height: 1.35; display: block; max-width: 140px; }
  .panel { border-radius: 16px; padding: 15px; margin-bottom: 12px; }
  .panel h3 { font-size: 14px; }
  .warehouse-row { gap: 10px; padding: 12px 0; }
  .warehouse-row b { font-size: 12px; }
  .warehouse-row small { font-size: 10px; }
  .warehouse-row strong { font-size: 12px; white-space: nowrap; }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .toolbar .field { width: 100%; min-width: 0; max-width: none !important; grid-column: 1 / -1; }
  .toolbar .btn, .toolbar select { width: 100%; min-width: 0; min-height: 44px; padding: 9px 10px; font-size: 11px; }
  .table-wrap { max-width: calc(100vw - 60px); overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 620px; }
  th, td { padding: 11px 10px; }
  .notice { font-size: 11px; }
  .appearance-panel { padding: 17px 15px; }
  .appearance-grid { grid-template-columns: 1fr; }
  .appearance-grid .full { grid-column: auto; }
  .appearance-preview { align-items: flex-start; flex-wrap: wrap; }
  .logo-upload-row { align-items: stretch; flex-direction: column; }
  .remove-logo-btn { width: 100%; }
  .preview-chip { margin-left: 54px; }
  .save-appearance { width: 100%; min-height: 48px; }
  .backup-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .backup-actions .btn { min-height: 46px; }
  .backup-actions .btn:nth-of-type(3) { grid-column: 1 / -1; }
  .field, select, textarea { min-height: 47px; padding: 12px; font-size: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .btn { min-height: 46px; }
  .modal-actions { position: sticky; bottom: -1px; background: var(--surface); padding: 10px 0 calc(6px + env(safe-area-inset-bottom)); }
  dialog { position: fixed; inset: auto 0 0; width: 100%; max-width: none; max-height: min(88dvh, 760px); margin: 0; padding: 18px 17px calc(12px + env(safe-area-inset-bottom)); border-radius: 23px 23px 0 0; box-shadow: 0 -18px 70px rgba(5,18,32,.25); }
  dialog::backdrop { background: rgba(10,21,35,.52); }
  dialog form { max-height: calc(88dvh - 42px - env(safe-area-inset-bottom)); overflow: auto; padding-bottom: 1px; }
  footer { display: none; }
  .toast { bottom: calc(77px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); text-align: center; }
  .mobile-dock { position: fixed; z-index: 15; inset: auto 0 0; display: grid; grid-template-columns: repeat(5,1fr); align-items: stretch; min-height: calc(64px + env(safe-area-inset-bottom)); padding: 5px 8px calc(5px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--line); box-shadow: 0 -8px 28px rgba(22,40,64,.08); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
  .dock-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; min-height: 50px; border: 0; border-radius: 13px; background: transparent; color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .dock-icon { min-width: 30px; height: 27px; display: grid; place-items: center; border-radius: 10px; font-size: 20px; line-height: 1; }
  .dock-item small { font-size: 9px; font-weight: 700; letter-spacing: .01em; }
  .dock-item.active { color: var(--accent-strong); }
  .dock-item.active .dock-icon { background: var(--accent-soft); }
  .dock-item.dock-add .dock-icon { width: 36px; height: 32px; background: var(--navy); color: #fff; font-size: 23px; box-shadow: 0 5px 13px rgba(21,43,71,.2); }
  body[data-density="compact"] .content { padding-top: 16px; }
  body[data-density="compact"] .panel { padding: 12px; }
  body[data-density="compact"] .stat { min-height: 98px; padding: 11px 10px; }
}

@media (max-width: 370px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .stat { padding: 12px 10px; }
  .stat label { font-size: 9px; }
  .toolbar { grid-template-columns: 1fr; }
  .toolbar .field { grid-column: auto; }
  .mobile-dock { padding-left: 4px; padding-right: 4px; }
}

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

/* Clear return and sign-in actions */
.password-entry{display:flex;gap:8px;align-items:stretch}.password-entry .field{flex:1;min-width:0}.password-toggle{flex:0 0 auto;min-width:76px}.auth-actions{margin-top:14px}.auth-actions .btn{min-height:42px}.return-step{padding:10px 12px;border-radius:9px;background:var(--surface-2);color:var(--muted);font-size:12px}
@media(max-width:620px){.password-toggle{min-width:72px}.auth-actions .btn{flex:1}}
.inline-actions{display:flex;gap:8px;align-items:center}.inline-actions select{flex:1;min-width:0}.inline-actions .btn{white-space:nowrap}
/* Premium iPhone glass and reporting */
:root{--glass:rgba(255,255,255,.72)}
.panel,.stat,.page-heading{border:1px solid color-mix(in srgb,var(--line) 72%,transparent);box-shadow:0 14px 34px rgba(16,39,71,.075);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px)}
.panel{border-radius:20px;background:var(--glass)}
.page-heading h1,.panel h3,.stat strong,.home-metric{font-weight:850;letter-spacing:-.025em}
.home-shortcuts{margin:14px 0}.home-shortcut{display:grid;gap:8px}.home-metric{font-size:27px;color:var(--ink)}.home-shortcut .btn{justify-self:start;margin-top:6px}
.report-filters{margin-bottom:14px}.report-filters .form-grid{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}.report-filters .panel-kicker{margin-bottom:10px}
@media(max-width:620px){.content{padding:12px 10px calc(82px + env(safe-area-inset-bottom))}.page-heading{align-items:flex-start;gap:10px}.page-heading h1{font-size:21px;font-weight:900}.page-heading .btn{min-height:42px;font-weight:800}.panel,.stat{border-radius:18px}.panel{padding:14px}.stats{gap:8px}.stat{padding:11px 10px;min-height:94px}.stat strong{font-size:22px}.toolbar{gap:8px}.report-filters .form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.report-filters .field{min-height:44px;font-size:15px}.home-shortcuts{gap:9px}.home-shortcut .btn{width:100%;justify-self:stretch}.table-wrap{border-radius:14px}.mobile-dock{background:rgba(250,252,255,.78);backdrop-filter:blur(24px) saturate(1.4);-webkit-backdrop-filter:blur(24px) saturate(1.4);border-top:1px solid rgba(255,255,255,.65);box-shadow:0 -12px 38px rgba(16,39,71,.14)}}
@media print{body.printing-report .sidebar,body.printing-report .topbar,body.printing-report footer,body.printing-report .mobile-dock,body.printing-report .page-heading>button,body.printing-report .report-filters{display:none!important}body.printing-report #content{padding:0!important}body.printing-report .panel,body.printing-report .stat{box-shadow:none!important;background:#fff!important;border:1px solid #ccc!important;break-inside:avoid}body.printing-report .table-wrap{overflow:visible!important}body.printing-report table{font-size:10pt}body.printing-report h3{color:#102747!important}}
/* iPhone sizing for combined design entry and stock overview */
.design-size-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(135px,1fr));gap:10px}.design-size-card{padding:12px;border:1px solid var(--line);border-radius:16px;background:rgba(255,255,255,.52)}@media(max-width:620px){.design-size-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
/* Compact size matrix for phone screens */
@media(max-width:620px){#content .table-wrap table{min-width:520px}.home-shortcuts{gap:8px}.home-shortcuts>.btn{min-height:48px;font-weight:800}.design-size-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
