
  :root {
    --green-dark: #145239;
    --green: #1F6E43;
    --green-mid: #2D8659;
    --green-light: #D4EDDA;
    --gold: #C8A24A;
    --gold-light: #FEF3C7;
    --warn: #B91C1C;
    --warn-light: #FEE2E2;
    --whatsapp: #25D366;
    --info: #1E40AF;
    --info-light: #DBEAFE;
    --ink: #0F172A;
    --ink-soft: #475569;
    --line: #E2E8F0;
    --bg: #F4F4EE;
    --card: #FFFFFF;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 30px rgba(0,0,0,0.15);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

  html, body {
    font-family: 'Tajawal', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

  /* ============ LOGIN SCREEN ============ */
  .login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 50%, var(--green-mid) 100%);
    padding: 20px;
  }

  .login-card {
    background: var(--card);
    border-radius: 24px;
    padding: 36px 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
  }

  .login-logo {
    text-align: center;
    margin-bottom: 28px;
  }

  .login-logo-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    border-radius: 18px;
    display: grid;
    place-items: center;
    margin: 0 auto 12px;
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 32px;
    color: #fff;
    box-shadow: 0 8px 16px rgba(31,110,67,0.3);
  }

  .login-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 24px;
    color: var(--ink);
    margin-bottom: 4px;
  }

  .login-subtitle {
    color: var(--ink-soft);
    font-size: 14px;
  }

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

  .form-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 6px;
  }

  .form-input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    font-family: 'Tajawal', sans-serif;
    font-size: 16px;
    background: var(--bg);
    transition: all 0.2s;
  }

  .form-input:focus {
    outline: none;
    border-color: var(--green);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(31,110,67,0.1);
  }

  .btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .btn-primary {
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #fff;
    box-shadow: 0 4px 12px rgba(31,110,67,0.3);
  }

  .btn-primary:hover { transform: translateY(-1px); }
  .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

  .login-error {
    background: var(--warn-light);
    border: 1.5px solid var(--warn);
    color: var(--warn);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 14px;
    display: none;
  }

  .login-error.show { display: block; animation: shake 0.4s; }

  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
  }

  .login-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--ink-soft);
    font-size: 12px;
  }

  /* ============ MAIN APP ============ */
  .app-wrap { display: none; min-height: 100vh; }
  .app-wrap.show { display: block; }

  /* Top Bar */
  .topbar {
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 100%);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
  }

  .topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .topbar-logo {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    display: grid; place-items: center;
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 18px;
  }

  .topbar-text { font-family: 'Cairo', sans-serif; font-weight: 800; font-size: 16px; }
  .topbar-text small { display: block; font-size: 11px; opacity: 0.8; font-weight: 400; }

  .topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .user-pill {
    background: rgba(255,255,255,0.15);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .user-pill-role {
    font-size: 10px;
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 999px;
  }

  .logout-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
  }
  .logout-btn:hover { background: rgba(255,255,255,0.25); }

  /* ============ PAGE CONTAINER ============ */
  .page { display: none; padding: 20px; max-width: 1200px; margin: 0 auto; }
  .page.active { display: block; animation: fadeIn 0.3s ease; }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* ============ HUB PAGE ============ */
  .welcome {
    background: var(--card);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
  }

  .welcome h1 {
    font-family: 'Cairo', sans-serif;
    font-size: 24px;
    color: var(--green-dark);
    margin-bottom: 6px;
  }

  .welcome-meta {
    color: var(--ink-soft);
    font-size: 13px;
  }

  .apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
  }

  .app-tile {
    background: var(--card);
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
  }

  .app-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--green), var(--green-mid));
  }

  .app-tile:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--green);
  }

  .app-tile.admin::before { background: linear-gradient(90deg, var(--gold), #B8932F); }
  .app-tile.supervisor::before { background: linear-gradient(90deg, #2563EB, #1E40AF); }
  .app-tile.supervisor::before { background: linear-gradient(90deg, var(--info), #1E3A8A); }

  .app-icon {
    font-size: 44px;
    margin-bottom: 12px;
    display: block;
  }

  .app-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 15px;
    color: var(--ink);
    margin-bottom: 4px;
  }

  .app-desc {
    font-size: 11px;
    color: var(--ink-soft);
    line-height: 1.4;
  }

  /* ============ PAGE HEADER ============ */
  .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .page-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 22px;
    color: var(--ink);
  }

  .back-btn {
    background: var(--card);
    border: 1px solid var(--line);
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .back-btn:hover { border-color: var(--green); color: var(--green); }

  /* ============ QUICK STATS ============ */
  .quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
  }

  .qs-card {
    background: var(--card);
    padding: 14px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    text-align: center;
  }

  .qs-val {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 26px;
    color: var(--green-dark);
    line-height: 1;
  }
  .qs-lbl {
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: 4px;
  }

  /* ============ FORMS ============ */
  .form-card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    margin-bottom: 16px;
  }

  .form-section { margin-bottom: 18px; }

  .section-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 14px;
    color: var(--green-dark);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--green-light);
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-size: 16px;
    background: var(--bg);
    transition: all 0.2s;
    -webkit-appearance: none;
  }

  .form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--green);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(31,110,67,0.1);
  }

  .form-textarea { resize: vertical; min-height: 70px; font-family: inherit; }

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

  .req { color: var(--warn); font-weight: 900; }

  .pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
  .pill {
    padding: 8px 14px;
    border: 1.5px solid var(--line);
    background: #fff;
    border-radius: 999px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    color: var(--ink-soft);
    transition: all 0.2s;
  }
  .pill.selected {
    background: var(--green); color: #fff; border-color: var(--green);
  }

  .btn-whatsapp {
    background: var(--whatsapp);
    color: #fff;
  }

  .btn-secondary {
    background: var(--card);
    color: var(--ink);
    border: 1.5px solid var(--line);
  }

  .btn-warn { background: var(--warn); color: #fff; }

  /* ============ DUPLICATE ALERT ============ */
  .duplicate-alert {
    background: var(--warn-light);
    border: 2px solid var(--warn);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
    display: none;
  }
  .duplicate-alert.show { display: block; animation: shake 0.4s ease; }

  .dup-title { color: var(--warn); font-weight: 800; margin-bottom: 6px; }
  .dup-actions { display: flex; gap: 8px; margin-top: 10px; }

  /* ============ WORKERS LIST ============ */
  .search-box {
    background: var(--card);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 12px;
  }

  .search-box input {
    flex: 1; border: none; padding: 10px 0;
    font-family: 'Tajawal', sans-serif;
    font-size: 15px; background: transparent; outline: none;
  }

  .filter-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 14px;
    -webkit-overflow-scrolling: touch;
  }

  .filter-pill {
    flex-shrink: 0;
    padding: 6px 14px;
    border: 1.5px solid var(--line);
    background: var(--card);
    border-radius: 999px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    color: var(--ink-soft);
    white-space: nowrap;
  }
  .filter-pill.active {
    background: var(--green); color: #fff; border-color: var(--green);
  }

  .worker-item {
    background: var(--card);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    cursor: pointer;
    transition: all 0.2s;
  }
  .worker-item:active { transform: scale(0.98); }

  .worker-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
  }

  .worker-name { font-weight: 800; font-size: 15px; }
  .worker-id { font-size: 10px; color: var(--ink-soft); font-family: monospace; direction: ltr; }

  .stage-badge {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
  }
  .stage-lead     { background: #DBEAFE; color: #1E40AF; }
  .stage-qualified{ background: #FEF3C7; color: #92400E; }
  .stage-sent     { background: #FED7AA; color: #9A3412; }
  .stage-arrived  { background: #BBF7D0; color: #166534; }
  .stage-hired    { background: var(--green-light); color: var(--green-dark); }
  .stage-active   { background: #C8A24A; color: #fff; }
  .stage-inactive { background: #E5E7EB; color: #6B7280; }
  .stage-blacklist{ background: var(--warn); color: #fff; }
  .stage-lost     { background: #FEE2E2; color: var(--warn); }

  .worker-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--ink-soft);
  }

  .worker-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
  }

  .action-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--line);
    background: var(--bg);
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    color: var(--ink);
  }
  .action-btn.whatsapp { background: var(--whatsapp); color: #fff; border-color: var(--whatsapp); }
  .action-btn.advance { background: var(--green); color: #fff; border-color: var(--green); }

  /* ============ MODAL ============ */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: flex-end;
    justify-content: center;
  }
  .modal-overlay.show { display: flex; }

  .modal {
    background: var(--card);
    width: 100%;
    max-width: 600px;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-handle {
    width: 40px; height: 4px;
    background: var(--line);
    border-radius: 999px;
    margin: 12px auto 0;
  }

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

  .modal-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800; font-size: 17px;
  }

  .modal-close {
    width: 32px; height: 32px;
    border: none;
    background: var(--bg);
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
  }

  .modal-body { padding: 20px; }

  /* ============ DESKTOP MODAL ============ */
  @media (min-width: 768px) {
    .modal-overlay { align-items: center; }
    .modal {
      border-radius: 20px;
      margin: 20px;
    }
  }

  /* ============ TOAST & LOADING ============ */
  .toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--green);
    color: #fff;
    padding: 12px 24px;
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    font-weight: 700;
    font-size: 14px;
    transition: transform 0.3s ease;
    pointer-events: none;
    max-width: 90%;
    text-align: center;
  }
  .toast.show { transform: translateX(-50%) translateY(0); }
  .toast.error { background: var(--warn); }

  .loading-overlay {
    position: fixed; inset: 0;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: none;
    align-items: center; justify-content: center;
    flex-direction: column; gap: 12px;
  }
  .loading-overlay.show { display: flex; }

  .spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--green-light);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ============ EMPTY STATES ============ */
  .empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--ink-soft);
  }
  .empty-icon { font-size: 56px; margin-bottom: 12px; opacity: 0.5; }

  /* ============ CONFIG WARNING ============ */
  .config-warning {
    background: var(--warn-light);
    border: 2px solid var(--warn);
    border-radius: 16px;
    padding: 20px;
    margin: 20px;
    color: var(--warn);
  }
  .config-warning code {
    display: block; background: #fff;
    padding: 10px; border-radius: 6px;
    margin: 8px 0; font-family: monospace;
    direction: ltr; font-size: 11px;
  }

  /* ============ STAGE FLOW ============ */
  .stage-flow {
    display: flex;
    gap: 4px;
    margin: 16px 0;
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .stage-step {
    flex-shrink: 0;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    background: var(--bg);
    color: var(--ink-soft);
  }
  .stage-step.current { background: var(--green); color: #fff; }
  .stage-step.done { background: var(--green-light); color: var(--green-dark); }

  /* iOS safe area */
  @supports (padding: env(safe-area-inset-bottom)) {
    .page { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  }

  /* ============ PREMIUM ADS PAGE STYLING ============ */
  .ads-hero {
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 50%, var(--green-mid) 100%);
    color: #fff;
    padding: 28px 24px;
    border-radius: 20px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(20, 82, 57, 0.25);
  }

  .ads-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(200, 162, 74, 0.15), transparent 70%);
    pointer-events: none;
  }

  .ads-hero-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 26px;
    margin-bottom: 4px;
    position: relative;
  }

  .ads-hero-subtitle {
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 18px;
    position: relative;
  }

  .ads-hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
    position: relative;
  }

  .hero-stat {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 14px 12px;
    text-align: center;
    transition: all 0.2s;
  }

  .hero-stat:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
  }

  .hero-stat-val {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 24px;
    line-height: 1;
    margin-bottom: 4px;
  }

  .hero-stat-val small { font-size: 14px; opacity: 0.8; }

  .hero-stat-lbl {
    font-size: 11px;
    opacity: 0.85;
    font-weight: 500;
  }

  /* Search & Filters */
  .ads-toolbar {
    background: var(--card);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
  }

  .ads-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    padding: 4px 14px;
    border-radius: 12px;
    border: 1.5px solid var(--line);
    margin-bottom: 12px;
    transition: all 0.2s;
  }

  .ads-search:focus-within {
    border-color: var(--green);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(31,110,67,0.1);
  }

  .ads-search input {
    flex: 1;
    border: none;
    padding: 10px 0;
    font-family: 'Tajawal', sans-serif;
    font-size: 15px;
    background: transparent;
    outline: none;
  }

  .ads-filters {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .ads-filter-pill {
    flex-shrink: 0;
    padding: 6px 14px;
    border: 1.5px solid var(--line);
    background: var(--card);
    border-radius: 999px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    color: var(--ink-soft);
    white-space: nowrap;
    transition: all 0.2s;
  }

  .ads-filter-pill:hover {
    border-color: var(--green);
    color: var(--green);
  }

  .ads-filter-pill.active {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
    box-shadow: 0 2px 8px rgba(31,110,67,0.25);
  }

  /* Grid Layout */
  .ads-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }

  @media (min-width: 768px) {
    .ads-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media (min-width: 1100px) {
    .ads-grid {
      grid-template-columns: repeat(3, 1fr);
    }
  }

  /* Premium Ad Card */
  .premium-ad {
    background: var(--card);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    transition: all 0.25s;
    display: flex;
    flex-direction: column;
  }

  .premium-ad:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
  }

  .premium-ad-header {
    padding: 18px 16px;
    color: #fff;
    position: relative;
  }

  .premium-ad-header.cat-premium { background: linear-gradient(135deg, #1F6E43, #2D8659); }
  .premium-ad-header.cat-cash { background: linear-gradient(135deg, #C8A24A, #D4A933); }
  .premium-ad-header.cat-flex { background: linear-gradient(135deg, #5B21B6, #7C3AED); }
  .premium-ad-header.cat-short { background: linear-gradient(135deg, #6B21A8, #A855F7); }
  .premium-ad-header.cat-warn { background: linear-gradient(135deg, #991B1B, #DC2626); }

  .premium-ad-num {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(4px);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 13px;
  }

  .premium-ad-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 6px;
    text-align: center;
  }

  .premium-ad-city {
    text-align: center;
    font-size: 13px;
    opacity: 0.95;
    margin-bottom: 10px;
  }

  .premium-ad-tag {
    display: inline-block;
    background: rgba(255,255,255,0.25);
    backdrop-filter: blur(4px);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    margin: 0 auto;
  }

  .premium-ad-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  .premium-ad-salary {
    background: var(--bg);
    padding: 14px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 12px;
  }

  .premium-ad-salary-val {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 26px;
    color: var(--green-dark);
    line-height: 1;
  }

  .premium-ad-salary-lbl {
    font-size: 11px;
    color: var(--ink-soft);
    margin-top: 4px;
  }

  .premium-ad-meta {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 12px;
    flex: 1;
  }

  .premium-ad-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 13px;
  }

  .premium-ad-meta-row:last-child {
    border-bottom: none;
  }

  .premium-ad-meta-label {
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
  }

  .premium-ad-meta-value {
    font-weight: 700;
    color: var(--ink);
  }

  .premium-ad-perks {
    background: linear-gradient(135deg, #FEF3C7, #FFFBEB);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    color: #78350F;
    margin-bottom: 12px;
    line-height: 1.5;
  }

  .premium-ad-perks-label {
    font-weight: 700;
    color: #92400E;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .premium-ad-register-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(31,110,67,0.25);
    transition: all 0.2s;
    margin-top: auto;
  }

  .premium-ad-register-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(31,110,67,0.35);
  }

  .premium-ad-inactive {
    opacity: 0.55;
    filter: grayscale(50%);
  }

  .premium-ad-inactive-badge {
    background: var(--warn);
    color: #fff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    display: inline-block;
    margin-top: 6px;
  }

  /* ============ PERMISSIONS MATRIX ============ */
  .perm-summary {
    background: var(--card);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
  }

  .perm-summary-card {
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    background: var(--bg);
  }

  .perm-summary-role {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 14px;
    color: var(--ink);
    margin-bottom: 4px;
  }

  .perm-summary-count {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 22px;
    color: var(--green-dark);
  }

  .perm-toolbar {
    background: var(--card);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
  }

  .perm-dirty-badge {
    background: var(--gold-light);
    color: #92400E;
    border: 1.5px solid var(--gold);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    display: none;
  }

  .perm-dirty-badge.show { display: inline-flex; align-items: center; gap: 6px; }

  .perm-save-btn {
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    margin-right: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(31,110,67,0.25);
    opacity: 0.5;
    pointer-events: none;
    transition: all 0.2s;
  }

  .perm-save-btn.active {
    opacity: 1;
    pointer-events: auto;
  }

  .perm-save-btn.active:hover {
    transform: translateY(-2px);
  }

  .perm-category {
    background: var(--card);
    border-radius: 14px;
    margin-bottom: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
  }

  .perm-category-header {
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #fff;
    padding: 12px 16px;
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .perm-category-count {
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
  }

  .perm-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .perm-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
  }

  .perm-table th,
  .perm-table td {
    padding: 10px 8px;
    text-align: center;
    font-size: 13px;
    border-bottom: 1px solid var(--line);
  }

  .perm-table th {
    background: var(--bg);
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    color: var(--ink);
    font-size: 12px;
    position: sticky;
    top: 0;
  }

  .perm-table th.perm-name-col {
    text-align: right;
    min-width: 200px;
  }

  .perm-table td.perm-name {
    text-align: right;
    font-weight: 600;
    color: var(--ink);
  }

  .perm-table tr:hover {
    background: rgba(31, 110, 67, 0.03);
  }

  .perm-role-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .perm-role-name {
    font-size: 11px;
    color: var(--ink);
  }

  .perm-role-count {
    font-size: 10px;
    background: var(--green);
    color: #fff;
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 700;
  }

  .perm-checkbox {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--green);
  }

  .perm-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.6;
  }

  .perm-locked {
    color: var(--green);
    font-size: 18px;
    cursor: not-allowed;
  }

  .perm-dirty {
    background: var(--gold-light) !important;
    animation: pulse 1s ease infinite;
  }

  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
  }

  .perm-search {
    flex: 1;
    min-width: 200px;
    padding: 8px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    background: var(--bg);
  }

  .perm-search:focus {
    outline: none;
    border-color: var(--green);
    background: #fff;
  }

  /* ============ LOCATIONS / SUPERVISOR ============ */
  .supervisor-hero {
    background: linear-gradient(135deg, #2563EB, #1E40AF);
    color: #fff;
    padding: 22px 18px;
    border-radius: 16px;
    margin-bottom: 16px;
    box-shadow: 0 10px 30px rgba(37,99,235,0.25);
  }

  .supervisor-hero h2 {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 20px;
    margin-bottom: 6px;
  }

  .supervisor-hero p {
    font-size: 13px;
    opacity: 0.9;
  }

  .supervisor-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
    margin-top: 12px;
  }

  .supervisor-stat {
    background: rgba(255,255,255,0.18);
    padding: 10px 8px;
    border-radius: 10px;
    text-align: center;
    backdrop-filter: blur(4px);
  }

  .supervisor-stat-val {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 24px;
    line-height: 1;
  }

  .supervisor-stat-lbl {
    font-size: 11px;
    opacity: 0.9;
    margin-top: 2px;
  }

  .location-card {
    background: var(--card);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    transition: all 0.2s;
  }

  .location-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
  }

  .location-card.housing { border-right: 4px solid #2563EB; }
  .location-card.factory { border-right: 4px solid #C8A24A; }

  .location-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
  }

  .location-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 15px;
  }

  .location-meta {
    font-size: 12px;
    color: var(--ink-soft);
    margin-bottom: 8px;
  }

  .location-capacity-bar {
    background: var(--bg);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
  }

  .location-capacity-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green-dark), var(--green));
    transition: width 0.5s;
  }

  .location-capacity-fill.warn { background: linear-gradient(90deg, #EA580C, #DC2626); }

  /* Worker card for supervisor view */
  .sup-worker-card {
    background: var(--card);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
  }

  .sup-worker-card.pending { border-right: 4px solid #EA580C; background: #FFF7ED; }
  .sup-worker-card.active { border-right: 4px solid var(--green); }
  .sup-worker-card.at-risk { border-right: 4px solid #DC2626; background: #FEF2F2; }

  .sup-worker-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 10px;
  }

  .sup-action-btn {
    padding: 10px 8px;
    border: none;
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .sup-action-btn:hover { transform: translateY(-1px); }

  .sup-action-btn.success {
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #fff;
    box-shadow: 0 2px 8px rgba(31,110,67,0.25);
  }

  .sup-action-btn.warn {
    background: linear-gradient(135deg, #EA580C, #DC2626);
    color: #fff;
    box-shadow: 0 2px 8px rgba(220,38,38,0.25);
  }

  .sup-action-btn.gold {
    background: linear-gradient(135deg, #C8A24A, #B8932F);
    color: #fff;
    box-shadow: 0 2px 8px rgba(200,162,74,0.25);
  }

  .sup-action-btn.secondary {
    background: var(--bg);
    color: var(--ink);
    border: 1.5px solid var(--line);
  }

  /* Report cards */
  .report-card {
    background: var(--card);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border-right: 4px solid var(--ink-soft);
  }

  .report-card.emergency { border-right-color: #DC2626; background: #FEF2F2; }
  .report-card.important { border-right-color: #EA580C; background: #FFF7ED; }
  .report-card.normal { border-right-color: #2563EB; }
  .report-card.financial { border-right-color: #16A34A; }

  .report-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
  }

  /* Section header */
  .sup-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0 12px;
    padding: 0 4px;
  }

  .sup-section-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .sup-section-count {
    background: var(--green);
    color: #fff;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
  }

  /* ============ BULK SELECTION & QUICK STATUS (Sprint 5.1) ============ */
  .bulk-toolbar {
    background: var(--card);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }

  .bulk-toolbar-btn {
    padding: 8px 14px;
    background: var(--bg);
    border: 1.5px solid var(--line);
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    color: var(--ink);
    transition: all 0.2s;
  }

  .bulk-toolbar-btn:hover {
    border-color: var(--green);
    color: var(--green);
  }

  .bulk-toolbar-btn.active {
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #fff;
    border-color: var(--green);
  }

  .worker-item.selected {
    background: #EEF2FF;
    border-color: var(--info);
    box-shadow: 0 0 0 2px rgba(31,110,67,0.15);
  }

  .bulk-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--green);
    flex-shrink: 0;
  }

  .worker-item-with-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
  }

  .worker-item-content {
    flex: 1;
    min-width: 0;
  }

  /* Quick Status Dropdown */
  .quick-status-wrap {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
  }

  .quick-status-label {
    font-size: 11px;
    color: var(--ink-soft);
    margin-bottom: 4px;
    font-weight: 700;
  }

  .quick-status-select {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-size: 13px;
    font-weight: 700;
    background: var(--card);
    cursor: pointer;
    color: var(--ink);
    transition: all 0.2s;
  }

  .quick-status-select:hover { border-color: var(--green); }
  .quick-status-select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,110,67,0.1); }

  /* Sticky Bulk Action Bar */
  .bulk-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 50;
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #fff;
    border-radius: 14px;
    padding: 12px 14px;
    margin-top: 16px;
    box-shadow: 0 -4px 20px rgba(20,82,57,0.3);
    display: none;
  }

  .bulk-action-bar.show { display: block; animation: slideUp 0.3s ease; }

  @keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

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

  .bulk-action-count {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 15px;
  }

  .bulk-action-cancel {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
  }

  .bulk-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .bulk-action-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    padding: 10px;
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .bulk-action-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
  }

  .bulk-action-btn.danger {
    background: rgba(220,38,38,0.4);
  }

  .bulk-action-btn.danger:hover {
    background: rgba(220,38,38,0.6);
  }

  /* Housing with Factories Hierarchy */
  .housing-card {
    background: var(--card);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    border-right: 4px solid #2563EB;
  }

  .housing-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .housing-factories-section {
    background: var(--gold-light);
    border-radius: 10px;
    padding: 12px;
    margin-top: 12px;
  }

  .housing-factories-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }

  .housing-factories-title {
    font-weight: 800;
    font-size: 13px;
    color: #92400E;
  }

  .housing-factory-item {
    background: var(--card);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .housing-factory-item:last-child { margin-bottom: 0; }

  .factory-name {
    font-size: 13px;
    font-weight: 700;
  }

  .factory-meta {
    font-size: 11px;
    color: var(--ink-soft);
  }

  /* ============ INSIGHTS HUB (Sprint 7) ============ */
  .insights-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 6px;
    background: var(--card);
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
  }

  .insights-tab {
    padding: 10px 16px;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: var(--ink-soft);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
  }

  .insights-tab:hover { color: var(--green); background: var(--bg); }

  .insights-tab.active {
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #fff;
    box-shadow: 0 4px 12px rgba(31,110,67,0.25);
  }

  .insights-tab-content { display: none; }
  .insights-tab-content.active { display: block; animation: fadeIn 0.3s ease; }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Recommendation Cards */
  .rec-card {
    background: var(--card);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    border-right: 4px solid #64748B;
    transition: all 0.2s;
  }

  .rec-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  .rec-card.high { border-right-color: #DC2626; background: #FEF2F2; }
  .rec-card.medium { border-right-color: #EA580C; background: #FFF7ED; }
  .rec-card.positive { border-right-color: #16A34A; background: #F0FDF4; }

  .rec-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 12px;
  }

  .rec-icon-title {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
  }

  .rec-icon {
    font-size: 26px;
    flex-shrink: 0;
  }

  .rec-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 15px;
    margin-bottom: 4px;
  }

  .rec-priority-badge {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
  }

  .rec-priority-badge.high { background: #DC2626; color: #fff; }
  .rec-priority-badge.medium { background: #EA580C; color: #fff; }
  .rec-priority-badge.positive { background: #16A34A; color: #fff; }

  .rec-description {
    font-size: 13px;
    color: var(--ink);
    margin-bottom: 8px;
    line-height: 1.5;
  }

  .rec-action {
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 700;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
  }

  /* Anomaly Cards */
  .anomaly-card {
    background: var(--card);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border-right: 4px solid #64748B;
  }

  .anomaly-card.critical { border-right-color: #DC2626; background: #FEF2F2; }
  .anomaly-card.warning { border-right-color: #EA580C; background: #FFF7ED; }
  .anomaly-card.positive { border-right-color: #16A34A; background: #F0FDF4; }

  /* Insights KPI cards */
  .insights-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }

  .insights-kpi {
    background: var(--card);
    border-radius: 12px;
    padding: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    text-align: center;
  }

  .insights-kpi-val {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 22px;
    margin-bottom: 4px;
    line-height: 1;
  }

  .insights-kpi-lbl {
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 600;
  }

  .insights-kpi-change {
    font-size: 11px;
    margin-top: 4px;
    font-weight: 700;
  }

  .insights-kpi-change.up { color: var(--green-dark); }
  .insights-kpi-change.down { color: var(--warn); }

  /* Funnel visualization */
  .funnel-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
  }

  .funnel-label {
    width: 100px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
  }

  .funnel-bar-wrap {
    flex: 1;
    background: var(--bg);
    border-radius: 8px;
    height: 28px;
    position: relative;
    overflow: hidden;
  }

  .funnel-bar {
    background: linear-gradient(90deg, var(--green-dark), var(--green));
    height: 100%;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    transition: width 0.5s;
  }

  .funnel-pct {
    width: 50px;
    text-align: left;
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 700;
  }

  /* Section card */
  .insights-section {
    background: var(--card);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
  }

  .insights-section-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 16px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* Performance table rows */
  .perf-row {
    display: grid;
    grid-template-columns: 30px 1fr auto auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 4px;
    background: var(--bg);
  }

  .perf-row.top { background: #FEF3C7; }
  .perf-row.problem { background: #FEE2E2; }

  .perf-rank {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    text-align: center;
  }

  .perf-name {
    font-weight: 700;
    font-size: 14px;
  }

  .perf-stat {
    font-size: 12px;
    color: var(--ink-soft);
    text-align: center;
  }

  .perf-rate {
    font-weight: 800;
    font-size: 14px;
  }

  /* Drop-off card */
  .dropoff-card {
    background: var(--bg);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .dropoff-card.high { background: #FEE2E2; border-right: 3px solid #DC2626; }
  .dropoff-card.medium { background: #FFF7ED; border-right: 3px solid #EA580C; }
  .dropoff-card.low { background: #F0FDF4; border-right: 3px solid #16A34A; }

  .dropoff-pct {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 20px;
  }

  /* City card */
  .city-card {
    background: var(--bg);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
  }

  .city-card.opportunity { background: #DCFCE7; border-right: 3px solid #16A34A; }
  .city-card.problem { background: #FEE2E2; border-right: 3px solid #DC2626; }

  /* Hour chart */
  .hour-bars {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 2px;
    align-items: end;
    height: 100px;
    margin-bottom: 8px;
  }

  .hour-bar {
    background: linear-gradient(180deg, var(--green), var(--green-dark));
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    transition: all 0.3s;
  }

  .hour-bar:hover { opacity: 0.7; cursor: pointer; }

  .hour-bar.best { background: linear-gradient(180deg, #C8A24A, #B8932F); }

  /* ============ PWA: OFFLINE & INSTALL ============ */

  /* Offline indicator banner */
  .pwa-offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #DC2626, #B91C1C);
    color: #fff;
    padding: 10px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    z-index: 10000;
    display: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    animation: slideDown 0.3s ease;
  }

  .pwa-offline-banner.show {
    display: block;
  }

  .pwa-offline-banner.online {
    background: linear-gradient(135deg, #16A34A, #15803D);
    animation: slideDownOut 2s ease forwards;
  }

  @keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
  }

  @keyframes slideDownOut {
    0% { transform: translateY(0); }
    70% { transform: translateY(0); }
    100% { transform: translateY(-100%); }
  }

  /* Install Banner */
  .pwa-install-banner {
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    background: linear-gradient(135deg, #145239, #1F6E43);
    color: #fff;
    padding: 14px 16px;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    z-index: 9999;
    display: none;
    align-items: center;
    gap: 12px;
    max-width: 500px;
    margin: 0 auto;
    animation: slideUp 0.4s ease;
  }

  .pwa-install-banner.show {
    display: flex;
  }

  @keyframes slideUp {
    from { transform: translateY(120%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .pwa-install-icon {
    font-size: 32px;
    flex-shrink: 0;
  }

  .pwa-install-content {
    flex: 1;
    min-width: 0;
  }

  .pwa-install-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 2px;
  }

  .pwa-install-desc {
    font-size: 11px;
    opacity: 0.9;
  }

  .pwa-install-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
  }

  .pwa-install-btn {
    background: #C8A24A;
    color: #145239;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
  }

  .pwa-install-btn-secondary {
    background: rgba(255,255,255,0.15);
    color: #fff;
    padding: 8px 10px;
  }

  /* PWA Mode Adjustments (when running as installed app) */
  @media (display-mode: standalone) {
    body {
      /* Safe area for notch */
      padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom);
    }

    /* Hide elements meant for browser only */
    .browser-only { display: none !important; }
  }

  /* Update available banner */
  .pwa-update-banner {
    position: fixed;
    top: 16px;
    left: 16px;
    right: 16px;
    background: var(--gold);
    color: #145239;
    padding: 12px 14px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 9999;
    display: none;
    align-items: center;
    gap: 10px;
    max-width: 500px;
    margin: 0 auto;
  }

  .pwa-update-banner.show {
    display: flex;
  }


  .cash-hero {
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
  }

  .cash-hero-label {
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 6px;
    font-weight: 500;
  }

  .cash-hero-val {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 36px;
    line-height: 1;
    margin-bottom: 10px;
  }

  .cash-hero-breakdown {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    font-size: 12px;
  }

  .cash-hero-stat {
    background: rgba(255,255,255,0.15);
    padding: 8px;
    border-radius: 8px;
    text-align: center;
  }

  .cash-hero-stat-val {
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 2px;
  }

  .cash-hero-stat-lbl {
    opacity: 0.85;
    font-size: 10px;
  }

  /* My Cash (Collector) - Big balance */
  .my-cash-hero {
    background: linear-gradient(135deg, #BA7517, var(--gold));
    color: #fff;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
    text-align: center;
    box-shadow: var(--shadow-md);
  }

  .my-cash-hero-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
    font-weight: 500;
  }

  .my-cash-hero-val {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 56px;
    line-height: 1;
    margin-bottom: 10px;
  }

  .my-cash-hero-meta {
    font-size: 13px;
    opacity: 0.9;
  }

  /* Balance Cards (Admin) */
  .balance-card {
    background: var(--card);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    border-right: 4px solid var(--ink-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .balance-card.high { background: #FEF3C7; border-right-color: #D97706; }
  .balance-card.critical { background: #FEE2E2; border-right-color: #DC2626; }
  .balance-card.overdue { background: #FED7AA; border-right-color: #EA580C; }
  .balance-card.normal { background: var(--card); border-right-color: var(--ink-soft); }
  .balance-card.fresh { background: #DCFCE7; border-right-color: #16A34A; }

  .balance-info {
    flex: 1;
  }

  .balance-name {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 15px;
    margin-bottom: 2px;
  }

  .balance-meta {
    font-size: 11px;
    color: var(--ink-soft);
  }

  .balance-amount {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 20px;
    text-align: left;
  }

  .balance-amount.high { color: #D97706; }
  .balance-amount.critical { color: #DC2626; }
  .balance-amount.normal { color: var(--green-dark); }

  /* Transaction items */
  .tx-item {
    background: var(--card);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 6px;
    box-shadow: var(--shadow-sm);
    border-right: 3px solid var(--ink-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }

  .tx-item.in { border-right-color: #16A34A; background: #F0FDF4; }
  .tx-item.out { border-right-color: #2563EB; background: #EFF6FF; }
  .tx-item.adjustment { border-right-color: #EA580C; background: #FFF7ED; }
  .tx-item.pending { border-right-color: #EAB308; background: #FEFCE8; }

  .tx-info {
    flex: 1;
    min-width: 0;
  }

  .tx-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 2px;
  }

  .tx-meta {
    font-size: 11px;
    color: var(--ink-soft);
  }

  .tx-amount {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 16px;
    white-space: nowrap;
  }

  .tx-amount.in { color: #16A34A; }
  .tx-amount.out { color: #2563EB; }
  .tx-amount.neg { color: #DC2626; }

  /* Alerts */
  .cash-alert {
    background: var(--card);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 6px;
    border-right: 3px solid;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .cash-alert.critical { background: #FEE2E2; border-right-color: #DC2626; }
  .cash-alert.warning { background: #FEF3C7; border-right-color: #D97706; }

  .cash-alert-icon {
    font-size: 24px;
  }

  .cash-alert-msg {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
  }

  /* Settlement form */
  .settlement-form {
    background: var(--green-light);
    border: 2px solid var(--green);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 14px;
  }

  .settlement-form-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 16px;
    color: var(--green-dark);
    margin-bottom: 12px;
  }

  .expected-hint {
    background: var(--card);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--green-dark);
    text-align: center;
  }

  .expected-hint-val {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 22px;
    color: var(--green-dark);
  }

  /* Discrepancy warning */
  .discrepancy-box {
    background: #FED7AA;
    border: 2px solid #EA580C;
    border-radius: 8px;
    padding: 10px;
    margin-top: 8px;
    font-size: 12px;
    color: #9A3412;
  }



/* ===== My Dashboard styles ===== */

.md-view-btn {
  background: transparent; border: none; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; font-size: 13px; color: #6B7280;
  transition: all 0.2s;
}
.md-view-btn-active {
  background: #1F6E43; color: white;
}
.md-funnel-bar {
  position: relative; padding: 10px 14px; border-radius: 6px;
  color: white; font-weight: 500; margin-bottom: 4px; transition: all 0.3s;
}
.md-badge {
  background: white; border-radius: 10px; padding: 12px;
  text-align: center; transition: all 0.3s; position: relative;
}
.md-badge.earned { box-shadow: 0 0 0 2px #FBBF24, 0 4px 12px rgba(251, 191, 36, 0.3); }
.md-badge.locked { opacity: 0.5; filter: grayscale(0.7); }
.md-insight-card {
  background: white; border-radius: 8px; padding: 12px 14px;
  display: flex; gap: 12px; align-items: start; box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  border-right: 4px solid #6B7280;
}
.md-insight-card.critical { border-color: #DC2626; background: #FEF2F2; }
.md-insight-card.warning { border-color: #F59E0B; background: #FFFBEB; }
.md-insight-card.positive { border-color: #10B981; background: #F0FDF4; }
.md-insight-card.info { border-color: #3B82F6; background: #EFF6FF; }
@media (max-width: 768px) {
  #md-charts-row { grid-template-columns: 1fr !important; }
}
