:root {
  --bg: #0a0c10;
  --surface: rgba(20, 24, 32, 0.72);
  --surface-strong: rgba(26, 31, 42, 0.9);
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(59, 130, 246, 0.55);
  --text: #f3f5f8;
  --muted: #8b95a7;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.16);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.15);
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
}

.app-shell {
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 12px 92px;
}

.glass {
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin-bottom: 12px;
  position: sticky;
  top: 8px;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.online-pill.offline .pulse-dot {
  background: var(--muted);
  box-shadow: none;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* Views */
.view {
  display: none;
  animation: fadeIn 0.2s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Segmented control */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  gap: 4px;
  margin-bottom: 12px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.2s ease, color 0.2s ease;
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Cards & Forms */
.card {
  padding: 14px;
  margin-bottom: 12px;
}

.card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.card-title i {
  color: #60a5fa;
}

.field-group {
  margin-bottom: 11px;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}

.input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.input:focus {
  border-color: var(--border-active);
  background: rgba(255, 255, 255, 0.06);
}

.textarea {
  resize: vertical;
  font-family: inherit;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Curtain (Accordion) Selectors */
.curtain {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.curtain.open {
  border-color: var(--border-active);
}

.curtain-trigger {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
}

.curtain-arrow {
  font-size: 12px;
  color: var(--muted);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.curtain.open .curtain-arrow {
  transform: rotate(180deg);
  color: #60a5fa;
}

.curtain-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.curtain.open .curtain-body {
  grid-template-rows: 1fr;
}

.curtain-inner {
  overflow: hidden;
  border-top: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.curtain.open .curtain-inner {
  border-top-color: var(--border);
}

.curtain-option {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s ease;
}

.curtain-option:hover,
.curtain-option.selected {
  background: var(--accent-soft);
  color: #93c5fd;
  font-weight: 600;
}

.profile-form {
  padding: 12px;
}

/* Catalog Chips */
.chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--border-active);
  color: #93c5fd;
}

/* Warning banner */
.warning-banner {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--amber-soft);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fde68a;
  font-size: 12.5px;
  margin-bottom: 12px;
}

.warning-banner i {
  margin-top: 2px;
  color: var(--amber);
}

/* Custom Checkbox */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.check-row input {
  display: none;
}

.check-box {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: transparent;
  margin-top: 1px;
  transition: all 0.18s ease;
}

.check-row input:checked + .check-box {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.check-text {
  font-size: 13px;
  color: var(--text);
}

.check-text small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

/* Price & Buttons */
.price-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.price-label {
  font-size: 13px;
  color: var(--muted);
}

.price-note {
  font-size: 11.5px;
  color: #93c5fd;
}

.price-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: var(--green);
  color: #052e16;
}

.btn-danger {
  background: var(--red-soft);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-primary:active,
.btn-secondary:active,
.btn-success:active,
.btn-danger:active {
  transform: scale(0.98);
}

.btn-sm {
  padding: 8px 11px;
  font-size: 12.5px;
  border-radius: 10px;
}

/* Shift Card & Metrics */
.shift-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.shift-status-label {
  font-size: 15px;
  font-weight: 700;
}

.btn-shift {
  border: none;
  border-radius: 11px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-shift.start {
  background: var(--green);
  color: #052e16;
}

.btn-shift.stop {
  background: var(--red-soft);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.metric {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

.metric.accent {
  border-color: rgba(34, 197, 94, 0.3);
  background: var(--green-soft);
}

.metric.warn {
  border-color: rgba(245, 158, 11, 0.28);
  background: var(--amber-soft);
}

.metric-val {
  font-size: 16px;
  font-weight: 700;
}

.metric-lbl {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* Lists & Order Cards */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 2px 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-size: 12.5px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-card {
  padding: 13px;
}

.order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.order-code {
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-pending { background: var(--amber-soft); color: #fcd34d; }
.badge-accepted { background: var(--accent-soft); color: #93c5fd; }
.badge-picked_up { background: var(--accent-soft); color: #93c5fd; }
.badge-in_transit { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }
.badge-delivered { background: var(--green-soft); color: #86efac; }
.badge-cancelled { background: var(--red-soft); color: #fca5a5; }
.badge-urgent { background: var(--red-soft); color: #fca5a5; }

.order-route {
  font-weight: 600;
  margin-bottom: 5px;
}

.order-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

.courier-box {
  margin-top: 9px;
  padding: 9px 10px;
  border-radius: 11px;
  background: rgba(59, 130, 246, 0.09);
  border: 1px solid rgba(59, 130, 246, 0.22);
  font-size: 12.5px;
}

.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.order-actions > * {
  flex: 1 1 120px;
}

.contract-pre {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  padding: 10px;
  margin: 0;
  color: #dbeafe;
  background: rgba(0, 0, 0, 0.35);
}

.empty-state {
  text-align: center;
  padding: 24px 14px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state i {
  font-size: 24px;
  margin-bottom: 8px;
  display: block;
  opacity: 0.6;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 496px;
  display: flex;
  justify-content: space-around;
  padding: 6px;
  z-index: 40;
  background: var(--surface-strong);
}

.nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 4px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.nav-btn i {
  font-size: 16px;
}

.nav-btn.active {
  color: #60a5fa;
  background: var(--accent-soft);
}

/* Toast */
.toast {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  background: #1d4ed8;
  color: #fff;
  padding: 9px 14px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 500;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-width: 90%;
  text-align: center;
}

.toast.error {
  background: #b91c1c;
}

.hidden {
  display: none !important;
}
