:root {
  --bg: #F8FAFC;
  --bg-2: #FFFFFF;
  --text: #111827;
  --text-2: #64748B;
  --border: #E2E8F0;
  --primary: #F97316;
  --primary-light: #FB923C;
  --dark: #111827;
  --success: #16A34A;
  --warning: #FB923C;
  --danger: #DC2626;
  --blue: #2563EB;
  --purple: #7C3AED;
  --radius: 24px;
  --shadow: 0 10px 40px rgba(2, 6, 23, 0.08);
  --shadow-sm: 0 4px 12px rgba(2, 6, 23, 0.05);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1220;
    --bg-2: #111827;
    --text: #F1F5F9;
    --text-2: #94A3B8;
    --border: #1E293B;
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.glass-header {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

@media (prefers-color-scheme: dark) {
  .glass-header { background: rgba(17,24,39,0.72); }
}

.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.1rem; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--warning));
  display: grid; place-items: center; color: #fff; font-weight: 800;
}

.user-pill {
  display: flex; align-items: center; gap: 12px;
  background: rgba(249,115,22,0.08);
  border: 1px solid rgba(249,115,22,0.15);
  padding: 8px 16px; border-radius: 999px; font-size: 0.9rem; font-weight: 500;
}

.btn {
  appearance: none; border: none; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; border-radius: 14px; font-size: 0.95rem; font-weight: 600;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s;
}

.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 18px rgba(249,115,22,0.35); }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--bg-2); color: var(--text); border: 1px solid var(--border); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-sm { height: 40px; padding: 0 16px; font-size: 0.85rem; }
.btn-icon { width: 48px; padding: 0; }

.card {
  background: var(--bg-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 24px;
}

/* Login */
.login-bg {
  height: 100vh;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, rgba(249,115,22,0.12), transparent 40%),
              radial-gradient(circle at 80% 80%, rgba(37,99,235,0.08), transparent 40%),
              var(--bg);
}

.login-card {
  width: min(420px, 92vw);
  text-align: center;
  padding: 40px 28px;
}

.login-logo { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 24px; }

