﻿:root {
  color-scheme: dark;
  --bg: #0d121b;
  --ink: #e7edf7;
  --muted: #9ba6b7;
  --panel: #141b26;
  --line: #273245;
  --accent: #2cc18f;
  --accent-dark: #1da97a;
  --secondary: #5a7a8f;
  --secondary-dark: #465766;
  --danger: #db5142;
  --danger-dark: #c24033;
  --selected-bg: #1a2f2a;
  --selected-line: #2f8e72;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 15% 8%, #1b2f45 0%, transparent 40%),
    radial-gradient(circle at 85% 6%, #173029 0%, transparent 34%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: 200% 200%;
}

.app-shell {
  width: min(980px, 95vw);
  margin: 10px auto 10px;
  display: grid;
  gap: 0.65rem;
}

.hero,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.26);
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.closed-status {
  border: 2px solid var(--danger);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  background: rgba(219, 81, 66, 0.15);
  text-align: center;
}

.closed-status p {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
  font-size: 1rem;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.hero h1 {
  margin: 0;
  font-size: 1.25rem;
  white-space: nowrap;
}

.menu-updated {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.hero-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.hero-controls > button {
  flex: 1 1 calc(33.333% - 0.4rem);
  min-width: auto;
}

.restaurant-selector {
  flex: 1 1 calc(33.333% - 0.4rem);
  min-width: auto;
}

.restaurant-selector select {
  width: 100%;
}

.subtitle {
  margin: 0.2rem 0 0.65rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 9px;
  padding: 0.45rem 0.75rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  line-height: 1.1;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#reloadButton {
  background: var(--secondary);
}

#reloadButton:hover {
  background: var(--secondary-dark);
}

select {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.45rem 0.75rem;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  line-height: 1.1;
}

select:hover {
  border-color: var(--accent);
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(44, 193, 143, 0.2);
}

.ghost {
  background: #2a3346;
  color: #dae4f5;
}

.ghost:hover {
  background: #33405a;
}

.danger {
  background: var(--danger);
}

.danger:hover {
  background: var(--danger-dark);
}

.status {
  margin: 0.55rem 0 0;
  color: #bfd0ea;
  font-size: 0.85rem;
}

.status.warning {
  color: #ff9f8f;
}

.menu-updated {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.menu-updated.warning {
  color: #ff9f8f;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.02rem;
}

.menu-list {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.55rem;
}

.menu-list.loading {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
}

.menu-list.loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(44, 193, 143, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.menu-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #162030 0%, #121a28 100%);
  overflow: hidden;
}

.group-title {
  margin: 0;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  background: #1a2435;
  font-size: 0.88rem;
  color: #dbe7fb;
}

.group-items {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.food-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  background: #131b27;
  cursor: pointer;
}

.food-row:hover {
  background: #192336;
}

.food-row.selected,
.food-row.selected:hover {
  background: var(--selected-bg);
  box-shadow: inset 0 0 0 1px var(--selected-line);
}

.group-items .food-row:last-child {
  border-bottom-left-radius: 9px;
  border-bottom-right-radius: 9px;
  overflow: hidden;
}

.food-row.history-only {
  background: #2a241f;
}

.food-main {
  min-width: 0;
}

.food-name {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: break-word;
}

.food-meta {
  margin: 0.14rem 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.15;
}

.food-prices {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  justify-content: end;
  gap: 0.8rem;
  color: #d0d9e8;
  font-size: 0.68rem;
  white-space: nowrap;
}

.price-token {
  display: grid;
  grid-template-columns: 1ch 6.2ch;
  align-items: baseline;
  gap: 0.3rem;
}

.price-label {
  color: #8b99ae;
}

.price-amount {
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.food-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.info-button {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 700;
  background: #30405f;
  color: #e8eeff;
}

.info-button:hover {
  background: #3b4f74;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  color: var(--muted);
  font-size: 0.85rem;
  background: #111925;
}

.closed-message {
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 0.7rem;
  color: var(--danger);
  font-size: 0.9rem;
  background: rgba(219, 81, 66, 0.1);
  margin-bottom: 1rem;
  font-weight: 500;
}

.billing-dialog,
.info-dialog {
  border: 0;
  border-radius: 12px;
  padding: 0;
}

.billing-dialog {
  width: min(760px, 94vw);
}

.info-dialog {
  width: min(560px, 94vw);
}

.billing-dialog::backdrop {
  background: rgba(3, 6, 10, 0.7);
}

.info-dialog::backdrop {
  background: rgba(3, 6, 10, 0.68);
}

.billing-shell,
.info-shell {
  background: #141b26;
  padding: 0.8rem;
}

.billing-header,
.info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.billing-header h2,
.info-header h2 {
  margin: 0;
}

.pricing-label {
  display: block;
  margin: 0.55rem 0 0.25rem;
  font-size: 0.85rem;
}

#pricingMode {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem;
  background: #0f1521;
  color: var(--ink);
}

.billing-items {
  margin-top: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 320px;
  overflow: auto;
}

.bill-row {
  display: grid;
  grid-template-columns: 150px 1fr 84px;
  gap: 0.5rem;
  align-items: center;
  padding: 0.48rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

.bill-row:last-child {
  border-bottom: 0;
}

.bill-date {
  color: var(--muted);
  font-size: 0.74rem;
}

.bill-type {
  color: #8f9cb1;
  font-size: 0.78rem;
}

.bill-price {
  text-align: right;
  font-weight: 700;
  font-size: 0.84rem;
  color: #f0f5ff;
}

.billing-total {
  margin: 0.65rem 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.billing-actions {
  display: flex;
  justify-content: flex-end;
}

.info-header h2 {
  font-size: 1rem;
}

.info-content {
  margin: 0.6rem 0 0;
  color: #d5deec;
  font-size: 0.9rem;
  line-height: 1.32;
  white-space: pre-wrap;
}

@media (max-width: 740px) {
  .panel-header {
    align-items: flex-start;
  }

  .menu-updated {
    max-width: 55%;
    line-height: 1.2;
  }

  .hero-controls {
    flex-wrap: wrap;
    width: 100%;
    gap: 0.5rem;
  }

  .restaurant-selector {
    width: 100%;
    flex: none;
    min-width: unset;
    order: -1;
  }

  .restaurant-selector select {
    width: 100%;
  }

  .hero-controls > button {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: auto;
  }

  .food-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.32rem 0.48rem;
  }

  .food-main {
    grid-column: 1 / -1;
  }

  .food-prices {
    grid-column: 1 / 2;
    grid-row: 2;
    font-size: 0.67rem;
    justify-self: end;
    justify-content: end;
    grid-template-columns: repeat(3, max-content);
  }

  .food-tools {
    grid-column: 2 / 3;
    grid-row: 2;
    justify-self: end;
    align-self: center;
  }

  .billing-shell {
    padding: 0.65rem;
  }

  .billing-items {
    margin-top: 0.45rem;
    max-height: 58vh;
  }

  .bill-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "food price"
      "date price";
    gap: 0.14rem 0.5rem;
    padding: 0.38rem 0.52rem;
  }

  .bill-food {
    grid-area: food;
    min-width: 0;
    line-height: 1.2;
  }

  .bill-date {
    grid-area: date;
    font-size: 0.7rem;
    line-height: 1.15;
  }

  .bill-price {
    grid-area: price;
    text-align: right;
    white-space: nowrap;
    align-self: center;
    font-size: 0.8rem;
  }

  .bill-type {
    font-size: 0.72rem;
  }

  .billing-total {
    margin: 0.5rem 0;
    font-size: 0.9rem;
  }

  .billing-actions {
    justify-content: stretch;
  }

  .billing-actions .danger {
    width: 100%;
  }
}
