:root {
  --pp-sidebar-bg: #083014;
  --pp-sidebar-active: #086018;
  --pp-sidebar-text: #FFFFFF;
  --pp-sidebar-muted: #A7C4B0;
  --pp-primary: #106C2C;
  --pp-primary-soft: #E8F3EA;
  --pp-accent: #EC6000;
  --pp-accent-soft: #FFF1E6;
  --pp-danger: #B41400;
  --pp-bg: #F5F5F5;
  --pp-surface: #FFFFFF;
  --pp-border: #D0D0D0;
  --pp-text: #041828;
  --pp-text-muted: #6B7280;
  --pp-chart-1: #106C2C;
  --pp-chart-2: #EC6000;
  --pp-chart-3: #2F9D21;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--pp-bg);
  color: var(--pp-text);
}

a { color: var(--pp-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #083014 0%, #106C2C 45%, #F5F5F5 45%);
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--pp-surface);
  border: 1px solid var(--pp-border);
  border-radius: 16px;
  padding: 32px;
}

.brand {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 4px;
}
.brand .pag { color: var(--pp-chart-3); }
.brand-dark .pedi { color: var(--pp-text); }
.brand-dark .pag { color: var(--pp-chart-3); }
.tagline { color: var(--pp-text-muted); margin: 0 0 24px; font-size: 14px; }

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

.sidebar {
  width: 260px;
  background: var(--pp-sidebar-bg);
  color: var(--pp-sidebar-text);
  padding: 24px 16px;
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: width 0.2s ease, padding 0.2s ease;
}
body.sidebar-collapsed .sidebar {
  width: 0;
  padding: 24px 0;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--pp-border);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  color: var(--pp-text);
  cursor: pointer;
}
.sidebar-toggle:hover { background: var(--pp-surface); }

