:root {
    /* Achtergrond + oppervlakken */
    --bg:        #EEF2F6;
    --card:      #FFFFFF;
    --border:    #D5DEE6;
    --border-soft: #E4ECF1;

    /* Tekst */
    --text:      #0F2F4D;
    --muted:     #64748B;

    /* Brand kleuren — gelijk aan login */
    --primary:      #0F2F4D;   /* navy */
    --primary-dark: #143A5E;
    --primary-soft: #2E5377;
    --accent:       #14B5C4;   /* teal */
    --accent-soft:  #DFF4F6;

    /* Sidebar */
    --sidebar:      #0F2F4D;
    --sidebar-text: #B7E3E8;

    /* Semantische kleuren (P&L, status) */
    --green:   #10B981;
    --red:     #EF4444;
    --orange:  #F59E0B;
    --blue:    #3B82F6;
    --neutral: #64748B;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background:
        radial-gradient(at 100% 0%, rgba(20,181,196,0.06) 0%, transparent 35%),
        radial-gradient(at 0% 100%, rgba(15,47,77,0.05) 0%, transparent 40%),
        var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Display",
                 Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}
.app {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: var(--sidebar);
    color: white;
    padding: 24px 16px;
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
}
.sidebar h1 {
    font-size: 14px;
    margin: 0 0 32px 0;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 700;
}
.sidebar nav {
    display: flex; flex-direction: column; gap: 4px;
}
.sidebar nav a {
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    display: flex; gap: 10px; align-items: center;
    transition: background 0.12s, color 0.12s;
}
.sidebar nav a.active {
    background: rgba(20,181,196,0.18);
    color: white;
    box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: white; }
.sidebar-footer { margin-top: auto; padding-top: 24px; }
.logout-link {
    color: var(--sidebar-text);
    text-decoration: none; font-size: 12px;
    padding: 7px 14px;
    border: 1px solid rgba(183,227,232,0.22);
    border-radius: 8px;
    display: inline-block;
    transition: background 0.12s, color 0.12s;
}
.logout-link:hover {
    background: rgba(20,181,196,0.18);
    color: white;
}

.main { padding: 28px 36px; }
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
}
.topbar h2 {
    margin: 0; font-size: 24px; font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.01em;
}
.topbar .filters { display: flex; gap: 10px; }
.chip {
    background: var(--card);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 7px 14px; font-size: 12.5px;
    color: var(--primary);
    font-weight: 500;
    display: flex; gap: 8px; align-items: center;
    box-shadow: 0 1px 2px rgba(15,47,77,0.04);
}
.subbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px;
    color: var(--muted); font-size: 13px;
}
.subbar a { color: var(--accent); text-decoration: none; margin-left: 6px; }

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 18px;
}
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    margin-bottom: 18px;
}

/* === Personaliseerbare tegelweergave (12-koloms grid) === */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
    align-items: start;
}
.tile { position: relative; }
.tile[data-width="4"]  { grid-column: span 4; }
.tile[data-width="6"]  { grid-column: span 6; }
.tile[data-width="12"] { grid-column: span 12; }

/* In edit-mode: hidden tiles tonen we semi-transparant zodat je ze terug kunt zetten */
.tile[data-hidden="1"] { display: none; }
body.edit-mode .tile[data-hidden="1"] {
    display: block;
    opacity: 0.45;
    background-image:
        repeating-linear-gradient(45deg, rgba(15,47,77,0.04) 0 8px, transparent 8px 16px);
}

/* Edit-mode visuele cues */
body.edit-mode .tile {
    border: 2px dashed transparent;
    transition: border-color 0.15s, transform 0.05s;
}
body.edit-mode .tile:hover {
    border-color: var(--accent);
}
body.edit-mode .tile.dragging {
    opacity: 0.4;
    transform: scale(0.98);
}
body.edit-mode .tile.drop-target {
    border-color: var(--accent);
    background: var(--accent-soft);
}
body.edit-mode .tile-controls { display: flex !important; }

.tile-controls {
    position: absolute; top: 10px; right: 10px;
    z-index: 5;
    display: flex; gap: 6px;
    align-items: center;
    background: rgba(255,255,255,0.95);
    padding: 4px 6px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(15,47,77,0.10);
    backdrop-filter: blur(6px);
}
.tile-controls button {
    border: none; background: transparent;
    color: var(--primary);
    font-size: 12px; font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}
.tile-controls button:hover { background: var(--accent-soft); }
.tile-handle { cursor: grab; font-size: 14px !important; letter-spacing: -0.05em; }
.tile-handle:active { cursor: grabbing; }
.tile-width-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.tile-width-toggle button {
    border-radius: 0 !important;
    border-right: 1px solid var(--border);
    padding: 4px 8px;
    font-size: 11px;
}
.tile-width-toggle button:last-child { border-right: none; }
.tile-width-toggle button.active {
    background: var(--primary);
    color: white;
}
.tile-width-toggle button.active:hover { background: var(--primary-dark); }
.tile-hide .when-hidden { display: none; }
.tile[data-hidden="1"] .tile-hide .when-visible { display: none; }
.tile[data-hidden="1"] .tile-hide .when-hidden { display: inline; }

