:root {
  color-scheme: dark;
  --bg: #171312;
  --panel: #241d1b;
  --panel-2: #302622;
  --line: #4a3a33;
  --text: #f4ece2;
  --muted: #b9a99a;
  --accent: #d2a24b;
  --accent-2: #7fb18f;
  --danger: #d86d5a;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(110deg, rgba(210, 162, 75, 0.08), transparent 34%),
    radial-gradient(circle at top right, rgba(127, 177, 143, 0.12), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar,
.person-strip,
.workbench,
.panel-header,
.bill-footer,
.menu-tools {
  display: flex;
  gap: 16px;
}

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

.view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.view-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: var(--panel-2);
}

.view-tab.is-active {
  border-color: transparent;
  background: var(--accent);
  color: #201510;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-family: Arial, sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
}

h1 {
  font-size: clamp(2rem, 6vw, 4.4rem);
}

h2 {
  font-size: 1.75rem;
}

.grand-total,
.bill-total {
  display: grid;
  gap: 4px;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(36, 29, 27, 0.82);
  padding: 12px 16px;
  box-shadow: 0 14px 36px var(--shadow);
}

.grand-total span,
.bill-total span {
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 0.82rem;
}

.grand-total strong,
.bill-total strong {
  color: var(--accent);
  font-size: 1.65rem;
}

.sync-status {
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 0.78rem;
}

.sync-status[data-mode="shared"] {
  color: var(--accent-2);
}

.person-strip {
  position: sticky;
  top: 0;
  z-index: 2;
  align-items: center;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(36, 29, 27, 0.94);
  padding: 10px;
  backdrop-filter: blur(10px);
}

.person-tabs,
.category-tabs,
.subcategory-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.person-tabs {
  flex: 1;
}

.person-tab,
.category-tab,
.subcategory-tab,
.ghost-button,
.primary-button,
.small-button,
.icon-button,
.person-form button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
}

.category-tab,
.subcategory-tab {
  white-space: nowrap;
  padding: 0 14px;
}

.subcategory-tabs {
  margin: -4px 0 14px;
}

.manual-item-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(110px, 150px) minmax(130px, 180px);
  gap: 10px;
  margin-bottom: 14px;
  border: 1px solid rgba(74, 58, 51, 0.65);
  border-radius: 8px;
  padding: 10px;
  background: rgba(24, 18, 16, 0.45);
}

.subcategory-tab {
  min-height: 36px;
  border-color: rgba(74, 58, 51, 0.75);
  color: var(--muted);
  background: #181210;
}

.person-tab {
  display: grid;
  grid-template-columns: 1fr 34px;
  align-items: center;
  min-width: max-content;
  overflow: hidden;
  padding: 0;
}

.person-tab.is-dragging {
  opacity: 0.45;
}

.person-tab.is-drop-target {
  border-color: var(--accent-2);
}

.person-select,
.person-remove {
  min-height: 40px;
  border: 0;
  color: inherit;
  background: transparent;
}

.person-select {
  padding: 0 8px 0 14px;
  white-space: nowrap;
}

.person-remove {
  width: 34px;
  color: var(--muted);
  font-size: 1.1rem;
}

.person-remove:hover {
  color: #ffd6cd;
  background: rgba(216, 109, 90, 0.16);
}

.person-tab.is-active,
.category-tab.is-active,
.subcategory-tab.is-active,
.primary-button {
  border-color: transparent;
  background: var(--accent);
  color: #201510;
  font-weight: 700;
}

.person-form {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 44px;
  gap: 8px;
}

input,
textarea {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #181210;
  color: var(--text);
  padding: 0 12px;
}

textarea {
  min-height: 78px;
  resize: vertical;
  padding: 10px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
}

.workbench {
  align-items: flex-start;
}

.bill-panel,
.menu-panel,
.paid-view,
.orders-view,
.rooms-view {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(36, 29, 27, 0.9);
  box-shadow: 0 18px 42px var(--shadow);
}

.paid-view,
.orders-view,
.rooms-view {
  padding: 18px;
}

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

