﻿:root {
    --bg: #f8fbff;
    --surface: #ffffff;
    --surface2: #f3f7fb;
    --surface3: #eef3f8;
    --border: #d4e4f1;
    --accent: #0ea5e9;
    --accent2: #06b6d4;
    --gold: #f59e0b;
    --green: #10b981;
    --red: #ef4444;
    --purple: #a855f7;
    --text: #1f2937;
    --text2: #6b7280;
    --text3: #9ca3af;
    --glow: rgba(14,165,233,0.08);
    --gold-glow: rgba(245,158,11,0.08);
  }

  body[data-theme="dark"] {
    --bg: #08111f;
    --surface: #0d1729;
    --surface2: #12203a;
    --surface3: #17304e;
    --border: #23354f;
    --accent: #38bdf8;
    --accent2: #22d3ee;
    --gold: #fbbf24;
    --green: #34d399;
    --red: #f87171;
    --purple: #a78bfa;
    --text: #e5eef9;
    --text2: #b5c2d6;
    --text3: #7c8ca5;
    --glow: rgba(56,189,248,0.12);
    --gold-glow: rgba(251,191,36,0.08);
  }

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

  body {
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
  }

  /* Ambient background */
  body::before {
    content: '';
    position: fixed;
    top: -30%;
    right: -20%;
    width: 70vw;
    height: 70vw;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
  }
  body::after {
    content: '';
    position: fixed;
    bottom: -20%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
  }

  /* Sidebar */
  .sidebar {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 260px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  }

  .sidebar-logo {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
  }

  .logo-mark {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(14,165,233,0.25);
  }

  .logo-text { flex: 1; }
  .logo-title { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.3; }
  .logo-sub { font-size: 11px; color: var(--text3); margin-top: 2px; font-family: 'JetBrains Mono'; }

  .role-badge {
    margin: 16px 20px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(245,158,11,0.04));
    border: 1px solid rgba(245,158,11,0.25);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .role-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--gold), #d97706);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
  }

  .role-info { flex: 1; min-width: 0; }
  .role-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .role-label { font-size: 10px; color: var(--gold); margin-top: 1px; }

  nav { flex: 1; padding: 8px 12px; overflow-y: auto; }

  .nav-section { margin-bottom: 20px; }
  .nav-section-title { font-size: 10px; color: var(--text3); font-weight: 600; letter-spacing: 0.1em; padding: 0 8px; margin-bottom: 6px; text-transform: uppercase; }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 2px;
    text-decoration: none;
    color: var(--text2);
    font-size: 13px;
    font-weight: 500;
    position: relative;
  }

  .nav-item:hover { background: var(--surface2); color: var(--text); }
  .nav-item.active {
    background: linear-gradient(135deg, rgba(14,165,233,0.12), rgba(6,182,212,0.08));
    color: var(--accent);
    border: 1px solid rgba(14,165,233,0.3);
  }
  .nav-item.active .nav-icon { color: var(--accent); }

  .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
  .nav-badge {
    margin-inline-start: auto;
    background: var(--red);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    font-family: 'JetBrains Mono';
  }

  .nav-badge.green { background: var(--green); }
  .nav-badge.gold { background: var(--gold); color: #000; }

  /* Main content */
  .main {
    margin-right: 260px;
    min-height: 100vh;
    position: relative;
    z-index: 1;
  }

  /* Top bar */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
  }

  body[data-theme="dark"] .topbar {
    background: rgba(13, 23, 41, 0.9);
  }

  .topbar-title { font-size: 18px; font-weight: 700; }
  .topbar-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

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

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s;
  }

  .btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: white;
    box-shadow: 0 4px 15px rgba(14,165,233,0.25);
  }

  body[data-theme="dark"] .btn-primary {
    box-shadow: 0 6px 18px rgba(56,189,248,0.2);
  }
  .btn-primary:hover { box-shadow: 0 8px 25px rgba(14,165,233,0.35); transform: translateY(-1px); }

  .btn-ghost {
    background: var(--surface2);
    color: var(--text2);
    border: 1px solid var(--border);
  }

  body[data-theme="dark"] .btn-ghost {
    background: rgba(18, 32, 58, 0.9);
  }
  .btn-ghost:hover { background: var(--surface3); color: var(--text); }

  .notif-btn {
    width: 38px; height: 38px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    font-size: 16px;
    transition: all 0.2s;
  }
  .notif-btn:hover { background: var(--surface3); border-color: var(--accent2); }
  .notif-dot {
    position: absolute;
    top: 6px; left: 6px;
    width: 8px; height: 8px;
    background: var(--red);
    border-radius: 50%;
    border: 2px solid var(--surface);
  }

  /* Content */
  .content { padding: 28px 32px; }

  /* Stats row */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
  }

  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
  }
  .stat-card::before {
    content: '';
    position: absolute;
    top: 0; inset-inline-end: 0;
    width: 60px; height: 60px;
    border-radius: 0 14px 0 60px;
    opacity: 0.08;
  }
  .stat-card.blue::before { background: var(--accent); }
  .stat-card.green::before { background: var(--green); }
  .stat-card.gold::before { background: var(--gold); }
  .stat-card.purple::before { background: var(--purple); }

  .stat-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }

  .stat-icon {
    font-size: 24px;
    margin-bottom: 12px;
    display: block;
  }
  .stat-value {
    font-size: 32px;
    font-weight: 700;
    font-family: 'JetBrains Mono';
    line-height: 1;
    margin-bottom: 6px;
  }
  .stat-card.blue .stat-value { color: var(--accent2); }
  .stat-card.green .stat-value { color: var(--green); }
  .stat-card.gold .stat-value { color: var(--gold); }
  .stat-card.purple .stat-value { color: var(--purple); }
  .stat-label { font-size: 12px; color: var(--text2); }
  .stat-change { font-size: 11px; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
  .stat-change.up { color: var(--green); }
  .stat-change.down { color: var(--red); }

  /* Main grid */
  .main-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
  }

  /* Card */
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 20px;
  }

  body[data-theme="dark"] .card {
    box-shadow: 0 12px 28px rgba(2, 8, 23, 0.28);
  }

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

  .card-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
  .card-title-icon { font-size: 16px; }

  .card-body { padding: 22px; }

  /* Policy list */
  .policy-item {
    padding: 16px;
    border-radius: 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
  }
  .policy-item:hover { border-color: rgba(14,165,233,0.5); background: var(--surface3); box-shadow: 0 4px 12px rgba(14,165,233,0.08); }

  .policy-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }

  .policy-status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
  }
  .status-active { background: var(--green); box-shadow: 0 0 8px var(--green); }
  .status-review { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
  .status-draft { background: var(--text3); }
  .status-pending { background: var(--purple); box-shadow: 0 0 8px var(--purple); }

  .policy-title { font-size: 13px; font-weight: 600; flex: 1; line-height: 1.4; }
  .policy-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

  .tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
  }

  body[data-theme="dark"] .tag {
    border-color: rgba(148,163,184,0.18);
  }

  .tag-dept { background: rgba(14,165,233,0.1); color: var(--accent2); border: 1px solid rgba(14,165,233,0.2); }
  .tag-active { background: rgba(16,185,129,0.1); color: var(--green); border: 1px solid rgba(16,185,129,0.2); }
  .tag-review { background: rgba(245,158,11,0.1); color: var(--gold); border: 1px solid rgba(245,158,11,0.2); }
  .tag-draft { background: rgba(100,116,139,0.1); color: var(--text3); border: 1px solid var(--border); }
  .tag-pending { background: rgba(139,92,246,0.1); color: #a78bfa; border: 1px solid rgba(139,92,246,0.2); }

  .policy-progress { margin-top: 10px; }
  .progress-label { display: flex; justify-content: space-between; font-size: 10px; color: var(--text3); margin-bottom: 5px; }
  .progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
  .progress-fill { height: 100%; border-radius: 2px; transition: width 1s ease; }
  .fill-green { background: linear-gradient(90deg, var(--green), #34d399); }
  .fill-blue { background: linear-gradient(90deg, var(--accent), var(--accent2)); }
  .fill-gold { background: linear-gradient(90deg, var(--gold), #fbbf24); }

  /* Workflow */
  .workflow {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 16px 22px;
    overflow-x: auto;
  }

  .workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    position: relative;
  }

  .workflow-step::after {
    content: '';
    position: absolute;
    top: 18px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--border);
  }

  .workflow-step:first-child::after { display: none; }

  .workflow-step.done::after { background: var(--green); }
  .workflow-step.active::after { background: linear-gradient(90deg, var(--green), var(--accent)); }

  .step-circle {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    position: relative;
    z-index: 1;
    margin-bottom: 8px;
    border: 2px solid var(--border);
    background: var(--surface);
  }

  .workflow-step.done .step-circle { background: var(--green); border-color: var(--green); color: white; }
  .workflow-step.active .step-circle {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 15px rgba(14,165,233,0.4);
    animation: pulse-step 2s infinite;
  }

  @keyframes pulse-step {
    0%, 100% { box-shadow: 0 0 15px rgba(14,165,233,0.4); }
    50% { box-shadow: 0 0 25px rgba(14,165,233,0.7); }
  }

  .step-label { font-size: 10px; color: var(--text3); text-align: center; max-width: 80px; }
  .workflow-step.done .step-label { color: var(--green); }
  .workflow-step.active .step-label { color: var(--accent2); }

  /* Approval card */
  .approval-card {
    background: linear-gradient(135deg, var(--surface2), var(--surface3));
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 12px;
  }

  .approval-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .approval-title { font-size: 13px; font-weight: 600; }
  .approval-time { font-size: 10px; color: var(--text3); font-family: 'JetBrains Mono'; }

  .approval-meta { font-size: 11px; color: var(--text2); margin-bottom: 14px; line-height: 1.6; }

  .approval-actions { display: flex; gap: 8px; }

  .btn-approve {
    flex: 1; padding: 9px;
    background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(16,185,129,0.1));
    border: 1px solid var(--green);
    color: var(--green);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
  }
  .btn-approve:hover { background: var(--green); color: white; }

  .btn-reject {
    flex: 1; padding: 9px;
    background: linear-gradient(135deg, rgba(239,68,68,0.1), rgba(239,68,68,0.05));
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--red);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
  }
  .btn-reject:hover { background: var(--red); color: white; }

  /* Sidebar right panel */
  .right-panel { }

  /* Activity feed */
  .activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }
  .activity-item:last-child { border-bottom: none; }

  .activity-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
  }

  .activity-content { flex: 1; min-width: 0; }
  .activity-text { font-size: 12px; color: var(--text2); line-height: 1.5; }
  .activity-text strong { color: var(--text); }
  .activity-time { font-size: 10px; color: var(--text3); margin-top: 3px; font-family: 'JetBrains Mono'; }

  /* Leaderboard */
  .leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .leaderboard-item:last-child { border-bottom: none; }

  .lb-rank {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: 'JetBrains Mono';
    flex-shrink: 0;
  }
  .rank-1 { background: linear-gradient(135deg, #f59e0b, #d97706); color: #000; }
  .rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: white; }
  .rank-3 { background: linear-gradient(135deg, #b45309, #92400e); color: white; }
  .rank-other { background: var(--surface2); color: var(--text3); }

  .lb-dept { flex: 1; font-size: 12px; font-weight: 600; }
  .lb-score { font-family: 'JetBrains Mono'; font-size: 13px; font-weight: 700; }

  .lb-bar-wrap { width: 80px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
  .lb-bar { height: 100%; border-radius: 2px; }
  .bar-1 { background: linear-gradient(90deg, var(--gold), #fbbf24); width: 98%; }
  .bar-2 { background: linear-gradient(90deg, var(--accent), var(--accent2)); width: 85%; }
  .bar-3 { background: linear-gradient(90deg, var(--purple), #a78bfa); width: 78%; }
  .bar-4 { background: linear-gradient(90deg, var(--green), #34d399); width: 65%; }
  .bar-5 { background: linear-gradient(90deg, var(--red), #f87171); width: 52%; }

  /* AI chip */
  .ai-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(139,92,246,0.05));
    border: 1px solid rgba(139,92,246,0.3);
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    color: #a78bfa;
  }

  /* Tabs */
  .tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface2); border-radius: 10px; margin-bottom: 20px; }
  .tab {
    flex: 1; padding: 8px 14px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    color: var(--text3);
    border: none;
    background: none;
    font-family: inherit;
  }
  .tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,0.1); font-weight: 700; }
  .tab:hover:not(.active) { color: var(--text2); }

  /* Filter bar */
  .filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
  .filter-chip {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text3);
    transition: all 0.2s;
  }
  .filter-chip.active { background: rgba(14,165,233,0.12); border-color: rgba(14,165,233,0.4); color: var(--accent); }
  .filter-chip:hover:not(.active) { color: var(--text2); border-color: var(--text3); }

  .search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
  }
  .search-input::placeholder { color: var(--text3); }
  .search-input:focus { border-color: var(--accent); }
  .search-hit {
    background: rgba(251, 191, 36, 0.38);
    color: inherit;
    border-radius: 4px;
    padding: 0 2px;
  }

  body[data-page="policies"] .card {
    overflow: visible;
  }

  body[data-page="policies"] .filter-bar {
    position: sticky;
    top: 74px;
    z-index: 6;
    margin-bottom: 14px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    backdrop-filter: blur(4px);
  }

  body[data-page="policies"] .filter-bar .btn {
    font-size: 11px;
    padding: 7px 10px;
  }

  body[data-page="policies"] #policyPresetSelect {
    min-width: 170px;
  }

  body[data-page="policies"] #policyPresetCount {
    font-size: 11px;
    padding: 6px 10px;
    font-weight: 700;
  }

  body[data-page="policies"] #policiesFilterSummary {
    font-size: 11px;
    padding: 6px 10px;
    font-weight: 700;
  }

  /* ISO export button */
  .iso-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(16,185,129,0.05));
    border: 1px solid rgba(16,185,129,0.25);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
    width: 100%;
    font-family: inherit;
    text-align: start;
  }
  .iso-btn:hover { background: rgba(16,185,129,0.15); border-color: var(--green); }
  .iso-icon { font-size: 22px; flex-shrink: 0; }
  .iso-text { flex: 1; }
  .iso-title { font-size: 12px; font-weight: 700; color: var(--green); }
  .iso-sub { font-size: 10px; color: var(--text3); margin-top: 2px; }

  /* Mobile toggle */
  .mobile-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 52px;
    height: 52px;
    background: var(--accent);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    z-index: 200;
    box-shadow: 0 4px 20px rgba(14,165,233,0.4);
    border: none;
  }

  /* Animations */
  @keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .card, .stat-card, .policy-item {
    animation: slideIn 0.5s ease forwards;
  }

  .stat-card:nth-child(2) { animation-delay: 0.05s; }
  .stat-card:nth-child(3) { animation-delay: 0.1s; }
  .stat-card:nth-child(4) { animation-delay: 0.15s; }

  /* Responsive */
  @media (max-width: 1200px) {
    .main-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
  }

  @media (max-width: 768px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-right: 0; }
    .content { padding: 16px; }
    .topbar { padding: 14px 16px; }
    .mobile-toggle { display: flex; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .topbar-title { font-size: 15px; }
    .topbar .btn-ghost { display: none; }
    .modal {
      align-items: flex-start;
      padding: 10px;
    }
    .modal-content {
      margin-top: 8px;
      max-height: calc(100vh - 20px);
    }
  }

  @media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 24px; }
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 4px; height: 4px; }
  ::-webkit-scrollbar-track { background: var(--surface); }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text3); }

  /* Overlay */
  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 90;
  }
  .overlay.show { display: block; }

  /* Modal */
  .modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
  }
  .modal.show { display: flex; }
  .modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); }
  .modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 520px;
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    position: relative;
    z-index: 1;
    animation: slideIn 0.3s ease;
  }
  .modal-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
  .modal-sub { font-size: 12px; color: var(--text2); margin-bottom: 20px; line-height: 1.6; }
  .modal-close {
    position: absolute;
    top: 16px; inset-inline-end: 16px;
    width: 32px; height: 32px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
  }
  .modal-close:hover { background: var(--surface3); border-color: var(--accent2); }
  .modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: min(880px, 100%);
    max-height: calc(100vh - 32px);
    overflow: hidden;
    position: relative;
    z-index: 1;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.2);
    animation: slideIn 0.25s ease;
  }
  .modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(14,165,233,0.06), rgba(6,182,212,0.03));
  }
  .modal-body {
    padding: 16px 20px;
    overflow: auto;
    max-height: calc(100vh - 190px);
  }
  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .pc-accordion {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
  }
  .pc-accordion > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    background: var(--surface2);
    border-bottom: 1px solid transparent;
  }
  .pc-accordion > summary::-webkit-details-marker { display: none; }
  .pc-accordion[open] > summary {
    border-bottom-color: var(--border);
  }
  .pc-accordion-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent2);
    background: rgba(14,165,233,0.12);
    border: 1px solid rgba(14,165,233,0.28);
    border-radius: 999px;
    padding: 2px 8px;
    min-width: 28px;
    text-align: center;
  }
  .pc-accordion-body {
    padding: 12px;
  }
  .form-group { margin-bottom: 16px; }
  .form-label { font-size: 11px; font-weight: 600; color: var(--text2); margin-bottom: 6px; display: block; }
  .form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
  }

  body[data-theme="dark"] .form-input,
  body[data-theme="dark"] .form-select,
  body[data-theme="dark"] .search-input {
    background: rgba(18, 32, 58, 0.95);
  }

  @media (max-width: 720px) {
    .modal-header { padding: 14px 14px; }
    .modal-body { padding: 12px 14px; }
    .modal-footer { padding: 10px 14px 14px; }
  }
  .form-input:focus { border-color: var(--accent); }
  .form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
  }

  /* Controls page redesign */
  body[data-page="controls"] .controls-kpi-grid .stat-card {
    min-height: 140px;
    transition: all 0.25s;
  }

  body[data-page="controls"] .controls-kpi-grid .stat-card:hover {
    border-color: rgba(14, 165, 233, 0.4);
    transform: translateY(-3px);
  }

  body[data-page="controls"] .controls-filters-card {
    background:
      radial-gradient(circle at 85% 15%, rgba(14, 165, 233, 0.14), transparent 45%),
      var(--surface);
    transition: border-color 0.2s;
  }

  body[data-page="controls"] .controls-filters-card:hover {
    border-color: rgba(14, 165, 233, 0.35);
  }

  body[data-page="controls"] .controls-filters-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  body[data-page="controls"] .controls-reset-btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  body[data-page="controls"] .controls-framework-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px dashed var(--border);
  }

  body[data-page="controls"] .fw-tab-btn {
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
  }

  body[data-page="controls"] .fw-tab-btn:hover {
    color: var(--text);
    border-color: rgba(14, 165, 233, 0.4);
  }

  body[data-page="controls"] .fw-tab-btn.active {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgba(14, 165, 233, 0.08));
    color: var(--accent2);
    border-color: rgba(14, 165, 233, 0.5);
    box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.2) inset;
  }

  body[data-page="controls"] .controls-filters-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
  }

  body[data-page="controls"] .controls-filter-field {
    display: grid;
    gap: 6px;
  }

  body[data-page="controls"] .controls-filter-field-search {
    grid-column: span 2;
  }

  body[data-page="controls"] .controls-filter-field-search input {
    transition: all 0.2s;
  }

  body[data-page="controls"] .controls-filter-field-search input:focus {
    background: var(--surface3);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
  }

  body[data-page="controls"] .controls-filter-label {
    font-size: 11px;
    color: var(--text2);
    font-weight: 600;
  }

  body[data-page="controls"] .controls-results-card .card-body {
    padding-top: 16px;
  }

  body[data-page="controls"] .controls-priority-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
  }

  body[data-page="controls"] .controls-priority-summary-item {
    background: linear-gradient(135deg, #f0f8ff, #e8f4fd);
    border: 1px solid rgba(14, 165, 233, 0.28);
    border-radius: 12px;
    padding: 12px 14px;
    text-align: center;
    transition: all 0.2s;
  }

  body[data-page="controls"] .controls-priority-summary-item:hover {
    border-color: rgba(14, 165, 233, 0.5);
    background: linear-gradient(135deg, #e0f2fe, #dbeafe);
  }

  body[data-page="controls"] .controls-priority-summary-value {
    font-family: 'JetBrains Mono';
    font-size: 22px;
    color: var(--accent);
    font-weight: 700;
    line-height: 1.1;
  }

  body[data-page="controls"] .controls-priority-summary-label {
    font-size: 11px;
    color: var(--text2);
    margin-top: 4px;
    font-weight: 500;
  }

  body[data-page="controls"] .controls-priority-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }

  body[data-page="controls"] .controls-priority-card {
    border: 1px solid rgba(239, 68, 68, 0.28);
    border-radius: 14px;
    background:
      radial-gradient(circle at 100% 0%, rgba(254, 226, 226, 0.8), transparent 50%),
      linear-gradient(135deg, #fff5f5, #fff);
    padding: 14px;
    display: grid;
    gap: 11px;
    transition: all 0.2s;
  }

  body[data-page="controls"] .controls-priority-card:hover {
    border-color: rgba(239, 68, 68, 0.45);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.1);
  }

  body[data-page="controls"] .controls-priority-card-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
  }

  body[data-page="controls"] .controls-priority-code {
    font-size: 10px;
    color: var(--text3);
    margin-bottom: 5px;
    font-family: 'JetBrains Mono';
    letter-spacing: 0.3px;
  }

  body[data-page="controls"] .controls-priority-title {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.6;
    color: var(--text);
  }

  body[data-page="controls"] .controls-priority-score-wrap {
    background: #f0f8ff;
    border: 1px solid rgba(14, 165, 233, 0.28);
    border-radius: 10px;
    padding: 9px 11px;
  }

  body[data-page="controls"] .controls-priority-score-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text2);
    margin-bottom: 5px;
  }

  body[data-page="controls"] .controls-priority-score-head strong {
    color: #d97706;
    font-family: 'JetBrains Mono';
    font-size: 13px;
    font-weight: 700;
  }

  body[data-page="controls"] .controls-priority-score-track {
    height: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
  }

  body[data-page="controls"] .controls-priority-score-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    transition: width 0.4s ease;
  }

  body[data-page="controls"] .controls-priority-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 26px;
  }

  body[data-page="controls"] .controls-priority-reason {
    font-size: 10px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(254, 226, 226, 0.8);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
    font-weight: 500;
  }

  body[data-page="controls"] .controls-priority-action {
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
    font-size: 12px;
    background: var(--surface2);
    border: 1px solid rgba(56, 189, 248, 0.3);
    transition: all 0.2s;
  }

  body[data-page="controls"] .controls-priority-action:hover {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.5);
    color: var(--accent2);
  }

  body[data-page="controls"] .controls-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
  }

  body[data-page="controls"] .controls-table th {
    background: linear-gradient(180deg, #f0f7ff, #e8f2fb);
    color: var(--text2);
    font-size: 12px;
    font-weight: 700;
    text-align: start;
    padding: 13px 11px;
    border-bottom: 2px solid rgba(14, 165, 233, 0.25);
    white-space: nowrap;
  }

  body[data-page="controls"] .controls-table td {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 13px 11px;
    vertical-align: middle;
    transition: background 0.15s;
  }

  body[data-page="controls"] .controls-table tbody tr:hover td {
    background: #f0f7ff;
  }

  body[data-page="controls"] .controls-table tbody tr:last-child td {
    border-bottom: none;
  }

  body[data-page="controls"] .risk-badge,
  body[data-page="controls"] .evidence-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 11px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: all 0.15s;
  }

  body[data-page="controls"] .risk-critical,
  body[data-page="controls"] .ev-rejected,
  body[data-page="controls"] .ev-expired {
    background: #fee2e2;
    color: #dc2626;
    border-color: rgba(239, 68, 68, 0.4);
  }

  body[data-page="controls"] .risk-high,
  body[data-page="controls"] .ev-requested,
  body[data-page="controls"] .ev-under_review {
    background: #fef3c7;
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.4);
  }

  body[data-page="controls"] .risk-medium,
  body[data-page="controls"] .ev-uploaded {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: rgba(59, 130, 246, 0.4);
  }

  body[data-page="controls"] .risk-low,
  body[data-page="controls"] .ev-approved {
    background: #d1fae5;
    color: #065f46;
    border-color: rgba(16, 185, 129, 0.4);
  }

  .toast {
    position: fixed;
    bottom: 24px;
    inset-inline-end: 24px;
    padding: 14px 20px;
    background: var(--green);
    color: white;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    z-index: 500;
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(16,185,129,0.4);
  }
  .toast.show { transform: translateY(0); opacity: 1; }
  .toast.error { background: var(--red); box-shadow: 0 4px 20px rgba(239,68,68,0.4); }

  /* Version badge */
  .version-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: rgba(14,165,233,0.1);
    border: 1px solid rgba(14,165,233,0.2);
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    color: var(--accent2);
    font-family: 'JetBrains Mono';
  }

  .policy-form-frame {
    border: 1px solid var(--border);
    border-radius: 14px;
    background:
      radial-gradient(circle at 90% 12%, rgba(14,165,233,0.14), transparent 42%),
      var(--surface2);
    padding: 14px;
    margin-top: 12px;
  }

  .policy-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed rgba(14,165,233,0.22);
  }

  .policy-form-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
  }

  .policy-form-code {
    font-size: 11px;
    font-family: 'JetBrains Mono';
    color: var(--text2);
    background: var(--surface);
    border: 1px solid rgba(14,165,233,0.25);
    border-radius: 6px;
    padding: 4px 8px;
  }

  .policy-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .policy-form-field {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px;
  }

  .policy-form-label {
    font-size: 11px;
    color: var(--text2);
    margin-bottom: 6px;
    display: block;
    font-weight: 600;
  }

  .policy-form-value {
    font-size: 12px;
    color: var(--text);
    line-height: 1.5;
    min-height: 20px;
  }

  .policy-form-full {
    grid-column: 1 / -1;
  }

  .policy-form-text {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    padding: 10px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    line-height: 1.8;
  }

  .policy-form-frame .form-input {
    background: var(--surface2);
    border-color: var(--border);
  }

  .policy-form-frame .form-input::placeholder,
  .policy-form-frame .policy-form-text::placeholder {
    color: var(--text3);
  }

  .policy-form-frame .form-input[type="file"] {
    padding: 8px 10px;
    background: var(--surface);
  }

  .policy-form-frame .form-input[type="file"]::file-selector-button {
    margin-inline-end: 10px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
  }

  .policy-form-frame .form-input[type="file"]::file-selector-button:hover {
    border-color: rgba(14,165,233,0.45);
    background: rgba(14,165,233,0.1);
  }

  @media (max-width: 768px) {
    .policy-form-grid {
      grid-template-columns: 1fr;
    }

    body[data-page="controls"] .controls-filters-grid {
      grid-template-columns: 1fr;
    }

    body[data-page="controls"] .controls-filter-field-search {
      grid-column: auto;
    }

    body[data-page="controls"] .controls-table {
      display: block;
      overflow-x: auto;
      white-space: nowrap;
    }

    body[data-page="controls"] .controls-filters-meta {
      width: 100%;
      justify-content: flex-end;
    }

    body[data-page="controls"] .controls-priority-summary {
      grid-template-columns: 1fr;
    }
  }
