:root {
  --bg: #f3ece2;
  --panel: rgba(255, 251, 245, 0.92);
  --panel-strong: #fff8ee;
  --line: #ddcfbc;
  --text: #2d241a;
  --muted: #6b5a49;
  --accent: #a54a2a;
  --accent-dark: #7a341c;
  --green: #4b7d55;
  --yellow: #c58e1d;
  --shadow: 0 18px 40px rgba(64, 41, 17, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(197, 142, 29, 0.18), transparent 26%),
    radial-gradient(circle at top right, rgba(165, 74, 42, 0.18), transparent 22%),
    linear-gradient(180deg, #f8f2e8 0%, var(--bg) 100%);
}

button,
input,
select,
a {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.topbar,
.panel,
.sub-panel {
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.topbar {
  background: linear-gradient(135deg, rgba(255, 249, 239, 0.96), rgba(242, 229, 209, 0.92));
  border-radius: calc(var(--radius) + 8px);
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

.hero-copy,
.muted {
  color: var(--muted);
}

.nav-links,
.button-row,
.summary-strip,
.compact-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-buttons {
  margin-top: 0.5em;
}

.nav-link,
button {
  border: 0;
  border-radius: 18px;
  padding: 14px 18px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background-color 120ms ease;
}

.nav-link:hover,
button:hover {
  transform: translateY(-1px);
}

.nav-link {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.secondary-btn {
  background: #eadbc8;
  color: var(--text);
}

.ghost-btn {
  background: rgba(107, 90, 73, 0.12);
  color: var(--text);
}

.category-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  background: transparent;
  color: var(--text);
  border-radius: 0;
}

.category-toggle-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(107, 90, 73, 0.12);
  font-weight: 700;
}

.danger-btn {
  background: rgba(165, 74, 42, 0.14);
  color: var(--accent-dark);
}

button:disabled,
.nav-link:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.page-grid,
.table-layout,
.menu-layout,
.stack-list,
.button-stack,
.totals-box,
.table-grid,
.menu-button-grid {
  display: grid;
  gap: 18px;
}

.page-grid {
  margin-top: 22px;
}

.menu-layout {
  grid-template-columns: 0.8fr 1.2fr;
}

.table-layout {
  margin-top: 22px;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  align-items: start;
}

.panel,
.sub-panel {
  background: var(--panel);
  border-radius: var(--radius);
}

.panel {
  padding: 22px;
}

.sub-panel {
  background: var(--panel-strong);
  padding: 18px;
}

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

.form-grid,
.menu-add-form,
.inline-form,
.triple-grid {
  display: grid;
  gap: 12px;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.menu-add-form {
  grid-template-columns: minmax(160px, 0.85fr) minmax(200px, 1.2fr) minmax(120px, 0.55fr) auto;
  align-items: end;
}

.inline-form,
.triple-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

input,
select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  padding: 14px 16px;
}

.form-message {
  min-height: 1.2em;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.form-message.error,
.save-state.error {
  color: var(--accent-dark);
}

.form-message.success,
.save-state {
  color: var(--green);
}

.summary-strip {
  margin-top: 16px;
}

.summary-chip,
.badge {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(221, 207, 188, 0.9);
}

.large-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.menu-button-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.menu-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.filter-group {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border-radius: 18px;
  background: rgba(107, 90, 73, 0.1);
}

.filter-btn {
  padding: 10px 14px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
}

.filter-btn.active {
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: 0 8px 18px rgba(64, 41, 17, 0.08);
}

.hidden-panel {
  display: none !important;
}

.table-tile,
.menu-item-btn {
  width: 100%;
  text-align: left;
  display: grid;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(221, 207, 188, 0.9);
}

.table-tile.available {
  border-left: 8px solid var(--green);
}

.table-tile {
  min-height: 138px;
}

.menu-item-btn {
  padding: 12px;
  align-content: space-evenly;
  border-radius: 20px;
  min-width: 0;
}

.menu-item-btn .tile-title,
.menu-item-btn strong {
  min-width: 0;
}

.menu-item-btn .tile-title {
  overflow-wrap: anywhere;
}

.menu-item-btn strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-tile.occupied {
  border-left: 8px solid var(--yellow);
}

.table-tile.completed {
  border-left: 8px solid var(--accent);
}

.tile-title {
  font-size: 1.08rem;
  font-weight: 700;
}

.tile-status {
  color: var(--muted);
}

.tile-meta {
  color: var(--accent-dark);
  font-size: 0.92rem;
}

.tile-total {
  font-size: 1.08rem;
}

.table-tile.selected {
  box-shadow: inset 0 0 0 3px rgba(165, 74, 42, 0.35);
  background: #fff4e8;
}

.list-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(221, 207, 188, 0.9);
}

.menu-category-panel {
  padding: 14px;
}

.menu-category-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.menu-category-header .category-toggle-btn {
  padding: 6px 0;
}

.category-count {
  display: inline-block;
  margin-left: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.menu-row-list {
  display: grid;
  gap: 8px;
}

.menu-row {
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(221, 207, 188, 0.9);
}

.menu-row.inactive {
  opacity: 0.62;
  background: rgba(255, 255, 255, 0.46);
}

.menu-row-form {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(180px, 1.25fr) minmax(100px, 0.45fr) auto minmax(80px, auto) auto auto;
  gap: 8px;
  align-items: end;
}

.row-field {
  gap: 4px;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.row-field input {
  padding: 10px 12px;
  border-radius: 12px;
}

.active-check {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  color: var(--text);
  font-size: 0.92rem;
  white-space: nowrap;
}

.active-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.save-state {
  min-width: 80px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  font-size: 0.86rem;
}

.compact-action {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 14px;
  white-space: nowrap;
}

.partial-card-btn {
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.partial-card-btn:hover {
  transform: translateY(-1px);
}

.partial-card-btn.selected {
  background: #fff0e0;
  box-shadow: inset 0 0 0 3px rgba(165, 74, 42, 0.3);
}

.order-line-card,
.order-line-top {
  display: grid;
  gap: 14px;
}

.order-line-top {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.order-line-info {
  min-width: 0;
}

.order-line-info .card-title {
  overflow-wrap: anywhere;
}

.order-line-price {
  min-width: 110px;
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

.bill-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.total-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.partial-payment-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.partial-payment-heading {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.partial-payment-btn {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(221, 207, 188, 0.9);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  text-align: left;
}

.partial-payment-btn strong,
.partial-payment-btn small {
  white-space: nowrap;
}

.partial-payment-btn small {
  color: var(--muted);
}

.empty-state {
  padding: 28px 20px;
  border-radius: 18px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(45, 36, 26, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-backdrop.hidden-panel {
  display: none;
}

.modal-card {
  width: min(460px, 100%);
  background: var(--panel-strong);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(45, 36, 26, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.modal-details {
  margin: 14px 0;
}

.modal-detail-list {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(221, 207, 188, 0.9);
}

.modal-detail-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 980px) {
  .table-layout,
  .menu-layout {
    grid-template-columns: 1fr;
  }

  .menu-add-form,
  .menu-row-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .active-check,
  .save-state {
    min-height: 0;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 1440px);
    padding-top: 10px;
  }

  .topbar,
  .panel-header,
  .order-line-top,
  .menu-toolbar,
  .menu-category-header,
  .menu-add-form,
  .menu-row-form {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar {
    padding: 18px;
  }

  .table-tile,
  .menu-item-btn {
    min-height: 120px;
  }

  .order-line-top {
    grid-template-columns: 1fr;
  }

  .order-line-price {
    text-align: left;
    min-width: 0;
  }

  .filter-group {
    width: 100%;
  }

  .filter-btn {
    flex: 1;
  }

  .partial-payment-btn {
    grid-template-columns: 1fr;
  }

  .save-state {
    min-height: 0;
  }
}
