@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&display=swap');

:root {
    --navy: #0B1E3D;
    --navy-deep: #071427;
    --navy-light: #16305C;
    --emerald: #0E9F6E;
    --emerald-light: #2FBE8C;
    --gold: #C9A227;
    --gold-light: #E8CD6D;
    --gold-soft: #F4E9C6;
    --cream: #FAF8F2;
    --surface: #FFFFFF;
    --border: #EAE4D3;
    --border-soft: #F0ECE0;
    --text: #1A2237;
    --text-muted: #71768A;

    --critical: #C4361F;
    --warning: #C07A1E;
    --notice: #A5821A;
    --ok: #0E9F6E;
    --unknown: #9CA3AF;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 2px 8px rgba(11, 30, 61, 0.06), 0 1px 3px rgba(11, 30, 61, 0.05);
    --shadow-lg: 0 12px 32px rgba(11, 30, 61, 0.10), 0 4px 10px rgba(11, 30, 61, 0.06);

    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    --sidebar-w: 250px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--cream);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* =====================================================
   MOBILE-FIRST BASE (< 901px)
   Sidebar is an off-canvas drawer, hidden by default.
   ===================================================== */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --------- Sidebar (drawer on mobile) --------- */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(78vw, 280px);
    z-index: 40;
    background:
        radial-gradient(circle at 15% 0%, rgba(201,162,39,0.14), transparent 55%),
        linear-gradient(180deg, var(--navy-deep) 0%, var(--navy) 55%, var(--navy-light) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}

.app-shell.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 20, 39, 0.5);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.app-shell.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 22px;
    border-bottom: 1px solid rgba(232, 205, 106, 0.16);
    margin-bottom: 18px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: linear-gradient(150deg, var(--gold-light) 0%, var(--gold) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    color: var(--navy-deep);
    box-shadow: 0 4px 14px rgba(201, 162, 39, 0.35);
    flex-shrink: 0;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0.2px;
}

.brand-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
    font-weight: 500;
}

.sidenav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.sidenav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.62);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.1px;
    border-left: 2.5px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.sidenav a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.sidenav a.active {
    background: linear-gradient(90deg, rgba(201,162,39,0.16), rgba(201,162,39,0.02));
    color: var(--gold-light);
    border-left-color: var(--gold);
}

.nav-icon {
    width: 18px;
    text-align: center;
    font-size: 15px;
    opacity: 0.9;
}

.sidebar-foot {
    font-size: 10.5px;
    color: rgba(255,255,255,0.32);
    padding: 14px 8px 4px;
    border-top: 1px solid rgba(255,255,255,0.08);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* --------- Content area --------- */

.content-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}

header.topbar {
    background: rgba(250, 248, 242, 0.92);
    backdrop-filter: blur(8px);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--border-soft);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

header.topbar h1 {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    margin: 0;
    color: var(--navy);
    letter-spacing: 0.1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hamburger button (mobile only) */
.hamburger-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
}
.hamburger-btn span {
    display: block;
    width: 17px;
    height: 2px;
    background: var(--navy);
    border-radius: 2px;
}

.refresh-btn {
    background: var(--navy);
    border: none;
    color: #fff;
    padding: 9px 14px;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: var(--shadow);
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}
.refresh-btn span:first-child { font-size: 14px; }
.refresh-btn:hover { background: var(--navy-light); }
.refresh-btn:disabled { opacity: 0.55; cursor: wait; }

main {
    max-width: 1220px;
    width: 100%;
    margin: 0 auto;
    padding: 18px 14px 50px;
}

/* =================== SUMMARY CARDS =================== */

.summary-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 16px 16px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--border), var(--border));
}

