:root {
  color-scheme: dark;
  --bg: #111614;
  --panel: #1a211f;
  --panel-soft: #222b28;
  --panel-strong: rgba(26, 33, 31, 0.94);
  --field: #121816;
  --row: rgba(26, 33, 31, 0.72);
  --ink: #eef5f1;
  --muted: #a7b6af;
  --muted-soft: #7d8a84;
  --line: #35423d;
  --line-strong: #485951;
  --accent: #48c9ae;
  --accent-dark: #32a88f;
  --amber: #e0a23a;
  --danger: #e15f58;
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.36);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(21, 29, 26, 0.96), rgba(12, 16, 15, 0.98)),
    repeating-linear-gradient(90deg, rgba(72, 201, 174, 0.05) 0 1px, transparent 1px 64px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  accent-color: var(--accent);
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(17, 22, 20, 0.9);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid #d2a45a;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 45% 28%, #fff7dc 0 14%, transparent 15%),
    linear-gradient(180deg, #f0b545 0 54%, #d6891e 55% 100%);
  box-shadow: inset 0 -9px 0 rgba(36, 62, 55, 0.13);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #243e37;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

h1 {
  margin: 0;
  font-size: clamp(1.25rem, 1.7vw, 1.75rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.subhead {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 4px;
}

.subhead span {
  color: var(--ink);
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.session-status {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 40px;
  border-radius: var(--radius);
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.button.primary {
  color: #07120f;
  background: var(--accent);
  border-color: var(--accent);
}

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

.button.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.button.ghost {
  background: transparent;
}

.button.icon {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  font-weight: 700;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

main {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 22px 34px;
}

.auth-panel {
  max-width: 440px;
  margin: 36px auto 0;
  padding: 18px;
}

.auth-panel form {
  margin-top: 12px;
}

.connection-banner {
  margin-bottom: 16px;
  border: 1px solid rgba(224, 162, 58, 0.55);
  border-radius: var(--radius);
  background: rgba(224, 162, 58, 0.12);
  color: var(--ink);
  padding: 12px 14px;
  font-size: 0.92rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 88px;
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.2);
}

.metric-label {
  color: var(--muted);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

.metric-value {
  margin-top: 8px;
  font-size: 1.55rem;
  font-weight: 800;
}

.workspace {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-header {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 1.05rem;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search,
.select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  padding: 8px 10px;
}

.search {
  width: min(260px, 100%);
}

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

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

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  font-size: 0.77rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  background: var(--panel-soft);
}

tbody tr {
  background: var(--row);
}

.beer-name {
  font-weight: 800;
}

.beer-detail {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.beer-description {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.beer-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.beer-summary-copy {
  min-width: 0;
}

.beer-expand {
  display: none;
}

.beer-expand-icon {
  display: block;
  line-height: 1;
  transition: transform 140ms ease;
}

tbody tr[data-expanded="true"] .beer-expand-icon {
  transform: rotate(180deg);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--field);
  font-size: 0.85rem;
  font-weight: 700;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-soft);
}

.status.active::before {
  background: var(--accent);
}

.status.off::before {
  background: var(--amber);
}

.toggle {
  position: relative;
  display: inline-flex;
  width: 50px;
  height: 28px;
  align-items: center;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #5a625d;
  transition: background 140ms ease;
}

.slider::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #f4f8f5;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.22);
  transition: transform 140ms ease;
}

.toggle input:checked + .slider {
  background: var(--accent);
}

.toggle input:checked + .slider::after {
  transform: translateX(22px);
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

.empty {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

.form-drawer {
  position: fixed;
  top: 88px;
  right: 18px;
  bottom: 18px;
  z-index: 15;
  width: min(420px, calc(100vw - 36px));
  overflow-y: auto;
}

.form-card {
  padding: 16px;
}

.form-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

form {
  display: grid;
  gap: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.25;
  padding: 9px 10px;
}

::placeholder {
  color: var(--muted-soft);
  opacity: 1;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(72, 201, 174, 0.28);
  outline-offset: 2px;
}

.check-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.check-label {
  display: inline-flex;
  grid-template-columns: unset;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.check-label input {
  width: 18px;
  min-height: 18px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-top: 4px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--ink);
  background: #222b28;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1024px) {
  .topbar-inner,
  .panel-header {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    padding: 16px 18px;
  }

  .toolbar,
  .filters {
    justify-content: flex-start;
  }

  main {
    padding: 20px 18px 32px;
  }

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

  .search {
    flex: 1 1 260px;
    width: auto;
  }

  .select {
    flex: 0 1 190px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  tbody {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 12px;
  }

  tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--row);
  }

  td {
    min-width: 0;
    padding: 10px 12px;
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
  }

  td[data-label="Beer"],
  td[data-label="Actions"] {
    grid-column: 1 / -1;
  }

  td[data-label="Beer"] {
    border-bottom: 1px solid var(--line);
  }

  td[data-label="Beer"]::before {
    display: none;
  }

  td[data-label="Actions"] {
    border-top: 1px solid var(--line);
  }

  .row-actions {
    justify-content: flex-start;
  }

  .form-drawer {
    top: 78px;
    right: 14px;
    bottom: 14px;
    width: min(520px, calc(100vw - 28px));
  }
}

@media (max-width: 700px) {
  .topbar-inner,
  main {
    padding-left: 14px;
    padding-right: 14px;
  }

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

  .toolbar,
  .filters,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .session-status {
    text-align: left;
  }

  .button {
    width: 100%;
  }

  .button.icon {
    width: 36px;
  }

  .button.icon.beer-expand {
    display: inline-flex;
    flex: 0 0 auto;
    background: var(--field);
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .metric {
    min-height: 54px;
    padding: 9px 10px;
  }

  .metric-label {
    font-size: 0.64rem;
  }

  .metric-value {
    margin-top: 3px;
    font-size: 1.18rem;
  }

  tbody {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  tbody tr {
    grid-template-columns: 1fr;
  }

  tbody tr:not([data-expanded="true"]) td:not([data-label="Beer"]):not([data-label="On Menu"]) {
    display: none;
  }

  td {
    display: grid;
    grid-template-columns: minmax(86px, 34%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
  }

  td::before {
    margin-bottom: 0;
  }

  td[data-label="Beer"] {
    display: block;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  td[data-label="Actions"] {
    grid-template-columns: 1fr;
    align-items: start;
  }

  td[data-label="Actions"]::before {
    margin-bottom: 2px;
  }

  .row-actions {
    gap: 8px;
  }

  .search,
  .select {
    width: 100%;
  }

  .form-drawer {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px;
    background: rgba(12, 16, 15, 0.72);
  }

  .form-card {
    min-height: auto;
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
  }

  .toast {
    right: 14px;
    bottom: 14px;
    left: 14px;
    max-width: none;
  }
}
