:root {
    --bg: #0b1120;
    --panel: #111827;
    --panel-light: #1f2937;
    --border: #243044;

    --text: #f3f4f6;
    --muted: #94a3b8;

    --blue: #3b82f6;
    --blue-hover: #2563eb;

    --green: #10b981;
    --yellow: #f59e0b;
    --orange: #f97316;
    --red: #ef4444;

    --shadow:
        0 10px 25px rgba(0,0,0,0.35);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;

    background: var(--bg);

    color: var(--text);

    font-family:
        Inter,
        system-ui,
        sans-serif;
}

body {
    min-height: 100vh;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    opacity: 0.9;
}

h1,
h2,
h3 {
    margin-top: 0;
    color: white;
}

p {
    line-height: 1.5;
}

.muted {
    color: var(--muted);
}

/* =========================
   APP LAYOUT
========================= */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;

    background: #08101d;
    border-right: 1px solid var(--border);

    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow: hidden;

    padding: 28px 22px 16px;
    box-sizing: border-box;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: scroll;
    flex: 1;
    padding-right: 4px;
}

.sidebar nav::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 5px;
}

.sidebar nav::-webkit-scrollbar-track {
    background: #0d1829;
    border-radius: 4px;
}

.sidebar nav::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

.sidebar nav::-webkit-scrollbar-thumb:hover {
    background: #60a5fa;
}


.brand {
    display: flex;
    align-items: center;
    gap: 14px;

    margin-bottom: 20px;
}

.brand-mark {
    width: 46px;
    height: 46px;

    border-radius: 12px;

    background: linear-gradient(
        135deg,
        #2563eb,
        #1d4ed8
    );

    display: flex;
    align-items: center;
    justify-content: center;

    font-weight: 700;
    color: white;
}

.brand span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

.sidebar nav a {
    color: #d1d5db;

    padding: 7px 10px;
    font-size: 13px;

    border-radius: 8px;

    transition: 0.2s ease;
}

.sidebar nav a:hover {
    background: #132033;
}

.main-content {
    flex: 1;
    padding: 34px;
    margin-left: 250px;
}

/* =========================
   HOMEPAGE
========================= */

.home-shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 42px;
}

.home-header {
    margin-bottom: 28px;
}

.home-brand {
    margin-bottom: 0;
}

.home-brand strong {
    font-size: 24px;
}

.home-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 24px;
    align-items: start;
}

.home-form-card {
    width: 420px;
    max-width: 420px;
}

.home-form-card input {
    width: 100%;
}

.home-form-card button {
    width: auto;
    align-self: flex-start;
}

.home-client-card {
    min-height: 300px;
}

.client-list {
    display: grid;
    gap: 14px;
}

.client-card {
    display: block;

    background: #0f172a;

    border: 1px solid var(--border);

    border-radius: 14px;

    padding: 18px;

    color: var(--text);

    transition: 0.2s ease;
}

.client-card:hover {
    border-color: var(--blue);
    background: #111c30;
}

.client-card strong {
    display: block;
    color: var(--blue);
    font-size: 18px;
    margin-bottom: 8px;
}

.client-card span {
    display: block;
    color: var(--muted);
}

/* =========================
   TOPBAR
========================= */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 20px;

    margin-bottom: 30px;
}

.back-link {
    display: inline-block;
    margin-bottom: 10px;
}

.report-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* =========================
   BUTTONS
========================= */

.button,
button {
    background: var(--blue);

    color: white;

    border: none;

    border-radius: 12px;

    padding: 12px 18px;

    font-weight: 600;

    cursor: pointer;

    transition: 0.2s ease;
}

.button:hover,
button:hover {
    background: var(--blue-hover);
}

.button.secondary {
    background: #1e293b;
}

.button.secondary:hover {
    background: #334155;
}

.danger-button {
    background: var(--red);
}

.danger-button:hover {
    background: #dc2626;
}

/* =========================
   STATS
========================= */

.stats-grid {
    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(180px, 1fr));

    gap: 18px;

    margin-bottom: 30px;
}

.stat-card {
    background: var(--panel);

    border: 1px solid var(--border);

    border-radius: 18px;

    padding: 22px;

    box-shadow: var(--shadow);
}

.stat-card span {
    display: block;

    color: var(--muted);

    font-size: 13px;

    margin-bottom: 10px;
}

.stat-card strong {
    font-size: 34px;
    font-weight: 700;
}

.risk-card {
    background:
        linear-gradient(
            145deg,
            #111827,
            #0f172a
        );
}

.risk-level {
    margin-top: 12px;
    font-weight: 700;
}

/* =========================
   CARDS
========================= */

.card {
    background: var(--panel);

    border: 1px solid var(--border);

    border-radius: 20px;

    padding: 28px;

    box-shadow: var(--shadow);

    margin-bottom: 30px;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;

    margin-bottom: 30px;
}

/* =========================
   FORMS
========================= */

.stacked-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

input,
textarea,
select {
    width: 100%;

    background: #0f172a;

    border: 1px solid #334155;

    color: white;

    border-radius: 12px;

    padding: 12px 14px;

    font-size: 14px;
}

textarea {
    resize: vertical;
}

label {
    font-size: 14px;
    font-weight: 600;
    color: #d1d5db;
}

