:root {
  --bg: #f4efe4;
  --panel: rgba(255, 252, 246, 0.86);
  --panel-strong: #fffaf1;
  --line: rgba(53, 44, 30, 0.14);
  --text: #231b12;
  --muted: #6f6455;
  --accent: #8d4f18;
  --accent-strong: #5c2f0a;
  --accent-soft: #f2c48d;
  --ok: #205b33;
  --warn: #8d4f18;
  --danger: #8a1f2b;
  --shadow: 0 24px 60px rgba(70, 44, 19, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(242, 196, 141, 0.65), transparent 34%),
    radial-gradient(circle at right center, rgba(133, 73, 18, 0.18), transparent 28%),
    linear-gradient(180deg, #f8f2e8 0%, #efe5d2 100%);
}

h1,
h2,
h3,
h4,
legend {
  font-family: Georgia, "Times New Roman", serif;
  margin: 0;
}

p {
  margin: 0;
}

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

button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff7ef;
  cursor: pointer;
  padding: 0.85rem 1.2rem;
  font-weight: 700;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
  box-shadow: 0 12px 24px rgba(92, 47, 10, 0.22);
}

button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid var(--line);
  box-shadow: none;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(141, 79, 24, 0.18);
  border-color: rgba(141, 79, 24, 0.45);
}

.password-field {
  position: relative;
  width: 100%;
}

.password-field input {
  padding-right: 3.25rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  color: var(--accent-strong);
  background: transparent;
  box-shadow: none;
  font-size: 1.15rem;
  line-height: 1;
}

.password-toggle:hover {
  transform: translateY(-50%);
  background: rgba(141, 79, 24, 0.1);
}

.hidden {
  display: none !important;
}

.password-dialog {
  width: min(520px, calc(100% - 2rem));
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.password-dialog::backdrop {
  background: rgba(35, 27, 18, 0.55);
  backdrop-filter: blur(3px);
}

.shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 2rem 1.4rem;
  border-right: 1px solid rgba(53, 44, 30, 0.08);
  background: linear-gradient(180deg, rgba(255, 249, 238, 0.92) 0%, rgba(248, 236, 214, 0.82) 100%);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.content {
  padding: 2rem;
  display: grid;
  gap: 1.35rem;
}

.hero,
.panel,
.login-card,
.card,
.metric,
.resource-card {
  border: 1px solid rgba(53, 44, 30, 0.08);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero,
.panel,
.login-card,
.card,
.resource-card {
  border-radius: var(--radius);
}

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

.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
  margin-bottom: 0.45rem;
  font-weight: 700;
}

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

.hint {
  font-size: 0.92rem;
}

.password-change-success {
  margin: 0.85rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(55,100,90,0.28);
  border-radius: 14px;
  color: #285c50;
  background: rgba(92,156,138,0.14);
  font-weight: 800;
}
.password-requirements {
  margin: 0.15rem 0 0;
  color: #8a5a32;
  font-size: 0.78rem;
  line-height: 1.45;
}
.password-requirements.valid { color: #28705e; }

.panel {
  padding: 1.35rem;
  display: grid;
  gap: 1rem;
}

.panel-body {
  display: grid;
  gap: 1rem;
}

.panel-body[hidden] {
  display: none;
}

.section-toggle {
  min-width: 104px;
  padding: 0.65rem 1rem;
}

.section-toggle::after {
  content: " ▾";
}

.section-toggle[aria-expanded="true"]::after {
  content: " ▴";
}

.section-head,
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1rem;
}

.card,
.login-card {
  padding: 1.15rem;
  display: grid;
  gap: 1rem;
}

.stack-form {
  display: grid;
  gap: 0.85rem;
}

.report-controls {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(180px, 240px) auto auto;
  gap: 0.85rem;
  align-items: end;
}

.report-controls label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
}

.inline-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
}

.notice-box {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 237, 196, 0.48);
}

.compact-form {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

details > summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 700;
}

.action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 150px;
}

.stack-form label,
.stack-form fieldset {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
}

