* { box-sizing: border-box; margin: 0; padding: 0 }

:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --amber: #d97706;
  --slate: #64748b;
  --slate-light: #f1f5f9;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #94a3b8;
  --red: #dc2626;
  --red-light: #fef2f2;
  --purple: #7c3aed;
  --orange: #ea580c;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 8px;
  --sidebar-w: 220px;
}

html { font-size: 16px; background: var(--bg); height: 100%; }
body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════════════════════════════ */

.topbar {
  display: flex; align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 60px;
  flex-shrink: 0;
  z-index: 100;
}
.topbar-left { width: 200px; flex-shrink: 0; }
.topbar-brand {
  font-size: 1.375rem; font-weight: 800; color: var(--primary);
  letter-spacing: -0.03em;
  text-transform: uppercase;
  user-select: none;
}
.topbar-brand span {
  font-weight: 400;
  opacity: 0.5;
}
.topbar-center {
  flex: 1; display: flex; justify-content: center;
}
.topbar-right {
  width: 200px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; justify-content: flex-end;
}
.topbar-user {
  font-family: var(--font); font-size: 0.8125rem; font-weight: 500;
  padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-secondary); cursor: pointer;
}
.topbar-user:hover { background: var(--slate-light); }
.topbar-updated { font-size: 0.6875rem; color: var(--muted); white-space: nowrap; }

/* SEARCH */
.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute; left: 12px; color: var(--muted);
  pointer-events: none; z-index: 1; display: flex; align-items: center;
}
.search-input {
  font-family: var(--font); font-size: 0.8125rem;
  padding: 0 16px 0 36px;
  border: 1.5px solid #94a3b8; border-radius: 999px;
  background: #fff; color: var(--text);
  width: 380px; height: 36px; outline: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.search-input::placeholder { color: var(--slate); }
.search-input:hover { border-color: #64748b; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* SAVE STATUS */
.save-status { font-size: 0.75rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.save-status.saving { color: var(--amber); }
.save-status.saved  { color: var(--green); }
.save-status.error  { color: var(--red); }

/* ═══════════════════════════════════════════════════════════════
   APP SHELL (sidebar + main)
   ═══════════════════════════════════════════════════════════════ */

.app-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════ */

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 12px 0;
  overflow-y: auto;
}
.sidebar-nav {
  display: flex; flex-direction: column; gap: 2px;
  padding: 0 8px;
}
/* Main nav buttons only — bigger targets */
.sidebar-nav:first-child .sidebar-item {
  padding: 16px 14px;
  font-size: 0.875rem;
}
.sidebar-nav:first-child .sidebar-item svg {
  width: 22px; height: 22px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius);
  background: none; border: none;
  font-family: var(--font); font-size: 0.8125rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  width: 100%; text-align: left;
  transition: background 0.12s, color 0.12s, box-shadow 0.15s, transform 0.15s;
}
.sidebar-item svg { color: var(--muted); flex-shrink: 0; }
/* Main nav only — bigger buttons */
.sidebar-nav:first-child {
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar-nav:first-child .sidebar-item {
  padding: 18px 14px;
  font-size: 0.9375rem;
  font-weight: 600;
}
.sidebar-nav:first-child .sidebar-item svg {
  width: 24px; height: 24px;
}
.sidebar-item svg { color: var(--muted); flex-shrink: 0; width: 20px; height: 20px; }
.sidebar-item:hover { background: var(--slate-light); color: var(--text); }
.sidebar-item:hover svg { color: var(--text-secondary); }
.sidebar-item.active {
  background: var(--primary-light); color: var(--primary); font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,0.15);
  transform: translateY(-1px);
}
.sidebar-item.active svg { color: var(--primary); }

.sidebar-section-label {
  font-size: 0.625rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 16px 20px 6px;
}
.sidebar-item-sub {
  display: block; width: 100%; text-align: left;
  background: none; border: none;
  font-family: var(--font); font-size: 0.8125rem; font-weight: 400;
  color: var(--text-secondary); cursor: pointer;
  padding: 6px 12px 6px 40px; border-radius: var(--radius);
}
.sidebar-item-sub:hover { background: var(--slate-light); color: var(--text); }

/* Sidebar dropdown */
.sidebar-dropdown {
  justify-content: flex-start;
}
.sidebar-dropdown-chevron {
  margin-left: auto; color: var(--muted);
  transition: transform 0.15s;
}
.dropdown-open .sidebar-dropdown-chevron {
  transform: rotate(180deg);
}
.sidebar-dropdown-items {
  display: none; flex-direction: column; gap: 1px;
  padding: 2px 0 4px;
}
.dropdown-open .sidebar-dropdown-items {
  display: flex;
}
.sidebar-dropdown-sep {
  height: 1px; background: var(--border); margin: 4px 8px;
}

/* Push Manage nav to bottom (above footer) */
.sidebar-nav:last-of-type {
  margin-top: auto;
}

.sidebar-item-danger { color: var(--muted) !important; opacity: 0.5; }
.sidebar-item-danger:hover { opacity: 0.7; }

/* ═══════════════════════════════════════════════════════════════
   MAIN AREA
   ═══════════════════════════════════════════════════════════════ */

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* PAGE */
.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* PAGE TOOLBAR */
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px 0;
  flex-shrink: 0;
}
.page-title {
  font-size: 1.25rem; font-weight: 700; color: var(--text);
  letter-spacing: -0.01em;
}
.page-actions { display: flex; gap: 8px; align-items: center; }
.btn-add-circle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.btn-add-circle:hover { background: var(--primary-dark); transform: scale(1.05); }
.btn-add-circle:active { transform: scale(0.97); }

/* PAGE BODY */
.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 80px;
  min-height: 0;
}

/* ═══════════════════════════════════════════════════════════════
   STATS STRIP
   ═══════════════════════════════════════════════════════════════ */

.stats-strip {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.75rem; color: var(--muted);
  margin-bottom: 12px;
}
.stat-item { display: inline-flex; align-items: baseline; gap: 3px; }
.stat-num { font-weight: 600; color: var(--text); }
.stat-sep { color: var(--border-strong); margin: 0 4px; }

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */

.btn {
  font-family: var(--font);
  font-size: 0.8125rem; font-weight: 500;
  padding: 7px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-secondary);
  cursor: pointer; line-height: 1.4;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background 0.1s, border-color 0.1s;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-light); border-color: var(--red); }
