:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --navy: #0f172a;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --violet: #7c3aed;
  --blue: #2563eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px -18px rgba(15, 23, 42, 0.35);
  font-family: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; }

/* ---------------------------------- login --------------------------------- */

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

.login__hero {
  position: relative;
  overflow: hidden;
  background: radial-gradient(1200px 600px at 10% 0%, #1e293b 0%, #0f172a 55%, #020617 100%);
  color: #e2e8f0;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login__hero::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  right: -160px;
  bottom: -200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.35), transparent 65%);
}

.login__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
  z-index: 1;
}

.login__brand span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #fb923c);
  font-size: 22px;
}

.login__title {
  z-index: 1;
  max-width: 480px;
}

.login__title h1 {
  font-size: 42px;
  line-height: 1.12;
  margin: 0 0 18px;
  font-weight: 800;
  letter-spacing: -0.8px;
}

.login__title h1 em {
  font-style: normal;
  color: #fdba74;
}

.login__title p {
  color: #94a3b8;
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
}

.login__features {
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.login__features li {
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: #cbd5e1;
}

.login__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.login-card {
  width: min(400px, 100%);
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.4px;
}

.login-card > p {
  margin: 0 0 28px;
  color: var(--muted);
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: #334155;
}

.field small { color: var(--muted); font-weight: 400; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.14);
}

