:root {
  color-scheme: light;
  --navy: #102a46;
  --navy-2: #173b61;
  --gold: #d9a62e;
  --gold-soft: #fbf3df;
  --ink: #18273a;
  --muted: #68788c;
  --line: #dbe3ec;
  --surface: #ffffff;
  --canvas: #f3f6fa;
  --danger: #b42318;
  --success: #16794b;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--canvas); color: var(--ink); }
body { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: 1.1px; }
.top-gap { margin-top: 24px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px 20px; background: linear-gradient(145deg, #0d223a, #173b61); }
.login-card { width: min(100%, 410px); padding: 32px 26px; border-radius: 24px; background: var(--surface); box-shadow: 0 24px 70px #06152566; }
.brand-mark { display: grid; place-items: center; width: 82px; height: 82px; margin-bottom: 20px; padding: 0; overflow: hidden; border: 0; border-radius: 20px; background: transparent; box-shadow: 0 8px 20px #102a4624; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.login-card h1 { margin: 0 0 8px; font-size: 28px; }
.login-card > p.muted { margin: 0; line-height: 1.55; }
.login-actions { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 12px; color: #94a3b8; }
.login-actions button, .back-link { padding: 5px; border: 0; background: transparent; color: #17527e; font-size: 12px; font-weight: 700; }
.security-panel h2 { margin: 18px 0 7px; font-size: 23px; }
.security-panel > p.muted { margin: 0; line-height: 1.5; }
.security-help { margin: 14px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.security-warning { margin: 0; padding: 9px 11px; border-radius: 9px; background: #fff0ed; color: var(--danger); font-size: 12px; line-height: 1.4; }
.form-success { margin: 13px 0 0; padding: 10px 12px; border-radius: 10px; background: #e8f7ef; color: var(--success); font-size: 13px; }
.authenticator-enrollment { display: grid; gap: 10px; }
.authenticator-enrollment img { width: min(100%, 250px); aspect-ratio: 1; justify-self: center; border: 1px solid var(--line); border-radius: 12px; background: white; }
.authenticator-enrollment code { display: block; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: #f6f8fb; color: var(--navy); font-size: 13px; font-weight: 750; letter-spacing: 1px; overflow-wrap: anywhere; text-align: center; }
.authenticator-enrollment a { display: flex; align-items: center; justify-content: center; text-decoration: none; }

.app-shell { min-height: 100vh; padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
.app-header { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: #fffffff2; backdrop-filter: blur(12px); }
.app-header h1 { margin: 0; font-size: 22px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.online-badge { padding: 6px 9px; border-radius: 999px; background: #e8f7ef; color: var(--success); font-size: 11px; font-weight: 800; }
.online-badge.offline { background: #fff0ed; color: var(--danger); }
.icon-button, .avatar-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 12px; }
.icon-button { background: var(--gold-soft); color: #815800; font-size: 20px; }
.avatar-button { background: var(--navy); color: white; font-weight: 800; }
.content { width: min(100%, 760px); margin: 0 auto; padding: 18px 16px 28px; }
.page { display: none; }
.page.active { display: block; animation: appear .18s ease-out; }
@keyframes appear { from { opacity: .25; transform: translateY(4px); } }

.hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; padding: 20px; border-radius: 20px; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: white; box-shadow: 0 10px 28px #102a4628; }
.hero h2 { margin: 3px 0 6px; font-size: 22px; }
.hero p { margin: 0; color: #d8e5f2; line-height: 1.45; }
.hero-icon { display: grid; place-items: center; flex: 0 0 48px; height: 48px; border-radius: 15px; background: #ffffff1a; color: var(--gold); font-size: 24px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metric-card { min-height: 112px; padding: 16px; border: 1px solid #e3e9f0; border-radius: 17px; background: var(--surface); box-shadow: 0 5px 18px #1a38520b; }
.metric-card.wide { grid-column: span 2; }
.metric-label { display: block; min-height: 32px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.metric-value { display: block; margin-top: 8px; color: var(--navy); font-size: 24px; font-weight: 800; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 2px 12px; }
.section-heading h2, .section-heading h3 { margin: 0; font-size: 17px; }
.section-heading p { margin: 3px 0 0; font-size: 12px; }

.panel { margin-bottom: 14px; padding: 17px; border: 1px solid #e0e7ee; border-radius: 18px; background: var(--surface); box-shadow: 0 5px 18px #1a38520b; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title h3 { margin: 0; font-size: 16px; }
.activity-list, .order-list { display: grid; gap: 10px; }
.activity { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 12px 0; border-bottom: 1px solid #edf1f5; }
.activity:last-child { border-bottom: 0; }
.activity-date { display: grid; place-items: center; height: 40px; border-radius: 11px; background: var(--gold-soft); color: #815800; font-size: 11px; font-weight: 800; text-align: center; }
.activity strong, .activity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity small { margin-top: 3px; color: var(--muted); }
.activity-amount { font-size: 12px; font-weight: 700; text-align: right; }

.stack { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 6px; color: #3c5068; font-size: 12px; font-weight: 700; }
.field-hint { color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.4; }
input, select, textarea { width: 100%; min-height: 46px; padding: 11px 12px; border: 1px solid #cbd6e1; border-radius: 11px; outline: none; background: #fff; color: var(--ink); }
textarea { min-height: 78px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px #d9a62e22; }
.fixed-field { display: flex; align-items: center; min-height: 46px; padding: 11px 12px; border: 1px solid #d9e2eb; border-radius: 11px; background: #f1f5f8; color: var(--navy); font-size: 14px; font-weight: 750; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px; border: 1px solid #cad5e0; border-radius: 11px; background: white; font-size: 12px; }
.choice input { width: auto; min-height: auto; margin-right: 7px; }

.line-card { position: relative; padding: 14px; border: 1px solid #dfe6ee; border-radius: 14px; background: #f9fbfd; }
.line-card + .line-card { margin-top: 10px; }
.line-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.line-header strong { font-size: 13px; }
.line-total { color: var(--navy); font-size: 14px; font-weight: 800; }
.small-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.remove-line { border: 0; background: transparent; color: var(--danger); font-size: 12px; font-weight: 700; }
.empty-state { padding: 16px; border: 1px dashed #ccd7e1; border-radius: 13px; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; }
.empty-state.compact { padding: 13px; }
.button-row { display: flex; gap: 10px; }
.button { min-height: 46px; padding: 10px 16px; border: 1px solid transparent; border-radius: 12px; font-weight: 750; }
.button.primary { background: var(--navy); color: white; box-shadow: 0 5px 15px #102a4624; }
.button.secondary { border-color: #cbd6e1; background: white; color: var(--navy); }
.button.gold { background: var(--gold); color: #10243a; }
.button.danger { border-color: #f0c9c4; background: #fff5f3; color: var(--danger); }
.button.small { min-height: 38px; padding: 7px 12px; font-size: 12px; }
.button.full { width: 100%; }
.button:disabled { opacity: .45; cursor: default; }
.form-error { margin: 13px 0 0; padding: 10px 12px; border-radius: 10px; background: #fff0ed; color: var(--danger); font-size: 13px; }

.order-card { padding: 15px; border: 1px solid #dfe6ed; border-radius: 16px; background: white; }
.order-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.order-card h3 { margin: 0 0 4px; font-size: 15px; }
.order-meta { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.status { flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; background: #edf3f8; color: var(--navy); font-size: 10px; font-weight: 800; }
.status.overdue { background: #fff0ed; color: var(--danger); }
.order-values { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 13px 0; padding: 11px 0; border-top: 1px solid #edf1f5; border-bottom: 1px solid #edf1f5; }
.order-values span { color: var(--muted); font-size: 10px; }
.order-values strong { display: block; margin-top: 3px; color: var(--ink); font-size: 13px; }
.filter-row { display: flex; gap: 8px; margin-bottom: 13px; overflow-x: auto; }
.filter-chip { min-height: 36px; padding: 7px 13px; border: 1px solid #cdd7e2; border-radius: 999px; background: white; color: #52647a; white-space: nowrap; font-size: 12px; }
.filter-chip.active { border-color: var(--navy); background: var(--navy); color: white; }
.empty { padding: 34px 18px; border: 1px dashed #ccd7e1; border-radius: 16px; color: var(--muted); text-align: center; }

.stock-action { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 14px; width: 100%; margin: 0; color: var(--ink); text-align: left; cursor: pointer; }
.stock-action-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--gold-soft); color: #805a00; font-size: 24px; font-weight: 800; }
.stock-action strong, .stock-action small { display: block; }
.stock-action strong { color: var(--navy); font-size: 16px; }
.stock-action small { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.45; }

.bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 20; display: grid; grid-template-columns: repeat(6, 1fr); min-height: calc(66px + env(safe-area-inset-bottom)); padding: 6px 7px env(safe-area-inset-bottom); border-top: 1px solid #d9e1e9; background: #fffffff7; box-shadow: 0 -8px 24px #102a4610; backdrop-filter: blur(12px); }
.nav-item { display: grid; place-items: center; align-content: center; gap: 3px; padding: 3px; border: 0; background: transparent; color: #758396; font-size: 10px; font-weight: 700; }
.nav-item span { display: grid; place-items: center; width: 28px; height: 27px; border-radius: 9px; font-size: 18px; }
.nav-item.active { color: var(--navy); }
.nav-item.active span { background: var(--gold-soft); color: #8b6200; }

.loading { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; align-content: center; gap: 12px; background: #102a4673; color: white; font-weight: 700; backdrop-filter: blur(3px); }
.spinner { width: 36px; height: 36px; border: 4px solid #ffffff45; border-top-color: var(--gold); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; right: 18px; bottom: calc(82px + env(safe-area-inset-bottom)); left: 18px; z-index: 110; max-width: 480px; margin: auto; padding: 13px 15px; border-radius: 13px; background: #142b42; color: white; box-shadow: 0 12px 35px #0716254f; font-size: 13px; text-align: center; }
.toast.error { background: #982b22; }

@media (min-width: 700px) {
  .metric-grid { grid-template-columns: repeat(5, 1fr); }
  .metric-card.wide { grid-column: auto; }
  .bottom-nav { right: max(16px, calc((100vw - 760px) / 2)); bottom: 14px; left: max(16px, calc((100vw - 760px) / 2)); border: 1px solid #d9e1e9; border-radius: 18px; }
  .app-shell { padding-bottom: 96px; }
}

@media (max-width: 390px) {
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .metric-value { font-size: 21px; }
}
