* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080b10;
  color: #f3f4f6;
}

body.kiosk {
  min-height: 100dvh;
  overflow-x: hidden;
  font-size: 16px;
}

.zoom {
  min-height: 100dvh;
  width: 100%;
}

.screen {
  min-height: 100dvh;
  width: 100%;
  background: #080b10;
  color: #f3f4f6;
  padding: clamp(12px, 3vw, 24px);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.page {
  padding: clamp(12px, 2.4vw, 28px);
}

.admin-page {
  padding: clamp(14px, 2.4vw, 28px);
}

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

.center-header {
  display: block;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(18px, 2.8vw, 28px);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.kiosk h1 {
  font-size: clamp(20px, 6vw, 34px);
}

.subtitle,
.sub {
  font-size: clamp(12px, 2.5vw, 15px);
  color: #a7b0bd;
  margin-top: 4px;
}

button {
  border: none;
  border-radius: 999px;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  background: #171d28;
  color: #f3f4f6;
  white-space: nowrap;
}

button.primary,
.submit-btn {
  background: #b91c1c;
  color: #fff;
}

button:active {
  transform: translateY(1px);
}

.tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: clamp(8px, 2.4vw, 14px);
  margin-top: clamp(10px, 3vw, 20px);
}

.zone-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: clamp(10px, 3vw, 18px);
}

.zone-tab {
  border: 1px solid #374151;
  background: #0d1118;
  min-height: 54px;
  font-size: clamp(14px, 3.4vw, 18px);
}

.zone-tab.active {
  background: #b91c1c;
  border-color: #b91c1c;
}

.table-btn {
  border-radius: 8px;
  min-height: clamp(58px, 13vw, 90px);
  padding: 10px 8px;
  font-size: clamp(17px, 4vw, 24px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .35);
}

.table-btn.special {
  grid-column: 1 / -1;
  background: #b91c1c;
}

#screen-order {
  display: none;
}

.login-screen {
  justify-content: center;
}

.login-form {
  width: min(100%, 420px);
  margin: 18px auto 0;
  display: grid;
  gap: 12px;
}

.order-header-top {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0 0 8px;
  background: #080b10;
  margin-bottom: 4px;
}

.current-table {
  font-size: clamp(22px, 6vw, 36px);
  font-weight: 900;
}

#order-form {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 8px;
  min-height: 0;
}

.field {
  width: 100%;
  margin-top: 0;
  min-width: 0;
}

label {
  display: block;
  font-size: clamp(14px, 3vw, 17px);
  margin-bottom: 4px;
  font-weight: 800;
}

.groups-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-bottom: 6px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: thin;
}

.group-btn {
  border: 1px solid #374151;
  min-height: 42px;
  padding: 8px 12px;
  font-size: 12px;
  background: #080b10;
  flex: 0 0 auto;
}

.group-btn.active {
  background: #b91c1c;
  border-color: #b91c1c;
}

.station-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.station-tab {
  border: 1px solid #374151;
  background: #080b10;
}

.station-tab.active {
  background: #b91c1c;
  border-color: #b91c1c;
}

.search-input {
  width: 100%;
  margin-bottom: 8px;
}

.items-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: min(52dvh, 520px);
  overflow-y: auto;
  padding-right: 2px;
}

.item-tile {
  border-radius: 8px;
  background: #0d1118;
  border: 1px solid #242b37;
  min-height: 62px;
  padding: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label controls"
    "meta controls";
  align-items: center;
  gap: 10px;
}

.item-label {
  grid-area: label;
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 800;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.item-meta {
  grid-area: meta;
  color: #a7b0bd;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.item-controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.item-count {
  min-width: 34px;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
}

.tile-btn {
  width: 46px;
  height: 46px;
  padding: 0;
  font-size: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #4b5563;
  background: #080b10;
}

.tile-btn.plus {
  background: #b91c1c;
  border-color: #b91c1c;
}

.note-input,
input[type="text"],
input[type="search"],
select {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #4b5563;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 16px;
  background: #080b10;
  color: #f9fafb;
}

.note-input {
  border-radius: 999px;
}

.actions-row,
.actions,
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.actions-row {
  justify-content: space-between;
  margin-top: 5px;
  align-items: flex-start;
}

.summary-text,
.info-text,
#status {
  font-size: 13px;
  color: #a7b0bd;
}

