/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --topbar-h: 58px;
  --banner-h: 46px;
  --primary: #1d6fbd;
  --primary-dark: #155a99;
  --primary-light: #e8f1fb;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --fridge-color: #0891b2;
  --dry-color: #d97706;
  --cleaning-color: #7c3aed;
  --header-bg: #1e3a5f;
  /* Category header row colours (like Excel bold rows) */
  --cat-bg: #c8daee;
  --cat-text: #1e3a5f;
  --cat-border: #8aaed4;
  --row-even: #f7f9fc;
  --row-odd: #ffffff;
}

html,
body {
  height: 100%;
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  overflow-x: hidden;
}

input,
textarea,
select {
  direction: ltr;
  unicode-bidi: isolate-override;
}

/* ===== TOPBAR ===== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--header-bg);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-left i {
  color: #60a5fa;
  font-size: 22px;
}
.app-title {
  letter-spacing: -0.3px;
}
.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.cat-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 10px;
}
.cat-tab {
  padding: 6px 16px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.cat-tab:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}
.cat-tab.active {
  background: white;
  color: var(--header-bg);
  font-weight: 600;
}
.cat-tab i {
  font-size: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
}
.btn-primary {
  background: #2563eb;
  color: white;
}
.btn-primary:hover {
  background: #1d4ed8;
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.22);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn-outline {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover {
  background: var(--gray-50);
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #b91c1c;
}

/* ===== SESSION BANNER ===== */
.session-banner {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  z-index: 90;
  height: var(--banner-h);
  background: var(--gray-800);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.session-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-400);
  white-space: nowrap;
  flex-shrink: 0;
}
.session-info i {
  color: #60a5fa;
}
.session-cols {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.col-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 3px 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  min-width: 120px;
}
.col-pair .pair-header {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
}
.col-pair .pair-label-tag {
  font-size: 10px;
  font-weight: 700;
  color: #93c5fd;
  white-space: nowrap;
}
.col-pair .pair-by {
  font-size: 9px;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}
.col-pair .pair-sub {
  display: flex;
  gap: 5px;
  width: 100%;
}
.col-pair .pair-sub span {
  flex: 1;
  text-align: center;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.col-pair .pair-sub .del-lbl {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}
.col-pair .pair-sub .inv-lbl {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}

/* ===== MAIN ===== */
.main {
  margin-top: calc(var(--topbar-h) + var(--banner-h));
  padding: 16px;
}

/* ===== SECTIONS ===== */
.inv-section {
  display: none;
}
.inv-section.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}
#section-fridge .section-header h2 i {
  color: var(--fridge-color);
}
#section-dry .section-header h2 i {
  color: var(--dry-color);
}
#section-cleaning .section-header h2 i {
  color: var(--cleaning-color);
}
.section-actions {
  display: flex;
  gap: 8px;
}

/* ===== TABLE WRAPPER ===== */
.table-wrap {
  background: white;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  overflow: auto;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

/* ===== INVENTORY TABLE ===== */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Sticky column headers */
.inv-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  color: white;
  padding: 9px 8px;
  font-weight: 600;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}
.inv-table thead th.th-product {
  text-align: left;
  padding-left: 14px;
  min-width: 220px;
  position: sticky;
  top: 0;
  left: 0;
  z-index: 20;
  background: var(--header-bg);
}
.inv-table thead th.th-pair {
  background: #154070;
  min-width: 110px;
}
.inv-table thead th.th-pair.th-session {
  border-left: 3px solid rgba(255, 255, 255, 0.3);
}
.inv-table thead th.th-pair.th-empty {
  color: rgba(255, 255, 255, 0.25);
  background: #2a3a50;
}

/* Sub-header row — shows Del date / Inv date per column */
.inv-table .sub-header th {
  background: var(--gray-800);
  font-size: 10px;
  padding: 3px 6px;
  color: var(--gray-300);
  font-weight: 500;
  text-align: center;
  border-top: none;
  vertical-align: middle;
}
.inv-table .sub-header th.th-product {
  background: var(--gray-800);
  text-align: left;
  padding-left: 14px;
  color: var(--gray-500);
}
.inv-table .sub-header th.del-sub {
  background: #2d1a00;
}
.inv-table .sub-header th.inv-sub {
  background: #002d1a;
}
.inv-table .sub-header th.session-divider {
  border-left: 3px solid rgba(255, 255, 255, 0.15);
}
/* Two-line sub-header: type label + date */
.inv-table .sub-header th .sub-type {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 1px;
}
.inv-table .sub-header th.del-sub .sub-type {
  color: #fbbf24;
}
.inv-table .sub-header th.inv-sub .sub-type {
  color: #34d399;
}
.inv-table .sub-header th .sub-date {
  display: block;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.55);
}