textarea { resize: vertical; min-height: 74px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover { filter: brightness(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary { background: linear-gradient(135deg, var(--accent), #fb923c); color: #fff; }
.btn--dark { background: var(--navy); color: #fff; }
.btn--ghost { border-color: var(--line); background: #fff; }
.btn--danger { background: #fee2e2; color: #b91c1c; }
.btn--success { background: #dcfce7; color: #15803d; }
.btn--sm { padding: 7px 11px; font-size: 12.5px; border-radius: 8px; }
.btn--block { width: 100%; padding: 12px; font-size: 15px; }

.login-hint {
  margin-top: 22px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
  background: #f8fafc;
}

.login-hint b { color: #334155; }

/* --------------------------------- layout --------------------------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 246px;
  flex: 0 0 246px;
  background: linear-gradient(180deg, #0f172a, #111c33);
  color: #cbd5e1;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.sidebar__brand span {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #fb923c);
  font-size: 18px;
}

.sidebar__label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: #64748b;
  padding: 14px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #cbd5e1;
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: rgba(148, 163, 184, 0.1); color: #fff; }
.nav-link.active { background: rgba(249, 115, 22, 0.16); color: #fdba74; }
.nav-link .count {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
}

.sidebar__foot { margin-top: auto; padding-top: 16px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 500;
}

.topbar h1 { font-size: 18px; margin: 0; letter-spacing: -0.3px; }
.topbar .spacer { flex: 1; }

.ws-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

.ws-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
}

.ws-dot.online::before { background: var(--green); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16); }

.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
}

.userbox small { display: block; color: var(--muted); font-size: 11.5px; }
.userbox b { font-size: 13px; }

.content { padding: 24px 28px 48px; max-width: 1500px; width: 100%; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.5px; }
.page-head p { margin: 0; color: var(--muted); }
.page-head .spacer { flex: 1; }

/* ---------------------------------- cards --------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat__label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.2px; }
.stat__value { font-size: 26px; font-weight: 800; letter-spacing: -0.8px; margin-top: 4px; }
.stat__hint { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.stat--accent { border-color: rgba(249, 115, 22, 0.35); background: linear-gradient(180deg, #fff7ed, #fff); }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.card__head h3 { margin: 0; font-size: 15px; letter-spacing: -0.2px; }
.card__head .spacer { flex: 1; }
.card__head small { color: var(--muted); }
.card__body { padding: 18px; }

.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
}
.empty .big { font-size: 30px; display: block; margin-bottom: 8px; }

/* --------------------------------- tables --------------------------------- */

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

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: none; }

td .sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
td .main { font-weight: 600; }
td.actions { white-space: nowrap; }
td.actions .btn { margin-right: 4px; }

.code { font-weight: 700; letter-spacing: 0.3px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge--pool { background: #e0e7ff; color: #3730a3; }
.badge--assigned { background: #fef3c7; color: #92400e; }
.badge--picked_up { background: #ede9fe; color: #5b21b6; }
.badge--delivered { background: #dcfce7; color: #166534; }
.badge--cancelled { background: #fee2e2; color: #991b1b; }
.badge--online { background: #dcfce7; color: #166534; }
.badge--offline { background: #f1f5f9; color: #64748b; }
.badge--break { background: #ffedd5; color: #9a3412; }

.count--alert { background: #f97316; color: #fff; }

.card--alert { border-color: rgba(249, 115, 22, 0.45); box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.08), var(--shadow); }

.break-stack { display: grid; gap: 10px; }

.break-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fffdf9;
}

.break-row > div:first-child { flex: 1; min-width: 200px; }
.break-row .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ----------------------------------- map ---------------------------------- */

.map { height: 380px; width: 100%; background: #e8edf5; }
.map--tall { height: 520px; }
.map--picker { height: 260px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.map .leaflet-popup-content { font-size: 13px; line-height: 1.55; }
.map .leaflet-popup-content b { color: var(--ink); }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

.coords {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  flex-wrap: wrap;
}

.coords b { color: #334155; }

/* ---------------------------------- forms --------------------------------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }

.fee-preview {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 12px 16px;
  margin: 4px 0 16px;
}

.fee-preview div { font-size: 12px; color: #9a3412; }
.fee-preview b { display: block; font-size: 18px; color: #7c2d12; margin-top: 2px; }

.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }
.search-results { margin-top: 8px; display: grid; gap: 6px; }

.search-result {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: #334155;
  line-height: 1.5;
}

.search-result:hover { border-color: var(--accent); background: #fff7ed; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* -------------------------------- restaurant ------------------------------ */

.restaurant-head {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.restaurant-head .name { font-size: 20px; font-weight: 800; letter-spacing: -0.4px; }
.restaurant-head .addr { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 13px; }
.switch input { display: none; }
.switch .track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background 0.15s;
}
.switch .track::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }

.restaurant-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
}

.order-list { display: grid; gap: 12px; }

.order-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
}

.order-card__top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.order-card__code { font-weight: 800; letter-spacing: 0.3px; }
.order-card__time { color: var(--muted); font-size: 12px; margin-left: auto; }
.order-card__row { color: #334155; font-size: 13px; line-height: 1.6; }
.order-card__row b { color: var(--ink); }
.order-card__foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.order-card__fee { font-weight: 800; color: var(--accent-dark); }

/* ---------------------------------- modal --------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
  animation: fade 0.15s ease;
}

.modal {
  background: #fff;
  border-radius: 16px;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 30px 80px -20px rgba(2, 6, 23, 0.5);
  animation: pop 0.16s ease;
}

.modal header {
  display: flex;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.modal header h3 { margin: 0; font-size: 17px; }
.modal header button {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 2px 6px;
}
.modal-body { padding: 22px; }
.modal .form-actions { margin-top: 20px; }
.modal .form-actions .btn { flex: 1; }

.pick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  margin-bottom: 8px;
}

.pick-row .who { flex: 1; min-width: 0; }
.pick-row .who b { display: block; font-size: 13.5px; }
.pick-row .who small { color: var(--muted); font-size: 11.5px; }

/* --------------------------------- toasts --------------------------------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 3000;
  max-width: min(380px, calc(100vw - 40px));
}

.toast {
  background: #fff;
  border-left: 4px solid var(--blue);
  border-radius: 10px;
  box-shadow: 0 12px 32px -12px rgba(15, 23, 42, 0.4);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  animation: slide 0.18s ease;
}

.toast--success { border-left-color: var(--green); }
.toast--error { border-left-color: var(--red); }
.toast--warn { border-left-color: var(--amber); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* -------------------------------- responsive ------------------------------ */

@media (max-width: 1080px) {
  .grid, .restaurant-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login__hero { padding: 32px; min-height: 260px; gap: 24px; }
  .login__title h1 { font-size: 30px; }
  .login__features { display: none; }
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px;
    gap: 4px;
  }
  .sidebar__brand { padding: 0 8px 0 2px; }
  .sidebar__label, .sidebar__foot { display: none; }
  .nav-link { padding: 8px 11px; }
  .nav-link .count { display: none; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { display: none; }
}