/* Edit-mode toolbar bovenaan main */
.edit-toolbar {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 18px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
}
.edit-toolbar-title {
    flex: 1 1 auto;
    font-size: 13px;
    color: var(--text);
}
.edit-toolbar-actions {
    display: flex; gap: 8px;
}
.layout-status {
    font-size: 12px;
    color: var(--muted);
    flex-basis: 100%;
    text-align: right;
    min-height: 14px;
}
.layout-status.success { color: var(--green); }
.layout-status.error { color: var(--red); }

.layout-btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.12s;
}
.layout-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
body.edit-mode .layout-btn {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.layout-btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.layout-btn-primary:hover { background: var(--primary-dark); }
.layout-btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
}
.layout-btn-ghost:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.card {
    background: var(--card);
    border-radius: 16px;
    padding: 22px 24px;
    border: 1px solid var(--border-soft);
    box-shadow:
        0 1px 2px rgba(15,47,77,0.03),
        0 8px 24px rgba(15,47,77,0.04);
    transition: box-shadow 0.15s;
}
.card:hover {
    box-shadow:
        0 1px 2px rgba(15,47,77,0.04),
        0 12px 32px rgba(15,47,77,0.06);
}
.card h3 {
    margin: 0 0 6px 0; font-size: 12px; color: var(--muted);
    font-weight: 500; letter-spacing: 0.04em;
    text-transform: uppercase;
    display: flex; align-items: center; gap: 6px;
}
.card .value {
    font-size: 30px; font-weight: 700; margin-top: 8px;
    letter-spacing: -0.02em;
    color: var(--primary);
}
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card.kpi { display: flex; flex-direction: column; gap: 4px; min-height: 130px; }
.kpi-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.kpi-row svg { flex-shrink: 0; }

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

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td {
    padding: 11px 10px; text-align: left;
    border-bottom: 1px solid var(--border-soft);
}
table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: rgba(20,181,196,0.04); }
table td.num, table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-row { text-align: center; color: var(--muted); padding: 30px !important; }
.dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    margin-right: 6px; vertical-align: middle;
}
.dot.put { background: var(--orange); }
.dot.call { background: var(--blue); }
.badge {
    display: inline-block; padding: 2px 8px;
    border-radius: 8px; font-size: 11px; font-weight: 600;
}
.side-short { background: #FEE2E2; color: #B91C1C; }
.side-long  { background: #DCFCE7; color: #166534; }
.status {
    display: inline-block; padding: 3px 8px;
    border-radius: 8px; font-size: 11px; font-weight: 600;
}
.status-ok { background: #DCFCE7; color: #166534; }
.status-warn { background: #FEF3C7; color: #92400E; }
.status-alert { background: #FEE2E2; color: #B91C1C; }
.status-expired { background: #E5E7EB; color: #374151; }

.donut-wrap { display: flex; gap: 12px; align-items: center; }
.donut-label strong { display: block; font-size: 14px; color: var(--text); }
.donut-label span { display: block; color: var(--muted); font-size: 12px; }

.split-bar {
    border-radius: 6px; overflow: hidden; display: flex;
    background: #F3F4F6;
}
.split-bar.empty {
    color: var(--muted); padding: 8px; font-size: 12px; height: auto;
}
.split-bar div { height: 100%; }
.split-meta {
    display: flex; justify-content: space-between; margin-top: 6px;
    font-size: 11px; font-weight: 600;
}

/* Alerts banner */
.alerts-banner {
    background: linear-gradient(135deg, #FEF2F2 0%, #FFF5F5 100%);
    border: 1px solid #FECACA;
    border-left: 4px solid #DC2626;
    border-radius: 14px;
    padding: 14px 18px;
    margin-bottom: 18px;
    box-shadow: 0 4px 12px rgba(220,38,38,0.06);
}
.alerts-head {
    display: flex; gap: 10px; align-items: center;
    color: #991B1B; font-size: 13px; margin-bottom: 8px;
}
.alerts-icon {
    width: 22px; height: 22px; border-radius: 50%;
    background: #DC2626; color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; line-height: 1;
}
.alerts-list {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-wrap: wrap; gap: 6px 14px;
    font-size: 12px; color: #374151;
}
.alerts-list li { display: flex; gap: 6px; align-items: center; }
.alert-days {
    background: #DC2626; color: white;
    padding: 1px 7px; border-radius: 10px;
    font-size: 10px; font-weight: 700;
}
.alert-days.expired { background: #6B7280; }

/* Filters */
.filter-row {
    display: flex; flex-wrap: wrap; gap: 8px;
    align-items: center; margin: 12px 0 8px 0;
}
.filter-row input[type="search"] {
    background: #F8FAFC;
    border: 1.5px solid var(--border-soft);
    border-radius: 10px; padding: 8px 12px; font-size: 13px;
    min-width: 200px; outline: none; font-family: inherit;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-row input[type="search"]:focus {
    border-color: var(--accent);
    background: white;
    box-shadow: 0 0 0 3px rgba(20,181,196,0.12);
}
.filter-group { display: flex; gap: 4px; align-items: center; }
.filter-group .group-label {
    font-size: 11px; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.06em;
    font-weight: 500;
    margin-right: 4px;
}
.filter-chip {
    background: #F1F5F9;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px; color: var(--primary);
    cursor: pointer; user-select: none;
    transition: all 0.12s;
    font-weight: 500;
}
.filter-chip:hover { background: #E2E8F0; }
.filter-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

table th.sortable {
    cursor: pointer; user-select: none;
    position: relative; padding-right: 18px;
}
table th.sortable:hover { color: var(--text); }
table th.sortable::after {
    content: "⇅"; position: absolute; right: 4px;
    color: #D1D5DB; font-size: 10px;
}
table th.sortable.sort-asc::after { content: "▲"; color: var(--accent); }
table th.sortable.sort-desc::after { content: "▼"; color: var(--accent); }
.no-results { text-align: center; padding: 24px; color: var(--muted); font-size: 13px; }

.score-components {
    flex: 1; display: flex; flex-direction: column;
    gap: 8px; min-width: 0;
}
.score-row {
    display: grid; grid-template-columns: 110px 1fr 32px;
    gap: 10px; align-items: center;
    font-size: 11px;
}
.score-name {
    color: var(--muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.score-bar-bg {
    background: #F1F5F9;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}
.score-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
}
.score-val {
    color: var(--primary); font-weight: 700;
    font-variant-numeric: tabular-nums; text-align: right;
}

.heatmap-wrap { overflow-x: auto; margin: 0 -8px; }
.heatmap-wrap svg { display: block; }

.best-worst-row {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 14px; padding: 4px 0;
}
.bw-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.bw-value { font-size: 22px; font-weight: 700; }
.bw-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.best-side { border-left: 3px solid var(--green); padding-left: 10px; }
.worst-side { border-left: 3px solid var(--red); padding-left: 10px; }

.ticker-pnl-table td:last-child { width: 50%; }
.ticker-bar-wrap {
    position: relative; height: 22px;
    background: #F9FAFB; border-radius: 4px;
    display: flex; align-items: center;
}
.ticker-bar { height: 100%; border-radius: 4px; opacity: 0.3; }
.ticker-bar-label {
    position: absolute; right: 6px;
    font-size: 12px; font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Login pagina — geïnspireerd op CNaVT helpdesk */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 24px;
    background:
        radial-gradient(at 20% 30%, rgba(20,181,196,0.18) 0%, transparent 45%),
        radial-gradient(at 80% 70%, rgba(15,47,77,0.20) 0%, transparent 50%),
        linear-gradient(135deg, #E9EEF3 0%, #DCE4EC 50%, #C9D8E1 100%);
}
.login-card {
    background: #FFFFFF;
    border: none;
    border-radius: 16px;
    padding: 40px 48px 32px;
    width: 420px;
    max-width: calc(100% - 32px);
    box-shadow:
        0 1px 2px rgba(15,47,77,0.04),
        0 12px 40px rgba(15,47,77,0.10);
    text-align: center;
}
.login-avatar {
    width: 80px; height: 80px;
    background: var(--primary);
    border-radius: 50%;
    margin: 0 auto 20px;
    display: flex; align-items: center; justify-content: center;
}
.login-avatar span {
    color: var(--accent);
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.04em;
}
.login-card h1 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}
.login-card p.login-sub {
    margin: 0 0 28px;
    color: var(--muted);
    font-size: 14px;
}
.login-card label {
    display: block;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    text-align: left;
}
.login-card input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    background: #FFFFFF;
    border: 1.5px solid #C5DBE0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:hover { border-color: #9FC3CB; }
.login-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(20,181,196,0.15);
}
.login-card button {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
}
.login-card button:hover { background: var(--primary-dark); }
.login-card button:active { transform: scale(0.99); }
.login-footer {
    margin: 24px 0 0;
    font-size: 12px;
    color: var(--muted);
}
.alert {
    background: #FEE2E2;
    color: #B91C1C;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 18px;
    text-align: left;
}

@media (max-width: 1100px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .dashboard-grid .tile[data-width="4"] { grid-column: span 6; }
}
@media (max-width: 700px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main { padding: 16px; }
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .dashboard-grid .tile { grid-column: span 12 !important; }
}
