/* ======================================================
   Brewery Distribution Manager — Styles
   ====================================================== */

:root {
  --sidebar-bg:      #1a2f23;
  --sidebar-hover:   #2d4a35;
  --sidebar-active:  #e07b00;
  --sidebar-text:    #c8e6c9;
  --sidebar-sub:     #7fa98a;
  --sidebar-width:   220px;

  --accent:          #e07b00;
  --accent-hover:    #c46900;
  --accent-light:    #fff3e0;

  --green-dark:      #1b5e20;
  --green-mid:       #2e7d32;
  --green-light:     #e8f5e9;

  --bg:              #f2f5f2;
  --card-bg:         #ffffff;
  --border:          #dde5dd;
  --border-light:    #eef2ee;

  --text:            #1a2414;
  --text-secondary:  #5a6e52;
  --text-muted:      #8fa882;

  --success-bg:      #e8f5e9;
  --success-text:    #1b5e20;
  --warning-bg:      #fff8e1;
  --warning-text:    #e65100;
  --danger-bg:       #fce4ec;
  --danger-text:     #b71c1c;
  --info-bg:         #e3f2fd;
  --info-text:       #0d47a1;
  --neutral-bg:      #f5f5f5;
  --neutral-text:    #616161;

  --radius:          8px;
  --radius-sm:       4px;
  --shadow:          0 2px 6px rgba(0,0,0,0.08);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.16);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────── */

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

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
  font-size: 28px;
  line-height: 1;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 11px;
  color: var(--sidebar-sub);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.nav-item .nav-icon {
  font-size: 8px;
  opacity: 0.5;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

/* ── Submenu ─────────────────────────────────────────── */

.nav-group { position: relative; }

.nav-item.has-submenu { justify-content: flex-start; }

.nav-arrow {
  margin-left: auto;
  font-size: 10px;
  opacity: 0.5;
  transition: transform 0.2s;
}

.nav-group.open > .nav-item .nav-arrow {
  transform: rotate(90deg);
}

.nav-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
  background: rgba(0,0,0,0.15);
}

.nav-group.open > .nav-submenu {
  max-height: 200px;
}

