/* ============================================================
   Yum Yum Donut Shops — Daily Recap Web App
   style.css — Full responsive stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary:      #1e3a5f;
  --primary-dark: #152c47;
  --primary-light:#2e5080;
  --accent:       #e8833a;
  --accent2:      #2e86ab;
  --success:      #2e7d32;
  --warning:      #e65100;
  --danger:       #c62828;
  --light:        #f4f7fb;
  --border:       #d1dce8;
  --text:         #1a2332;
  --muted:        #5a6a7e;
  --white:        #ffffff;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.12);
  --radius:       10px;
  --radius-sm:    6px;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; overflow-x: hidden; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--light);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden; /* prevent wide tables from stretching layout viewport on mobile */
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, #2e5080 60%, #1a7a9e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  background: var(--white);
  border-radius: 16px;
  padding: 48px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .donut-icon { font-size: 48px; margin-bottom: 10px; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.login-logo p  { font-size: 13px; color: var(--muted); margin-top: 4px; }
.login-box h2  { font-size: 18px; font-weight: 700; color: var(--primary); margin-bottom: 24px; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(46,134,171,0.15);
}
.form-control.error { border-color: var(--danger); }
.form-control:read-only { background: #f0f4f8; color: var(--muted); cursor: not-allowed; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; gap: 14px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* Input with prefix ($) */
.input-group { position: relative; }
.input-prefix {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--muted);
  pointer-events: none;
}
.input-group .form-control { padding-left: 26px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); text-decoration: none; }
.btn-accent    { background: var(--accent); color: var(--white); }
.btn-accent:hover  { background: #d4722e; color: var(--white); text-decoration: none; }
.btn-success   { background: var(--success); color: var(--white); }
.btn-success:hover { background: #1b5e20; color: var(--white); text-decoration: none; }
.btn-danger    { background: var(--danger); color: var(--white); }
.btn-danger:hover  { background: #b71c1c; color: var(--white); text-decoration: none; }
.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: var(--white); text-decoration: none; }
.btn-ghost     { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover   { background: var(--light); color: var(--text); text-decoration: none; }
.btn-sm  { padding: 6px 14px; font-size: 12px; }
.btn-lg  { padding: 13px 28px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── APP SHELL ── */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--primary);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}
.sidebar.active,
.sidebar.open {
  transform: translateX(0);
}
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo .donut { font-size: 28px; }
.sidebar-logo h2 { font-size: 15px; font-weight: 800; line-height: 1.2; margin-top: 6px; }
.sidebar-logo p  { font-size: 11px; opacity: 0.6; margin-top: 2px; }

.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
}
.sidebar-user .name  { font-weight: 700; font-size: 13px; }
.sidebar-user .role  {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.role-store      { background: rgba(232,131,58,0.25); color: #f4a96a; }
.role-district   { background: rgba(46,134,171,0.25); color: #7ecbe8; }
.role-corporate  { background: rgba(46,125,50,0.25);  color: #81c784; }
.role-franchisee { background: rgba(142,68,173,0.25); color: #c39bd3; }

.sidebar-nav { padding: 14px 0; flex: 1; }
.nav-section-title {
  padding: 10px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.45;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,0.12); color: var(--white); border-left-color: var(--accent); }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* Main content */
.main-content {
  margin-left: 0;
  flex: 1;
  min-width: 0;
  width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top bar */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.topbar-sub   { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* Page content */
.page-content { padding: 28px 32px; flex: 1; }

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--primary); }
.card-body  { padding: 22px; }
.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ── STATS GRID ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }
.stat-sub   { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── WEEK TABS ── */
.week-tabs {
  display: flex;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.week-tab {
  flex: 1;
  min-width: 90px;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.week-tab:hover { background: var(--light); color: var(--primary); }
.week-tab.active { background: var(--primary); color: var(--white); }
.week-tab.has-data::after {
  content: '●';
  display: block;
  font-size: 8px;
  color: var(--success);
  margin-top: 2px;
}
.week-tab.active.has-data::after { color: rgba(255,255,255,0.6); }
.tab-day-name { font-size: 12px; font-weight: 700; }
.tab-date     { font-size: 10px; font-weight: 400; margin-top: 1px; }

/* Tab panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── SECTION HEADERS ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.section-header h4 { font-size: 14px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .5px; }
.section-icon { font-size: 18px; }

/* ── TABLES ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: #eef2f7;
  color: var(--primary);
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.data-table .total-row td { font-weight: 700; background: #eef2f7; border-top: 2px solid var(--border); }
.data-table .money { text-align: right; font-family: 'Courier New', monospace; font-size: 13px; }
.data-table .center { text-align: center; }

/* ── STATUS BADGES ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.badge-draft     { background: #e3f2fd; color: #1565c0; }
.badge-submitted { background: #e8f5e9; color: #2e7d32; }
.badge-reviewed  { background: #f3e5f5; color: #6a1b9a; }
.badge-missing   { background: #ffebee; color: #c62828; }
.badge-warning   { background: #fff3e0; color: #e65100; }

/* ── ALERTS ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: #e8f5e9; border: 1px solid #a5d6a7; color: #2e7d32; }
.alert-error   { background: #ffebee; border: 1px solid #ef9a9a; color: #c62828; }
.alert-warning { background: #fff3e0; border: 1px solid #ffcc80; color: #e65100; }
.alert-info    { background: #e3f2fd; border: 1px solid #90caf9; color: #1565c0; }
.alert-icon    { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* ── PAYOUT ROWS ── */
.payout-rows { display: flex; flex-direction: column; gap: 8px; }
.payout-row  { display: grid; grid-template-columns: 1fr 140px 36px; gap: 8px; align-items: center; }
.payout-row .remove-payout {
  background: none; border: none; cursor: pointer;
  color: var(--danger); font-size: 18px; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.add-payout-btn {
  margin-top: 8px;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  width: 100%;
  transition: all .15s;
}
.add-payout-btn:hover { border-color: var(--accent2); color: var(--accent2); background: #e3f2fd; }

/* ── QNF PURCHASES ── */
.qnf-row { display: grid; grid-template-columns: 150px 1fr 140px 36px; gap: 8px; align-items: center; }

/* ── RECAP TABLE ── */
.recap-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.recap-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.recap-table th {
  background: var(--primary);
  color: var(--white);
  padding: 10px 12px;
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.recap-table th:first-child { text-align: left; }
.recap-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: right; font-size: 13px; }
.recap-table td:first-child { text-align: left; font-weight: 600; }
.recap-table tr:nth-child(even) td { background: #f8fafc; }
.recap-table .total-row td { background: #eef2f7; font-weight: 800; border-top: 2px solid var(--primary); font-size: 14px; }
.recap-table .money { font-family: 'Courier New', monospace; }
.over  { color: var(--success); font-weight: 700; }
.short { color: var(--danger);  font-weight: 700; }

/* ── STORE GRID (corporate dashboard) ── */
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.store-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: box-shadow .15s;
}
.store-card:hover { box-shadow: var(--shadow); }
.store-card.submitted { border-color: #a5d6a7; }
.store-card.draft     { border-color: #90caf9; }
.store-card.missing   { border-color: #ef9a9a; }
.store-num  { font-size: 18px; font-weight: 800; color: var(--primary); }
.store-name { font-size: 12px; color: var(--muted); margin-top: 2px; }
.store-mgr  { font-size: 11px; color: var(--muted); margin-top: 6px; }
.store-status { margin-top: 10px; }

/* ── PROGRESS BAR ── */
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width .3s; }

/* ── MODALS ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; padding: 0; }
.modal-close:hover { color: var(--danger); }
.modal-body   { padding: 22px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── SIGNATURE PAD ── */
.sig-pad-wrap {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
  position: relative;
  overflow: hidden;
}
#signaturePad { display: block; cursor: crosshair; touch-action: none; }
.sig-pad-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ── UTILITY ── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--muted); }
.text-small  { font-size: 12px; }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.required::after { content: ' *'; color: var(--danger); }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast notifications */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Breadcrumb */
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 16px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--accent2); }
.breadcrumb .sep { opacity: .4; }

/* Info tip */
.tip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
}

/* Readonly computed field */
.computed-field {
  background: #f0f4f8;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  font-family: 'Courier New', monospace;
}
.computed-field.positive { color: var(--success); }
.computed-field.negative { color: var(--danger); }

/* ── PRINT STYLES ── */
@media print {
  .sidebar, .topbar, .btn, .week-tabs, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .page-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── RESPONSIVE ── */

/* Menu toggle (mobile) - always defined so it can be shown/hidden */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--primary);
  padding: 4px;
  line-height: 1;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 999;
}
.sidebar-overlay.active,
.sidebar-overlay.open { display: block; }

@media screen and (min-width: 992px) {
  .sidebar {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none !important;
  }
  .main-content {
    margin-left: 260px;
  }
}

@media screen and (max-width: 991.98px) {
  .main-content {
    margin-left: 0;
  }
  .menu-toggle {
    display: flex;
    align-items: center;
  }
}

/* ── Tablet (≤1024px) ── */
@media (max-width: 1024px) {
  /* Allow card to show horizontal scroll overflow */
  .card { overflow: visible; }

  /* recap table: allow horizontal scroll on tablet */
  .recap-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .recap-table { font-size: 12px; min-width: 700px; }
  .recap-table th, .recap-table td { padding: 8px 9px; }
}

/* ── Mobile (≤768px) ── */
@media (max-width: 768px) {
  /* Allow card to show horizontal scroll overflow */
  .card { overflow: visible; }

  /* Sidebar shadow when open on small screens */
  .sidebar.active, .sidebar.open { box-shadow: 4px 0 20px rgba(0,0,0,0.25); }

  /* Topbar: tighter padding, wrap actions below title on small screens */
  .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .topbar > div:first-child { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; overflow: hidden; }
  .topbar-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-sub   { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .topbar-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
  .topbar-actions .btn { font-size: 12px; padding: 6px 10px; }

  /* Page content */
  .page-content { padding: 14px; }

  /* Week info bar (inline-styled in PHP) — override via utility */
  .week-info-bar { flex-wrap: wrap !important; gap: 12px !important; padding: 12px 14px !important; }
  .week-info-bar > div:last-child { margin-left: 0 !important; width: 100%; }
  .week-info-bar > div:last-child .btn { width: 100%; justify-content: center; margin: 0 !important; }

  /* Day tabs: scrollable row instead of wrapping */
  .week-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding: 6px;
    scrollbar-width: none;
  }
  .week-tabs::-webkit-scrollbar { display: none; }
  .week-tab { flex: 0 0 auto; min-width: 64px; font-size: 11px; padding: 8px 6px; }

  /* Form grids */
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
  .payout-row { grid-template-columns: 1fr 110px 36px; }
  .qnf-row    { grid-template-columns: 1fr 1fr; }
  .qnf-row > *:nth-child(3) { grid-column: 1; }
  .qnf-row > *:nth-child(4) { grid-column: 2; }

  /* Stats / store grids */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .store-grid { grid-template-columns: repeat(2, 1fr); }

  /* Recap table: horizontal scroll */
  .recap-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .recap-table { font-size: 11px; min-width: 650px; }
  .recap-table th, .recap-table td { padding: 7px 8px; }

  /* Drawer / change-bank shift grids */
  .shift-grid { grid-template-columns: 1fr 1fr !important; }

  /* Buttons: full-width on mobile for primary actions */
  .btn-mobile-full { width: 100%; justify-content: center; }

  /* Input touch targets */
  .form-control { min-height: 42px; font-size: 16px; } /* 16px prevents iOS zoom */
  select.form-control { min-height: 42px; }

  /* Cards */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }

  /* Section headers */
  .section-header { flex-wrap: wrap; gap: 8px; }
  .section-header h4 { font-size: 14px; }

  /* Week info bar: stack items on mobile */
  .week-info-bar { display: flex !important; flex-wrap: wrap !important; gap: 10px 20px !important; }
  .week-info-bar > div { min-width: 0; flex: 1 1 auto; }
  .week-info-bar > div strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .week-info-bar > div:last-child { flex: 1 1 100%; margin-left: 0 !important; }
  .week-info-bar > div:last-child .btn { display: block; width: 100%; text-align: center; margin: 4px 0 0 0 !important; }

  /* Summary cards on recap page */
  .summary-cards { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .summary-card { padding: 14px !important; }
  .summary-card .value { font-size: 20px !important; }
}

/* ── Small Mobile (≤480px) ── */
@media (max-width: 480px) {
  .page-content { padding: 10px; }
  .topbar { padding: 8px 12px; }
  .topbar-title { font-size: 14px; }

  /* Single column forms */
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .payout-row { grid-template-columns: 1fr 100px 36px; }

  /* Grids */
  .stats-grid { grid-template-columns: 1fr; }
  .store-grid { grid-template-columns: 1fr; }

  /* Day tabs: smaller */
  .week-tab { min-width: 56px; font-size: 10px; padding: 7px 4px; }

  /* Recap summary cards: stack on very small screens */
  .summary-cards { grid-template-columns: 1fr !important; }

  /* Shift grids: 2 cols on small phone */
  .shift-grid { grid-template-columns: 1fr 1fr !important; }

  /* Breadcrumb: shorter */
  .breadcrumb { font-size: 11px; flex-wrap: wrap; gap: 4px; }

  /* Recap table even smaller font */
  .recap-table { font-size: 10px; min-width: 600px; }
  .recap-table th, .recap-table td { padding: 6px 6px; }

  /* Buttons */
  .btn { font-size: 13px; padding: 8px 12px; }
  .btn-sm { font-size: 11px; padding: 5px 9px; }
}
/* ============================================================
   Dashboard-wide mobile/tablet optimization hardening
   Added responsive safeguards for report-heavy pages and inline layouts.
   ============================================================ */

/* Keep all app content from forcing viewport overflow. */
.main-content, .page-content, .card, .card-body, .card-header,
.stats-grid, .store-grid, .data-table, .form-row, .topbar, .topbar-actions {
  min-width: 0;
}

/* Make common wide tables scroll smoothly on touch devices. */
.table-scroll,
.table-responsive,
.data-table-wrap,
div[style*="overflow-x:auto"],
div[style*="overflow-x: auto"] {
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  max-width: 100%;
}

/* Long identifiers, store names, emails, and URLs should wrap instead of breaking mobile layouts. */
td, th, .stat-card, .metric, .head-box, .meta, .note-box, .card, .modal {
  overflow-wrap: anywhere;
}

/* Tablet refinements */
@media screen and (max-width: 1024px) {
  .page-content { padding: 20px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .store-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 9px; }
  .card-header { gap: 10px; flex-wrap: wrap; }
  .modal { max-width: min(92vw, 720px) !important; }
}

/* Phone and small tablet refinements */
@media screen and (max-width: 768px) {
  body { -webkit-text-size-adjust: 100%; }

  .topbar { align-items: stretch; }
  .topbar-actions {
    flex: 1 1 100%;
    width: 100%;
    margin-left: 0 !important;
    padding-right: 0 !important;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions .btn { flex: 0 0 auto; }

  .card, .stat-card, .metric, .bd-card, .vcard, .cardx, .report-head {
    border-radius: 10px !important;
  }

  .card-header,
  .section-header,
  .bd-title,
  .sv-filters,
  .filters,
  .actions,
  .submitbar,
  .sig-pad-actions,
  div[style*="align-items:center"][style*="flex-wrap:wrap"] {
    gap: 8px !important;
  }

  .filters,
  .sv-filters {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    align-items: end !important;
  }
  .filters .btn,
  .sv-filters .btn,
  .filters button,
  .sv-filters button { width: 100%; justify-content: center; }

  .form-control,
  input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="email"], input[type="password"], select, textarea {
    font-size: 16px !important;
    max-width: 100%;
  }

  .btn { min-height: 38px; justify-content: center; }
  .btn-sm { min-height: 32px; }

  .data-table,
  .bd-table,
  .sv-table,
  .table,
  .actiontable {
    min-width: 680px;
  }
  .data-table th, .data-table td,
  .bd-table th, .bd-table td,
  .sv-table th, .sv-table td,
  .table th, .table td,
  .actiontable th, .actiontable td {
    white-space: normal;
  }

  .table-scroll,
  .bd-card.table-scroll,
  div[style*="overflow-x:auto"],
  div[style*="overflow-x: auto"] {
    overflow-x: auto !important;
    max-width: 100%;
    border-radius: 10px;
  }

  .modal-overlay,
  .modal-backdrop { padding: 12px !important; }
  .modal {
    width: 100% !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100vh - 24px) !important;
    overflow-y: auto !important;
  }

  .login-box { padding: 32px 24px; }
}

/* Small phone refinements */
@media screen and (max-width: 480px) {
  .page-content { padding: 10px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { font-size: 11px; padding: 6px 9px; }

  .stats-grid, .store-grid, .metric-row, .score-strip, .score-grid, .head-grid, .two-col, .photos {
    grid-template-columns: 1fr !important;
  }

  .filters,
  .sv-filters,
  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4 {
    grid-template-columns: 1fr !important;
  }

  .card-body, .card-header, .bd-card, .vcard, .cardx, .report-head {
    padding: 12px !important;
  }

  .data-table,
  .bd-table,
  .sv-table,
  .table,
  .actiontable {
    min-width: 620px;
    font-size: 11px;
  }

  .btn:not(.btn-sm) { width: 100%; }
  .actions, .submitbar { flex-direction: column; align-items: stretch; }
  .actions .btn, .submitbar .btn { width: 100%; }
}