.pin-dots { display: flex; justify-content: center; gap: 18px; margin: 32px 0; }
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-2); transition: 0.2s;
}
.pin-dot.filled { background: var(--primary); box-shadow: 0 0 14px var(--primary); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.key {
  height: 72px; border-radius: 18px; font-size: 1.4rem; font-weight: 600;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; box-shadow: var(--shadow-sm); transition: all 0.15s;
}
.key:hover { background: var(--border); }
.key:active { transform: scale(0.96); background: var(--primary-light); color: #fff; }

/* Dashboard summary */
.summary-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; padding: 24px 28px 10px;
}
@media (max-width: 1024px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  border-radius: 22px; padding: 20px; display: flex; align-items: center; gap: 16px;
  background: var(--bg-2); box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.stat-icon { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; font-size: 1.4rem; }
.stat-orange { background: #FFF7ED; color: var(--primary); }
.stat-blue { background: #EFF6FF; color: var(--blue); }
.stat-green { background: #F0FDF4; color: var(--success); }
.stat-purple { background: #F3E8FF; color: var(--purple); }
.stat-danger { background: #FEF2F2; color: var(--danger); }

.stat-title { font-size: 0.8rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.6rem; font-weight: 800; margin-top: 2px; }

/* Floor map */
.floor-tabs { display: flex; gap: 10px; padding: 0 28px 18px; }
.floor-tab {
  display: inline-block; padding: 10px 20px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text-2); text-decoration: none; cursor: pointer; font-weight: 600;
}
.floor-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.floor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px; padding: 0 28px 28px; overflow-y: auto; flex: 1;
}

.table-card {
  aspect-ratio: 1/1; border-radius: 26px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: #fff; text-decoration: none; position: relative; cursor: pointer; transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: var(--shadow);
}
.table-card:hover { transform: translateY(-4px); }
.table-card .tnum { font-size: 1.5rem; font-weight: 800; }
.table-card .tinfo { font-size: 0.78rem; opacity: 0.95; text-align: center; }
.table-card .twaiter { position: absolute; bottom: 12px; font-size: 0.7rem; font-weight: 600; }

.t-available { background: linear-gradient(135deg, var(--success), #22c55e); }
.t-ordering { background: linear-gradient(135deg, var(--warning), #fdba74); }
.t-waiting { background: linear-gradient(135deg, var(--blue), #3b82f6); }
.t-ready { background: linear-gradient(135deg, var(--purple), #a78bfa); }
.t-bill { background: linear-gradient(135deg, var(--danger), #f87171); }

/* Order screen layout */
.order-shell { display: flex; height: calc(100vh - 72px); overflow: hidden; }
.order-cats { width: 240px; border-right: 1px solid var(--border); overflow-y: auto; padding: 18px; }
.order-menu { flex: 1; overflow-y: auto; padding: 18px; }
.order-cart { width: 360px; border-left: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg-2); }

.cat-pill {
  display: block; width: 100%; text-align: left; padding: 14px 18px; margin-bottom: 10px;
  border-radius: 16px; border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text); text-decoration: none; cursor: pointer; font-weight: 600;
}
.cat-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.menu-item {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 20px; overflow: hidden;
  cursor: pointer; transition: 0.15s; text-align: center;
}
.menu-item:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.menu-item .mi-img { width: 100%; height: 110px; background: var(--bg); display: grid; place-items: center; font-size: 2.8rem; }
.menu-item .mi-info { padding: 14px; }
.menu-item .mi-name { font-weight: 700; font-size: 0.9rem; }
.menu-item .mi-price { color: var(--primary); font-weight: 800; margin-top: 4px; }

.cart-head { padding: 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 1.1rem; }
.cart-body { flex: 1; overflow-y: auto; padding: 18px; }
.cart-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.cart-item .cname { font-weight: 700; }
.cart-item .cmeta { font-size: 0.75rem; color: var(--text-2); }
.cart-item .cprice { font-weight: 700; }
.cart-totals { padding: 18px; border-top: 1px solid var(--border); background: var(--bg-2); }
.trow { display: flex; justify-content: space-between; margin-bottom: 6px; }
.tgrand { font-size: 1.2rem; font-weight: 800; margin-top: 8px; padding-top: 8px; border-top: 2px solid var(--border); }
.cart-actions { display: flex; gap: 10px; padding: 14px 18px; }
.cart-actions .btn { flex: 1; }

/* KDS */
.kds-shell { display: flex; height: calc(100vh - 72px); gap: 24px; padding: 24px; overflow-x: auto; }
.kds-col { width: 320px; min-width: 320px; display: flex; flex-direction: column; }
.kds-head { font-weight: 800; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 12px; color: var(--text-2); }
.kds-list { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; flex: 1; }
.ticket {
  background: var(--bg-2); border-radius: 22px; padding: 18px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border); animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.ticket-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ticket-table { font-size: 1.2rem; font-weight: 800; }
.ticket-time { font-size: 0.75rem; color: var(--text-2); }
.ticket-items { font-size: 0.9rem; margin-bottom: 12px; }
.ticket-items .ti-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.ticket-actions { display: flex; gap: 8px; }
.ticket-actions .btn { flex: 1; height: 40px; }

/* Cashier */
.bills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; padding: 24px; }
.bill-card { background: var(--bg-2); border-radius: 20px; padding: 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.bill-card .bhead { display: flex; justify-content: space-between; margin-bottom: 12px; }
.bill-card .btable { font-size: 1.3rem; font-weight: 800; }
.bill-card .bwaiter { color: var(--text-2); font-size: 0.85rem; }
.bill-card .btotal { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin-top: 10px; }

/* Receipt print */
.receipt-frame { max-width: 280px; margin: 20px auto; background: #fff; color: #111; padding: 16px; font-family: 'Courier New', monospace; font-size: 0.85rem; border-radius: 4px; }
.receipt-frame .rh-title { text-align: center; font-size: 1.1rem; font-weight: 800; margin-bottom: 6px; }
.receipt-frame .rh-sub { text-align: center; margin-bottom: 16px; }
.receipt-frame table { width: 100%; border-collapse: collapse; }
.receipt-frame th, .receipt-frame td { text-align: left; padding: 2px 0; }
.receipt-frame .ralign { text-align: right; }
.receipt-frame .dashed { border-top: 1px dashed #000; margin: 10px 0; }

@media print {
  @page { margin: 0; }
  body { background: #fff !important; }
  body * { visibility: hidden; }
  #receipt, #receipt * { visibility: visible; }
  #receipt {
    position: absolute; left: 0; top: 0;
    width: 72mm; max-width: 72mm;
    padding: 8mm 4mm !important;
    font-size: 0.75rem !important;
    background: #fff !important;
    color: #000 !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
  .no-print { display: none !important; }
}

/* Notifications */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 100;
  background: var(--bg-2); border-radius: 20px; padding: 18px 24px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; min-width: 260px;
  animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-icon { width: 44px; height: 44px; border-radius: 14px; background: var(--success); color: #fff; display: grid; place-items: center; font-size: 1.3rem; }

/* Utility */
.flex { display: flex; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-xl { font-size: 1.2rem; }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }

input, select {
  width: 100%; height: 48px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); padding: 0 16px; font-size: 1rem; font-family: inherit;
}

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

/* Cashier side nav */
.cashier-layout { display: flex; flex: 1; overflow: hidden; }
.cashier-sidebar {
  width: 260px; padding: 24px; background: #071529; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}
.cashier-sidebar a {
  padding: 12px 16px; border-radius: 12px; color: var(--text-2); text-decoration: none;
  font-weight: 600; font-size: 0.95rem; transition: all 0.2s;
}
.cashier-sidebar a:hover, .cashier-sidebar a.active { background: rgba(249,115,22,0.12); color: var(--text); }
.cashier-main { flex: 1; overflow-y: auto; padding: 24px; }
.cashier-section { margin-bottom: 36px; }
.cashier-section h2 { margin: 0 0 18px; }
