:root {
  --bg: #101412;
  --surface: #181e1b;
  --surface-2: #202824;
  --border: #2c3731;
  --text: #f3f5f3;
  --muted: #9aa79f;
  --green: #22a53c;
  --green-bright: #2ecc52;
  --red: #ef4444;
  --amber: #f59e0b;
  --gold: #ffc100;
  --blue: #3b82f6;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body, button, a, input, select {
  touch-action: manipulation;
}

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

button, input, select {
  font-family: inherit;
}

/* PIN LOGIN OVERLAY */
.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(12, 16, 14, 0.94);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pin-overlay.hidden {
  display: none;
}
.pin-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.pin-card h2 {
  font-size: 1.3rem;
  font-weight: 900;
  margin-bottom: 8px;
}
.pin-card p {
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 18px;
}
.pin-input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.25em;
  outline: none;
  margin-bottom: 12px;
}
.pin-input.login-text {
  text-align: left;
  letter-spacing: 0.02em;
  font-size: 0.96rem;
  font-weight: 700;
}
.pin-input:focus {
  border-color: var(--green-bright);
}
.pin-input::placeholder {
  letter-spacing: 0.02em;
  font-size: 0.92rem;
  font-weight: 600;
}
.pin-error {
  color: #f87171;
  font-size: 0.82rem;
  font-weight: 700;
  min-height: 20px;
  margin-bottom: 10px;
}

