/* The `hidden` attribute must actually hide. The UA rule is `[hidden] {
   display: none }`, which any author rule setting `display` on a class or an
   element outranks — so `el.hidden = true` in JS silently does nothing and
   the element stays on screen. This has already bitten .store-sheet,
   .compact-form, label, and .page-actions; one guard beats patching the
   next one after it ships. */
[hidden] {
  display: none !important;
}

:root {
  color-scheme: light;
  --color-bg: #ffffff;
  --color-bg-muted: #fafafa;
  --color-bg-subtle: #f4f4f5;
  --color-fg: #09090b;
  --color-fg-muted: #52525b;
  --color-fg-subtle: #71717a;
  --color-border: #e4e4e7;
  --color-border-strong: #d4d4d8;
  --ea-primary: #18181b;
  --ea-primary-hover: #27272a;
  --ea-primary-bg: #f4f4f5;
  --ea-primary-light: #e4e4e7;
  --ea-success: #16a34a;
  --ea-success-bg: #f0fdf4;
  --ea-warning: #ca8a04;
  --ea-warning-bg: #fefce8;
  --ea-danger: #dc2626;
  --ea-danger-bg: #fef2f2;
  --ea-info: #2563eb;
  --ea-info-bg: #eff6ff;
  --ea-accent: #ea580c;
  --ea-accent-bg: #fff7ed;
  --content-bg: #fafafa;
  --card-bg: #ffffff;
  --card-border: #e4e4e7;
  --card-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --text-primary: #09090b;
  --text-regular: #3f3f46;
  --text-secondary: #71717a;
  --text-placeholder: #a1a1aa;
  --border-base: #d4d4d8;
  --radius-base: 6px;
  --sidebar-width: 220px;
  --topbar-height: 56px;
  font-family: Sarabun, -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--content-bg);
  color: var(--text-regular);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--content-bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--color-border);
  color: var(--text-primary);
}

.sidebar-logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo-text {
  font-size: 15px;
  font-weight: 600;
}

.sidebar-nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  margin: 0;
  padding: 8px 14px 4px;
  color: var(--text-placeholder);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-item {
  height: 36px;
  border: 0;
  border-radius: var(--radius-base);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--color-bg-subtle);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--color-bg-subtle);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-icon {
  width: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.nav-text {
  flex: 1;
}

.main {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-height);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
}

