/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #161412;
  --surface:   #1f1b18;
  --border:    #2a2520;
  --accent:    #e8a83e;
  --accent-dim:#b8842e;
  --text:      #f0ebe3;
  --muted:     #8c7f73;
  --cash:      #4caf82;
  --cc:        #5b9cf6;
  --danger:    #e05c5c;
  --radius:    10px;
  --ff-display: 'Playfair Display', Georgia, serif;
  --ff-mono:    'JetBrains Mono', 'Courier New', monospace;
  --ff-body:    'DM Sans', system-ui, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Chalk texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
}

/* ── Layout ───────────────────────────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
}

/* ── Header ───────────────────────────────────────────────────────────── */
header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--border);
}

.app-title {
  font-family: var(--ff-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.app-time {
  font-family: var(--ff-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Tab Bar ──────────────────────────────────────────────────────────── */
nav {
  flex-shrink: 0;
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tab-btn {
  flex: 1;
  padding: 13px 8px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-family: var(--ff-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  touch-action: manipulation;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Views ────────────────────────────────────────────────────────────── */
main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 18px 16px 24px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

.view.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* ── Toast ────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: var(--bg);
  font-family: var(--ff-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 24px;
  border-radius: 100px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════════════════════════════════
   VIEW 1 — ENTRY (Tab-based)
══════════════════════════════════════════════════════════════════════ */

.section-label {
  font-family: var(--ff-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

/* Entry sub-header (Open Tabs / ＋ New Tab) */
.entry-sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.entry-sub-title {
  font-family: var(--ff-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.new-tab-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: var(--ff-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  touch-action: manipulation;
}

.new-tab-btn:active { background: var(--accent-dim); }

/* Inline new-tab name input */
.new-tab-inline {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.new-tab-inline input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.95rem;
}

.new-tab-inline input::placeholder { color: var(--muted); }

/* Open tab rows */
.open-tabs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.open-tab-row {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.open-tab-row:hover { border-color: var(--accent); }

.tab-ticket-num {
  font-family: var(--ff-mono);
  font-size: 0.82rem;
  color: var(--muted);
  flex-shrink: 0;
  width: 32px;
}

.tab-label {
  font-weight: 500;
  font-size: 0.95rem;
}

.tab-running-total {
  font-family: var(--ff-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.tab-open-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.open-tab-row:hover .tab-open-btn { border-color: var(--accent); color: var(--accent); }

/* Tab detail */
.tab-back-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.back-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 7px 14px;
  font-family: var(--ff-body);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.back-btn:hover { border-color: var(--text); color: var(--text); }

.tab-detail-title {
  font-family: var(--ff-display);
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-subtotal-display {
  font-family: var(--ff-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

/* Items in tab detail */
.tab-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.tab-item-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tab-item-name {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-item-detail {
  font-family: var(--ff-mono);
  font-size: 0.78rem;
  color: var(--muted);
  flex-shrink: 0;
}

.tab-item-total {
  font-family: var(--ff-mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  min-width: 56px;
  text-align: right;
}

.tab-item-note {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
}

.tab-item-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.stepper-qty {
  font-family: var(--ff-mono);
  font-size: 0.9rem;
  min-width: 22px;
  text-align: center;
}

.stepper-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  width: 28px;
  height: 28px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper-btn:hover { border-color: var(--accent); color: var(--accent); }
.minus-btn:hover   { border-color: var(--danger); color: var(--danger); }

/* Menu grid */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 22px;
}

.menu-btn {
  min-height: 72px;
  padding: 10px 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  touch-action: manipulation;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.menu-btn:active { transform: scale(0.96); }

.menu-btn.selected {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  border-color: var(--accent);
  color: var(--accent);
}

.menu-btn .btn-price {
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.menu-btn.selected .btn-price { color: var(--accent-dim); }

.menu-btn.custom-btn {
  border-style: dashed;
  color: var(--muted);
}

.menu-btn.custom-btn.selected {
  color: var(--accent);
  border-style: solid;
}

/* Form */
.entry-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.form-field label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-field input, .form-field textarea {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s;
  min-height: 52px;
  width: 100%;
}

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

.form-field input[type="number"] {
  font-family: var(--ff-mono);
}

/* Qty stepper */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 52px;
}

.qty-btn {
  width: 52px;
  min-height: 52px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 300;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
  flex-shrink: 0;
}

.qty-btn:active { background: color-mix(in srgb, var(--accent) 15%, transparent); }

.qty-display {
  flex: 1;
  text-align: center;
  font-family: var(--ff-mono);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

/* Payment toggle */
.payment-toggle {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 52px;
}

.pay-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--ff-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  touch-action: manipulation;
  letter-spacing: 0.05em;
}

.pay-btn[data-method="cash"].active {
  background: color-mix(in srgb, var(--cash) 22%, var(--surface));
  color: var(--cash);
}

.pay-btn[data-method="cc"].active {
  background: color-mix(in srgb, var(--cc) 22%, var(--surface));
  color: var(--cc);
}

/* Total display */
.total-display {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.total-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.total-amount {
  font-family: var(--ff-mono);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
}

/* Add to Tab button */
.add-to-tab-btn {
  width: 100%;
  min-height: 52px;
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--ff-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s;
  touch-action: manipulation;
}

.add-to-tab-btn:active { background: color-mix(in srgb, var(--accent) 25%, var(--surface)); }
.add-to-tab-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Pay & Close area — overridden in new CSS section below */

.pay-close-btn {
  width: 100%;
  min-height: 52px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--ff-display);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  touch-action: manipulation;
  letter-spacing: 0.04em;
}

.pay-close-btn:hover { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* Tab info (name + summary) */
.tab-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tab-summary {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Payment modal extras */
.payment-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
}

.payment-diff {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
  min-height: 1.2em;
  margin-bottom: 4px;
}

.pay-method-btn {
  flex: 1;
  min-height: 52px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--ff-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  touch-action: manipulation;
}

.pay-method-btn[data-method="cash"].active {
  background: color-mix(in srgb, var(--cash) 22%, var(--surface));
  border-color: var(--cash);
  color: var(--cash);
}

.pay-method-btn[data-method="cc"].active {
  background: color-mix(in srgb, var(--cc) 22%, var(--surface));
  border-color: var(--cc);
  color: var(--cc);
}

/* ══════════════════════════════════════════════════════════════════════
   VIEW 2 — TODAY
══════════════════════════════════════════════════════════════════════ */

.today-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.today-title {
  font-family: var(--ff-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.refresh-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 7px 14px;
  cursor: pointer;
  font-family: var(--ff-body);
  transition: border-color 0.2s, color 0.2s;
}

.refresh-btn:hover { border-color: var(--accent); color: var(--accent); }

.sales-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.sale-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: opacity 0.2s;
}

.sale-time {
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
  width: 42px;
}

.sale-info {
  flex: 1;
  min-width: 0;
}

.sale-name {
  font-weight: 500;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sale-detail {
  font-family: var(--ff-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.sale-amount {
  font-family: var(--ff-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.pay-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 100px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.pay-badge.cash { background: color-mix(in srgb, var(--cash) 20%, transparent); color: var(--cash); }
.pay-badge.cc   { background: color-mix(in srgb, var(--cc)   20%, transparent); color: var(--cc); }

.delete-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-btn:hover { border-color: var(--danger); color: var(--danger); }

.totals-footer {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  text-align: center;
}

.totals-item { display: flex; flex-direction: column; gap: 4px; }

.totals-item-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.totals-item-value {
  font-family: var(--ff-mono);
  font-size: 1.1rem;
  font-weight: 600;
}

.totals-item-value.cash-val { color: var(--cash); }
.totals-item-value.cc-val   { color: var(--cc); }
.totals-item-value.grand-val { color: var(--accent); }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ══════════════════════════════════════════════════════════════════════
   VIEW 3 — MONTH REPORT
══════════════════════════════════════════════════════════════════════ */

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.month-arrow {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  touch-action: manipulation;
}

.month-arrow:hover { border-color: var(--accent); color: var(--accent); }

.month-label {
  font-family: var(--ff-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  min-width: 180px;
  text-align: center;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.report-table thead tr {
  background: var(--surface);
}

.report-table th {
  padding: 10px 12px;
  text-align: right;
  font-family: var(--ff-body);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

.report-table th:first-child { text-align: left; }

.report-table td {
  padding: 10px 12px;
  text-align: right;
  font-family: var(--ff-mono);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.report-table td:first-child {
  text-align: left;
  font-family: var(--ff-body);
  color: var(--muted);
}

.report-table tr:last-child td { border-bottom: none; }

.report-table .td-cash  { color: var(--cash); }
.report-table .td-cc    { color: var(--cc); }
.report-table .td-total { color: var(--text); font-weight: 600; }

.report-table tfoot tr {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border-top: 2px solid var(--accent);
}

.report-table tfoot td {
  font-weight: 700;
  border-bottom: none;
}

.report-table tfoot td:first-child {
  font-family: var(--ff-body);
  color: var(--accent);
  font-weight: 700;
}

.report-table tfoot .td-cash  { color: var(--cash); }
.report-table tfoot .td-cc    { color: var(--cc); }
.report-table tfoot .td-total { color: var(--accent); }

.report-wrapper {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════════
   VIEW 4 — MENU SETTINGS
══════════════════════════════════════════════════════════════════════ */

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.settings-title {
  font-family: var(--ff-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.add-item-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: var(--ff-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  touch-action: manipulation;
}

.add-item-btn:active { background: var(--accent-dim); }

.menu-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-item-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: opacity 0.2s;
}

.menu-item-row.inactive { opacity: 0.45; }

.menu-item-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.95rem;
}

.menu-item-price {
  font-family: var(--ff-mono);
  font-size: 0.88rem;
  color: var(--muted);
  flex-shrink: 0;
}

.active-toggle {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.active-toggle.on  { border-color: var(--cash); background: color-mix(in srgb, var(--cash) 15%, transparent); }
.active-toggle.off { border-color: var(--border); }

.edit-btn-sm {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
}

.edit-btn-sm:hover { border-color: var(--accent); color: var(--accent); }

.del-btn-sm {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
}

.del-btn-sm:hover { border-color: var(--danger); color: var(--danger); }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  transform: translateY(16px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-title {
  font-family: var(--ff-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
}

.modal-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-ghost {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 10px 20px;
  font-family: var(--ff-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-ghost:hover { border-color: var(--text); color: var(--text); }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-family: var(--ff-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-dim); }

/* ── Scrollbar ────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Tablet: larger touch targets ────────────────────────────────────── */
.new-tab-btn, .btn-primary, .btn-ghost, .add-item-btn, .refresh-btn,
.back-btn, .month-arrow {
  min-height: 48px;
}
.tab-btn { padding: 15px 8px; font-size: 0.85rem; }

/* ── Rename tab inline ────────────────────────────────────────────────── */
.rename-tab-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
.rename-tab-btn:hover { border-color: var(--accent); color: var(--accent); }

.tab-rename-row {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.tab-rename-row input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.95rem;
}

/* ── Secondary totals (tips/discounts/expenses/net) ───────────────────── */
.totals-secondary {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.totals-sec-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.totals-sec-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.totals-sec-value {
  font-family: var(--ff-mono);
  font-size: 0.95rem;
  font-weight: 600;
}

.tip-val      { color: var(--cash); }
.discount-val { color: var(--danger); }
.expense-val  { color: var(--danger); }
.net-val      { color: var(--accent); }

.totals-sec-row.totals-net-row {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 2px;
}

/* ── Month net summary ────────────────────────────────────────────────── */
.month-secondary {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Expenses view ────────────────────────────────────────────────────── */
.expense-form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.expense-form-row .form-field:first-child { flex: 2; }
.expense-form-row .form-field:last-child  { flex: 1; }

.expense-add-btn {
  align-self: flex-end;
  min-height: 52px;
  padding: 0 20px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: var(--ff-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  touch-action: manipulation;
  white-space: nowrap;
}

.expense-add-btn:active { background: var(--accent-dim); }
.expense-add-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.expense-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.expense-title {
  font-family: var(--ff-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.expense-today-total {
  font-family: var(--ff-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--danger);
}

/* ── Auth Overlays ─────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  gap: 20px;
}

.auth-overlay.hidden { display: none; }

.auth-title {
  font-family: var(--ff-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}

.auth-subtitle {
  font-size: 0.95rem;
  color: var(--muted);
  text-align: center;
}

.auth-email-display {
  font-family: var(--ff-mono);
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.auth-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-input {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.auth-input:focus { border-color: var(--accent); }

.auth-error {
  color: var(--danger);
  font-size: 0.88rem;
  min-height: 1.4em;
  text-align: center;
}

.setup-step {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

/* PIN dots */
.pin-dots {
  display: flex;
  gap: 14px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

/* PIN numpad */
.pin-numpad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 10px;
}

.pin-key {
  width: 72px;
  height: 72px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font-family: var(--ff-mono);
  font-size: 1.4rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}

.pin-key:active { background: color-mix(in srgb, var(--accent) 20%, var(--surface)); border-color: var(--accent); }
.pin-key.empty  { border: none; background: none; cursor: default; pointer-events: none; }
.pin-key.backspace { font-size: 1.1rem; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}

.shake { animation: shake 0.4s ease; }

/* ── Settings view ─────────────────────────────────────────────────────── */
.settings-section {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.settings-section-title {
  font-family: var(--ff-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
}

/* ── Expense quick buttons ─────────────────────────────────────────────── */
.expense-quick-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.expense-quick-row::-webkit-scrollbar { display: none; }

.expense-quick-btn {
  flex-shrink: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.82rem;
  padding: 6px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: border-color 0.15s;
  touch-action: manipulation;
}

.expense-quick-btn:active { border-color: var(--accent); }

.expense-quick-price {
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  color: var(--muted);
}

/* ── Compact tab detail form ───────────────────────────────────────────── */
.compact-form-row {
  display: flex;
  gap: 8px;
  align-items: center;
  height: 48px;
}

.compact-qty {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: 48px;
  flex-shrink: 0;
}

.compact-qty-btn {
  width: 44px;
  height: 48px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 300;
  cursor: pointer;
  touch-action: manipulation;
}

.compact-qty-btn:active { background: color-mix(in srgb, var(--accent) 15%, transparent); }

.compact-qty-display {
  width: 36px;
  text-align: center;
  font-family: var(--ff-mono);
  font-size: 1rem;
  font-weight: 600;
}

.compact-price-input {
  flex: 1;
  height: 48px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--ff-mono);
  font-size: 1rem;
  padding: 0 12px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
  width: 100%;
}

.compact-price-input:focus { border-color: var(--accent); }

.entry-form { gap: 10px; }

.pay-close-area {
  padding: 10px 0 4px;
  margin-top: 8px;
}

/* ── Two-column tab detail layout ──────────────────────────────────────── */
.tab-detail-columns {
  display: grid;
  grid-template-columns: 38fr 62fr;
  gap: 20px;
  align-items: start;
}

.tab-summary-col {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: sticky;
  top: 0;
}

.tab-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 10px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.tab-total-bar .tab-subtotal-display {
  font-size: 1.3rem;
}

@media (max-width: 700px) {
  .tab-detail-columns {
    grid-template-columns: 1fr;
  }
  .tab-summary-col {
    position: static;
  }
}