/* ===================================================
   CATEGORY HEADER ROWS — matches bold rows in Excel
   Bold text, coloured background, NO inputs
=================================================== */
.inv-table tr.row-cat-header td {
  background: var(--cat-bg) !important;
  color: var(--cat-text);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 14px;
  letter-spacing: 0.02em;
  border-top: 2px solid var(--cat-border);
  border-bottom: 1px solid var(--cat-border);
}

/* Category header inner layout */
.cat-header-name {
  display: inline;
}

/* "+ Add item" button on category header row — always visible */
.btn-add-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  padding: 3px 10px;
  border: 1px solid var(--cat-border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--cat-text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  vertical-align: middle;
  min-height: 28px; /* comfortable tap target */
}
.btn-add-item:hover,
.btn-add-item:active {
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary);
}
.btn-add-item i {
  font-size: 9px;
}

/* ===== PRODUCT NAME CELL ===== */
.inv-table td.td-product {
  padding: 3px 8px 3px 28px; /* indent like Excel sub-items */
  font-weight: 400;
  font-size: 13px;
  color: var(--gray-800);
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: inherit;
  z-index: 5;
  min-width: 220px;
  border-right: 1px solid var(--gray-200);
}

/* Inner flex wrapper for name + action button */
.td-product-inner {
  display: flex;
  align-items: center;
  gap: 0;
}

.td-product .item-sku {
  font-size: 10px;
  color: var(--gray-400);
  font-weight: 400;
  display: inline;
  margin-left: 6px;
}
.td-product .item-note {
  font-size: 10px;
  color: #d97706;
  font-weight: 400;
  display: block;
  font-style: italic;
  margin-top: 1px;
}

/* Edit button (pencil) — custom items only — always visible */
.btn-edit-item {
  flex-shrink: 0;
  margin-left: 6px;
  width: 30px;
  height: 30px; /* generous tap target */
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--gray-50);
  color: var(--primary);
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.btn-edit-item:hover,
.btn-edit-item:active {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* Insert-after "+" button — hardcoded items — visible but unobtrusive */
.btn-insert-after {
  flex-shrink: 0;
  margin-left: 6px;
  width: 28px;
  height: 28px; /* generous tap target */
  border: 1px dashed var(--gray-300);
  border-radius: 5px;
  background: transparent;
  color: var(--gray-300);
  font-size: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}
.btn-insert-after:hover,
.btn-insert-after:active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  border-style: solid;
}

/* Custom item row — subtle left accent */
.inv-table tr.custom-item-row td.td-product {
  border-left: 3px solid #60a5fa;
  padding-left: 25px;
}

/* ===== DATA CELLS ===== */
.inv-table td.td-val {
  padding: 3px 4px;
  text-align: center;
  vertical-align: middle;
  border-right: 1px solid var(--gray-100);
  width: 58px;
}
.inv-table td.td-val.session-divider {
  border-left: 3px solid var(--gray-300);
}
.inv-table td.td-empty {
  background: var(--gray-50) !important;
}

/* ===== ROW STRIPING ===== */
.inv-table tbody tr:nth-child(even) td {
  background: var(--row-even);
}
.inv-table tbody tr:nth-child(odd) td {
  background: var(--row-odd);
}
.inv-table tbody tr:not(.row-cat-header):hover td {
  background: #eff6ff !important;
}
/* Category header rows always override striping */
.inv-table tr.row-cat-header td {
  background: var(--cat-bg) !important;
}

/* ===== QTY CELL — display/edit toggle ===== */
.qty-cell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  min-height: 30px;
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  cursor: text;
  background: transparent;
  transition:
    border-color 0.15s,
    background 0.15s;
}

/* Coloured states */
.qty-cell.has-del {
  border-color: #f59e0b;
  background: #fffbeb;
}
.qty-cell.has-inv {
  border-color: #10b981;
  background: #ecfdf5;
}
.qty-cell:focus-within {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(29, 111, 189, 0.15);
}

/* Display span — shown when not editing */
.qty-display {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-800);
  line-height: 1;
  padding: 2px 3px;
  pointer-events: none;
  user-select: none;
}
.qty-cell.has-del .qty-display {
  color: #92400e;
}
.qty-cell.has-inv .qty-display {
  color: #065f46;
}