.topbar-menu {
  display: none;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.breadcrumb-item.is-current {
  color: var(--text-primary);
  font-weight: 500;
}

.breadcrumb-link {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: auto;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.breadcrumb-link:hover {
  background: transparent;
  color: var(--text-primary);
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--text-placeholder);
}

.topbar-spacer {
  flex: 1;
}

.topbar-user {
  padding: 6px 10px;
  border-radius: var(--radius-base);
  border: 1px solid transparent;
  background: var(--color-bg-subtle);
  color: var(--text-regular);
  font-size: 13px;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.topbar-user:hover {
  border-color: var(--color-border-strong);
}

.topbar-create {
  background: var(--ea-primary);
  border-color: var(--ea-primary);
  color: #fff;
  min-height: 36px;
}

.topbar-create:hover {
  background: var(--ea-primary-hover);
  border-color: var(--ea-primary-hover);
  color: #fff;
}

.content {
  width: min(1240px, calc(100vw - var(--sidebar-width) - 48px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--text-placeholder);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.page-title,
h1,
h2 {
  margin: 0;
  color: var(--text-primary);
}

.page-title {
  font-size: 22px;
  font-weight: 600;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.setup-guide {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.6fr);
  gap: 20px;
  align-items: start;
  background: var(--color-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-base);
  box-shadow: var(--card-shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.setup-guide h2 {
  font-size: 17px;
  line-height: 1.4;
}

.guide-kicker {
  margin: 0 0 6px;
  color: var(--text-placeholder);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.setup-guide ol {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
}

.setup-guide li {
  min-height: 82px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background: var(--content-bg);
  padding: 12px;
}

.setup-guide strong,
.setup-guide span {
  display: block;
}

.setup-guide strong {
  color: var(--text-primary);
  font-size: 13px;
  margin-bottom: 4px;
}

.setup-guide span {
  color: var(--text-secondary);
  font-size: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.controls {
  display: flex;
  gap: 8px;
}

.row-end {
  justify-content: flex-end;
  margin-bottom: 16px;
}

input,
select {
  height: 36px;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--border-base);
  border-radius: var(--radius-base);
  background: var(--color-bg);
  color: var(--text-primary);
  padding: 0 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  border-color: var(--ea-primary);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}

button {
  min-height: 32px;
  border: 1px solid var(--border-base);
  border-radius: var(--radius-base);
  background: var(--color-bg);
  color: var(--text-regular);
  padding: 0 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

button:hover {
  background: var(--ea-primary-bg);
  border-color: var(--ea-primary-light);
  color: var(--text-primary);
}

form button,
#refreshButton,
#reloadMenuButton {
  background: var(--ea-primary);
  border-color: var(--ea-primary);
  color: #fff;
}

form button:hover,
#refreshButton:hover,
#reloadMenuButton:hover {
  background: var(--ea-primary-hover);
  border-color: var(--ea-primary-hover);
  color: #fff;
}

.primary-action,
.primary-action:hover {
  background: var(--ea-primary);
  border-color: var(--ea-primary);
  color: #fff;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.metrics article,
.panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-base);
  box-shadow: var(--card-shadow);
}

.metrics article {
  padding: 20px;
}

.metrics span {
  display: block;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: 13px;
}

.metrics strong {
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 600;
}

.panel {
  overflow: hidden;
  margin-bottom: 16px;
}

.form-panel {
  overflow: visible;
}

.primary-setup-panel {
  margin-bottom: 16px;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.entity-card-list {
  display: flex;
  flex-direction: column;
}

.entity-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--color-bg-subtle);
  background: var(--card-bg);
  padding: 14px 20px;
  text-align: left;
  cursor: pointer;
}

.entity-card:hover {
  background: var(--color-bg-muted);
  border-color: var(--color-bg-subtle);
}

.entity-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entity-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.entity-card-chevron {
  flex: 0 0 auto;
  color: var(--text-placeholder);
  display: inline-flex;
}

.store-sheet[hidden] {
  display: none;
}

.store-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--content-bg);
  display: flex;
  flex-direction: column;
}

.store-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--card-border);
}

.store-sheet-eyebrow {
  margin: 0 0 2px;
  color: var(--text-placeholder);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.store-sheet-title {
  font-size: 18px;
}

.store-sheet-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.store-sheet-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--card-border);
  overflow-x: auto;
}

.sheet-tab {
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  border-color: var(--card-border);
  color: var(--text-regular);
  font-weight: 600;
  white-space: nowrap;
}

.sheet-tab.active {
  background: var(--ea-primary);
  border-color: var(--ea-primary);
  color: #fff;
}

.store-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.sheet-panel {
  display: none;
}

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

.btn-small-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 11px;
  font-size: 12px;
}

.btn-small-row.is-primary {
  background: var(--ea-primary);
  border-color: var(--ea-primary);
  color: #fff;
}

.btn-small-row.is-primary:hover {
  background: var(--ea-primary-hover);
  border-color: var(--ea-primary-hover);
  color: #fff;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
}

.panel-subtitle {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12px;
}

.step-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.step-title span {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--ea-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

#status,
#menuStatus,
#orgStatus,
.section-status {
  color: var(--text-secondary);
  font-size: 13px;
}

.form-grid,
.compact-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 20px;
}

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

/* [hidden] ties with these classes on specificity (0,0,1,0 each) — without
   this, the class rule's display:grid wins by source order and the form
   never actually hides. Same bug class as .store-sheet[hidden] earlier. */
.form-grid[hidden],
.compact-form[hidden],
label[hidden] {
  display: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

label small {
  color: var(--text-placeholder);
  font-size: 11px;
  font-weight: 500;
}

.field-wide {
  grid-column: span 2;
}

.checkbox {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-regular);
}

.checkbox input {
  width: auto;
  height: auto;
  accent-color: var(--ea-primary);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.category-manager {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.category-chip-wrap {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--card-border);
  overflow: hidden;
}

.category-chip {
  min-height: 42px;
  padding: 0 8px 0 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-regular);
  font-weight: 700;
}