.nav-subitem {
  display: block;
  padding: 7px 18px 7px 38px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 400;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.nav-subitem:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-subitem.active {
  color: #fff;
  font-weight: 600;
  background: rgba(224,123,0,0.25);
}

/* ── Location Switcher ───────────────────────────────── */

.location-switcher {
  display: flex;
  gap: 4px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.loc-btn {
  flex: 1;
  padding: 5px 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  color: var(--sidebar-text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loc-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.loc-btn.active {
  background: var(--sidebar-active);
  border-color: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar-user {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-photo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255,255,255,0.1);
}

.sidebar-user-info {
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 10px;
  color: var(--sidebar-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--sidebar-sub);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--sidebar-sub);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
  transition: color .15s;
}

.btn-logout:hover {
  color: var(--sidebar-text);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.connected  { background: #66bb6a; }
.status-dot.error      { background: #ef5350; }
.status-dot.warning    { background: #ffa726; }

/* ── Main Content ─────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
}

.content-area {
  padding: 28px 32px;
  max-width: 1200px;
}

/* ── Setup Banner ─────────────────────────────────────── */

.setup-banner {
  background: #fff3e0;
  border-bottom: 2px solid #ff9800;
  position: sticky;
  top: 0;
  z-index: 200;
}

.setup-banner-inner {
  max-width: 1200px;
  margin: 0 auto 0 var(--sidebar-width);
  padding: 10px 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #e65100;
  flex-wrap: wrap;
}

.setup-banner-inner strong { font-weight: 700; }
.setup-banner-inner code {
  background: rgba(0,0,0,0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
}

/* ── View Header ─────────────────────────────────────── */

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}

.view-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.view-header .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

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

/* ── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border-light); }
.btn-success   { background: var(--green-mid); color: #fff; }
.btn-success:hover { background: var(--green-dark); }
.btn-danger    { background: #c62828; color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-ghost     { background: transparent; color: var(--text-secondary); border: none; padding: 4px 8px; }
.btn-ghost:hover { background: var(--border-light); color: var(--text); }
.btn-sm        { padding: 4px 10px; font-size: 12px; }
.btn-light     { background: rgba(255,255,255,0.2); color: inherit; border: 1px solid rgba(255,255,255,0.3); }
.btn-light:hover { background: rgba(255,255,255,0.35); }

/* ── Cards ────────────────────────────────────────────── */

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* ── Stat Cards ───────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  border-left: 4px solid var(--green-mid);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}

.stat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.stat-card.accent  { border-left-color: var(--accent); }
.stat-card.warning { border-left-color: #ffa726; }
.stat-card.danger  { border-left-color: #e53935; }

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--green-dark);
  line-height: 1;
}

.stat-card.accent  .stat-value { color: var(--accent); }
.stat-card.warning .stat-value { color: #e65100; }
.stat-card.danger  .stat-value { color: #c62828; }

.stat-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* ── Dashboard Grid ────────────────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.dashboard-grid .card.full-width {
  grid-column: 1 / -1;
}

.dash-list { list-style: none; }

.dash-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.dash-list li.clickable {
  cursor: pointer;
  border-radius: 4px;
  padding: 8px 6px;
  margin: 0 -6px;
  transition: background 0.12s;
}

.dash-list li.clickable:hover {
  background: var(--hover-bg, #f5f5f5);
}

.dash-list li:last-child { border-bottom: none; }

.dash-list .dash-label {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-list .dash-meta {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

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

/* ── Filter Bar ─────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar input,
.filter-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--accent);
}

.filter-bar input[type="search"] { min-width: 200px; }

/* ── Table ────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card-bg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: #f7faf7;
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

thead th.sortable-th {
  cursor: pointer;
  user-select: none;
}
thead th.sortable-th:hover { color: var(--primary); background: #eef5ee; }
thead th.sorted { color: var(--primary); }

.td-link {
  cursor: pointer;
  color: var(--green-dark);
}
.td-link:hover { text-decoration: underline; }

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

tbody td {
  padding: 9px 14px;
  color: var(--text);
  vertical-align: middle;
}

.note-cell { max-width: 320px; }
.note-text { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.note-toggle { color: var(--primary); font-size: 11px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.note-toggle:hover { text-decoration: underline; }

.td-actions {
  display: flex;
  gap: 4px;
  white-space: nowrap;
}

/* ── Badges ────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-active    { background: var(--success-bg); color: var(--success-text); }
.badge-prospect  { background: var(--info-bg);    color: var(--info-text); }
.badge-inactive  { background: var(--neutral-bg); color: var(--neutral-text); }

.badge-email     { background: #e3f2fd; color: #1565c0; }
.badge-phone     { background: #e8f5e9; color: #1b5e20; }
.badge-sms       { background: #f3e5f5; color: #6a1b9a; }
.badge-in-person { background: var(--accent-light); color: #bf360c; }
.badge-any       { background: var(--neutral-bg); color: var(--neutral-text); }

.badge-high      { background: var(--danger-bg);  color: var(--danger-text); }
.badge-medium    { background: var(--warning-bg); color: var(--warning-text); }
.badge-low       { background: var(--success-bg); color: var(--success-text); }

.badge-overdue   { background: var(--danger-bg);  color: var(--danger-text); }
.badge-today     { background: var(--warning-bg); color: var(--warning-text); }
.badge-upcoming  { background: var(--success-bg); color: var(--success-text); }
.badge-future    { background: var(--neutral-bg); color: var(--neutral-text); }
.badge-completed  { background: var(--neutral-bg); color: var(--neutral-text); }
.badge-recurrence { background: var(--neutral-bg); color: var(--neutral-text); font-size: 0.7rem; padding: 1px 4px; vertical-align: middle; cursor: default; }

.badge-low-stock { background: var(--danger-bg); color: var(--danger-text); }
.badge-ok-stock  { background: var(--success-bg); color: var(--success-text); }

/* Order status badges */
.badge-pre-sale  { background: #f3e5f5; color: #7b1fa2; }
.badge-pending   { background: #e3f2fd; color: #1565c0; }
.badge-paid      { background: var(--success-bg); color: var(--success-text); }
.badge-cancelled { background: var(--neutral-bg); color: var(--neutral-text); }

/* Todo type badges */
.badge-type-followup  { background: #e3f2fd; color: #1565c0; }
.badge-type-delivery  { background: #e8f5e9; color: #2e7d32; }
.badge-type-payment   { background: #fff8e1; color: #f57f17; }
.badge-type-sampling  { background: #f3e5f5; color: #6a1b9a; }
.badge-type-event     { background: #e0f2f1; color: #00695c; }
.badge-type-cleaning  { background: #fce4ec; color: #c62828; }
.badge-type-presale   { background: #e8eaf6; color: #283593; }
.badge-type-other     { background: #eceff1; color: #455a64; }

/* Staff active badges */
.badge-staff-active   { background: var(--success-bg); color: var(--success-text); }
.badge-staff-inactive { background: var(--neutral-bg); color: var(--neutral-text); }

/* Order totals footer row */
.table-totals td {
  font-weight: 700;
  background: #f7faf7;
  border-top: 2px solid var(--border);
  padding: 14px 12px;
  font-size: 14px;
}

/* ── Modal ────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

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

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  margin: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--border-light); color: var(--text); }

.modal-body {
  padding: 20px 22px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Forms ────────────────────────────────────────────── */

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-group label .required {
  color: #e53935;
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224,123,0,0.12);
}

textarea.form-control { resize: vertical; min-height: 72px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 18px 0 14px;
}

.form-section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Toast ────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  border-left: 4px solid var(--green-mid);
  animation: slideIn 0.2s ease;
}

.toast.error   { border-left-color: #e53935; }
.toast.warning { border-left-color: #ffa726; }
.toast.info    { border-left-color: #1e88e5; }

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Loading ──────────────────────────────────────────── */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Misc Utilities ───────────────────────────────────── */

.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 12px; }
.hidden       { display: none !important; }
.text-danger  { color: #c62828; }
.text-warning { color: #e65100; }
.text-success { color: var(--green-dark); }
.fw-600       { font-weight: 600; }
.mb-0         { margin-bottom: 0; }

.confirm-body {
  padding: 8px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Account Profile ─────────────────────────────────── */

.profile-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.profile-stat {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  text-align: center;
}

.profile-stat .stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.profile-stat .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profile-info {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 24px;
}

.profile-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-info-item.profile-info-full {
  grid-column: 1 / -1;
}

.profile-info-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.profile-section {
  margin-bottom: 32px;
}

.profile-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.profile-section-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

tr.row-completed td {
  opacity: 0.55;
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
}

tr.row-completed .badge,
tr.row-completed button {
  text-decoration: none;
  opacity: 1;
}

/* ── Pagination ──────────────────────────────────────── */

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--card-bg);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  margin-top: -1px;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
}

.pagination-per-page {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-per-page label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.pagination-per-page select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.pagination-info {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.pagination-ellipsis {
  padding: 0 6px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Settings ────────────────────────────────────────── */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  max-width: 640px;
}

.settings-location-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.settings-location-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.settings-location-item:last-child {
  border-bottom: none;
}

.settings-location-name {
  font-weight: 600;
  font-size: 14px;
}

.settings-location-actions {
  display: flex;
  gap: 4px;
}

/* ── Mobile Menu Button & Backdrop (hidden on desktop) ── */

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--sidebar-bg);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  box-shadow: var(--shadow);
  align-items: center;
  justify-content: center;
}

.sidebar-backdrop {
  display: none;
}

/* ── Bulk Actions Bar ──────────────────────────────────── */

.bulk-actions-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: var(--accent-light);
  border: 1px solid #ffe0b2;
  border-radius: var(--radius-sm);
}

.acct-select,
th input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 900px) {
  :root { --sidebar-width: 190px; }
  .content-area { padding: 18px 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  /* ── Show hamburger button ── */
  .mobile-menu-btn {
    display: flex;
  }

  /* ── Sidebar: off-screen by default, slide in when .open ── */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

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

  /* ── Backdrop overlay when sidebar is open ── */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
  }

  .sidebar-backdrop.open {
    display: block;
  }

  /* ── Main content: remove sidebar offset ── */
  .main-content {
    margin-left: 0;
  }

  .setup-banner-inner {
    margin-left: 0;
  }

  /* ── Content area: tighter padding for phones ── */
  .content-area {
    padding: 14px 12px;
    padding-top: 56px;
  }

  /* ── View header: stack title and actions vertically ── */
  .view-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .view-header-actions {
    justify-content: flex-start;
  }

  /* ── Profile stats: 2 columns instead of 5 ── */
  .profile-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* ── Profile info: single column ── */
  .profile-info {
    grid-template-columns: 1fr;
  }

  /* ── Filter bar: inputs adapt to available width ── */
  .filter-bar input[type="search"] {
    min-width: 0;
    flex: 1 1 100%;
  }

  .filter-bar select {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* ── Table: tighter cell padding ── */
  thead th {
    padding: 8px 10px;
    font-size: 11px;
  }

  tbody td {
    padding: 7px 10px;
    font-size: 12.5px;
  }

  /* ── Stat cards: smaller text on mobile ── */
  .stat-value {
    font-size: 24px;
  }

  .stat-card {
    padding: 14px 16px;
  }

  /* ── Stats grid: smaller minimums ── */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
  }

  /* ── Modal: nearly full-screen ── */
  .modal-overlay {
    padding: 10px 8px;
    align-items: stretch;
  }

  .modal {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 0;
  }

  .modal-body {
    max-height: 70vh;
    padding: 16px;
  }

  .modal-header {
    padding: 14px 16px 12px;
  }

  .modal-footer {
    padding: 12px 16px;
  }

  /* ── Toast: fit to phone width ── */
  #toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  /* ── Dashboard grid: single column ── */
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  /* ── Pagination: stack vertically ── */
  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }

  .pagination-per-page,
  .pagination-nav {
    justify-content: center;
  }

  /* ── Buttons: slightly smaller for mobile density ── */
  .btn {
    padding: 6px 12px;
    font-size: 12.5px;
  }

  .btn-sm {
    padding: 4px 8px;
    font-size: 11.5px;
  }
}

@media (max-width: 400px) {
  .profile-stat .stat-value {
    font-size: 18px;
  }

  .view-header h2 {
    font-size: 18px;
  }

  .content-area {
    padding: 12px 8px;
    padding-top: 56px;
  }
}