/* Input — sits over the display, transparent until editing */
.qty-cell .qty-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 5px;
  background: transparent;
  text-align: center;
  direction: ltr !important;
  unicode-bidi: isolate-override !important;
  font-size: 13px;
  font-weight: 500;
  color: transparent; /* text invisible until editing */
  caret-color: var(--gray-800);
  outline: none;
  padding: 0 3px;
  cursor: text;
  /* always interactive — no pointer-events:none */
}
.qty-cell.editing .qty-input {
  color: var(--gray-800); /* text visible when editing */
}
.qty-cell.editing .qty-display {
  opacity: 0;
  pointer-events: none;
}
.qty-cell.has-del .qty-input {
  caret-color: #92400e;
}
.qty-cell.has-inv .qty-input {
  caret-color: #065f46;
}
.qty-input::placeholder {
  color: var(--gray-300);
  font-size: 10px;
}

/* Placeholder dash */
.qty-placeholder {
  color: var(--gray-300);
  font-size: 12px;
  font-weight: 400;
}

/* ===== FRACTION STYLING ===== */
/* Whole number part — normal size */
.qty-whole {
  font-size: 13px;
  font-weight: 600;
  margin-right: 2px;
}

/* Fraction container — sits to the right of whole number */
.qty-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  margin-left: 1px;
  position: relative;
  top: -1px;
}
.qty-num {
  border-bottom: 1px solid currentColor;
  padding: 0 1px;
  line-height: 1.1;
}
.qty-slash {
  display: none;
} /* hidden — we use stacked layout */
.qty-den {
  padding: 0 1px;
  line-height: 1.1;
}

/* Colour the fraction part slightly muted vs whole */
.qty-cell.has-del .qty-frac {
  color: #b45309;
}
.qty-cell.has-inv .qty-frac {
  color: #047857;
}
.qty-cell:not(.has-del):not(.has-inv) .qty-frac {
  color: var(--gray-500);
}

/* Plain decimal/whole */
.qty-plain {
  font-size: 13px;
  font-weight: 500;
}

/* ===== TOUCH: bigger tap target ===== */
@media (pointer: coarse) {
  .qty-cell {
    width: 58px;
    min-height: 36px;
  }
  .qty-cell .qty-input {
    font-size: 15px;
  }
  .qty-display {
    font-size: 14px;
  }
  .qty-whole {
    font-size: 14px;
  }
  .qty-frac {
    font-size: 10px;
  }
}

/* ===== LOADING ===== */
.loading-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--gray-400);
  gap: 10px;
  font-size: 15px;
}

/* ===== SESSIONS MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.open {
  display: flex;
}
.modal {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-header h2 i {
  color: var(--primary);
}
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px;
}
.modal-close:hover {
  color: var(--gray-700);
}
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.help-text {
  color: var(--gray-500);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.help-text strong {
  color: var(--gray-700);
}

.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.no-sessions {
  color: var(--gray-400);
  font-size: 13px;
  text-align: center;
  padding: 16px;
}

.session-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-50);
  gap: 10px;
}
.session-item.active-session {
  border-color: #93c5fd;
  background: var(--primary-light);
}
.session-item-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.session-item-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.session-by {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 400;
}
.session-item-dates {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
}
.del-chip {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.inv-chip {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}
.del-chip i,
.inv-chip i {
  font-size: 9px;
}
.session-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: flex-start;
}
.session-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: #dbeafe;
  color: #1d4ed8;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.add-session-form {
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}
.add-session-form h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 6px;
}
.add-session-form h4 i {
  color: var(--primary);
}

/* Date pair row — Delivery vs Inventory side by side */
.form-row-dates {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.date-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 2px solid;
}
.date-block-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase;
}
.del-date-block {
  border-color: #fde68a;
  background: #fffdf0;
}
.del-date-block .date-block-label {
  color: #92400e;
}
.inv-date-block {
  border-color: #6ee7b7;
  background: #f0fdf9;
}
.inv-date-block .date-block-label {
  color: #065f46;
}
.date-block input[type="date"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 7px;
  font-size: 13px;
  outline: none;
  background: white;
}
.date-block input[type="date"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(29, 111, 189, 0.12);
}
.date-block-divider {
  color: var(--gray-400);
  font-size: 14px;
  flex-shrink: 0;
  padding-top: 20px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.form-row-meta {
  margin-top: 4px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
}
.form-group label .optional {
  color: var(--gray-400);
  font-weight: 400;
}
.form-group input {
  padding: 7px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 7px;
  font-size: 13px;
  outline: none;
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(29, 111, 189, 0.12);
}

/* ===== ITEM MODAL ===== */
.modal-sm {
  max-width: 480px;
}

.item-modal-category-pill {
  margin-bottom: 14px;
}
.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 600;
}
.cat-pill i {
  font-size: 11px;
}