.btn-ghost { background: none; border: 1px solid transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text-secondary); background: var(--slate-light); }
.btn-ghost:disabled { opacity: 0.4; cursor: default; }
.btn-ghost:disabled:hover { color: var(--muted); background: none; }

/* ═══════════════════════════════════════════════════════════════
   FILTER ROW
   ═══════════════════════════════════════════════════════════════ */

.filter-row td {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.filter-row-inner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-pagination {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  font-size: 0.8125rem; color: var(--text-secondary); white-space: nowrap;
  margin-left: auto;
}
.filter-select {
  font-family: var(--font); font-size: 0.8125rem;
  color: var(--text-secondary); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 28px 6px 12px;
  cursor: pointer; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.filter-select:hover { border-color: var(--border-strong); }
.filter-select:focus { border-color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════
   TABLE
   ═══════════════════════════════════════════════════════════════ */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.inv-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.inv-table thead {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
}
.inv-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); white-space: nowrap; user-select: none;
}
.inv-table th.sortable { cursor: pointer; }
.inv-table th.sortable:hover { color: var(--text-secondary); }
.sort-arrow { font-size: 0.5625rem; color: var(--primary); margin-left: 2px; }
.inv-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.5;
  max-width: 200px;
}
.col-check { width: 40px; text-align: center !important; }
.col-check input { cursor: pointer; }
.col-actions { width: 60px; text-align: center !important; }
.inv-table th.col-actions,
.inv-table th.col-check { cursor: default !important; }

.inv-row { cursor: pointer; transition: background 0.08s; }
.inv-row:hover { background: var(--surface-hover); }
.inv-row.selected { background: var(--primary-light); }
.inv-row:last-child td { border-bottom: none; }

/* PAGINATION */
.pagination-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.pagination-info {
  white-space: nowrap;
}
.pagination-pages {
  display: flex;
  align-items: center;
  gap: 2px;
}
.pagination-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-size: 0.8125rem; font-family: inherit;
  cursor: pointer; transition: background 0.1s, border-color 0.1s;
}
.pagination-btn:hover:not(:disabled) {
  background: var(--slate-light); border-color: var(--border-strong);
}
.pagination-btn:disabled {
  opacity: 0.35; cursor: default;
}
.pagination-btn-active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  font-weight: 600;
}
.pagination-ellipsis {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 32px;
  color: var(--muted); font-size: 0.875rem;
}

.item-name { font-weight: 600; color: var(--text); }
.item-desc-preview { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* STATUS */
.status-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 7px; vertical-align: middle; flex-shrink: 0;
}
.status-badge {
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center;
}

/* SERIAL */
.serial-badge {
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  font-size: 0.75rem; color: var(--text-secondary);
  background: var(--slate-light); padding: 2px 6px; border-radius: 4px;
}

/* OWNER */
.owner-badge { font-size: 0.8125rem; font-weight: 500; color: var(--purple); }
.text-muted { color: var(--muted); font-style: normal; }

/* QUANTITY */
.col-qty { text-align: center !important; width: 56px; }
.qty-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 22px; padding: 0 7px;
  background: var(--primary-light); color: var(--primary);
  font-size: 0.75rem; font-weight: 600; border-radius: 4px;
}
.qty-zero { background: var(--red-light); color: var(--red); }

/* ROW ACTION BUTTONS */
.row-btn {
  width: 28px; height: 28px;
  border: none; border-radius: var(--radius);
  background: transparent; color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.row-btn:hover { background: var(--slate-light); color: var(--text-secondary); }

/* DUPLICATE BANNER */
.duplicate-banner {
  display: flex; align-items: center; gap: 8px;
  background: #fefce8; border: 1px solid #fde68a;
  border-radius: var(--radius); padding: 8px 12px;
  font-size: 0.8125rem; color: var(--amber); margin-bottom: 16px;
}
.duplicate-banner strong { color: var(--text); }

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════ */

.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 64px 32px; text-align: center;
}
.empty-icon {
  color: var(--muted); margin-bottom: 16px; opacity: 0.5;
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--slate-light);
  display: flex; align-items: center; justify-content: center;
}
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-desc { font-size: 0.8125rem; color: var(--muted); margin-bottom: 20px; }

/* ═══════════════════════════════════════════════════════════════
   BULK ACTION BAR
   ═══════════════════════════════════════════════════════════════ */

.bulk-bar {
  position: fixed; bottom: 0; left: var(--sidebar-w); right: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 24px; display: flex; align-items: center; gap: 8px; z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}
.bulk-count { font-size: 0.8125rem; font-weight: 600; color: var(--primary); margin-right: 8px; }

/* ═══════════════════════════════════════════════════════════════
   ITEM PANEL (slide-out from right)
   ═══════════════════════════════════════════════════════════════ */

#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.2);
  z-index: 1000;
  display: flex; justify-content: flex-end;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#modal-overlay.active { pointer-events: auto; opacity: 1; }
.panel-body {
  background: var(--surface);
  border-left: 1px solid var(--border);
  width: 100%; max-width: 860px;
  height: 100vh;
  overflow-y: auto;
  padding: 0;
  position: relative;
  box-shadow: -4px 0 24px rgba(0,0,0,0.06);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
#modal-overlay.active .panel-body {
  transform: translateX(0);
}
.panel-new { border-left: 3px solid var(--green); }
.panel-duplicate { border-left: 3px solid var(--amber); }