.category-chip-remove {
  min-height: 42px;
  width: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-placeholder);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.category-chip-remove:hover {
  background: var(--ea-danger-bg);
  color: var(--ea-danger);
}

.category-chip:hover,
.category-chip-wrap:hover {
  background: var(--ea-primary-light);
}

.category-chip-wrap.active {
  background: var(--ea-primary);
  border-color: var(--ea-primary);
}

.category-chip-wrap.active .category-chip,
.category-chip-wrap.active .category-chip-remove {
  color: #fff;
}

.category-chip-wrap.active .category-chip:hover,
.category-chip-wrap.active:hover {
  background: var(--ea-primary-hover);
}

.category-chip-wrap.active .category-chip-remove:hover {
  background: var(--ea-danger);
  color: #fff;
}

.stock-branch-picker {
  padding: 16px 20px 0;
  max-width: 360px;
}

.scoop-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scoop-option {
  min-height: 44px;
  min-width: 64px;
  padding: 0 14px;
  border-radius: var(--radius-base);
  background: var(--color-bg-subtle);
  border-color: var(--card-border);
  color: var(--text-regular);
  font-weight: 700;
}

.scoop-option.active {
  background: var(--ea-primary);
  border-color: var(--ea-primary);
  color: #fff;
}

.scoop-option.active:hover {
  background: var(--ea-primary-hover);
  border-color: var(--ea-primary-hover);
  color: #fff;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 360px) auto;
  gap: 10px;
  align-items: center;
}

.quick-menu-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(140px, 0.7fr) auto minmax(120px, 0.5fr) auto auto;
  gap: 12px;
  align-items: end;
  padding: 20px;
}

.quick-menu-form > button[type="submit"] {
  min-width: 150px;
}

.step-panel button[type="submit"] {
  min-width: 132px;
}

.toggle-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-regular);
  font-size: 13px;
  font-weight: 700;
}

.ios-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: 0 0 auto;
  display: inline-flex;
  cursor: pointer;
}

.ios-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.ios-switch span {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--color-border-strong);
  transition: background 0.16s ease;
}

.ios-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.16s ease;
}

.ios-switch input:checked + span {
  background: #34c759;
}

.ios-switch input:checked + span::after {
  transform: translateX(20px);
}

.modal {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.modal::backdrop {
  background: rgba(24, 24, 27, 0.45);
}

.modal-card {
  background: var(--card-bg);
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 24px;
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--card-border);
  border-bottom: 0;
}

.modal-actions-spacer {
  flex: 1;
}

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

.danger-action:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
}

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-bg-subtle);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

td {
  color: var(--text-regular);
}

code {
  color: var(--text-regular);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.row-title {
  color: var(--text-primary);
  font-weight: 600;
}

.row-actions {
  text-align: right;
  white-space: nowrap;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill,
.soft-pill {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.status-pill.is-online {
  background: var(--ea-success-bg);
  color: var(--ea-success);
}

.status-pill.is-offline {
  background: var(--ea-danger-bg);
  color: var(--ea-danger);
}

.soft-pill {
  background: var(--color-bg-subtle);
  color: var(--text-regular);
}

.soft-pill--accent {
  background: var(--ea-accent-bg);
  color: var(--ea-accent);
}

.soft-pill--info {
  background: var(--ea-info-bg);
  color: var(--ea-info);
}

.icon {
  display: inline-block;
  vertical-align: middle;
  color: currentColor;
}

.btn-icon-slot {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.icon-chip--accent {
  background: var(--ea-accent-bg);
  color: var(--ea-accent);
}

.icon-chip--info {
  background: var(--ea-info-bg);
  color: var(--ea-info);
}

.icon-chip--success {
  background: var(--ea-success-bg);
  color: var(--ea-success);
}

.icon-chip--warning {
  background: var(--ea-warning-bg);
  color: var(--ea-warning);
}

.icon-chip--danger {
  background: var(--ea-danger-bg);
  color: var(--ea-danger);
}

.icon-chip--neutral {
  background: var(--color-bg-subtle);
  color: var(--text-secondary);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 36px 16px;
  color: var(--text-secondary);
}

.empty-state-title {
  margin: 6px 0 0;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
}

.empty-state-message {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.empty-state-cta {
  margin-top: 10px;
  background: var(--ea-primary);
  border-color: var(--ea-primary);
  color: #fff;
}

.empty-state-cta:hover {
  background: var(--ea-primary-hover);
  border-color: var(--ea-primary-hover);
  color: #fff;
}

.table-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-base);
  object-fit: cover;
  border: 1px solid var(--card-border);
  background: var(--color-bg-subtle);
  display: block;
}

.image-placeholder {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-subtle);
  color: var(--text-placeholder);
  font-size: 12px;
}

#itemsBody td:nth-child(2),
#itemsBody td:nth-child(3),
#itemsBody th:nth-child(2),
#itemsBody th:nth-child(3) {
  text-align: right;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.35);
  z-index: 90;
}