.form-row-2col {
  grid-template-columns: 1fr 1fr;
}

.required {
  color: var(--danger);
  font-weight: 700;
}

.item-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
  margin-top: 4px;
}

.btn-danger-outline {
  background: white;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger-outline:hover {
  background: #fef2f2;
}

.btn-ghost-dark {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-ghost-dark:hover {
  background: var(--gray-200);
}

/* ===== STORAGE MODE BADGE ===== */
.storage-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.storage-badge.local {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}
.storage-badge i {
  font-size: 10px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  padding: 11px 18px;
  border-radius: 8px;
  background: var(--gray-900);
  color: white;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 340px;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.toast.success {
  background: var(--success);
}
.toast.error {
  background: var(--danger);
}
.toast.warning {
  background: var(--warning);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .app-title {
    display: none;
  }
  .cat-tab {
    padding: 6px 10px;
    font-size: 12px;
  }
  .session-cols {
    display: none;
  }
}
@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  .main {
    padding: 10px;
  }
}

/* ===== TOUCH / TABLET (pointer: coarse = no fine mouse) ===== */
@media (pointer: coarse) {
  /* Bigger qty cells — easier to tap */
  .qty-cell {
    width: 62px;
    min-height: 38px;
  }
  .qty-display {
    font-size: 15px;
  }
  .qty-whole {
    font-size: 15px;
  }
  .qty-frac {
    font-size: 11px;
  }
  .qty-cell .qty-input {
    font-size: 16px;
  }

  /* Bigger row action buttons */
  .btn-edit-item {
    width: 36px;
    height: 36px;
    font-size: 13px;
  }
  .btn-insert-after {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }
  .btn-add-item {
    padding: 5px 14px;
    font-size: 12px;
    min-height: 32px;
  }

  /* Bigger tab buttons */
  .cat-tab {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* Taller table rows so items don't feel cramped */
  .inv-table tbody tr td {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  /* Larger modal form inputs & buttons */
  .form-group input,
  .date-block input[type="date"],
  select#itemSortAfter {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
    padding: 10px 12px;
    min-height: 44px;
  }
  .btn {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 14px;
  }
  .btn-sm {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 13px;
  }
  .modal-close {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  /* Larger session remove / edit buttons */
  .session-item-actions .btn {
    min-height: 40px;
  }
  /* Scrollbars hidden on touch (not useful) */
  ::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .topbar,
  .session-banner,
  .section-actions,
  #exportPdfBtn,
  #manageSessionsBtn {
    display: none !important;
  }
  .main {
    margin-top: 0;
    padding: 0;
  }
  body {
    background: white;
    font-size: 11px;
  }
  .inv-section {
    display: block !important;
    page-break-after: always;
  }
  .inv-table {
    font-size: 10px;
  }
  .qty-cell {
    border: none !important;
    background: none !important;
    min-height: unset;
  }
  .qty-cell .qty-input {
    display: none;
  }
  .qty-display {
    font-size: 9px;
    opacity: 1 !important;
  }
  .qty-frac {
    font-size: 7px;
  }
  .qty-whole {
    font-size: 9px;
  }
  .table-wrap {
    border: none;
    box-shadow: none;
    overflow: visible;
  }
  .inv-table tr.row-cat-header td {
    background: #c8daee !important;
    -webkit-print-color-adjust: exact;
  }
}

/* ===== CUSTOM KEYPAD (Mobile/Tablet) ===== */
.custom-keypad {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 2px solid var(--gray-200);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  z-index: 99999; /* Increased z-index */
  transform: translateY(100%);
  transition: transform 0.3s ease;
  display: none;
}

.custom-keypad.show {
  transform: translateY(0);
  display: block;
}

.keypad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.keypad-title {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 14px;
}

.keypad-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--gray-500);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.keypad-close:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

.keypad-keys {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 16px;
}

.keypad-key {
  height: 48px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: white;
  color: var(--gray-700);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.keypad-key:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.keypad-key:active {
  background: var(--gray-100);
  transform: scale(0.98);
}

.keypad-key.keypad-space {
  grid-column: span 2;
  font-family: monospace;
}

.keypad-key.keypad-zero {
  grid-column: span 2;
}

.keypad-key.keypad-backspace,
.keypad-key.keypad-clear,
.keypad-key.keypad-enter {
  background: var(--gray-100);
  border-color: var(--gray-400);
  font-weight: 600;
}

.keypad-key.keypad-backspace:hover,
.keypad-key.keypad-clear:hover,
.keypad-key.keypad-enter:hover {
  background: var(--gray-200);
}

.keypad-key.keypad-enter {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.keypad-key.keypad-enter:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