.summary-card.critical::before { background: linear-gradient(90deg, var(--critical), #E8785F); }
.summary-card.warning::before  { background: linear-gradient(90deg, var(--warning), #E8A94F); }
.summary-card.notice::before   { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.summary-card.ok::before       { background: linear-gradient(90deg, var(--ok), var(--emerald-light)); }

.summary-card .num {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.summary-card .label {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.1px;
}

.summary-card.critical .num { color: var(--critical); }
.summary-card.warning .num { color: var(--warning); }
.summary-card.notice .num { color: #A5821A; }
.summary-card.ok .num { color: var(--ok); }

/* =================== TOTAL BAND =================== */

.total-band {
    background:
        radial-gradient(circle at 85% 15%, rgba(232,205,106,0.16), transparent 55%),
        linear-gradient(120deg, var(--navy-deep) 0%, var(--navy) 60%, var(--navy-light) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 22px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.total-band::after {
    content: '';
    position: absolute;
    right: -40px; top: -40px;
    width: 160px; height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232,205,106,0.14), transparent 70%);
}

.total-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--gold-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.total-amounts {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    align-items: baseline;
}

.total-figure {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 600;
    color: #fff;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.total-note {
    font-size: 11.5px;
    color: rgba(255,255,255,0.45);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* =================== PANELS / TABLES =================== */

section.panel {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}

.panel-header {
    padding: 15px 16px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel-header h2 {
    font-family: var(--font-display);
    font-size: 15.5px;
    font-weight: 600;
    margin: 0;
    color: var(--navy);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header .count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--cream);
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Tables scroll horizontally on narrow screens instead of squishing */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.data-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 13px;
}

table.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    font-weight: 700;
    background: var(--cream);
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

table.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
    white-space: nowrap;
}

table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #FDFCF9; }

.item-name {
    font-weight: 700;
    color: var(--navy);
    font-family: var(--font-display);
    font-size: 13.5px;
    white-space: normal !important;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1px;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.badge.critical { background: #FCEEEB; color: var(--critical); }
.badge.warning  { background: #FCF1E3; color: var(--warning); }
.badge.notice   { background: var(--gold-soft); color: #8A6C15; }
.badge.ok       { background: #E5F6EF; color: var(--ok); }
.badge.expired  { background: var(--navy-deep); color: #F4C7BB; }
.badge.unknown  { background: #F1F2F5; color: var(--unknown); }

.empty-state {
    padding: 38px 18px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.error-banner {
    background: #FCEEEB;
    border: 1px solid #F3B8A8;
    color: #8A2E1B;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 13px;
    line-height: 1.55;
}

.error-banner code {
    background: rgba(138,46,27,0.08);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11.5px;
}

.footer-note {
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 26px;
    letter-spacing: 0.1px;
}

/* =================== HINT NOTE =================== */

.hint-note {
    background: #EFF6FF;
    border: 1px solid #C7DCF7;
    color: #234876;
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-bottom: 16px;
}

.hint-note a { color: var(--navy); font-weight: 700; }

/* =================== ACCOUNT GRID (Abonnements) =================== */

.account-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: start;
}

details.account-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

details.account-card[open],
details.account-card:hover {
    box-shadow: var(--shadow-lg);
}

details.account-card summary {
    list-style: none;
    cursor: pointer;
    padding: 17px 18px;
    position: relative;
    user-select: none;
    background: linear-gradient(180deg, var(--surface), #FEFDFA);
}

details.account-card summary::-webkit-details-marker { display: none; }

.account-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 9px;
    padding-right: 24px;
}

.account-card-name {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--navy);
}

.account-card-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.account-card-caret {
    position: absolute;
    top: 19px;
    right: 18px;
    color: var(--gold);
    transition: transform 0.2s;
    font-size: 13px;
}

details.account-card[open] .account-card-caret { transform: rotate(180deg); }
details.account-card[open] summary { border-bottom: 1px solid var(--border-soft); }

details.account-card .data-table { font-size: 12px; min-width: 480px; }
details.account-card .data-table th, details.account-card .data-table td { padding: 9px 14px; }

/* =====================================================
   TABLET / DESKTOP (≥ 901px)
   Sidebar becomes a fixed, always-visible column.
   ===================================================== */

@media (min-width: 901px) {

    .app-shell { flex-direction: row; }

    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        width: var(--sidebar-w);
        flex-shrink: 0;
        transform: none;
        padding: 26px 18px;
    }

    .sidebar-overlay { display: none; }

    .sidebar-brand { padding: 4px 8px 26px; margin-bottom: 22px; }
    .brand-mark { width: 42px; height: 42px; font-size: 17px; }
    .brand-name { font-size: 15.5px; }

    .sidenav a { padding: 11px 14px; font-size: 13.5px; }

    .hamburger-btn { display: none; }

    header.topbar { padding: 26px 36px 20px; }
    header.topbar h1 { font-size: 26px; }

    .refresh-btn { padding: 10px 18px; font-size: 12.5px; }
    .refresh-btn:hover { transform: translateY(-1px); }

    main { padding: 30px 36px 70px; }

    .summary-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 26px; }
    .summary-card { padding: 20px 22px; }
    .summary-card .num { font-size: 32px; margin-bottom: 8px; }
    .summary-card .label { font-size: 12px; }

    .total-band { padding: 28px 32px; margin-bottom: 26px; }
    .total-label { font-size: 12.5px; margin-bottom: 12px; }
    .total-figure { font-size: 40px; }
    .total-note { font-size: 12px; margin-top: 14px; padding-top: 14px; }

    .panel-header { padding: 18px 24px; }
    .panel-header h2 { font-size: 17px; }
    .panel-header .count { font-size: 11.5px; }

    .table-scroll { overflow-x: visible; }
    table.data-table { font-size: 13.5px; min-width: 0; }
    table.data-table th { padding: 11px 24px; font-size: 10.5px; }
    table.data-table td { padding: 13px 24px; white-space: normal; }

    .item-name { font-size: 14px; }
    .badge { font-size: 11px; }

    .hint-note { padding: 12px 18px; font-size: 12.5px; margin-bottom: 18px; }

    .account-grid { grid-template-columns: 1fr; gap: 18px; max-width: 820px; }
    details.account-card summary { padding: 20px 22px; }
    .account-card-name { font-size: 17px; }
    .account-card-meta { flex-direction: row; justify-content: space-between; }
    .account-card-caret { top: 22px; right: 22px; }
    details.account-card .data-table { font-size: 12.5px; min-width: 0; }
    details.account-card .data-table th, details.account-card .data-table td { padding: 10px 18px; }
}