.sidebar .brand { color: #fff; font-size: 22px; }
.sidebar .brand .pag { color: #7CFF7A; }
.sidebar nav { margin-top: 28px; display: grid; gap: 4px; }
.sidebar a {
  color: var(--pp-sidebar-muted);
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
}
.sidebar a:hover,
.sidebar a.active {
  background: var(--pp-sidebar-active);
  color: var(--pp-sidebar-text);
  text-decoration: none;
}

.sidebar-group { border-radius: 10px; }
.sidebar-group summary {
  color: var(--pp-sidebar-muted);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-group summary::-webkit-details-marker { display: none; }
.sidebar-group summary::after {
  content: '›';
  transform: rotate(90deg);
  transition: transform 0.15s ease;
}
.sidebar-group[open] summary::after { transform: rotate(-90deg); }
.sidebar-group summary:hover,
.sidebar-group summary.active {
  background: var(--pp-sidebar-active);
  color: var(--pp-sidebar-text);
}
.sidebar-submenu { display: grid; gap: 2px; padding: 4px 0 4px 14px; }
.sidebar-submenu a { font-size: 13px; }

.content { flex: 1; padding: 28px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.topbar h1 { margin: 0; font-size: 24px; }
.muted { color: var(--pp-text-muted); font-size: 13px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--pp-surface);
  border: 1px solid var(--pp-border);
  border-radius: 14px;
  padding: 16px;
}
.card .label { color: var(--pp-text-muted); font-size: 13px; }
.card .value { font-size: 28px; font-weight: 700; margin-top: 8px; }
.card .accent { color: var(--pp-accent); }

.panel {
  background: var(--pp-surface);
  border: 1px solid var(--pp-border);
  border-radius: 14px;
  padding: 16px;
  overflow: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--pp-border); }
th { color: var(--pp-text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.btn {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.btn-primary { background: var(--pp-primary); color: #fff; }
.btn-accent { background: var(--pp-accent); color: #fff; }
.btn-danger { background: var(--pp-danger); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--pp-border); color: var(--pp-text); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

.form-grid { display: grid; gap: 14px; max-width: 640px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--pp-text-muted); }
input, select, textarea {
  border: 1px solid var(--pp-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--pp-text);
  background: #fff;
}
.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-error { background: #FDECEC; color: var(--pp-danger); }
.alert-success { background: var(--pp-primary-soft); color: var(--pp-primary); }
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--pp-primary-soft);
  color: var(--pp-primary);
  font-weight: 600;
}
.badge-offline { background: none; color: #000; }
.badge-prep-pending { background: var(--pp-accent-soft); color: var(--pp-accent); }
.badge-prep-preparing { background: var(--pp-primary-soft); color: var(--pp-primary); }
.badge-prep-ready { background: var(--pp-primary-soft); color: var(--pp-primary); }
.badge-cancelled { background: none; color: var(--pp-text); text-decoration: line-through; }
.badge-danger { background: #FDECEC; color: var(--pp-danger); }

.order-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.order-card {
  background: var(--pp-surface);
  border: 1px solid var(--pp-border);
  border-left: 4px solid var(--pp-border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.order-card--pending { border-left-color: var(--pp-accent); }
.order-card--preparing { border-left-color: var(--pp-primary); }
.order-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.order-card-company { font-weight: 700; font-size: 15px; }
.order-card-dish { color: var(--pp-text-muted); font-size: 13px; margin-top: -8px; }
.order-card-stats { display: flex; gap: 24px; }
.order-card-stat { display: flex; flex-direction: column; }
.order-card-stat-value { font-size: 22px; font-weight: 700; }
.order-card-stat-label { color: var(--pp-text-muted); font-size: 12px; text-transform: uppercase; }
.order-card .actions { margin-top: auto; }
.order-card .actions form { display: contents; }

.delivery-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.delivery-card {
  background: var(--pp-surface);
  border: 1px solid var(--pp-border);
  border-left: 4px solid var(--pp-border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.delivery-card--searching { border-left-color: var(--pp-accent); }
.delivery-card--progress { border-left-color: var(--pp-primary); }
.delivery-card--delivered { border-left-color: var(--pp-primary); }
.delivery-card--cancelled { border-left-color: var(--pp-danger); }
.delivery-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.delivery-card-id { font-weight: 700; font-size: 15px; }
.delivery-card-list { margin-top: -8px; }
.delivery-card-info { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.delivery-card-info-label { color: var(--pp-text-muted); margin-right: 4px; }
.delivery-card-stats { display: flex; gap: 24px; }
.delivery-card-stat { display: flex; flex-direction: column; }
.delivery-card-stat-value { font-size: 18px; font-weight: 700; }
.delivery-card-stat-label { color: var(--pp-text-muted); font-size: 12px; text-transform: uppercase; }
.delivery-card .actions { margin-top: auto; }
.delivery-card .actions form { display: contents; }

.list-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.list-card {
  background: var(--pp-surface);
  border: 1px solid var(--pp-border);
  border-left: 4px solid var(--pp-border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.list-card--open { border-left-color: var(--pp-accent); }
.list-card--progress { border-left-color: var(--pp-primary); }
.list-card--failed { border-left-color: var(--pp-danger); }
.list-card--cancelled { border-left-color: var(--pp-border); }
.list-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.list-card-id { font-weight: 700; font-size: 15px; }
.list-card-dish { color: var(--pp-text-muted); font-size: 13px; margin-top: -8px; }
.list-card-stats { display: flex; gap: 24px; }
.list-card-stat { display: flex; flex-direction: column; }
.list-card-stat-value { font-size: 18px; font-weight: 700; }
.list-card-stat-label { color: var(--pp-text-muted); font-size: 12px; text-transform: uppercase; }
.list-card .actions { margin-top: auto; }

/* Delivery timeline history: sits below the map now, so it's deliberately
   toned down (smaller text, tighter rows) instead of competing with it for
   attention like the old full-size table did. */
.timeline-history { margin-top: 16px; }
.timeline-history-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--pp-text-muted);
}
.timeline-history table { font-size: 12px; }
.timeline-history th, .timeline-history td { padding: 6px 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* Slot closed with no purchase: struck through like a dead line item —
   the status text stays plain row-color text (no .badge highlight) so it
   doesn't draw the eye, matching everything else in the row. */
tr.closed-no-purchase td { text-decoration: line-through; }

.alert-bell { position: relative; }
.alert-bell-toggle {
  position: relative;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.alert-bell-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--pp-danger);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  line-height: 1.4;
}
.alert-bell-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--pp-surface);
  border: 1px solid var(--pp-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 100;
}
.alert-bell-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--pp-border);
  font-size: 13px;
}
.alert-bell-panel-header button {
  background: none;
  border: none;
  color: var(--pp-primary);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.alert-bell-list { list-style: none; margin: 0; padding: 0; }
.alert-bell-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--pp-border);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.alert-bell-item:last-child { border-bottom: none; }
.alert-bell-item button {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--pp-border);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--pp-text-muted);
}

.alert-toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}
.alert-toast {
  background: var(--pp-accent-soft);
  color: var(--pp-text);
  border-left: 4px solid var(--pp-accent);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  opacity: 1;
  transition: opacity 0.4s ease;
}
.alert-toast-hide { opacity: 0; }
