/* Extracted from the live index.html <style> block — do not edit the live copy. */
  * { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --accent: #f59e0b;
    --success: #16a34a;
    --warning: #eab308;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  }
  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
  }

  /* ============ LOGIN ============ */
  .login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
    padding: 20px;
  }
  .login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-lg);
  }
  .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
  }
  .logo-mark {
    width: 48px; height: 48px;
    background: var(--primary);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
  }
  .logo-text { font-size: 22px; font-weight: 700; color: var(--gray-900); }
  /* Logo image — used everywhere site-wide. Drop logo.png next to index.html */
  .logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
  }
  /* on-dark: transparent background, no invert — logo displays as-is */
  .logo-mark.on-dark { background: transparent; padding: 4px; }
  /* Larger logo for invoices, tracking page header */
  .logo-large {
    width: 120px; height: 120px;
    display: inline-flex; align-items: center; justify-content: center;
    overflow: hidden;
  }
  .logo-large .logo-img { width: 100%; height: 100%; object-fit: contain; }
  /* Login page extra-large logo */
  .logo-hero {
    width: 110px; height: 110px;
    margin: 0 auto 8px;
    display: flex; align-items: center; justify-content: center;
  }
  .logo-hero .logo-img { width: 100%; height: 100%; object-fit: contain; }
  /* Tracking-page hero logo on dark bg — no invert */
  .logo-hero.on-dark .logo-img { filter: none; }
  /* Wide horizontal logo banner — used in loading screen, track-header, orders header */
  .logo-banner {
    display: block;
    width: clamp(160px, 40vw, 320px);
    height: auto;
    object-fit: contain;
    max-width: 100%;
  }
  .login-sub { color: var(--gray-500); margin-bottom: 24px; }
  .role-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 16px;
  }
  .role-btn {
    padding: 14px 10px;
    background: var(--gray-100);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    text-align: center;
    transition: all .15s;
    font-size: 14px;
  }
  .role-btn:hover { background: var(--gray-200); }
  .role-btn.primary {
    background: var(--primary);
    color: white;
    grid-column: span 2;
  }
  .role-btn.primary:hover { background: var(--primary-dark); }

  /* ============ APP LAYOUT ============ */
  .app { display: none; min-height: 100vh; }
  .app.active { display: flex; }
  .sidebar {
    width: 240px;
    background: var(--gray-900);
    color: white;
    padding: 20px 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
  .sidebar .nav {
    flex-shrink: 0;
  }
  .sidebar .logo { padding: 0 20px 20px; border-bottom: 1px solid #1f2937; }
  .sidebar .logo-text { color: white; font-size: 18px; }
  .branch-selector {
    padding: 12px 16px 8px;
    border-bottom: 1px solid #1f2937;
  }
  .branch-selector label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-500);
    display: block;
    margin-bottom: 4px;
  }
  .branch-selector select {
    width: 100%;
    padding: 6px 8px;
    background: #1f2937;
    color: white;
    border: 1px solid #374151;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
  }
  .branch-selector select:focus { outline: none; border-color: var(--primary-light); }
  .sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--gray-500);
  }
  .sync-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--gray-500);
  }
  .sync-dot.local { background: var(--warning); }
  .sync-dot.cloud { background: var(--success); }
  .sync-dot.offline { background: var(--danger); }
  .sync-dot.syncing {
    background: var(--primary-light);
    animation: pulse 1s infinite;
  }
  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
  }
  .sync-status {
    cursor: pointer;
  }
  .sync-status:hover { color: white; }
  .nav { padding: 12px 0; }
  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    cursor: pointer;
    color: var(--gray-300);
    transition: all .15s;
    font-size: 14px;
    border-left: 3px solid transparent;
  }
  .nav-item:hover { background: #1f2937; color: white; }
  .nav-item.active {
    background: #1f2937;
    color: white;
    border-left-color: var(--primary-light);
  }
  .nav-item .icon { font-size: 18px; }
  .nav-section {
    padding: 16px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-500);
  }
  .user-box {
    flex-shrink: 0;
    border-top: 1px solid #1f2937;
    font-size: 13px;
    display: flex;
    flex-direction: column;
  }
  .user-box-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px 10px;
  }
  .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px;
    flex-shrink: 0;
    color: white;
  }
  .user-box-info { flex: 1; min-width: 0; }
  .user-box-name { font-weight: 600; font-size: 13px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .user-box-meta { font-size: 11px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
  .user-box-actions {
    padding: 2px 0 8px;
  }
  .user-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 20px;
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background .12s, color .12s;
    position: relative;
  }
  .user-action-btn:hover { background: #1f2937; color: white; }
  .user-action-btn .ua-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
  .user-action-btn .ua-label { flex: 1; }
  .logout-btn {
    background: none; border: none;
    color: var(--gray-300); cursor: pointer;
    font-size: 16px;
  }
  .logout-btn:hover { color: white; }

  .main {
    flex: 1;
    min-width: 0; /* allow the flex item to shrink so it (not the whole page) owns the horizontal scroll */
    padding: 24px 32px;
    overflow-x: auto;
  }
  .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .page-title { font-size: 24px; font-weight: 700; }
  .page-sub { color: var(--gray-500); font-size: 14px; margin-top: 2px; }

  /* ============ BUTTONS ============ */
  .btn {
    padding: 9px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .15s;
    text-decoration: none;
    color: inherit;
  }
  .btn-primary { background: var(--primary); color: white; }
  .btn-primary:hover { background: var(--primary-dark); }
  .btn-secondary { background: white; border: 1px solid var(--gray-300); color: var(--gray-700); }
  .btn-secondary:hover { background: var(--gray-50); }
  .btn-success { background: var(--success); color: white; }
  .btn-success:hover { filter: brightness(.95); }
  .btn-danger { background: var(--danger); color: white; }
  .btn-danger:hover { filter: brightness(.95); }
  .btn-ghost { background: transparent; color: var(--gray-700); }
  .btn-ghost:hover { background: var(--gray-100); }
  /* Customer call-to-action — vibrant accent that stands out from staff sign-in */
  .btn-customer {
    background: linear-gradient(135deg, var(--accent) 0%, #f97316 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
    transition: all 0.2s;
  }
  .btn-customer:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
    filter: brightness(1.05);
  }
  .btn-sm { padding: 5px 10px; font-size: 12px; }

  /* ============ CARDS ============ */
  .card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
  }
  .card-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--gray-900); }

  /* ============ STATS GRID ============ */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
  }
  .stat-card {
    background: white;
    padding: 18px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
  }
  .stat-card.success { border-left-color: var(--success); }
  .stat-card.warning { border-left-color: var(--warning); }
  .stat-card.danger { border-left-color: var(--danger); }
  .stat-label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
  .stat-value { font-size: 26px; font-weight: 700; color: var(--gray-900); }
  .stat-trend { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

  /* ============ FORMS ============ */
  .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
  }
  .field { display: flex; flex-direction: column; gap: 4px; }
  .field label { font-size: 13px; font-weight: 500; color: var(--gray-700); }
  .field input, .field select, .field textarea {
    padding: 9px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: border-color .15s;
  }
  .field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,64,175,.1);
  }
  .field input[readonly] { background: var(--gray-100); cursor: default; }
  /* Inline form validation — marks the offending field in red */
  .field-error, .field input.field-error, .field select.field-error, .field textarea.field-error {
    border-color: var(--danger) !important;
    background: #fef2f2 !important;
    animation: shake 0.4s;
  }
  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
  }
  /* "NEEDS REVISION" — red blinking card for QA-rejected orders on the kanban */
  .kanban-card.needs-revision {
    background: #fef2f2 !important;
    border-left-color: var(--danger) !important;
    animation: blink-revision 1.2s infinite;
  }
  @keyframes blink-revision {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
  }
  .field-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 8px;
  }
  .player-row {
    display: grid;
    grid-template-columns: 1.5fr 0.6fr 0.7fr 2fr 0.8fr;
    gap: 8px;
    align-items: end;
    margin-bottom: 0;
  }
  @media (max-width: 900px) {
    .player-row { grid-template-columns: 1fr 1fr; gap: 6px; }
  }

  /* ---- PLAYER CARD (matches order.html) ---- */
  .player-card {
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 10px;
    background: white;
    overflow: hidden;
    transition: box-shadow .15s;
  }
  .player-card:hover { box-shadow: var(--shadow); }
  .player-card-header {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    min-height: 38px;
  }
  .player-badge {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--primary); color: white;
    font-size: 12px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .player-label {
    font-size: 13px; font-weight: 600; color: var(--gray-700);
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .player-remove-btn {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    background: transparent; border: none; cursor: pointer; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px; color: var(--gray-500);
    transition: background .12s, color .12s;
  }
  .player-remove-btn:hover:not(:disabled) { background: #fee2e2; color: var(--danger); }
  .player-remove-btn:disabled { opacity: .35; cursor: not-allowed; }
  .player-card-body { padding: 10px 12px 12px; }
  @keyframes playerSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .player-card-new { animation: playerSlideIn .25s ease-out; }

  /* ---- PAYMENT EXTRA FIELDS ---- */
  .payment-extra-fields {
    display: flex; flex-direction: column; gap: 12px;
    border-top: 1px solid var(--gray-200);
    margin-top: 14px; padding-top: 14px;
  }
  .proof-upload-label {
    display: flex; align-items: center; gap: 8px; cursor: pointer;
    padding: 9px 12px; border: 1.5px dashed var(--gray-300); border-radius: 6px;
    background: var(--gray-50); font-size: 13px; color: var(--gray-700);
    transition: border-color .15s, background .15s; width: 100%;
  }
  .proof-upload-label:hover { border-color: var(--primary); background: #eff6ff; }
  .proof-upload-label input[type=file] { display: none; }
  .proof-file-info { font-size: 12px; color: var(--gray-500); margin-top: 3px; min-height: 16px; word-break: break-all; }
  .proof-file-info.has-file { color: var(--success); font-weight: 500; }
  .pay-field-label {
    font-size: 13px; font-weight: 500; color: var(--gray-700);
    margin-bottom: 4px; display: flex; align-items: center; gap: 4px;
  }
  .pay-req-star { color: var(--danger); font-size: 11px; }
  .pay-opt-tag  { color: var(--gray-500); font-size: 11px; font-weight: 400; }
  .addon-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: 6px;
    margin-bottom: 6px;
  }
  .addon-row input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
  .addon-row input[type=text], .addon-row input[type=number] {
    padding: 5px 8px; font-size: 13px; flex: 1;
  }
  .addon-row .addon-name { flex: 1; font-size: 14px; }

  /* ============ TABLES ============ */
  .table-wrap {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    overflow-x: auto;
    position: relative;
  }
  /* Subtle hint on horizontally-scrollable tables on small screens */
  @media (max-width: 1024px) {
    .table-wrap {
      background-image:
        linear-gradient(to right, white, white),
        linear-gradient(to right, white, white),
        linear-gradient(to right, rgba(0,0,0,0.08), rgba(255,255,255,0)),
        linear-gradient(to left, rgba(0,0,0,0.08), rgba(255,255,255,0));
      background-position: left center, right center, left center, right center;
      background-repeat: no-repeat;
      background-size: 20px 100%, 20px 100%, 10px 100%, 10px 100%;
      background-attachment: local, local, scroll, scroll;
    }
  }
  table { width: 100%; border-collapse: collapse; }
  th, td {
    padding: 12px 14px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-200);
  }
  th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
  }
  tr:hover { background: var(--gray-50); }
  .empty-row { text-align: center; color: var(--gray-500); padding: 32px; }

  /* ============ BADGES ============ */
  .badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
  }
  .badge-success { background: #dcfce7; color: #166534; }
  .badge-warning { background: #fef3c7; color: #854d0e; }
  .badge-danger { background: #fee2e2; color: #991b1b; }
  .badge-info { background: #dbeafe; color: #1e40af; }
  .badge-gray { background: var(--gray-200); color: var(--gray-700); }

  /* ============ KANBAN ============ */
  .kanban {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .kanban-col {
    scroll-snap-align: start;
  }
  .kanban-col {
    background: var(--gray-200);
    border-radius: 8px;
    padding: 10px;
    min-width: 260px;
    flex: 1;
  }
  .kanban-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px 10px;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-700);
  }
  .kanban-col-count {
    background: white;
    color: var(--gray-700);
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
  }
  .kanban-card {
    background: white;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform .15s;
    border-left: 3px solid var(--primary);
  }
  .kanban-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
  /* Floating "back to top" pill for the Production Board — fades in on scroll,
     dims when idle, hides at the top. */
  .kanban-scrolltop {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 60;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0,0,0,.25);
    opacity: 0;
    transform: translateY(14px) scale(.85);
    pointer-events: none;
    transition: opacity .35s ease, transform .35s ease;
  }
  .kanban-scrolltop.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }
  .kanban-scrolltop.show.idle { opacity: .28; }
  .kanban-scrolltop.show:hover {
    opacity: 1;
    transform: translateY(-2px) scale(1.06);
  }
  /* Floating ◀ ▶ buttons to scroll the board sideways from anywhere on screen,
     fixed to the viewport so you never scroll down to the native bar. Solid,
     crisp circular buttons; the side you can't move toward is dimmed. */
  .kanban-sidenav {
    position: fixed;
    top: 50%;
    z-index: 60;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,.28);
    opacity: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .3s ease, transform .2s ease, background .2s ease;
  }
  .kanban-sidenav.left  { left: 252px; transform: translateY(-50%) translateX(-8px); } /* clear the 240px sidebar */
  .kanban-sidenav.right { right: 14px; transform: translateY(-50%) translateX(8px); }
  .kanban-sidenav.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) translateX(0);
  }
  .kanban-sidenav.show:hover { background: var(--primary-dark, #1d4ed8); transform: translateY(-50%) scale(1.08); }
  .kanban-sidenav.show.disabled { opacity: .55; pointer-events: none; }
  /* Blue scrollbars on the Production Board only (scoped via html.kanban-page).
     The page's vertical scrollbar lives on <html>, the board's horizontal one on
     .kanban — cover both, plus any nested scrollers on the page. */
  html.kanban-page,
  html.kanban-page .kanban,
  html.kanban-page .main { scrollbar-color: var(--primary) rgba(0,0,0,.06); } /* Firefox */
  html.kanban-page::-webkit-scrollbar,
  html.kanban-page ::-webkit-scrollbar { width: 12px; height: 12px; }
  html.kanban-page::-webkit-scrollbar-thumb,
  html.kanban-page ::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 7px;
    border: 3px solid transparent;
    background-clip: padding-box;
  }
  html.kanban-page::-webkit-scrollbar-thumb:hover,
  html.kanban-page ::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark, #1d4ed8);
    background-clip: padding-box;
  }
  html.kanban-page::-webkit-scrollbar-track,
  html.kanban-page ::-webkit-scrollbar-track { background: transparent; }
  @media (max-width: 1024px) {
    .kanban-sidenav.left { left: 14px; }  /* sidebar is an off-canvas drawer here */
  }
  @media (max-width: 768px) {
    .kanban-scrolltop { right: 16px; bottom: 16px; width: 42px; height: 42px; }
    .kanban-sidenav { width: 38px; height: 38px; font-size: 20px; }
  }
  .kanban-card-team { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
  .kanban-card-meta { font-size: 12px; color: var(--gray-500); display: flex; justify-content: space-between; }
  .kanban-card-actions { margin-top: 8px; display: flex; gap: 4px; }

  /* "Touched by" chip — shows who last acted on the order (from the timeline).
     Appears on kanban cards and in the list view. */
  .touched-by { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--gray-500); }
  .touched-by .tb-avatar {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; flex-shrink: 0;
  }
  .touched-by .tb-name { font-weight: 600; color: var(--gray-700); }
  .touched-by .tb-role {
    font-size: 10px; font-weight: 600; color: var(--primary);
    background: #eff6ff; border: 1px solid #dbeafe; border-radius: 4px;
    padding: 1px 6px; white-space: nowrap;
  }
  .kanban-card-touched { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--gray-200); }

  /* ============ PRODUCTION BOARD — SUMMARY STRIP ============ */
  .prod-summary { background: #fff; border: 1px solid var(--gray-200); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
  .prod-summary-top { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
  .prod-summary-count { font-size: 14px; font-weight: 700; }
  .prod-summary-count .big { font-size: 22px; color: var(--primary); }
  .prod-progress-track { position: relative; height: 22px; border-radius: 11px; background: var(--gray-100); overflow: hidden; margin-top: 10px; }
  .prod-progress-fill { height: 100%; border-radius: 11px; background: linear-gradient(90deg, var(--primary), var(--success)); position: relative; overflow: hidden; transition: width .6s ease; }
  .prod-progress-fill::after { content: ''; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.45) 50%, transparent 60%); animation: prodShimmer 2.4s infinite; }
  @keyframes prodShimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
  .prod-progress-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--gray-700); text-shadow: 0 1px 2px rgba(255,255,255,.7); }
  .prod-dist-track { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--gray-100); margin-top: 8px; }
  .prod-dist-seg { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #fff; overflow: hidden; white-space: nowrap; transition: width .6s ease; }
  .prod-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 11.5px; color: var(--gray-700); }
  .prod-legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; }
  .prod-legend span { white-space: nowrap; }
  .prod-summary-sub { font-weight: 500; color: var(--gray-500); font-size: 12.5px; }
  .prod-summary-pct { font-weight: 700; font-size: 13.5px; white-space: nowrap; }
  .prod-summary-pct .pct-num { color: var(--success); font-size: 18px; }

  @media (max-width: 768px) {
    .prod-summary { padding: 12px 14px; }
    .prod-summary-top { flex-direction: column; align-items: flex-start; gap: 2px; }
    .prod-summary-count { font-size: 13px; }
    .prod-summary-count .big { font-size: 19px; }
    .prod-summary-sub { display: block; margin-top: 1px; }
    .prod-legend { font-size: 10.5px; gap: 3px 9px; }
  }
  @media (max-width: 480px) {
    .prod-summary { padding: 10px 12px; margin-bottom: 10px; }
    .prod-progress-track { height: 19px; }
    .prod-progress-text { font-size: 11px; }
    /* Counts inside tiny segments overflow at phone widths — legend still shows them */
    .prod-dist-seg { font-size: 0; }
    .prod-legend .dot { width: 8px; height: 8px; }
  }

  /* ============ PRODUCTION BOARD — VIEW TOGGLE ============ */
  .view-toggle { display: inline-flex; gap: 0; border: 1px solid var(--gray-300); border-radius: 8px; overflow: hidden; background: #fff; }
  .view-toggle button {
    border: 0; background: transparent; cursor: pointer;
    padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--gray-500);
    display: inline-flex; align-items: center; gap: 6px;
  }
  .view-toggle button + button { border-left: 1px solid var(--gray-300); }
  .view-toggle button.active { background: var(--primary); color: #fff; }
  .view-toggle button:not(.active):hover { background: var(--gray-50); color: var(--gray-700); }

  /* ============ PRODUCTION BOARD — LIST VIEW ============ */
  .kanban-list { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
  .kanban-list th, .kanban-list td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
  .kanban-list th { background: var(--gray-50); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--gray-500); position: sticky; top: 0; z-index: 1; }
  .kanban-list tbody tr { cursor: pointer; }
  .kanban-list tbody tr:hover { background: var(--gray-50); }
  .kanban-list tr.needs-revision td:first-child { border-left: 3px solid var(--danger); }
  .kanban-list .col-team { font-weight: 600; color: var(--gray-900); white-space: normal; }
  .kanban-list .col-id { font-family: monospace; font-size: 12px; color: var(--gray-500); }
  .kanban-list select { padding: 5px; border: 1px solid var(--gray-300); border-radius: 4px; font-size: 12px; }
  @media (max-width: 768px) {
    .kanban-list-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  }

  /* ============ MODAL ============ */
  .modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .modal.active { display: flex; }
  .modal-content {
    background: white;
    border-radius: 12px;
    max-width: 760px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
  }
  .modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .modal-title { font-size: 18px; font-weight: 600; }
  .modal-close {
    background: none; border: none;
    cursor: pointer; font-size: 22px; color: var(--gray-500);
  }
  .modal-body { padding: 20px 24px; }
  .modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
  }
  /* Order-detail modal is wider than the default so the QA Line-up table
     (many columns, incl. the right-hand QA action button) isn't cut off. */
  #modal.modal-wide .modal-content { max-width: none; width: 95vw; max-height: 94vh; }
  /* Full-order edit modal runs near-fullscreen — the 5-column player rows
     need the room (responsive breakpoints key off viewport, not modal width). */
  #modal.modal-edit { padding: 16px; }
  #modal.modal-edit .modal-content { max-width: none; width: 96vw; height: 92vh; max-height: 92vh; }
  #modal.modal-edit .modal-body { overflow-x: auto; }

  /* ============ TIMELINE / TRACKER ============ */
  .progress-tracker {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 0;
    overflow-x: auto;
  }
  .progress-step {
    flex: 1;
    min-width: 90px;
    text-align: center;
    position: relative;
  }
  .progress-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 18px;
    left: 50%;
    width: 100%;
    height: 3px;
    background: var(--gray-300);
    z-index: 0;
  }
  .progress-step.completed:not(:last-child)::after { background: var(--success); }
  .progress-step.in-progress:not(:last-child)::after {
    background: linear-gradient(to right, var(--success) 50%, var(--gray-300) 50%);
  }
  .step-circle {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--gray-300);
    color: white;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 8px;
    font-weight: 600;
    position: relative;
    z-index: 1;
    font-size: 14px;
  }
  .progress-step.completed .step-circle { background: var(--success); }
  .progress-step.in-progress .step-circle { background: var(--warning); }
  .step-label { font-size: 12px; font-weight: 500; color: var(--gray-700); }
  .step-time { font-size: 10px; color: var(--gray-500); margin-top: 2px; }

  /* ============ TIMELINE ============ */
  .timeline { padding-left: 20px; border-left: 2px solid var(--gray-200); }
  .timeline-item { position: relative; padding-bottom: 16px; padding-left: 16px; }
  .timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 4px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--primary);
  }
  .timeline-time { font-size: 12px; color: var(--gray-500); }
  .timeline-text { font-size: 14px; }

  /* ============ PUBLIC TRACKING PAGE ============ */
  .track-page {
    display: none;
    min-height: 100vh;
    background: var(--gray-100);
    padding: 24px;
  }
  .track-page.active { display: block; }
  .track-container {
    max-width: 880px;
    margin: 0 auto;
  }
  .track-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
    color: white;
    padding: 32px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 20px;
  }
  .track-back {
    background: rgba(255,255,255,.2);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin-top: 10px;
  }

  /* ============ TABS ============ */
  .tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 16px;
    overflow-x: auto;
  }
  .tab {
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }
  .tab.active { color: var(--primary); border-bottom-color: var(--primary); }

  /* ============ CHARTS ============ */
  .chart-bar {
    display: flex;
    align-items: end;
    gap: 8px;
    height: 200px;
    padding: 16px 8px 8px;
  }
  .bar {
    flex: 1;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    position: relative;
    min-height: 2px;
    transition: all .3s;
  }
  .bar:hover { background: var(--primary-dark); }
  .bar-label {
    position: absolute;
    bottom: -22px;
    left: 0; right: 0;
    text-align: center;
    font-size: 11px;
    color: var(--gray-500);
  }
  .bar-value {
    position: absolute;
    top: -20px;
    left: 0; right: 0;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
  }

  /* ============ NOTIFICATIONS ============ */
  .toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .toast {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    min-width: 280px;
    animation: slideIn .3s;
  }
  .toast {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    min-width: 300px;
    max-width: 380px;
    animation: slideIn .3s;
    position: relative;
  }
  .toast.success { border-left-color: var(--success); }
  .toast.error { border-left-color: var(--danger); }
  .toast-exit { animation: slideOut .4s forwards; }
  @keyframes slideIn {
    from { transform: translateX(110%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
  }
  @keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(110%); opacity: 0; }
  }
  .toast-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; color: var(--gray-900); }
  .toast-msg { font-size: 12px; color: var(--gray-600); line-height: 1.4; }
  .toast-order-tag { font-size: 11px; color: var(--primary); font-weight: 600; margin-top: 3px; }
  .toast-close {
    position: absolute; top: 8px; right: 10px;
    background: none; border: none; cursor: pointer;
    font-size: 18px; color: var(--gray-400); line-height: 1;
  }
  .toast-close:hover { color: var(--gray-700); }

  /* ============ NOTIFICATION BELL ============ */
  .notif-bell-btn {
    position: relative; background: none; border: none; cursor: pointer;
    font-size: 20px; padding: 4px 8px; border-radius: 6px; line-height: 1;
    color: var(--gray-300); transition: background .15s, color .15s;
  }
  .notif-bell-btn:hover { background: #1f2937; color: white; }
  .notif-bell-btn.has-unread { color: #fbbf24; }
  .notif-badge {
    position: absolute; top: -3px; right: -3px;
    background: var(--danger); color: white;
    border-radius: 10px; min-width: 18px; height: 18px;
    font-size: 10px; font-weight: 700;
    display: none; align-items: center; justify-content: center;
    padding: 0 4px; border: 2px solid var(--gray-900);
    animation: notif-pop .3s;
  }
  @keyframes notif-pop {
    0% { transform: scale(0); }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); }
  }
  /* Bell ring animation — plays when there are unread notifications */
  @keyframes bell-ring {
    0%   { transform: rotate(0deg);    transform-origin: top center; }
    5%   { transform: rotate(18deg);   transform-origin: top center; }
    10%  { transform: rotate(-16deg);  transform-origin: top center; }
    15%  { transform: rotate(14deg);   transform-origin: top center; }
    20%  { transform: rotate(-12deg);  transform-origin: top center; }
    25%  { transform: rotate(10deg);   transform-origin: top center; }
    30%  { transform: rotate(-8deg);   transform-origin: top center; }
    35%  { transform: rotate(5deg);    transform-origin: top center; }
    40%  { transform: rotate(0deg);    transform-origin: top center; }
    100% { transform: rotate(0deg);    transform-origin: top center; }
  }
  /* Only the emoji span rings — not the whole button */
  .has-unread .bell-icon { display: inline-block; animation: bell-ring 2.5s ease-in-out infinite; }
  /* Waving hand animation for logout modal */
  @keyframes wave-hand {
    0%   { transform: rotate(0deg);   transform-origin: 70% 70%; }
    10%  { transform: rotate(14deg);  transform-origin: 70% 70%; }
    20%  { transform: rotate(-8deg);  transform-origin: 70% 70%; }
    30%  { transform: rotate(14deg);  transform-origin: 70% 70%; }
    40%  { transform: rotate(-4deg);  transform-origin: 70% 70%; }
    50%  { transform: rotate(10deg);  transform-origin: 70% 70%; }
    60%  { transform: rotate(0deg);   transform-origin: 70% 70%; }
    100% { transform: rotate(0deg);   transform-origin: 70% 70%; }
  }
  .wave-emoji { display: inline-block; animation: wave-hand 1.8s ease-in-out infinite; font-size: 42px; }
  /* Mobile topbar bell — different border color */
  .mobile-topbar .notif-bell-btn { color: rgba(255,255,255,.7); }
  .mobile-topbar .notif-bell-btn:hover { background: rgba(255,255,255,.1); color: white; }
  .mobile-topbar .notif-bell-btn.has-unread { color: #fbbf24; }
  .mobile-topbar .notif-badge { border-color: var(--gray-900); }

  /* ============ NOTIFICATION PANEL ============ */
  .notif-overlay {
    position: fixed; inset: 0; z-index: 1490;
    background: transparent; display: none;
  }
  .notif-overlay.active { display: block; }
  .notif-panel {
    position: fixed; top: 0; right: -380px; bottom: 0;
    width: 360px; background: white;
    box-shadow: -4px 0 24px rgba(0,0,0,.18);
    z-index: 1500; display: flex; flex-direction: column;
    transition: right .25s cubic-bezier(.4,0,.2,1);
  }
  .notif-panel.open { right: 0; }
  .notif-panel-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-900); color: white;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
  }
  .notif-panel-head h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
  .notif-panel-head-actions { display: flex; gap: 6px; align-items: center; }
  .notif-mark-all-btn {
    background: none; border: 1px solid rgba(255,255,255,.2); color: rgba(255,255,255,.7);
    font-size: 11px; padding: 3px 8px; border-radius: 4px; cursor: pointer;
    transition: all .15s;
  }
  .notif-mark-all-btn:hover { background: rgba(255,255,255,.1); color: white; }
  .notif-panel-close {
    background: none; border: none; color: rgba(255,255,255,.6);
    font-size: 22px; cursor: pointer; padding: 0 2px; line-height: 1;
  }
  .notif-panel-close:hover { color: white; }
  .notif-list { flex: 1; overflow-y: auto; }
  .notif-item {
    padding: 12px 16px; border-bottom: 1px solid var(--gray-100);
    cursor: pointer; transition: background .1s; display: flex; gap: 10px;
    align-items: flex-start;
  }
  .notif-item:hover { background: var(--gray-50); }
  .notif-item.unread { background: #eff6ff; }
  .notif-item.unread:hover { background: #dbeafe; }
  .notif-item-icon { font-size: 20px; flex-shrink: 0; padding-top: 1px; }
  .notif-item-body { flex: 1; min-width: 0; }
  .notif-item-title {
    font-size: 13px; font-weight: 600; color: var(--gray-700);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .notif-item.unread .notif-item-title { color: var(--gray-900); font-weight: 700; }
  .notif-item-msg {
    font-size: 12px; color: var(--gray-500); margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .notif-item-meta { display: flex; gap: 8px; align-items: center; margin-top: 3px; }
  .notif-item-order { font-size: 11px; color: var(--primary); font-weight: 600; }
  .notif-item-time { font-size: 11px; color: var(--gray-400); }
  .notif-unread-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--primary); flex-shrink: 0; margin-top: 5px;
  }
  .notif-empty { padding: 48px 24px; text-align: center; color: var(--gray-500); font-size: 14px; }
  .notif-empty-icon { font-size: 40px; margin-bottom: 12px; }
  .notif-panel-footer {
    padding: 10px 16px; border-top: 1px solid var(--gray-200);
    text-align: center; flex-shrink: 0;
    background: var(--gray-50);
  }
  @media (max-width: 600px) {
    .notif-panel { width: 100%; right: -100%; }
  }

  .toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
    flex-wrap: wrap;
  }
  .search-input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    min-width: 220px;
  }

  .order-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
  }
  .order-link:hover { text-decoration: underline; }

  /* ============ INVOICE PRINT ============ */
  @media print {
    .sidebar, .page-header button, .no-print, .toolbar { display: none !important; }
    body { background: white; }
    .main { padding: 0; }
    .invoice { padding: 30px; }
  }
  .invoice {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 0 auto;
  }

  /* ============================================================
     MOBILE TOP BAR & DRAWER (hidden on desktop)
     ============================================================ */
  .mobile-topbar { display: none; }
  .mobile-overlay { display: none; }
  .mobile-menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 26px;
    cursor: pointer;
    padding: 4px 12px;
    line-height: 1;
  }
  .mobile-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: white;
    font-size: 16px;
    flex: 1;
    overflow: hidden;
  }

  /* ============================================================
     TABLET BREAKPOINT (≤ 1024px) — sidebar becomes slide-in drawer
     ============================================================ */
  @media (max-width: 1024px) {
    .app { flex-direction: column; }

    .mobile-topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 8px 12px;
      background: var(--gray-900);
      color: white;
      position: sticky;
      top: 0;
      z-index: 100;
      height: 56px;
      box-shadow: var(--shadow);
    }

    /* Sidebar transforms into a slide-in drawer */
    .sidebar {
      position: fixed;
      top: 0;
      left: -300px;
      bottom: 0;
      width: 280px;
      height: 100vh;
      z-index: 200;
      transition: left 0.25s ease;
      box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .sidebar.open { left: 0; }
    .sidebar .logo { padding: 16px 20px; }
    .sidebar .logo-text { display: block; }
    .nav-item span:not(.icon) { display: inline; }
    .user-box > div, .user-box > span:not(.avatar) { display: flex; }
    .user-box-actions { flex-direction: column; }
    .user-action-btn { width: 100%; text-align: left; }
    .nav-item { justify-content: flex-start; padding: 10px 20px; }

    .mobile-overlay {
      display: block;
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(0,0,0,0.5);
      z-index: 150;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s;
    }
    .mobile-overlay.active {
      opacity: 1;
      pointer-events: auto;
    }

    .main {
      padding: 16px;
      width: 100%;
    }

    /* Page header stacks the title and action buttons */
    .page-header {
      flex-direction: column;
      align-items: stretch;
      gap: 10px;
    }
    .page-header > :last-child {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    /* Stats grid: tighter on tablet */
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }

    /* Toolbar inputs wrap */
    .toolbar { flex-wrap: wrap; gap: 8px; }
    .toolbar > * { flex: 1; min-width: 140px; }
    .search-input { min-width: 0 !important; width: 100%; }

    /* Modal nicely fits */
    .modal { padding: 10px; }
    .modal-content { max-height: 95vh; }

    /* Kanban: narrower columns */
    .kanban { gap: 10px; padding-bottom: 12px; }
    .kanban-col { min-width: 240px; padding: 8px; }

    /* Tables: smooth scroll */
    .table-wrap { -webkit-overflow-scrolling: touch; }
    th, td { padding: 10px 12px; font-size: 13px; }
  }

  /* ============================================================
     MOBILE BREAKPOINT (≤ 640px) — small phones
     ============================================================ */
  @media (max-width: 640px) {
    .main { padding: 12px; }
    .page-title { font-size: 19px; }
    .page-sub { font-size: 13px; }

    /* Stat cards stack 2 per row on small phones */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-label { font-size: 10px; }
    .stat-value { font-size: 18px; }
    .stat-trend { font-size: 11px; }

    /* Cards & content padding */
    .card { padding: 14px; }
    .card-title { font-size: 15px; }

    /* Form layouts go single column — also reset all inline span-2 overrides */
    .form-grid { grid-template-columns: 1fr; gap: 10px; }
    .form-grid > * { grid-column: span 1 !important; }
    .field input, .field select, .field textarea { font-size: 16px; /* prevents iOS zoom-in */ }

    /* Player rows: stack as a card-like layout */
    .player-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .player-row > .field:first-child  { grid-column: span 2; }
    .player-row > .field:nth-child(4) { grid-column: span 2; }
    .player-card { margin-bottom: 12px; }
    .player-card-body { padding: 8px 10px 10px; }

    /* Modal goes nearly full-screen */
    .modal { padding: 0; align-items: stretch; }
    .modal-content { max-height: 100vh; max-width: 100%; border-radius: 0; }
    .modal-header { padding: 12px 14px; position: sticky; top: 0; background: white; z-index: 1; }
    .modal-body { padding: 14px; }
    .modal-footer {
      padding: 10px 14px;
      flex-wrap: wrap;
      gap: 6px;
      position: sticky;
      bottom: 0;
      background: white;
      border-top: 1px solid var(--gray-200);
    }
    .modal-footer .btn { flex: 1 1 auto; justify-content: center; }

    /* Tabs scroll horizontally with snap */
    .tabs { overflow-x: auto; gap: 0; -webkit-overflow-scrolling: touch; }
    .tab { padding: 8px 14px; font-size: 13px; flex-shrink: 0; }

    /* Buttons in toolbars/headers more compact */
    .btn { font-size: 13px; padding: 8px 12px; }
    .btn-sm { font-size: 11px; padding: 5px 8px; }

    /* Kanban: very narrow columns to fit at least 1.5 on screen */
    .kanban-col { min-width: 200px; padding: 6px; }
    .kanban-col-header { padding: 4px 6px 8px; font-size: 12px; }
    .kanban-card { padding: 8px; }
    .kanban-card-team { font-size: 13px; }
    .kanban-card-meta { font-size: 11px; }

    /* Tables: tighter padding */
    th, td { padding: 8px 10px; font-size: 12px; }
    .badge { font-size: 10px; padding: 2px 8px; }

    /* Login screen: full-width card */
    .login-card { padding: 24px 18px; max-width: 100%; }
    .login-screen { padding: 12px; }

    /* Tracking page tighter */
    .track-page { padding: 12px; }
    .track-header { padding: 22px 18px; }
    .track-header h1 { font-size: 22px !important; }

    /* Progress tracker steps wrap */
    .progress-tracker { flex-wrap: wrap; gap: 8px; }
    .progress-step { min-width: 70px; flex: 1 1 25%; }
    .progress-step:not(:last-child)::after { display: none; }
    .step-label { font-size: 11px; }
    .step-circle { width: 30px; height: 30px; font-size: 12px; }

    /* Hide the standalone sidebar avatar text on mobile (mobile-topbar already shows it) */
    .user-box > div { font-size: 12px; }
  }

  /* Small accessibility/aesthetic adjustments */
  @media (max-width: 480px) {
    .page-header > :last-child .btn { font-size: 12px; padding: 7px 10px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .toolbar > * { flex-basis: 100%; }
    .login-card .role-grid { grid-template-columns: 1fr; }
  }

  /* ============================================================
     iPHONE 17 AND BELOW (≤ 430px) — Standard & compact iPhones
     ============================================================ */
  @media (max-width: 430px) {
    /* Tighter main padding */
    .main { padding: 10px; }
    .card { padding: 12px 10px; }
    .card-title { font-size: 14px; }
    .page-title { font-size: 18px; }
    .page-sub { font-size: 12px; }

    /* Mobile topbar: slightly shorter */
    .mobile-topbar { height: 50px; padding: 6px 10px; }

    /* Player row: name spans full width so it's not cramped */
    .player-row { grid-template-columns: 1fr 1fr; gap: 6px; }
    .player-row > .field:first-child  { grid-column: span 2; }
    .player-row > .field:nth-child(4) { grid-column: span 2; }
    .player-card-body { padding: 8px 10px 10px; }

    /* Prevent iOS auto-zoom on inputs — must be ≥ 16px */
    .field input, .field select, .field textarea { font-size: 16px; }

    /* Bulk product selector: full width on mobile */
    #bulkProduct { max-width: 100% !important; width: 100%; }

    /* Additional items extras row: selector full width */
    #newExtraProduct { min-width: 0 !important; width: 100%; }

    /* Form action buttons in new-order page */
    .page-header { flex-direction: column; align-items: stretch; gap: 8px; }
    .page-header > :last-child { flex-wrap: wrap; gap: 6px; }
    .page-header > :last-child .btn { flex: 1 1 calc(50% - 6px); justify-content: center; font-size: 12px; padding: 8px 6px; }

    /* Stats: single column on very small phones */
    .stat-card { padding: 10px 12px; }
    .stat-value { font-size: 20px; }

    /* Tabs: smaller font */
    .tab { padding: 6px 10px; font-size: 12px; }

    /* Login card: tight */
    .login-card { padding: 20px 14px; }

    /* Toolbar: full-width inputs */
    .search-input { font-size: 16px; }

    /* Tables: minimal padding */
    th, td { padding: 7px 8px; font-size: 11px; }
    .badge { font-size: 10px; padding: 2px 6px; }

    /* Kanban cards: minimal padding */
    .kanban-card { padding: 6px 8px; }
    .kanban-card-team { font-size: 12px; }
  }

  /* ============================================================
     VERY SMALL PHONES (≤ 375px) — iPhone SE / 1st-gen mini
     ============================================================ */
  @media (max-width: 375px) {
    .main { padding: 8px; }
    .card { padding: 10px 8px; }
    .mobile-topbar { padding: 6px 8px; }
    .stat-label { font-size: 9px; }
    .stat-value { font-size: 18px; }
    th, td { padding: 6px; font-size: 11px; }
  }

  /* ============ SECRETARY QUEUE ============ */
  .sq-section { margin-bottom: 28px; }
  .sq-section-header { display: flex; align-items: center; gap: 10px; margin: 22px 0 12px; }
  .sq-section-title  { font-size: 16px; font-weight: 700; color: var(--gray-900); }
  .sq-section-count  {
    padding: 2px 9px; border-radius: 12px;
    font-size: 12px; font-weight: 600;
    background: var(--gray-200); color: var(--gray-700);
  }
  .sq-section-count.has-items { background: var(--primary); color: white; }
  .sq-section-count.danger    { background: var(--danger);  color: white; }

  /* Empty state */
  .sq-empty { background: white; border-radius: 10px; padding: 28px; text-align: center; color: var(--gray-500); font-size: 14px; box-shadow: var(--shadow); }
  .sq-empty-icon { font-size: 32px; margin-bottom: 8px; }

  /* Cards grid */
  .sq-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

  /* Individual order card */
  .sq-card {
    background: white; border-radius: 10px; border-left: 4px solid var(--gray-300);
    box-shadow: var(--shadow); overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease;
    animation: sqFadeInUp .35s cubic-bezier(.22,1,.36,1) both;
  }
  .sq-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

  /* Payment state variants */
  .sq-card.sq-ok   { border-left-color: var(--success); }
  .sq-card.sq-warn { border-left-color: var(--warning); }
  .sq-card.sq-unpaid {
    border-left-color: var(--danger); background: #fff8f8;
    animation: sqFadeInUp .35s cubic-bezier(.22,1,.36,1) both, sqRedGlow 2.4s ease-in-out 0.35s infinite;
  }
  .sq-card.sq-notify { border-left-color: #3b82f6; }

  /* Card structure */
  .sq-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 13px 16px 10px; border-bottom: 1px solid var(--gray-100); }
  .sq-card-id     { font-size: 10px; font-family: monospace; letter-spacing: .04em; color: var(--gray-400); margin-bottom: 3px; }
  .sq-card-team   { font-size: 15px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
  .sq-card-contact { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

  /* Payment badge (top-right of card) */
  .sq-payment-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
  .sq-payment-badge.paid  { background: #dcfce7; color: #15803d; }
  .sq-payment-badge.warn  { background: #fef3c7; color: #92400e; }
  .sq-payment-badge.nopay { background: #fee2e2; color: #991b1b; }
  .sq-payment-badge .blink-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: sqDotBlink 1.6s ease-in-out infinite; }

  /* Card body meta grid */
  .sq-card-body { padding: 10px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
  .sq-notify-cards .sq-card-body { grid-template-columns: 1fr 1fr 1fr; }
  .sq-meta-item  { display: flex; flex-direction: column; gap: 2px; }
  .sq-meta-label { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--gray-400); font-weight: 600; }
  .sq-meta-value { font-size: 13px; font-weight: 500; color: var(--gray-900); }

  /* No-payment warning strip */
  .sq-nopay-strip { background: #fee2e2; color: #991b1b; padding: 6px 16px; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }

  /* DP progress bar */
  .sq-prog-wrap { height: 4px; background: var(--gray-100); }
  .sq-prog-fill { height: 100%; transition: width .4s ease; }
  .sq-prog-fill.green  { background: var(--success); }
  .sq-prog-fill.yellow { background: var(--warning); }
  .sq-prog-fill.red    { background: var(--danger); }

  /* Card footer (action buttons) */
  .sq-card-footer { padding: 10px 16px; border-top: 1px solid var(--gray-100); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

  /* Info banner at top of queue */
  .sq-info-banner { background: #eff6ff; border-left: 4px solid var(--primary-light); border-radius: 8px; padding: 11px 16px; margin-bottom: 16px; font-size: 13px; color: #1e40af; }

  /* Stagger entry delays */
  .sq-card:nth-child(1) { animation-delay: .04s; }
  .sq-card:nth-child(2) { animation-delay: .09s; }
  .sq-card:nth-child(3) { animation-delay: .14s; }
  .sq-card:nth-child(4) { animation-delay: .19s; }
  .sq-card:nth-child(5) { animation-delay: .24s; }
  .sq-card:nth-child(6) { animation-delay: .29s; }

  /* Animations */
  @keyframes sqFadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes sqRedGlow {
    0%, 100% { box-shadow: 0 1px 3px rgba(0,0,0,.1),  0 0 0 0 rgba(220,38,38,.0);  }
    50%       { box-shadow: 0 4px 10px rgba(0,0,0,.08), 0 0 0 6px rgba(220,38,38,.12); }
  }
  @keyframes sqDotBlink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .4; transform: scale(.65); }
  }

  /* For Validation cards — red pulsing high-priority */
  .sq-card.sq-validation {
    border-left-color: var(--danger);
    background: #fff8f8;
    animation: sqFadeInUp .35s cubic-bezier(.22,1,.36,1) both, sqRedGlow 2.4s ease-in-out 0.35s infinite;
  }

  /* Payment Received badge on validation cards */
  .sq-validation-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 11px; border-radius: 20px;
    font-size: 11px; font-weight: 700;
    background: #fef2f2; color: #991b1b;
    white-space: nowrap; flex-shrink: 0;
  }
  .sq-val-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #dc2626;
    animation: sqDotBlink 1.2s ease-in-out infinite;
  }

  /* Payment type badges (Online / Cash) */
  .sq-pay-type-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 12px;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
  }
  .sq-pay-type-badge.online { background: #dbeafe; color: #1e40af; }
  .sq-pay-type-badge.cash   { background: #fef3c7; color: #92400e; }

  /* Action buttons on cards */
  .sq-remind-btn { background: #f97316; color: white; font-weight: 600; }
  .sq-remind-btn:hover { background: #ea580c; }
  .sq-check-btn  { background: var(--danger); color: white; font-weight: 700; }
  .sq-check-btn:hover  { background: #b91c1c; }

  /* Urgent label on For Validation section header */
  .sq-urgent-label {
    font-size: 11px; font-weight: 700; color: #dc2626;
    animation: sqDotBlink 1.4s ease-in-out infinite;
    margin-left: 4px;
  }
