:root {
    --bg: #0f1420;
    --surface: #1a2233;
    --surface-hover: #212b40;
    --border: #2b3550;
    --text: #e6e9f0;
    --text-muted: #9aa5b8;
    --accent: #5b8def;

    --free: #4d9de0;
    --notpa: #e8a33d;
    --pa: #3fb984;
    --managed: #a56ee6;
    --on: #3fb984;
    --off: #e35d6a;
    --unknown: #6b7385;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f4f6fb;
        --surface: #ffffff;
        --surface-hover: #eef1f8;
        --border: #dde2ee;
        --text: #1b2233;
        --text-muted: #5b6478;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.page-header {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.8rem;
}

.subtitle {
    margin: 0;
    color: var(--text-muted);
}

.back-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover { text-decoration: underline; }

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

.card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s ease, transform 0.15s ease;
}

.card:hover {
    background: var(--surface-hover);
    transform: translateY(-2px);
}

.card h2 {
    margin: 0;
    font-size: 1.1rem;
}

.card-stats {
    display: flex;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

section {
    margin-top: 2rem;
}

section h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.2rem;
}

.count-badge {
    font-size: 0.8rem;
    font-weight: normal;
    color: var(--text-muted);
}

.table-scroll {
    overflow-x: auto;
    border-radius: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.row-noncompliant { background: rgba(227, 93, 106, 0.08); }

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.badge-free { background: var(--free); }
.badge-notpa { background: var(--notpa); }
.badge-pa { background: var(--pa); }
.badge-managed { background: var(--managed); }
.badge-on { background: var(--on); }
.badge-off { background: var(--off); }
.badge-unknown { background: var(--unknown); }
.badge-error { background: var(--off); }
.badge-super { background: var(--managed); }

.alert {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.alert-error {
    border-color: var(--off);
    color: var(--off);
}

.alert-success {
    border-color: var(--on);
    color: var(--on);
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.bulk-actions #selected-count {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-right: auto;
}

.bulk-actions button {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
}

.bulk-actions .btn-on { background: var(--on); border-color: var(--on); }
.bulk-actions .btn-off { background: var(--off); border-color: var(--off); }

.data-table th:first-child,
.data-table td:first-child {
    width: 2.5rem;
    text-align: center;
}

.topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.25rem 2rem 0;
}

.topnav-brand {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.topnav-links {
    display: flex;
    gap: 0.5rem;
}

.topnav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
}

.topnav-links a:hover { background: var(--surface-hover); }

.topnav-links a.active {
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.stat-main {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    text-decoration: none;
    color: inherit;
}

.stat-main:hover .stat-value { text-decoration: underline; }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
}

.stat-sub:hover { text-decoration: underline; }

.stat-sub-warning { color: var(--off); }

.sync-status {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.sync-status code {
    background: var(--surface);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.filter-bar input[type="text"],
.filter-bar select {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
}

.filter-bar button {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
}

.filter-bar button:hover { background: var(--surface-hover); }

.view-toggle {
    display: flex;
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.view-toggle a {
    padding: 0.5rem 0.9rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.view-toggle a:hover { background: var(--surface-hover); }

.view-toggle a.active {
    background: var(--accent);
    color: #fff;
}