.asset-dashboard-form {
    display: grid;

    grid-template-columns: 1fr 1fr 1fr;

    gap: 18px;

    margin-bottom: 28px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

/* =========================
   TABLES
========================= */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;

    padding: 14px;

    background: #0f172a;

    color: #d1d5db;

    font-size: 13px;

    border-bottom: 1px solid #243044;
}

td {
    padding: 16px 14px;

    border-bottom: 1px solid #1e293b;

    vertical-align: top;
}

td p {
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

/* =========================
   BADGES
========================= */

.badge {
    display: inline-block;

    padding: 6px 12px;

    border-radius: 999px;

    background: #1e293b;

    font-size: 12px;

    font-weight: 700;
}

.severity-critical {
    color: #fecaca;
    background: rgba(239,68,68,0.18);
}

.severity-high {
    color: #fdba74;
    background: rgba(249,115,22,0.18);
}

.severity-medium {
    color: #fde68a;
    background: rgba(245,158,11,0.18);
}

.severity-low {
    color: #86efac;
    background: rgba(16,185,129,0.18);
}

/* =========================
   BUTTON ROW
========================= */

.button-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

/* =========================
   CHARTS
========================= */

.chart-grid {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 24px;

    margin-top: 24px;
}

.chart-panel {
    background: #0f172a;

    border: 1px solid var(--border);

    border-radius: 16px;

    padding: 24px;

    position: relative;

    height: 340px;
}

.chart-panel h3 {
    margin-top: 0;
    margin-bottom: 18px;
}

.chart-panel canvas {
    width: 100% !important;
    height: 240px !important;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1200px) {

    .action-grid {
        grid-template-columns: 1fr;
    }

    .asset-dashboard-form {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 1100px) {

    .chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {

    .sidebar {
        display: none;
    }

    .main-content {
        padding: 20px;
    }

    .topbar {
        flex-direction: column;
    }

    .asset-dashboard-form {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .home-grid {
        grid-template-columns: 1fr;
    }

    .home-form-card {
        width: 100%;
        max-width: 100%;
    }

    .home-shell {
        padding: 24px;
    }
}

@media (max-width: 600px) {

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 20px;
    }

    .chart-panel {
        height: 300px;
    }
}

/* =========================
   DARK MODE TOGGLE BUTTON
========================= */

.dark-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: 0.2s ease;
}

.dark-toggle:hover {
    background: var(--panel-light);
}

/* =========================
   LIGHT MODE (manual .dark removed)
========================= */

html.light {
    --bg: #f0f4f8;
    --panel: #ffffff;
    --panel-light: #e8edf3;
    --border: #cbd5e0;
    --text: #1a202c;
    --muted: #4a5568;
    --blue: #2563eb;
    --blue-hover: #1d4ed8;
}

html.light body {
    background: var(--bg);
    color: var(--text);
}

html.light .sidebar {
    background: #1e293b;
}

html.light th {
    background: #e2e8f0;
    color: #1a202c;
}

html.light td {
    border-bottom: 1px solid #e2e8f0;
}

html.light .client-card {
    background: #ffffff;
    border-color: #cbd5e0;
}

html.light .client-card:hover {
    border-color: var(--blue);
    background: #eff6ff;
}

html.light input,
html.light textarea,
html.light select {
    background: #ffffff;
    border-color: #cbd5e0;
    color: #1a202c;
}

html.light .chart-panel {
    background: #ffffff;
    border-color: #cbd5e0;
}

html.light .stat-card {
    background: #ffffff;
    border-color: #cbd5e0;
}

html.light .card {
    background: #ffffff;
    border-color: #cbd5e0;
}

/* =========================
   OS DARK MODE (prefers-color-scheme)
   Applies when no manual class is set
========================= */

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1f2e;
        --panel: #252d3d;
        --panel-light: #2d3748;
        --border: #3a4a5e;
        --text: #e2e8f0;
        --muted: #a0aec0;
    }

    th {
        background: #1e2a3a;
        color: #e2e8f0;
    }

    input,
    textarea,
    select {
        background: #1e2a3a;
        border-color: #3a4a5e;
        color: #e2e8f0;
    }

    .chart-panel {
        background: #1e2a3a;
    }
}

/* =========================
   TOAST NOTIFICATION (Feature 15)
========================= */

#ccg-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #3b82f6;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    display: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    max-width: 320px;
}

#ccg-toast.show {
    display: block;
    animation: slideIn 0.3s ease;
}

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

/* =========================
   STATUS BADGES (Feature 4)
========================= */

.status-open {
    color: #fde68a;
    background: rgba(245,158,11,0.18);
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.status-in-progress {
    color: #93c5fd;
    background: rgba(59,130,246,0.18);
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.status-resolved {
    color: #86efac;
    background: rgba(16,185,129,0.18);
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

/* =========================
   SCAN JOB STATUS BADGE (Feature 2)
========================= */

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

.job-queued  { background: rgba(100,116,139,0.3); color: #cbd5e1; }
.job-running { background: rgba(59,130,246,0.25); color: #93c5fd; }
.job-done    { background: rgba(16,185,129,0.25); color: #86efac; }
.job-error   { background: rgba(239,68,68,0.25);  color: #fca5a5; }

/* =========================
   PRINT STYLES (Feature 13)
========================= */

@media print {
    .no-print { display: none !important; }
    body { background: white; color: black; }
    .card { border: 1px solid #ccc; box-shadow: none; }
}