@media (max-width: 920px) {
  :root {
    --sidebar-width: 64px;
  }

  .sidebar-logo {
    justify-content: center;
    padding: 0;
  }

  .sidebar-logo-text,
  .nav-section-label,
  .nav-text {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .content {
    width: min(100%, calc(100vw - var(--sidebar-width) - 24px));
    padding: 16px 0 32px;
  }

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

  .form-grid,
  .compact-form,
  .quick-menu-form,
  .inline-form,
  .split,
  .setup-guide,
  .setup-guide ol {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 12px;
  }

  .topbar-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar-user {
    display: none;
  }

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

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

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

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

  .panel {
    overflow-x: auto;
  }

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-logo {
    justify-content: flex-start;
    padding: 0 18px;
  }

  .sidebar-logo-text,
  .nav-section-label,
  .nav-text {
    display: block;
  }

  .nav-item {
    justify-content: flex-start;
    padding: 0 10px;
  }

  .main {
    margin-left: 0;
  }
}

/* --- Payment profiles ---------------------------------------------------- */
/* The per-profile action buttons sit under their card inside the same
   card list, so they need the card's horizontal padding to line up. */
.entity-card-list .row-actions {
  padding: 10px 16px 14px;
  border-bottom: 1px solid var(--color-bg-subtle);
  flex-wrap: wrap;
}

.muted-note {
  color: var(--text-secondary);
  font-size: 12px;
}

/* On its own row so a long sentence wraps instead of scrolling the panel
   sideways next to the buttons. */
.entity-card-list .row-actions .muted-note {
  flex: 1 1 100%;
}

.branch-profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-bg-subtle);
}

.branch-profile-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.branch-profile-row select {
  max-width: 60%;
}

/* iPhone-first: the name and the picker stack rather than squeezing the
   select down to a few unreadable characters. */
@media (max-width: 560px) {
  .branch-profile-row {
    flex-direction: column;
    align-items: stretch;
  }
  .branch-profile-row select {
    max-width: none;
  }
}


/* --- Sign-in gate -------------------------------------------------------- */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--color-bg-muted);
}

.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  padding: 32px 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 12px);
  background: var(--card-bg);
  text-align: center;
}

.login-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--ea-accent-bg);
}

.login-card h1 {
  margin: 0;
  font-size: 20px;
}

.login-sub {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Google renders its own button in here; give it room without letting it
   stretch the card on a narrow phone. */
.login-google {
  min-height: 44px;
  display: flex;
  justify-content: center;
}

.login-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-base);
  background: var(--ea-danger-bg);
  color: var(--ea-danger);
  font-size: 13px;
  line-height: 1.5;
}

.login-hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--color-border);
}