.summary-text {
  flex: 1 1 180px;
  line-height: 1.25;
  max-height: 48px;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

.submit-btn {
  width: 100%;
  min-height: 56px;
  margin-top: 0;
  padding: 12px;
  font-size: 18px;
  letter-spacing: .14em;
}

.status {
  margin-top: 5px;
  min-height: 18px;
  font-size: 13px;
  text-align: center;
}

.status.ok { color: #22c55e; }
.status.error { color: #f97373; }

.orders-list,
.list {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.order-card,
.card {
  border-radius: 8px;
  background: #0d1118;
  border: 1px solid #242b37;
  padding: clamp(12px, 2vw, 18px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}

.order-header,
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.order-table,
.card-table {
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 900;
}

.order-time,
.card-time {
  font-size: 14px;
  color: #a7b0bd;
}

.order-items,
.card-items {
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.order-meta {
  color: #a7b0bd;
  font-size: 14px;
  font-weight: 800;
  margin: -2px 0 8px;
}

.order-note,
.card-note {
  font-size: clamp(15px, 1.7vw, 19px);
  color: #c9d0da;
  margin-top: 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.order-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 8px;
}

.badge-empty {
  font-size: 14px;
  color: #a7b0bd;
  margin-top: 12px;
  text-align: center;
}

.toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #242b37;
  background: #080b10;
  font-size: 11px;
  color: #e5e7eb;
  user-select: none;
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  background: #171d28;
  border: 1px solid #2f3948;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  display: none;
  z-index: 20;
}

.toast.show {
  display: block;
}

.toast-title {
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 900;
  margin-bottom: 6px;
}

.toast-body,
.toast-items {
  font-size: clamp(16px, 2.4vw, 22px);
}

.toast-note {
  font-size: 13px;
  color: #a7b0bd;
  margin-top: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

th,
td {
  padding: 8px 6px;
  border-bottom: 1px solid #242b37;
  font-size: 14px;
}

th {
  text-align: left;
  font-weight: 800;
  color: #a7b0bd;
}

code {
  color: #c9d0da;
}

.small {
  font-size: 12px;
  color: #a7b0bd;
  margin-top: 8px;
}

.admin-toolbar {
  position: sticky;
  top: 0;
  z-index: 15;
  background: #080b10;
  border-bottom: 1px solid #242b37;
  padding: 0 0 12px;
  margin-bottom: 12px;
}

.admin-section-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.admin-section-tab {
  border: 1px solid #374151;
  background: #0d1118;
}

.admin-section-tab.active {
  background: #b91c1c;
  border-color: #b91c1c;
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.admin-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.admin-stat-card,
.admin-box,
.admin-danger-zone {
  border: 1px solid #242b37;
  border-radius: 8px;
  background: #0d1118;
  padding: 14px;
}

.stat-label {
  color: #a7b0bd;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 6px;
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 900;
}

.admin-split,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.admin-box h2,
.admin-danger-zone h2 {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.admin-danger-zone {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.admin-danger-zone p {
  margin: 0;
  color: #a7b0bd;
  font-size: 13px;
}

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

.analytics-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid #242b37;
  padding: 8px 0;
}

.analytics-row span {
  overflow-wrap: anywhere;
}

.analytics-row small {
  display: block;
  color: #a7b0bd;
  font-size: 11px;
  margin-top: 2px;
}

.empty-note {
  color: #a7b0bd;
  font-size: 13px;
}

.settings-actions {
  margin-top: 10px;
}

.users-list {
  display: grid;
  gap: 10px;
}

.user-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px auto;
  gap: 10px;
  align-items: end;
  border: 1px solid #242b37;
  border-radius: 8px;
  background: #080b10;
  padding: 12px;
}

.admin-filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 190px) minmax(180px, 240px);
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.admin-filter-row .search-input {
  margin-bottom: 0;
}

.admin-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 10px;
}

.admin-group-heading {
  grid-column: 1 / -1;
  color: #f3f4f6;
  background: #171d28;
  border: 1px solid #242b37;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.admin-item-card {
  border: 1px solid #242b37;
  border-radius: 8px;
  background: #0d1118;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.admin-item-card.is-hidden-item {
  opacity: .58;
}

.admin-item-head {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.admin-item-title {
  font-size: 17px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.admin-item-meta {
  margin-top: 3px;
  color: #a7b0bd;
  font-size: 12px;
  font-weight: 700;
}

.admin-item-card label {
  font-size: 12px;
  color: #a7b0bd;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.admin-item-card input,
.admin-item-card select {
  margin-top: 4px;
}

.admin-switch {
  align-self: end;
  display: flex;
  min-height: 46px;
  gap: 10px;
  align-items: center;
  border: 1px solid #4b5563;
  border-radius: 8px;
  padding: 10px 12px;
  background: #080b10;
}

.admin-switch input {
  width: 20px;
  height: 20px;
  margin: 0;
}

.admin-switch span {
  color: #f3f4f6;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: none;
}

@media (max-width: 760px) {
  .admin-page,
  .page {
    padding: 12px;
  }

  header {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls {
    width: 100%;
  }

  .controls > *,
  .actions > * {
    flex: 1 1 auto;
  }

  .admin-filter-row,
  .admin-list,
  .admin-item-card,
  .user-card,
  .admin-danger-zone {
    grid-template-columns: 1fr;
  }

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

  .admin-danger-zone {
    align-items: stretch;
    flex-direction: column;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tr {
    border-bottom: 1px solid #242b37;
    padding: 8px 0;
  }

  td {
    border-bottom: 0;
    padding: 4px 0;
  }

  td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin: 2px 0 4px;
    color: #a7b0bd;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
  }
}

@media (min-width: 680px) {
  .screen {
    max-width: 980px;
    margin: 0 auto;
  }

  .tables-grid {
    grid-template-columns: repeat(5, minmax(100px, 1fr));
  }

  .item-tile {
    min-height: 72px;
  }
}

@media (min-width: 960px) {
  #order-form {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    align-items: start;
  }

  #order-form .field:first-child {
    grid-row: 1 / span 2;
  }

  #order-form .field:nth-child(2) {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  #order-form .field:nth-child(3),
  #order-form .actions-row,
  #order-form .submit-btn,
  #order-form .status {
    grid-column: 1 / -1;
  }

  .groups-row {
    display: grid;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .items-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 58dvh;
  }
}

@media (min-width: 1180px) {
  .orders-list,
  .list {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}