.paid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.room-counter {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.room-counter div {
  min-width: 88px;
  border: 1px solid rgba(74, 58, 51, 0.65);
  border-radius: 8px;
  padding: 8px 12px;
  background: rgba(24, 18, 16, 0.7);
}

.room-counter span {
  display: block;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 0.8rem;
}

.room-counter strong {
  color: var(--accent-2);
  font-size: 1.2rem;
}

.room-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(150px, 220px) minmax(150px, 210px);
  gap: 10px;
  margin-bottom: 14px;
}

.rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
}

.room-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #302622, #221a18);
  padding: 14px;
}

.room-card.is-occupied {
  border-color: rgba(127, 177, 143, 0.45);
}

.room-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(74, 58, 51, 0.65);
  padding-bottom: 10px;
}

.room-card-header h3 {
  margin: 0;
}

.room-card-header small,
.room-meta span {
  color: var(--muted);
  font-family: Arial, sans-serif;
}

.room-card-header > strong {
  color: var(--accent);
}

.room-status {
  display: inline-grid;
  min-height: 28px;
  align-items: center;
  border-radius: 8px;
  padding: 0 9px;
  font-family: Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
}

.room-status.is-free {
  color: #dff6e6;
  background: rgba(127, 177, 143, 0.18);
}

.room-status.is-occupied {
  color: #201510;
  background: var(--accent);
}

.room-book-form,
.room-meta {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.room-book-form {
  grid-template-columns: 1fr 92px 130px;
}

.room-book-form textarea,
.room-book-form button {
  grid-column: 1 / -1;
}

.room-meta {
  grid-template-columns: repeat(3, 1fr);
}

.room-meta div {
  border: 1px solid rgba(74, 58, 51, 0.65);
  border-radius: 8px;
  padding: 9px;
  background: rgba(24, 18, 16, 0.45);
}

.room-meta span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.78rem;
}

.room-meta strong {
  color: var(--accent-2);
}

.room-note-field {
  margin: 12px 0;
}

.paid-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #302622, #221a18);
  padding: 14px;
}

.orders-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.orders-board > section {
  min-width: 0;
}

.orders-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  padding-bottom: 10px;
}

.orders-column-header h3 {
  margin: 0;
  font-size: 1.3rem;
}

.orders-column-header strong {
  display: grid;
  min-width: 34px;
  min-height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #201510;
}

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

.order-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #302622, #221a18);
  padding: 14px;
}

.order-card ul {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.order-card li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-family: Arial, sans-serif;
}

.order-card label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.order-card input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent-2);
}

.order-item.is-checked span {
  color: var(--accent-2);
  text-decoration: line-through;
}

.order-note {
  border: 1px solid rgba(127, 177, 143, 0.35);
  border-radius: 8px;
  margin: 12px 0 0;
  padding: 10px;
  color: var(--text);
  background: rgba(127, 177, 143, 0.08);
  font-family: Arial, sans-serif;
}

.order-deposit-panel {
  border-top: 1px solid rgba(74, 58, 51, 0.65);
  margin-top: 12px;
  padding-top: 12px;
}

.order-deposit-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: Arial, sans-serif;
}

.order-deposit-total strong {
  color: var(--accent-2);
}

.order-deposit-form {
  margin-bottom: 10px;
}

.order-card li strong {
  color: var(--accent);
}

.order-title-line {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.order-title-line h3 {
  margin: 0;
}

.order-title-line .small-button {
  min-height: 34px;
}

.paid-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(74, 58, 51, 0.65);
  padding-bottom: 10px;
}

.paid-card h3 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.paid-card small,
.paid-card li {
  color: var(--muted);
  font-family: Arial, sans-serif;
}