.sidebar-account {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-signout {
  width: 100%;
  justify-content: center;
  font-size: 13px;
}

/* Collapsed icon rail: the email would just be an ellipsis, and the button
   has no room for its label. The topbar chip covers sign-out at this width. */
@media (max-width: 920px) and (min-width: 641px) {
  .sidebar-footer {
    display: none;
  }
}

/* Secret inputs with a reveal button. The button sits inside the field's
   box so the row still reads as one control. */
.secret-field {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.secret-field input {
  flex: 1;
  min-width: 0;
}

.secret-eye {
  flex: 0 0 auto;
  padding: 0 12px;
  font-size: 13px;
}

.secret-eye[hidden] {
  display: none;
}

/* --- Live payment test --------------------------------------------------- */
.paytest {
  padding: 0 16px 16px;
}

.paytest-amount {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.paytest-result {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--color-bg-subtle);
}

.paytest-result[hidden] {
  display: none;
}

/* White plate behind the QR: a dark theme would otherwise invert the quiet
   zone and some bank apps refuse to read it. */
.paytest-qr {
  width: 220px;
  height: 220px;
  padding: 8px;
  border-radius: var(--radius-base);
  background: #fff;
}

.paytest-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}

.paytest-amount-label {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.paytest-state {
  margin: 0;
  font-size: 15px;
}

.paytest-countdown {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.paytest-verdict {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: var(--radius-base);
  font-size: 13px;
  line-height: 1.6;
}

.paytest-verdict[hidden] {
  display: none;
}

.paytest-verdict.is-good {
  background: var(--ea-success-bg);
  color: var(--ea-success);
}

.paytest-verdict.is-warn {
  background: var(--ea-warning-bg);
  color: var(--ea-warning);
}

.paytest-verdict code {
  display: inline-block;
  margin-top: 4px;
  word-break: break-all;
  font-size: 12px;
}

.paytest-routing {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Collapsible panel header: the whole header is the hit target, so it works
   as a thumb tap on a phone rather than a small chevron. */
.panel-header.disclosure {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: none;
  text-align: start;
  cursor: pointer;
}

.panel-header.disclosure:hover {
  background: var(--color-bg-muted);
}

.disclosure-chevron {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--text-secondary);
  border-bottom: 2px solid var(--text-secondary);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.panel-header.disclosure[aria-expanded="true"] .disclosure-chevron {
  transform: rotate(-135deg);
}

/* Inline "move menus, then delete" bar for a category that still has items. */
.category-move {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--ea-warning);
  border-radius: var(--radius-base);
  background: var(--ea-warning-bg);
}

.category-move[hidden] {
  display: none;
}

.category-move p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-regular);
}

.category-move .row-actions {
  flex-wrap: wrap;
}

/* "+" chip that opens the new-category field, sized to match the chips it
   sits beside rather than a full-width button. */
.category-chip-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px dashed var(--color-border-strong);
  border-radius: 999px;
  background: none;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.category-chip-add:hover {
  border-style: solid;
  border-color: var(--ea-primary);
  color: var(--ea-primary);
}

#categoryForm[hidden] {
  display: none;
}

/* --- Stock reconciliation ------------------------------------------------ */
.reconcile {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-bg-subtle);
}

.reconcile-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.reconcile-verdict {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-base);
  font-size: 13px;
  line-height: 1.6;
}

.reconcile-verdict.is-good { background: var(--ea-success-bg); color: var(--ea-success); }
.reconcile-verdict.is-bad { background: var(--ea-danger-bg); color: var(--ea-danger); }
.reconcile-verdict.is-warn { background: var(--ea-warning-bg); color: var(--ea-warning); }
.reconcile-verdict.is-idle { background: var(--color-bg-subtle); color: var(--text-secondary); }

.reconcile-table {
  width: 100%;
  font-size: 13px;
  background: none;
}

.reconcile-table td {
  padding: 5px 0;
  border: 0;
}

/* Digits line up so the column reads as a sum, not a list. */
.reconcile-table td:last-child {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.reconcile-total td {
  padding-top: 8px;
  border-top: 1px solid var(--color-border) !important;
  font-weight: 700;
}

.reconcile-flag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.reconcile-flag.is-good { background: var(--ea-success-bg); color: var(--ea-success); }
.reconcile-flag.is-bad { background: var(--ea-danger-bg); color: var(--ea-danger); }
.reconcile-flag.is-warn { background: var(--ea-warning-bg); color: var(--ea-warning); }
.reconcile-flag.is-idle { background: var(--color-bg-subtle); color: var(--text-secondary); }

.reconcile-detail td {
  padding-bottom: 10px !important;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: start !important;
}