.nfc-scan-button {
  background: linear-gradient(135deg, #1f6f5d, #12483e);
}

.nfc-status {
  min-height: 1.3rem;
  color: var(--ok);
  font-weight: 700;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.9rem;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.55rem;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  border: 1px solid rgba(53, 44, 30, 0.08);
  color: var(--text);
}

.checkbox-grid input {
  width: auto;
}

.nav {
  display: grid;
  gap: 1rem;
}

.nav-group {
  display: grid;
  gap: 0.5rem;
}

.nav-title {
  padding-left: 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.nav a {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0.35rem;
  color: var(--text);
  text-decoration: none;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.56);
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(70, 44, 19, 0.06);
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.nav a:hover {
  transform: translateY(-2px);
  border-color: rgba(141, 79, 24, 0.3);
  background: rgba(255, 250, 241, 0.96);
  box-shadow: 0 12px 24px rgba(70, 44, 19, 0.1);
}

.nav a.active {
  color: #fffaf1;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 24px rgba(92, 47, 10, 0.24);
}

.nav-icon {
  width: 1.65rem;
  height: 1.65rem;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  color: var(--accent-strong);
  background: rgba(141, 79, 24, 0.1);
  font-family: Georgia, serif;
  font-size: 1rem;
  font-weight: 800;
}

.nav a.active .nav-icon {
  color: #fffaf1;
  background: rgba(255, 255, 255, 0.17);
}

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

.label {
  color: var(--muted);
  font-size: 0.85rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  background: rgba(141, 79, 24, 0.1);
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem;
}

.metric {
  border-radius: 20px;
  padding: 1rem;
}

.metric strong {
  display: block;
  font-size: 1.8rem;
  margin-top: 0.35rem;
}

.list-box,
.table-wrap,
.resource-grid {
  display: grid;
  gap: 0.75rem;
}

.dispenser-health-note { margin-top: -0.45rem; }
.dispenser-health-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.dispenser-health-card { min-width: 0; display: grid; grid-template-columns: 82px minmax(0, 1fr); align-items: center; gap: 0.85rem; padding: 0.9rem; border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 18px; background: var(--panel-strong); }
.dispenser-health-card--low { border-left-color: var(--warn); }
.dispenser-health-card--empty, .dispenser-health-card--unassigned { border-left-color: var(--danger); }
.radial-progress { --ring: var(--ok); width: 82px; aspect-ratio: 1; display: grid; place-content: center; text-align: center; border-radius: 50%; background: conic-gradient(var(--ring) calc(var(--progress) * 1%), rgba(53, 44, 30, 0.11) 0); position: relative; }
.radial-progress::before { content: ""; position: absolute; inset: 8px; border-radius: inherit; background: var(--panel-strong); }
.radial-progress span, .radial-progress small { position: relative; z-index: 1; }
.radial-progress span { font-weight: 800; font-size: 1rem; }
.radial-progress small { color: var(--muted); font-size: 0.62rem; }
.radial-progress--low { --ring: var(--warn); }
.radial-progress--empty, .radial-progress--unassigned { --ring: var(--danger); }
.dispenser-health-content { min-width: 0; display: grid; gap: 0.4rem; }
.dispenser-health-content .card-head { align-items: center; gap: 0.55rem; }
.dispenser-health-content .card-head > div { min-width: 0; }
.dispenser-health-content .card-head p { margin-top: 0.2rem; }
.dispenser-health-content strong,
.dispenser-health-content .hint { overflow-wrap: anywhere; }
.dispenser-health-content .status { flex: 0 0 auto; }
.dispenser-stock-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.dispenser-stock-row > strong { min-width: 0; text-align: right; }
.stock-state { border-radius: 999px; padding: 0.22rem 0.55rem; color: var(--ok); background: rgba(32, 91, 51, 0.12); font-size: 0.76rem; font-weight: 800; }
.stock-state--low { color: var(--warn); background: rgba(141, 79, 24, 0.12); }
.stock-state--empty, .stock-state--unassigned { color: var(--danger); background: rgba(138, 31, 43, 0.12); }

@media (max-width: 1450px) {
  .dispenser-health-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .dispenser-health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .dispenser-health-grid { grid-template-columns: 1fr; }
}

.list-item,
.resource-card {
  padding: 0.95rem;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.resource-card {
  gap: 0.85rem;
}

.beer-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
}

.resource-card form {
  display: grid;
  gap: 0.7rem;
}

.table-wrap {
  min-width: 0;
}

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

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

th,
td {
  padding: 0.8rem 0.7rem;
  border-bottom: 1px solid rgba(53, 44, 30, 0.08);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.pagination > div {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.page-button {
  padding: 0.55rem 0.8rem;
}

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

.table-search {
  width: min(260px, 100%);
  margin-left: auto;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
}

.subsection-head {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.table-thumb {
  width: 92px;
  height: 58px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.row-editor {
  min-width: 290px;
}

.row-editor summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 700;
}

.row-editor form {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.8rem;
  padding: 0.85rem;
  border-radius: 14px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.status.active,
.status.online,
.status.paid,
.status.approved {
  background: rgba(32, 91, 51, 0.12);
  color: var(--ok);
}

.status.blocked,
.status.maintenance,
.status.pending,
.status.draft {
  background: rgba(141, 79, 24, 0.12);
  color: var(--warn);
}

.status.inactive,
.status.disabled,
.status.offline,
.status.lost,
.status.replaced {
  background: rgba(138, 31, 43, 0.12);
  color: var(--danger);
}

.status.void {
  background: rgba(53, 44, 30, 0.1);
  color: var(--muted);
}

.empty {
  padding: 1rem;
  border-radius: 18px;
  border: 1px dashed rgba(53, 44, 30, 0.2);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.resource-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.danger-button {
  background: linear-gradient(135deg, #a42d38 0%, #7d1f28 100%);
}

.credential-panel {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
  padding: 1rem;
  border: 2px solid rgba(141, 79, 24, 0.35);
  border-radius: 18px;
  background: rgba(255, 237, 196, 0.72);
}

.credential-panel.hidden {
  display: none;
}

.credential-warning {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.credential-value {
  display: block;
  max-width: 100%;
  padding: 0.9rem;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #fff8f1;
  background: #241b12;
  user-select: all;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: 360px;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  color: #fff8f1;
  background: rgba(35, 27, 18, 0.94);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.toast.hidden {
  display: none;
}

.error-message {
  color: var(--danger);
  font-weight: 800;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

@media (max-width: 1080px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(53, 44, 30, 0.08);
  }

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

  .nav a {
    min-height: 68px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .report-controls {
    grid-template-columns: 1fr;
  }

  .section-head,
  .card-head {
    flex-direction: column;
  }

  .inline-form {
    width: 100%;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .pagination > div {
    justify-content: space-between;
  }
}
