* { box-sizing: border-box; margin: 0; padding: 0; }
      body {
        font-family: system-ui, -apple-system, sans-serif;
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
        background: #f8fafc;
        color: #1e293b;
      }
      h1 { font-size: 28px; margin-bottom: 8px; }
      h2 { font-size: 20px; margin-top: 36px; padding-bottom: 10px; border-bottom: 2px solid #e2e8f0; margin-bottom: 16px; }
      h3 { font-size: 16px; margin-bottom: 12px; }

      .stats-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 16px;
        margin-top: 16px;
      }
      .stat-card {
        padding: 20px;
        border: none;
        border-radius: 12px;
        background: #ffffff;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
      }
      .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
      }
      .stat-card strong { font-size: 14px; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
      .stat-card .value { font-size: 32px; font-weight: 800; margin-top: 8px; color: #0f172a; }

      .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

      input, select, textarea {
        padding: 12px 16px;
        border: 2px solid #e2e8f0;
        border-radius: 8px;
        font-size: 14px;
        background: #f8fafc;
        transition: all 0.2s ease;
      }
      input:focus, select:focus, textarea:focus {
        outline: none;
        border-color: #6366f1;
        background: #ffffff;
        box-shadow: 0 0 0 4px rgba(99,102,241,0.15);
      }

      button {
        padding: 12px 20px;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 600;
        background: #ffffff;
        color: #334155;
        border: 1px solid #e2e8f0;
        box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        transition: all 0.2s ease;
        display: inline-flex;
        align-items: center;
        gap: 8px;
      }
      button:hover { 
        background: #f8fafc; 
        transform: translateY(-1px);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
      }
      button:active { transform: translateY(0); }
      
      .btn-primary { background: linear-gradient(135deg, #6366f1, #4f46e5); color: white; border: none; }
      .btn-primary:hover { background: linear-gradient(135deg, #4f46e5, #4338ca); color: white; }
      .btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; border: none; }
      .btn-danger:hover { background: linear-gradient(135deg, #dc2626, #b91c1c); color: white; }
      .btn-success { background: linear-gradient(135deg, #22c55e, #16a34a); color: white; border: none; }
      .btn-success:hover { background: linear-gradient(135deg, #16a34a, #15803d); color: white; }

      table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        margin-top: 16px;
        background: white;
        border-radius: 12px;
        overflow: hidden;
        border: 1px solid #e2e8f0;
        box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
      }
      th { background: #f8fafc; font-size: 13px; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; padding: 14px 16px; border-bottom: 2px solid #e2e8f0; }
      td { padding: 14px 16px; text-align: left; border-bottom: 1px solid #e2e8f0; font-size: 14px; color: #334155; }
      tr:last-child td { border-bottom: none; }
      tr:hover td { background: #f1f5f9; }

      .form-card {
        padding: 24px;
        border: none;
        border-radius: 12px;
        background: white;
        margin-bottom: 24px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
      }
      .form-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 16px;
      }
      .form-grid input, .form-grid select { width: 100%; }

      /* --- Modal system with proper z-index --- */
      .modal-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.2s, visibility 0.2s;
      }
      .modal-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
      }
      /* Each subsequent modal gets a higher z-index */
      .modal-overlay.z2 { z-index: 1010; }
      .modal-overlay.z3 { z-index: 1020; }

      .modal-box {
        background: white;
        padding: 28px;
        border-radius: 14px;
        width: 100%;
        max-width: 520px;
        max-height: 85vh;
        overflow-y: auto;
        box-shadow: 0 20px 60px rgba(0,0,0,0.3);
        transform: translateY(10px);
        transition: transform 0.2s;
      }
      .modal-overlay.active .modal-box {
        transform: translateY(0);
      }
      .modal-box h2 { margin-top: 0; border: none; padding-bottom: 0; margin-bottom: 16px; }

      .msg { font-size: 14px; margin-top: 10px; }
      .msg-error { color: #dc2626; }
      .msg-success { color: #16a34a; }

      .tab-bar { 
        display: flex; 
        gap: 8px; 
        margin-bottom: 0; 
        border-bottom: 2px solid #e2e8f0; 
        padding-bottom: 12px;
        overflow-x: auto;
      }
      .tab-btn {
        padding: 10px 18px;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-weight: 600;
        color: #64748b;
        transition: all 0.2s ease;
        white-space: nowrap;
        box-shadow: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
      }
      .tab-btn:hover { 
        color: #4f46e5;
        background: #f1f5f9;
        transform: translateY(-1px);
        box-shadow: none;
      }
      .tab-btn.active { 
        color: #ffffff; 
        background: linear-gradient(135deg, #6366f1, #4f46e5); 
        box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
      }
      .tab-panel { display: none; padding-top: 24px; animation: fadeIn 0.3s ease-in-out; }
      .tab-panel.active { display: block; }
      @keyframes fadeIn {
        from { opacity: 0; transform: translateY(4px); }
        to { opacity: 1; transform: translateY(0); }
      }

      .badge {
        display: inline-block;
        padding: 3px 10px;
        border-radius: 999px;
        font-size: 12px;
        font-weight: 600;
      }
      .badge-green { background: #dcfce7; color: #166534; }
      .badge-red { background: #fee2e2; color: #991b1b; }
      .badge-blue { background: #dbeafe; color: #1e40af; }
      .badge-yellow { background: #fef9c3; color: #854d0e; }

      #loginSection {
        max-width: 400px;
        margin: 80px auto;
        padding: 32px;
        background: white;
        border-radius: 14px;
        border: 1px solid #e2e8f0;
      }
      #loginSection h1 { text-align: center; margin-bottom: 20px; }
      #loginSection input { width: 100%; margin-bottom: 10px; }
      #loginSection button { width: 100%; }

      .logout-btn { float: right; font-size: 13px; }