.paid-card ul {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.paid-card li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.paid-card li strong,
.paid-card-header > strong {
  color: var(--accent);
}

.paid-delete,
.paid-reopen {
  min-height: 38px;
}

.paid-card-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.paid-rest {
  border-top: 1px solid rgba(74, 58, 51, 0.65);
  padding-top: 8px;
}

.bill-panel {
  position: sticky;
  top: 82px;
  display: flex;
  flex: 0 0 390px;
  flex-direction: column;
  max-height: calc(100vh - 104px);
}

.panel-header {
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.small-button {
  padding: 0 12px;
  color: var(--text);
  background: var(--panel-2);
}

.icon-button {
  width: 42px;
  font-size: 1.55rem;
}

.danger {
  color: #ffd6cd;
  border-color: rgba(216, 109, 90, 0.45);
  background: rgba(216, 109, 90, 0.16);
}

.bill-items {
  min-height: 260px;
  overflow: auto;
  padding: 10px;
}

.deposit-panel {
  border-top: 1px solid var(--line);
  padding: 12px;
}

.order-note-field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.order-note-field span {
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 0.82rem;
}

.order-card-note {
  margin: 12px 0 0;
}

.deposit-form {
  display: grid;
  grid-template-columns: minmax(88px, 0.8fr) minmax(110px, 1fr) 42px;
  gap: 8px;
  margin-bottom: 10px;
}

.deposit-form button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
}

.deposit-list {
  display: grid;
  gap: 6px;
}

.deposit-empty {
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 0.86rem;
}

.deposit-row {
  display: grid;
  grid-template-columns: 1fr 32px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(74, 58, 51, 0.65);
  border-radius: 8px;
  padding: 8px;
}

.deposit-row strong {
  color: var(--accent-2);
}

.deposit-row small {
  display: block;
  color: var(--muted);
  font-family: Arial, sans-serif;
}

.deposit-row button {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(216, 109, 90, 0.45);
  border-radius: 8px;
  color: #ffd6cd;
  background: rgba(216, 109, 90, 0.16);
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: var(--muted);
  text-align: center;
  font-family: Arial, sans-serif;
}

.bill-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid rgba(74, 58, 51, 0.65);
  padding: 10px 6px;
}

.bill-row strong {
  display: block;
}

.bill-row small {
  color: var(--muted);
  font-family: Arial, sans-serif;
}

.quantity-controls {
  display: grid;
  grid-template-columns: 34px 58px 34px;
  align-items: center;
  text-align: center;
}

.quantity-controls button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #181210;
  color: var(--text);
}

.quantity-controls input {
  width: 58px;
  min-height: 34px;
  padding: 0 4px;
  text-align: center;
}

.bill-footer {
  margin-top: auto;
  flex-direction: column;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.bill-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.bill-summary div {
  border: 1px solid rgba(74, 58, 51, 0.65);
  border-radius: 8px;
  padding: 10px;
}

.bill-summary span {
  display: block;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.bill-summary strong {
  color: var(--accent-2);
}

.bill-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wide-action {
  grid-column: 1 / -1;
}

.ghost-button,
.primary-button {
  width: 100%;
  padding: 0 14px;
}

.menu-panel {
  flex: 1;
  min-width: 0;
  padding: 14px;
}

.menu-tools {
  align-items: center;
  margin-bottom: 14px;
}

.search-wrap {
  flex: 0 0 240px;
}

.category-tabs {
  flex: 1;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.menu-item {
  display: grid;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #302622, #221a18);
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.menu-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.menu-item strong {
  align-self: end;
  min-height: 42px;
  font-size: 1.05rem;
}

.menu-item span {
  align-self: end;
  color: var(--accent-2);
  font-family: Arial, sans-serif;
  font-weight: 700;
}

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

  .topbar,
  .workbench,
  .menu-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .person-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .bill-panel {
    position: static;
    flex-basis: auto;
    max-height: none;
  }

  .search-wrap {
    flex-basis: auto;
  }

  .menu-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .deposit-form,
  .manual-item-form,
  .paid-card-actions,
  .bill-summary,
  .orders-board,
  .room-form,
  .room-book-form,
  .room-meta {
    grid-template-columns: 1fr;
  }

  .room-book-form textarea,
  .room-book-form button {
    grid-column: auto;
  }
}