/* Panel header bar */
.modal-header-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
}
.modal-header-left {
  display: flex; align-items: center; gap: 16px;
}
.modal-title-sm { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.modal-header-qty {
  display: flex; align-items: center; gap: 6px;
}
.modal-header-qty-label {
  font-size: 0.625rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.modal-header-qty-num {
  font-size: 1rem; font-weight: 700; color: var(--text);
  min-width: 16px; text-align: center;
}

/* Panel inner content */
.panel-content {
  padding: 0;
}

/* ═══════════════════════════════════════════════════════════════
   PANEL FORM ELEMENTS (same visual as before, renamed)
   ═══════════════════════════════════════════════════════════════ */

.modal-top-row {
  display: flex; align-items: flex-start; gap: 20px;
  margin-bottom: 16px; padding: 0 32px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-top-left { flex: 1; min-width: 0; }
.modal-top-right {
  display: flex; gap: 10px; flex-shrink: 0; align-items: flex-start;
  padding-top: 4px;
}
.modal-top-field label {
  display: block; font-size: 0.625rem; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.modal-top-field select {
  font-family: var(--font); font-size: 0.8125rem; color: var(--text);
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 5px 28px 5px 12px; outline: none;
  min-width: 110px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.modal-top-field select:hover { border-color: var(--border-strong); }
.modal-top-field select:focus { border-color: var(--primary); }

.modal-name-input {
  width: 100%; font-family: var(--font); font-size: 1.0625rem; font-weight: 600;
  color: var(--text); background: none; border: 1px solid transparent;
  border-radius: var(--radius); padding: 4px 6px; outline: none;
}
.modal-name-input:hover { border-color: var(--border); }
.modal-name-input:focus { border-color: var(--primary); background: #fff; }

.modal-status-wrap {
  border: 2px solid var(--status-color); border-radius: var(--radius);
  padding: 0; overflow: hidden;
}
.modal-status-select {
  border: none !important; padding: 4px 8px !important;
  min-width: 110px; font-weight: 600 !important;
  background: transparent !important;
}

.modal-subtitle { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.modal-id-tag {
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  font-size: 0.6875rem; color: var(--primary); background: var(--primary-light);
  padding: 2px 6px; border-radius: 4px;
}
.modal-serial-tag {
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  font-size: 0.6875rem; color: var(--slate); background: var(--slate-light);
  padding: 2px 6px; border-radius: 4px;
}
.modal-deleted-tag {
  font-size: 0.6875rem; font-weight: 600; color: var(--red);
  background: var(--red-light); padding: 2px 6px; border-radius: 4px;
}

.modal-footer-bar {
  display: flex; align-items: center;
  padding: 16px 32px 0; border-top: 1px solid var(--border); margin-top: 8px;
}
.modal-footer-left { flex: 1; display: flex; align-items: center; gap: 8px; }
.modal-footer-right { display: flex; align-items: center; gap: 8px; }

/* ═══════════════════════════════════════════════════════════════
   PANEL FORM
   ═══════════════════════════════════════════════════════════════ */

.modal-form { padding: 16px 32px 0; }
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block; font-size: 0.6875rem; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; font-family: var(--font); font-size: 0.8125rem;
  color: var(--text); background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 12px; font-weight: 400;
  text-transform: none; letter-spacing: normal;
}
.form-group select {
  cursor: pointer; outline: none; appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.form-group select:hover { border-color: var(--border-strong); }
.form-group textarea { resize: vertical; min-height: 44px; line-height: 1.5; }
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { outline: none; border-color: var(--primary); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; min-width: 0; }
.form-row-3 .form-group { flex: 1; }

/* QUANTITY DISPLAY + ADJUST */
.qty-display {
  display: flex; align-items: center; gap: 8px;
  height: 36px;
}
.qty-number {
  font-size: 1rem; font-weight: 700; color: var(--text);
  min-width: 20px; text-align: center;
}

.qty-adjust-panel {
  background: var(--slate-light); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
}
.qty-adjust-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 10px;
}
.qty-adj-dir {
  font-family: var(--font); font-size: 0.8125rem; font-weight: 600;
  color: var(--text); background: #fff;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 6px 8px; outline: none; width: 90px;
}
.qty-adj-dir:focus { border-color: var(--primary); }
.qty-adj-amount {
  font-family: var(--font); font-size: 0.875rem; font-weight: 600;
  color: var(--text); background: #fff;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 6px 8px; outline: none; width: 80px; text-align: center;
}
.qty-adj-amount:focus { border-color: var(--primary); }
.qty-adj-reason {
  flex: 1; font-family: var(--font); font-size: 0.8125rem;
  color: var(--text); background: #fff;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 6px 8px; outline: none; min-width: 0;
}
.qty-adj-reason:focus { border-color: var(--primary); }
.qty-adjust-actions {
  display: flex; justify-content: flex-end; gap: 8px;
}

/* SERIAL WARNING */
.serial-warning {
  display: flex; align-items: center; gap: 8px;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius); padding: 8px 12px;
  margin-bottom: 10px; font-size: 0.8125rem; color: var(--amber);
}
.serial-warning svg { flex-shrink: 0; }

/* MODAL SECTION */
.modal-section { border-top: 1px solid var(--border); padding: 14px 32px 0; margin-top: 14px; }
.modal-section-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.8125rem; font-weight: 600; color: var(--text); margin-bottom: 10px;
}
.modal-notes-count {
  font-size: 0.6875rem; font-weight: 500; color: var(--muted);
  padding: 2px 8px; background: var(--slate-light); border-radius: 4px;
}

/* COLLAPSIBLE */
.collapsible-header {
  cursor: pointer; user-select: none;
  padding: 4px 8px; margin: -4px -8px 10px; border-radius: var(--radius);
}
.collapsible-header:hover { background: var(--slate-light); }
.collapsible-label { display: flex; align-items: center; gap: 6px; }
.collapsible-chevron { font-size: 0.6rem; color: var(--muted); }
.collapsible-body { overflow: hidden; max-height: 2000px; opacity: 1; }
.collapsible-body.collapsed { max-height: 0; opacity: 0; margin: 0; }

/* ═══════════════════════════════════════════════════════════════
   HISTORY LIST
   ═══════════════════════════════════════════════════════════════ */

.history-list { list-style: none; }
.history-item {
  padding: 8px 12px; background: var(--slate-light);
  border-radius: var(--radius); margin-bottom: 4px;
  border: 1px solid var(--border);
}
.history-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.history-field { font-size: 0.8125rem; font-weight: 600; color: var(--primary); }
.history-right { display: flex; align-items: center; gap: 6px; }
.history-user { font-size: 0.6875rem; font-weight: 500; color: var(--text-secondary); background: var(--surface); padding: 1px 6px; border-radius: 3px; }
.history-time { font-size: 0.6875rem; color: var(--muted); }
.history-change { font-size: 0.8125rem; display: flex; align-items: center; gap: 6px; }
.history-old { color: var(--red); text-decoration: line-through; opacity: 0.7; }
.history-arrow { color: var(--muted); }
.history-new { color: var(--green); font-weight: 500; }
.history-item-reason { background: #eff6ff; border-color: #bfdbfe; }
.history-qty-change { color: var(--primary); font-weight: 600; font-size: 0.8125rem; }
.history-reason-sep { color: var(--muted); margin: 0 2px; }
.history-reason-text { color: var(--text-secondary); font-style: italic; font-size: 0.8125rem; }

/* ═══════════════════════════════════════════════════════════════
   SECONDARY MODALS (import, manage, bulk edit)
   ═══════════════════════════════════════════════════════════════ */

.modal-overlay-secondary {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,0.25);
  z-index: 1100; justify-content: center; align-items: flex-start;
  padding: 48px 24px; overflow-y: auto;
}
.modal-overlay-secondary.active { display: flex; }
.modal-body-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 540px; padding: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}
#import-overlay .modal-body-secondary {
  max-width: 1200px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
#bulk-edit-overlay .modal-body-secondary {
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════════
   RESET MODAL
   ═══════════════════════════════════════════════════════════════ */

.reset-warning {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; margin-bottom: 16px;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius);
  font-size: 0.8125rem; color: #991b1b; line-height: 1.5;
}
.reset-warning svg { flex-shrink: 0; margin-top: 1px; color: #dc2626; }

.reset-presets {
  display: flex; gap: 8px; margin-bottom: 16px;
}

.reset-groups {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px;
}
.reset-group-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  cursor: pointer; transition: background 0.1s;
}
.reset-group-item:hover { background: var(--slate-light); }
.reset-group-item input[type="checkbox"] {
  margin-top: 2px; accent-color: var(--primary); width: 16px; height: 16px; flex-shrink: 0;
}
.reset-group-info { display: flex; flex-direction: column; gap: 2px; }
.reset-group-name { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.reset-group-desc { font-size: 0.75rem; color: var(--muted); }

.reset-secret-section {
  margin-bottom: 20px;
}
.reset-secret-label {
  display: block; font-size: 0.8125rem; color: var(--text-secondary);
  margin-bottom: 6px;
}
.reset-secret-input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.875rem;
  font-family: inherit; outline: none; transition: border-color 0.15s;
  box-sizing: border-box;
}
.reset-secret-input:focus { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,0.1); }

.reset-actions {
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   BACKUP MODAL
   ═══════════════════════════════════════════════════════════════ */

.backup-status {
  font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 14px;
  padding: 8px 12px; background: var(--slate-light); border-radius: var(--radius);
}
.backup-status-warn {
  background: #fef3c7; color: #92400e; border: 1px solid #fcd34d;
}

.backup-create-btn, .backup-toolbar {
  width: 100%; margin-bottom: 16px;
}
.backup-toolbar {
  display: flex; gap: 8px;
}
.backup-toolbar .btn { flex: 1; justify-content: center; }

.backup-list {
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--radius);
  max-height: 340px; overflow-y: auto; padding: 4px;
}

.backup-empty {
  padding: 24px 16px; text-align: center; font-size: 0.8125rem; color: var(--muted);
}
.backup-empty-error { color: var(--red); }

.backup-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius); transition: background 0.1s;
}
.backup-item:hover { background: var(--slate-light); }

