:root {
  color-scheme: dark;
  --bg: #100f0e;
  --panel: #171514;
  --panel-2: #211d1a;
  --line: #3a312b;
  --text: #fff8f1;
  --muted: #b8aaa0;
  --red: #ef3f2f;
  --red-soft: rgba(239, 63, 47, 0.15);
  --amber: #f5b642;
  --green: #4fd27b;
  --blue: #58a6ff;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 240px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 2px solid var(--red);
  border-radius: 8px;
  background: #241411;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-mark.large {
  width: 72px;
  height: 72px;
  font-size: 28px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 27px;
  font-weight: 850;
}

h2 {
  font-size: 18px;
  font-weight: 800;
}

h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

.brand p,
.panel-heading span,
.kpi span,
.muted {
  color: var(--muted);
}

.filters {
  display: flex;
  align-items: end;
  gap: 10px;
}

.filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.filters input,
.filters select,
.login-form input {
  height: 38px;
  min-width: 142px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12100f;
  color: var(--text);
  padding: 0 10px;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  padding: 0 13px;
  font-weight: 780;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

button.danger {
  background: rgba(239, 63, 47, 0.1);
  border-color: rgba(239, 63, 47, 0.42);
  color: #ffb4aa;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi,
.orders-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 98px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.kpi strong {
  font-size: 31px;
  line-height: 1;
}

.orders-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

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

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

td {
  font-size: 14px;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: rgba(255, 255, 255, 0.035);
}

.client-cell,
.order-lines {
  display: grid;
  gap: 4px;
}

.client-cell span,
.order-lines span {
  color: var(--muted);
  font-size: 12px;
}

.actions,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.actions button {
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 3px 10px;
  color: var(--muted);
  background: var(--panel-2);
  font-weight: 760;
  white-space: nowrap;
}

.badge.sent-to-kitchen,
.badge.preparing,
.modal-kicker.sent-to-kitchen,
.modal-kicker.preparing {
  color: #ffd27d;
  border-color: rgba(245, 182, 66, 0.42);
  background: rgba(245, 182, 66, 0.12);
}

.badge.ready,
.modal-kicker.ready {
  color: #a6f0bc;
  border-color: rgba(79, 210, 123, 0.42);
  background: rgba(79, 210, 123, 0.12);
}

.badge.out-for-delivery,
.modal-kicker.out-for-delivery {
  color: #acd2ff;
  border-color: rgba(88, 166, 255, 0.42);
  background: rgba(88, 166, 255, 0.12);
}

.badge.delivered,
.modal-kicker.delivered {
  color: #c6f6d5;
}

.badge.cancelled,
.modal-kicker.cancelled {
  color: #ffb4aa;
  border-color: rgba(239, 63, 47, 0.42);
  background: rgba(239, 63, 47, 0.12);
}

.empty-state {
  height: 120px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.66);
  z-index: 10;
}

.modal-backdrop[hidden] {
  display: none;
}

.order-modal {
  width: min(820px, 100%);
  max-height: min(820px, 92vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151211;
  box-shadow: var(--shadow);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #151211;
}

.modal-kicker {
  display: inline-flex;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 22px;
}

.modal-body {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid article,
.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

.detail-grid article {
  display: grid;
  gap: 5px;
}

.detail-grid span,
.detail-list dt,
.timeline span {
  color: var(--muted);
  font-size: 12px;
}

.pizza-list,
.timeline {
  margin: 0;
  padding-left: 20px;
}

.pizza-list {
  display: grid;
  gap: 7px;
}

.detail-list {
  margin: 0;
  display: grid;
  gap: 8px;
}

.detail-list div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
}

.detail-list dd {
  margin: 0;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline p {
  margin-top: 3px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100% - 32px));
}

.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
  display: grid;
  gap: 18px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-form input {
  width: 100%;
}

.login-error {
  min-height: 20px;
  color: #ffb4aa;
  font-size: 13px;
}

@media (max-width: 980px) {
  .topbar,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 14px;
  }

  .filters,
  .kpis,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .filters input,
  .filters select {
    width: 100%;
  }

  .detail-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