/* SOUND UNLOCK BANNER */
.sound-unlock-banner {
  background: linear-gradient(90deg, #b91c1c, #dc2626);
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  font-weight: 800;
  font-size: 0.9rem;
  border-bottom: 2px solid var(--gold);
}

.sound-unlock-banner.hidden {
  display: none;
}

/* FLASHING NEW ORDER ALERT BAR */
.new-order-flash {
  background: linear-gradient(90deg, var(--red), #b91c1c);
  color: #fff;
  padding: 12px 24px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-weight: 900;
  font-size: 0.98rem;
  animation: flashPulse 1.1s ease-in-out infinite;
}
.new-order-flash.show {
  display: flex;
}

@keyframes flashPulse {
  0%, 100% { background: #dc2626; }
  50% { background: #991b1b; }
}

/* TOP BAR */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand-chip {
  background: var(--green);
  color: #fff;
  padding: 6px 12px;
  border-radius: 10px;
  border-bottom: 3px solid var(--red);
  font-weight: 900;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.brand-chip span.num {
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 0.78rem;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(34, 165, 60, 0.16);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.live-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulseDot 1.6s infinite;
}

.live-indicator.offline {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}
.live-indicator.offline .dot {
  background: #ef4444;
  animation: none;
}

@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
}
.btn:hover {
  border-color: #4a5c51;
  background: #28332d;
}

.btn-green {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.btn-green:hover {
  background: #1b8a32;
}

.btn-amber {
  background: var(--amber);
  border-color: var(--amber);
  color: #111;
}
.btn-amber:hover {
  background: #d97706;
}

.btn-red {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.btn-red:hover {
  background: #dc2626;
}

.btn-gold {
  background: var(--gold);
  border-color: var(--gold);
  color: #111;
}

.select-mini {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  outline: none;
}

/* MAIN WRAP */
.panel-wrap {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

/* KPI STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-val {
  font-size: 1.85rem;
  font-weight: 900;
  line-height: 1.1;
}

.stat-card.new { border-left: 4px solid var(--red); }
.stat-card.new .stat-val { color: #f87171; }
.stat-card.prep { border-left: 4px solid var(--amber); }
.stat-card.prep .stat-val { color: #fbbf24; }
.stat-card.way { border-left: 4px solid var(--green-bright); }
.stat-card.way .stat-val { color: #4ade80; }
.stat-card.done { border-left: 4px solid var(--blue); }
.stat-card.done .stat-val { color: #60a5fa; }
.stat-card.rev { border-left: 4px solid var(--gold); }
.stat-card.rev .stat-val { color: var(--gold); }

/* SOUND CONTROL STRIP + TABS */
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tabs {
  display: flex;
  gap: 8px;
  background: var(--surface);
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.tab-btn {
  padding: 8px 16px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--green);
  color: #fff;
}

.sound-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text);
}

/* KANBAN COLUMNS */
.kanban-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  align-items: start;
}

.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  min-height: 460px;
}

.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.col-title {
  font-size: 0.96rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 8px;
}

.col-count {
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
}

.col-new .col-count { background: rgba(239, 68, 68, 0.22); color: #f87171; }
.col-prep .col-count { background: rgba(245, 158, 11, 0.22); color: #fbbf24; }
.col-way .col-count { background: rgba(34, 165, 60, 0.25); color: #4ade80; }

.order-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-col {
  text-align: center;
  padding: 46px 12px;
  color: var(--muted);
  font-size: 0.84rem;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
}

/* ORDER CARD */
.order-card {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.order-card.status-new {
  border-color: var(--red);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.4), 0 10px 26px rgba(239, 68, 68, 0.16);
  animation: newCardGlow 1.6s ease-in-out infinite alternate;
}

@keyframes newCardGlow {
  from { border-color: #ef4444; }
  to { border-color: #ffc100; }
}

.order-card.status-preparing {
  border-color: var(--amber);
}

.order-card.status-on_the_way {
  border-color: var(--green-bright);
  box-shadow: 0 8px 24px rgba(34, 165, 60, 0.14);
}

.order-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.order-code {
  font-size: 1.12rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.02em;
}

.order-time {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
}

.badge-type {
  font-size: 0.7rem;
  font-weight: 900;
  padding: 4px 9px;
  border-radius: 999px;
  text-transform: uppercase;
}
.badge-delivery {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}
.badge-pickup {
  background: rgba(255, 193, 0, 0.2);
  color: var(--gold);
}

.order-customer {
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.order-customer strong {
  font-size: 0.9rem;
}

.order-customer a {
  color: #4ade80;
  font-weight: 800;
  text-decoration: none;
}

.order-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
}

.order-item-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 700;
}

.order-item-qty {
  display: inline-block;
  background: var(--gold);
  color: #111;
  font-weight: 900;
  padding: 1px 7px;
  border-radius: 6px;
  margin-right: 6px;
  font-size: 0.8rem;
}

.item-subnote {
  font-size: 0.76rem;
  color: #fcd34d;
  margin-left: 30px;
  font-weight: 600;
}

.order-note-box {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.order-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 900;
  font-size: 1rem;
}

.order-total-row .price {
  color: #4ade80;
  font-size: 1.18rem;
}

.courier-note-input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 0.78rem;
  outline: none;
}
.courier-note-input:focus {
  border-color: var(--green-bright);
}

.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.order-actions .btn {
  flex: 1;
  padding: 11px 12px;
  font-size: 0.82rem;
}

/* HISTORY & MENU TABLES */
.tab-section {
  display: none;
}
.tab-section.active {
  display: block;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.status-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}
.chip-new { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.chip-preparing { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.chip-on_the_way { background: rgba(34, 165, 60, 0.25); color: #4ade80; }
.chip-delivered { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.chip-cancelled { background: rgba(156, 163, 175, 0.2); color: #d1d5db; }

.price-input {
  width: 82px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-weight: 800;
  font-size: 0.84rem;
}

.site-images-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.site-img-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-img-box img {
  width: 86px;
  height: 66px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.site-img-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.site-img-meta strong {
  font-size: 0.84rem;
}

.menu-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 200;
  background: #222b26;
  color: #fff;
  padding: 13px 20px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 0.86rem;
  border-left: 4px solid var(--green-bright);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: all 0.25s ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .kanban-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .site-images-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { padding: 12px 14px; gap: 10px; }
  .topbar-controls { width: 100%; }
  .topbar-controls .btn, .topbar-controls .select-mini { flex: 1; font-size: 0.74rem; padding: 8px 10px; }
  .panel-wrap { padding: 14px 12px 36px; }
  .stats-grid { gap: 10px; }
  .stat-card.rev { grid-column: span 2; }
  .stat-val { font-size: 1.5rem; }
  .tabs { width: 100%; overflow-x: auto; }
  .tab-btn { flex-shrink: 0; font-size: 0.76rem; padding: 8px 12px; }
  .sound-box { width: 100%; justify-content: space-between; }
  .kanban-col { padding: 12px; min-height: auto; }
  .order-card { padding: 14px; }
  .order-actions .btn { font-size: 0.78rem; padding: 10px 8px; }
}