.backup-item-info {
  flex: 1; min-width: 0;
}
.backup-item-name {
  font-size: 0.8125rem; font-weight: 600; color: var(--text);
  word-break: break-all;
}
.backup-item-meta {
  font-size: 0.75rem; color: var(--muted); margin-top: 2px;
}

.backup-item-actions {
  display: flex; gap: 4px; flex-shrink: 0;
}

.backup-restore-confirm {
  flex: 1 1 100%; padding: 12px; margin-top: 4px;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius);
}

.backup-restore-warning {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 0.8125rem; color: #991b1b; line-height: 1.5; margin-bottom: 10px;
}
.backup-restore-warning svg { flex-shrink: 0; margin-top: 1px; color: #dc2626; }

.backup-restore-secret {
  margin-bottom: 10px;
}
.backup-restore-secret label {
  display: block; font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 6px;
}
.backup-restore-secret input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.875rem; font-family: inherit;
  outline: none; box-sizing: border-box;
}
.backup-restore-secret input:focus {
  border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,0.1);
}

.backup-restore-btns {
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   IMPORT
   ═══════════════════════════════════════════════════════════════ */

.import-info { font-size: 0.8125rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px; }
.import-info strong { color: var(--text); font-weight: 600; }
.import-note { font-size: 0.75rem; color: var(--amber); margin-top: 6px; }
.import-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.import-option {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8125rem; color: var(--text); cursor: pointer;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
}
.import-option:hover { background: var(--slate-light); }
.import-option input[type="radio"] { accent-color: var(--primary); }
.import-drop {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px; text-align: center; cursor: pointer;
}
.import-drop:hover { border-color: var(--primary); background: var(--primary-light); }
.import-drop.dragover { border-color: var(--primary); background: var(--primary-light); }
.import-drop-text { color: var(--muted); font-size: 0.8125rem; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.import-drop-text svg { color: var(--border-strong); }
.import-preview-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 0.875rem; }
.import-preview-table { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.import-preview-table table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.import-preview-table th {
  background: var(--slate-light); padding: 6px 10px; text-align: left;
  font-weight: 600; color: var(--muted); font-size: 0.6875rem;
  text-transform: uppercase; letter-spacing: 0.04em;
  position: sticky; top: 0;
}
.import-preview-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.import-result-box {
  margin-top: 16px; background: #f0fdf4;
  border: 1px solid #bbf7d0; border-radius: var(--radius); padding: 16px;
}
.import-success strong { color: var(--green); font-size: 0.9375rem; }
.import-stats { display: flex; gap: 16px; margin-top: 8px; }
.import-stat { font-size: 0.8125rem; font-weight: 500; }
.import-stat.added { color: var(--green); }
.import-stat.updated { color: var(--primary); }
.import-stat.skipped { color: var(--amber); }

/* IMPORT REVIEW TABLE */
.import-review-header { margin-bottom: 12px; }
.import-review-header strong { font-size: 0.9375rem; color: var(--text); }
.import-review-hint { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.import-review-table-wrap { max-height: 65vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.import-review-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.import-review-table th {
  background: var(--slate-light); padding: 6px 8px; text-align: left;
  font-weight: 600; color: var(--text-secondary); font-size: 0.6875rem;
  text-transform: uppercase; letter-spacing: 0.04em;
  position: sticky; top: 0; z-index: 1;
}
.import-review-table td { padding: 2px 4px; border-bottom: 1px solid var(--border); }
.review-th-remove { width: 32px; }
.review-td-remove { text-align: center; }
.review-remove-btn {
  width: 22px; height: 22px; border: none; border-radius: var(--radius);
  background: transparent; color: var(--muted); font-size: 0.875rem;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.review-remove-btn:hover { background: var(--red-light); color: var(--red); }
.review-cell {
  width: 100%; font-family: var(--font); font-size: 0.8125rem;
  color: var(--text); background: transparent; border: 1px solid transparent;
  border-radius: 3px; padding: 4px 6px; outline: none;
}
.review-cell:hover { border-color: var(--border); }
.review-cell:focus { border-color: var(--primary); background: #fff; }
.import-review-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}

/* Import column mapping select */
.import-map-select {
  width: 100%; font-family: var(--font); font-size: 0.8125rem;
  color: var(--text); background: #fff;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 6px 28px 6px 10px; outline: none; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.import-map-select:focus { border-color: var(--primary); }
.import-map-select-unmapped {
  border-color: var(--red) !important;
  background: var(--red-light);
}
.import-map-unmapped td:first-child {
  font-weight: 600;
}

/* Import review table selects */
.import-review-select {
  width: 100%; font-family: var(--font); font-size: 0.8125rem;
  color: var(--text); background: #fff;
  border: 1px solid var(--border); border-radius: 3px;
  padding: 4px 24px 4px 6px; outline: none; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center;
}
.import-review-select:focus { border-color: var(--primary); }
.import-review-invalid {
  border-color: var(--red) !important;
  background: var(--red-light);
  color: var(--red);
  font-weight: 600;
}

/* Duplicate rows in import */
.import-row-dup td { background: #fffbeb; }
.import-dup-banner td { background: #fef3c7; padding: 0 !important; }
.import-dup-inner { padding: 10px 14px; }
.import-dup-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 600; color: #92400e; margin-bottom: 6px;
}
.import-dup-label svg { flex-shrink: 0; color: #d97706; }
.import-dup-orig {
  font-size: 0.8125rem; color: var(--text); margin-bottom: 8px; line-height: 1.5;
}
.import-dup-tag {
  display: inline-block; font-size: 0.625rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--primary-dark); background: var(--primary-light);
  padding: 1px 6px; border-radius: 4px; margin-right: 4px;
}
.import-dup-actions { display: flex; gap: 6px; }
.import-dup-resolved td { padding: 0 !important; }
.import-dup-resolved-inner {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; background: #f0fdf4; border-top: 1px solid #bbf7d0;
}
.import-dup-resolved-label {
  font-size: 0.75rem; font-weight: 600; color: #166534;
  background: #dcfce7; padding: 2px 8px; border-radius: 4px;
}

/* Resizable table columns */
.resizable-th {
  position: relative;
  user-select: none;
}
.resize-handle {
  position: absolute;
  top: 0; right: -2px;
  width: 5px; height: 100%;
  cursor: col-resize;
  z-index: 2;
}
.resize-handle:hover,
.resize-handle.active {
  background: var(--primary);
  opacity: 0.4;
}
.import-resizable {
  table-layout: fixed;
}

/* ═══════════════════════════════════════════════════════════════
   MANAGE LISTS
   ═══════════════════════════════════════════════════════════════ */

.manage-add-row { display: flex; gap: 8px; margin-bottom: 16px; }
.manage-add-row input {
  flex: 1; font-family: var(--font); font-size: 0.8125rem;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px;
}
.manage-add-row input:focus { outline: none; border-color: var(--primary); }
.manage-list { list-style: none; }
.manage-list-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.manage-list-item:last-child { border-bottom: none; }
.manage-list-name { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.manage-list-count {
  font-size: 0.6875rem; font-weight: 600; color: var(--primary);
  background: var(--primary-light); padding: 1px 6px; border-radius: 4px;
  margin-left: 6px;
}
.manage-list-count-zero {
  color: var(--muted); background: var(--slate-light);
}
.manage-list-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.manage-list-contact { font-size: 0.6875rem; color: var(--muted); }
.manage-list-actions { display: flex; gap: 2px; }
.manage-contact-input { flex: 1 !important; max-width: 180px; }
.manage-hint { font-size: 0.75rem; color: var(--muted); margin-bottom: 12px; line-height: 1.4; }
.manage-list-btn {
  width: 28px; height: 28px;
  border: none; border-radius: var(--radius);
  background: transparent; color: var(--muted);
  font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.manage-list-btn:hover { background: var(--slate-light); color: var(--text-secondary); }
.manage-list-btn.btn-del:hover { color: var(--red); background: var(--red-light); }

/* ═══════════════════════════════════════════════════════════════
   LABELS
   ═══════════════════════════════════════════════════════════════ */

.label-options {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px;
}
.label-option-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 16px; text-align: center; cursor: pointer; background: var(--surface);
}
.label-option-card:hover { border-color: var(--primary); background: var(--primary-light); }
.label-option-icon { color: var(--muted); margin-bottom: 8px; }
.label-option-title { font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.label-option-desc { font-size: 0.75rem; color: var(--muted); }

.label-page { padding: 0; }
.label-grid { display: grid; grid-template-columns: repeat(3, 2.5in); gap: 0.15in; justify-content: center; }
.label {
  border: 1px solid #000; border-radius: 4px;
  padding: 0.15in; width: 2.5in; height: 1.5in;
  overflow: hidden; display: flex; flex-direction: column;
}
.label-header { margin-bottom: 4px; }
.label-title { font-size: 9px; font-weight: 700; color: #000; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-model { font-size: 7px; color: #666; }
.label-barcode { text-align: center; margin: 2px 0; flex-shrink: 0; }
.label-barcode svg { max-width: 100%; }
.label-details { font-size: 7px; color: #333; line-height: 1.4; }
.label-field-name { font-weight: 600; }

@media print {
  body > *:not(#label-print-area):not(#forms-print-area) { display: none !important; }
  #label-print-area, #forms-print-area { display: block !important; position: static !important; }
  body { background: #fff !important; margin: 0; padding: 0; }
  .label-page { padding: 0; margin: 0; }
  .label-grid { margin: 0 auto; }
  .label { border-color: #ccc; }
}

/* ═══════════════════════════════════════════════════════════════
   PRINTABLE FORMS
   ═══════════════════════════════════════════════════════════════ */

.form-page {
  width: 8.5in; min-height: 11in;
  padding: 0.45in 0.55in;
  font-family: 'Inter', -apple-system, sans-serif;
  color: #000; background: #fff;
  box-sizing: border-box;
  page-break-after: always;
}
.form-page:last-child { page-break-after: auto; }

.form-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 14px;
}
.form-header-left { display: flex; flex-direction: column; gap: 2px; }
.form-brand { font-size: 1.25rem; font-weight: 700; color: #2563eb; }
/* force date inputs to picker-only, no manual typing */
input[type="date"]::-webkit-datetime-edit { pointer-events: none; }
.form-title { font-size: 1.125rem; font-weight: 600; color: #000; }
.form-subtitle { font-size: 0.6875rem; color: #666; }

.form-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px;
  margin-bottom: 16px; font-size: 0.8125rem;
}
.form-meta-field {
  display: flex; align-items: baseline; gap: 6px;
}
.form-meta-label { font-weight: 600; white-space: nowrap; }
.form-meta-line {
  flex: 1; border-bottom: 1px solid #999; min-width: 80px;
  height: 1.1em;
}

.form-grid {
  width: 100%; border-collapse: collapse; font-size: 0.75rem;
}
.form-grid th {
  border: 1px solid #333; padding: 6px 8px;
  background: #f0f0f0; font-weight: 600; text-align: left;
  font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.form-grid td {
  border: 1px solid #bbb; padding: 0; height: 36px;
  vertical-align: bottom;
}
.form-grid .row-num {
  text-align: center; font-weight: 500; color: #999;
  font-size: 0.625rem; padding: 0 4px; height: 36px;
  vertical-align: middle;
}

.form-footer {
  margin-top: 14px; display: flex; justify-content: space-between;
  font-size: 0.75rem; color: #444;
}
.form-signature {
  display: flex; gap: 40px; margin-top: 20px; font-size: 0.75rem;
}
.form-sig-block {
  display: flex; flex-direction: column; gap: 4px;
}
.form-sig-line {
  width: 180px; border-bottom: 1px solid #000; height: 1px;
}
.form-sig-label { font-size: 0.625rem; color: #666; }

/* Count sheet specifics */
.count-total {
  font-size: 0.8125rem; font-weight: 500; margin-top: 14px;
  padding: 8px 0; border-top: 1px solid #999;
}

/* Intake block layout (each item is a section, not a grid row) */
.intake-block {
  display: flex; gap: 0; margin-bottom: 0;
  border-top: 1px solid #888; overflow: hidden;
  padding: 8px 0 6px;
}
.intake-block:last-child {
  border-bottom: 1px solid #888;
}
.intake-block-num {
  width: 28px; display: flex; align-items: flex-start;
  justify-content: center; padding-top: 2px; font-size: 0.75rem; font-weight: 700;
  color: #999; flex-shrink: 0;
}
.intake-block-body {
  flex: 1; padding: 5px 8px 4px;
}
.intake-row {
  display: flex; gap: 12px; margin-bottom: 3px;
}
.intake-row:last-child { margin-bottom: 0; }
.intake-row-2col .intake-field { flex: 1; }
.intake-row-3col .intake-field { flex: 1; }
.intake-row-3col .intake-field-narrow { flex: 0.5; }
.intake-field {
  display: flex; align-items: baseline; gap: 4px;
}
.intake-field-wide { flex: 1; }
.intake-label {
  font-size: 0.5625rem; font-weight: 600; color: #888;
  text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.intake-line {
  flex: 1; border-bottom: 1px solid #aaa; min-width: 40px; height: 1.1em;
}

/* Forms picker modal */
.form-picker-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 16px;
}
.form-picker-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 16px; text-align: center; cursor: pointer;
  background: var(--surface); transition: border-color 0.1s, background 0.1s;
}
.form-picker-card:hover { border-color: var(--primary); background: var(--primary-light); }
.form-picker-icon { color: var(--muted); margin-bottom: 10px; }
.form-picker-title { font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.form-picker-desc { font-size: 0.75rem; color: var(--muted); line-height: 1.4; }

.form-options { margin-bottom: 16px; }
.form-options label {
  display: block; font-size: 0.8125rem; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 4px;
}
.form-options select, .form-options input {
  font-family: var(--font); font-size: 0.8125rem; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 10px; outline: none; width: 100%;
}
.form-options select:focus, .form-options input:focus { border-color: var(--primary); }
.form-options-row { display: flex; gap: 12px; }
.form-options-row > div { flex: 1; }

/* ═══════════════════════════════════════════════════════════════
   ACTIVITY PAGE
   ═══════════════════════════════════════════════════════════════ */

.activity-filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.activity-search {
  font-family: var(--font); font-size: 0.8125rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 12px; outline: none; width: 200px;
}
.activity-search::placeholder { color: var(--muted); }
.activity-search:focus { border-color: var(--primary); }
.activity-date {
  font-family: var(--font); font-size: 0.75rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 5px 8px; outline: none;
}
.activity-date:focus { border-color: var(--primary); }
.activity-time { font-size: 0.8125rem; color: var(--text-secondary); white-space: nowrap; }
.activity-item { font-weight: 500; }
.activity-field { color: var(--primary); font-weight: 600; font-size: 0.8125rem; }
.activity-old { color: var(--red); font-size: 0.8125rem; }
.activity-new { color: var(--green); font-size: 0.8125rem; font-weight: 500; }
.activity-user { font-size: 0.8125rem; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════════
   REPORTS PAGE
   ═══════════════════════════════════════════════════════════════ */

.reports-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.report-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; min-width: 140px; flex: 1;
}
.report-card-label { font-size: 0.6875rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.report-card-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.report-section { margin-bottom: 24px; }
.report-sections-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.report-section-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.report-section-card .report-table { max-width: none; }
.report-section-title { font-size: 0.8125rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.report-table { width: 100%; max-width: 400px; border-collapse: collapse; font-size: 0.8125rem; }
.report-table td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.report-count { text-align: right; font-weight: 600; color: var(--text); width: 60px; }
.report-group-label { font-size: 0.6875rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding-top: 16px !important; }

/* prompt modal */
#prompt-overlay { align-items: center; }
.prompt-modal { max-width: 440px; padding: 32px; text-align: center; border-radius: 16px; }
.prompt-modal h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: 24px; }
.prompt-modal input[type="text"] {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 1rem; outline: none; font-family: var(--font); margin-bottom: 20px; text-align: center;
}
.prompt-modal input[type="text"]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.prompt-modal-btns { display: flex; gap: 8px; justify-content: center; }
.prompt-modal-btns .btn { padding: 10px 24px; font-size: 0.875rem; }
.prompt-extra { margin-top: 20px; text-align: center; }
.prompt-extra-btn {
  background: none; border: none; color: var(--muted); font-size: 0.75rem;
  font-family: var(--font); cursor: pointer; padding: 4px 8px;
}
.prompt-extra-btn:hover { color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════════
   ACCOUNTS PAGE
   ═══════════════════════════════════════════════════════════════ */

.account-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.account-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: background 0.1s, border-color 0.1s;
}
.account-list-item:hover {
  background: var(--surface-hover); border-color: var(--border-strong);
}
.account-list-info { display: flex; align-items: baseline; gap: 10px; }
.account-list-name { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.account-list-contact { font-size: 0.75rem; color: var(--text-secondary); }
.account-list-right { display: flex; align-items: center; gap: 12px; }
.account-list-count {
  font-size: 0.8125rem; font-weight: 500; color: var(--text);
  min-width: 28px; text-align: center;
}
.account-list-count-zero {
  color: var(--muted);
}
.account-list-arrow { font-size: 1.25rem; color: var(--muted); line-height: 1; }

.account-detail-header {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 12px;
}
.account-detail-name { font-size: 1.125rem; font-weight: 700; color: var(--text); }
.account-detail-contact { font-size: 0.8125rem; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════════
   BULK EDIT MODAL
   ═══════════════════════════════════════════════════════════════ */

.bulk-edit-hint { font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 14px; }
.bulk-edit-batch {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
}
.bulk-edit-batch-label {
  font-size: 0.6875rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px;
}
.bulk-edit-batch-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.bulk-edit-batch-row .form-group { min-width: 130px; margin-bottom: 0; }
.bulk-edit-table-wrap { max-height: 400px; overflow-y: auto; flex: 1; min-height: 0; }
.bulk-edit-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.bulk-edit-table th {
  text-align: left; padding: 8px 10px; font-weight: 600; font-size: 0.6875rem;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}
.bulk-edit-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.bulk-edit-name { font-weight: 500; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.bulk-edit-table select {
  font-family: var(--font); font-size: 0.8125rem; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px 8px; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center;
  padding-right: 24px;
}
.bulk-edit-table select:focus { border-color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════ */

#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  font-size: 0.8125rem; font-weight: 500;
  pointer-events: auto; max-width: 340px;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-visible { transform: translateX(0); }
.toast-icon {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: 700; flex-shrink: 0;
}
.toast-success { border-left: 3px solid #22c55e; }
.toast-success .toast-icon { background: #dcfce7; color: #166534; }
.toast-error   { border-left: 3px solid #ef4444; }
.toast-error .toast-icon   { background: #fef2f2; color: #991b1b; }
.toast-warning { border-left: 3px solid #f59e0b; }
.toast-warning .toast-icon { background: #fef3c7; color: #92400e; }
.toast-info    { border-left: 3px solid #3b82f6; }
.toast-info .toast-icon    { background: #dbeafe; color: #1e40af; }
.toast-message { flex: 1; color: var(--text); }
.toast-close {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 1rem; padding: 0 0 0 8px; line-height: 1;
}
.toast-close:hover { color: var(--text); }

/* ═══════════════════════════════════════════════════════════════
   FILTER CHIPS
   ═══════════════════════════════════════════════════════════════ */

.filter-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 0 4px; min-height: 0;
}
.filter-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  background: var(--primary-light); color: var(--primary-dark);
  border-radius: 999px; font-size: 0.6875rem; font-weight: 600;
  animation: chipIn 0.15s ease;
}
.filter-tag strong { font-weight: 700; }
.filter-tag-remove {
  cursor: pointer; margin-left: 2px; opacity: 0.5;
  font-size: 0.875rem; line-height: 1;
}
.filter-tag-remove:hover { opacity: 1; }

@keyframes chipIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   TOOLTIPS (CSS-only, data-tooltip attribute)
   ═══════════════════════════════════════════════════════════════ */

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%) scale(0.9);
  padding: 4px 8px; background: #1e293b; color: #fff;
  font-size: 0.6875rem; font-weight: 500; border-radius: 4px;
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity 0.15s, transform 0.15s; z-index: 100;
}
[data-tooltip]:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }

/* ═══════════════════════════════════════════════════════════════
   MICRO-INTERACTIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.inv-row { animation: rowFadeIn 0.2s ease backwards; }
.inv-row:nth-child(1)  { animation-delay: 0ms; }
.inv-row:nth-child(2)  { animation-delay: 12ms; }
.inv-row:nth-child(3)  { animation-delay: 24ms; }
.inv-row:nth-child(4)  { animation-delay: 36ms; }
.inv-row:nth-child(5)  { animation-delay: 48ms; }
.inv-row:nth-child(n+6) { animation-delay: 60ms; }

.btn { transition: background 0.1s, border-color 0.1s, transform 0.1s; }
.btn:active { transform: scale(0.97); }

/* ═══════════════════════════════════════════════════════════════
   CATEGORY COMBOBOX
   ═══════════════════════════════════════════════════════════════ */

.cat-combo {
  position: relative;
}
.cat-combo-input {
  width: 100%;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8125rem;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.cat-combo-input:focus {
  border-color: var(--primary);
}
.cat-combo-disabled .cat-combo-input {
  background: var(--bg-hover);
  color: var(--muted);
  pointer-events: none;
}
.cat-combo-chevron {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.cat-combo-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 100;
}
.cat-combo-dropdown.open {
  display: block;
}
.cat-combo-group {
  padding: 6px 10px 3px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: default;
}
.cat-combo-option {
  padding: 5px 10px;
  font-size: 0.8125rem;
  cursor: pointer;
  color: var(--text);
}
.cat-combo-option.cat-combo-sub {
  padding-left: 22px;
  color: var(--text-secondary);
}
.cat-combo-new {
  color: var(--primary) !important;
  border-top: 1px solid var(--border);
}
.cat-combo-option:hover {
  background: var(--bg-hover);
}
.cat-combo-empty {
  padding: 10px;
  font-size: 0.8125rem;
  color: var(--muted);
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   PAGES — MAX WIDTH (Accounts, Categories, Locations list only)
   ═══════════════════════════════════════════════════════════════ */

.page-accounts .account-list,
.page-locations .account-list {
  max-width: 680px;
}
.page-categories .cat-two-col {
  max-width: 920px;
}

/* ═══════════════════════════════════════════════════════════════
   CATEGORIES PAGE — TWO-COLUMN LAYOUT
   ═══════════════════════════════════════════════════════════════ */

.cat-two-col {
  display: flex; gap: 0; align-items: flex-start;
}

.cat-col {
  flex: 0 0 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cat-col-subs {
  flex: 1; min-width: 0;
  overflow: visible;
}
.cat-subs-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; cursor: pointer;
  transition: background 0.1s;
}
.cat-row:hover { background: var(--surface-hover); }
.cat-row-selected {
  background: var(--primary-light);
}
.cat-row-selected:hover { background: var(--primary-light); }

.cat-row-info { display: flex; align-items: center; gap: 8px; }
.cat-row-name { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.cat-row-sub .cat-row-name { font-weight: 500; color: var(--text-secondary); }

.cat-row-badge {
  font-size: 0.625rem; color: var(--muted);
  background: var(--bg); padding: 1px 6px; border-radius: 4px;
}

.cat-row-right { display: flex; align-items: center; gap: 6px; }
.cat-row-count { font-size: 0.8125rem; color: var(--muted); }
.cat-row-arrow { transition: transform 0.15s; }
.cat-row-selected .cat-row-arrow { transform: rotate(0deg); color: var(--primary); }

.cat-row-sub {
  border-top: 1px solid var(--border);
}
.cat-row-sub:first-child { border-top: none; }

.cat-row-add {
  display: block; width: 100%; border: none; background: none;
  padding: 10px 16px; text-align: left;
  font-size: 0.8125rem; color: var(--primary); cursor: pointer;
  border-top: 1px solid var(--border);
  transition: background 0.1s;
}
.cat-row-add:hover { background: var(--bg-hover); }

.cat-group-header {
  padding: 8px 16px 4px;
  font-size: 0.6875rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Legacy classes used by accounts/locations pages */
.cat-groups { display: flex; flex-direction: column; }
.cat-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cat-group + .cat-group { margin-top: 8px; }
.cat-parent {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; cursor: pointer;
  transition: background 0.1s;
}
.cat-parent:hover { background: var(--surface-hover); }
.cat-parent-info { display: flex; align-items: center; gap: 8px; }
.cat-parent-name { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.cat-parent-subs { font-size: 0.6875rem; color: var(--muted); background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.cat-parent-right { display: flex; align-items: center; gap: 6px; }
.cat-parent-count { font-size: 0.8125rem; color: var(--muted); }
.cat-sub {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 16px 9px 28px; cursor: pointer;
  border-top: 1px solid var(--border);
  transition: background 0.1s;
}
.cat-sub:hover { background: var(--surface-hover); }
.cat-sub-info { display: flex; align-items: center; gap: 8px; }
.cat-sub-name { font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); }
.cat-sub-right { display: flex; align-items: center; gap: 6px; }
.cat-sub-count { font-size: 0.8125rem; color: var(--muted); }

/* ═══════════════════════════════════════════════════════════════
   LIST ITEM DROPDOWN MENU
   ═══════════════════════════════════════════════════════════════ */

.list-menu-wrap {
  position: relative;
}
.list-menu-trigger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: none; background: none;
  border-radius: var(--radius); font-size: 1.125rem; line-height: 1;
  color: var(--muted); cursor: pointer; transition: background 0.1s, color 0.1s;
}
.list-menu-trigger:hover { background: var(--bg-hover); color: var(--text); }
.list-menu-dropdown {
  display: none; position: absolute; right: 0; top: 100%;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  min-width: 120px; z-index: 50; padding: 4px 0;
}
.list-menu-wrap.open .list-menu-dropdown { display: block; }
.list-menu-item {
  display: block; width: 100%; text-align: left;
  padding: 7px 14px; border: none; background: none;
  font-family: var(--font); font-size: 0.8125rem; color: var(--text);
  cursor: pointer;
}
.list-menu-item:hover { background: var(--bg-hover); }
.list-menu-item-danger { color: var(--danger); }
.list-menu-item-danger:hover { background: var(--red-light); }

/* ═══════════════════════════════════════════════════════════════
   DELETE CONFIRM DIALOG
   ═══════════════════════════════════════════════════════════════ */

.delete-confirm-body { padding: 4px 0; }
.delete-confirm-msg {
  font-size: 0.875rem; color: var(--text); line-height: 1.5;
  margin: 0 0 16px;
}
.delete-confirm-options {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 20px;
}
.delete-confirm-option {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8125rem; color: var(--text); cursor: pointer;
}
.delete-confirm-option input[type="radio"] { flex-shrink: 0; }
.delete-confirm-select,
.delete-confirm-input {
  flex: 1; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.8125rem;
  background: var(--bg); color: var(--text); outline: none;
  max-width: 220px;
}
.delete-confirm-select:focus,
.delete-confirm-input:focus { border-color: var(--primary); }
.delete-confirm-actions {
  display: flex; gap: 8px; justify-content: flex-end;
}
.btn-danger {
  background: var(--red); color: #fff; border-color: var(--red);
}
.btn-danger:hover { background: #dc2626; }

/* Status color picker in manage modal */
.manage-color-input {
  width: 32px; height: 32px; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; background: none;
}

.category-subs-bar {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 0 12px; list-style: none; margin: 0;
}
.category-subs-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 0.8125rem; color: var(--text); cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.category-subs-pill:hover {
  background: var(--bg-hover); border-color: var(--border-strong);
}
.category-subs-count {
  font-size: 0.6875rem; color: var(--muted);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .sidebar { display: none; }
  .bulk-bar { left: 0; }
  .page-body { padding: 12px 16px 80px; }
  .table-wrap { overflow-x: auto; }
  .inv-table { min-width: 760px; }
  .label-grid { grid-template-columns: repeat(2, 2.5in); }
}
