/* ============================================================
   Coffre Le39 — Thème sombre glassmorphism
   ============================================================ */

:root {
    --bg: #0b0f1a;
    --panel: rgba(255,255,255,0.06);
    --panel2: rgba(255,255,255,0.08);
    --stroke: rgba(255,255,255,0.10);
    --text: rgba(255,255,255,0.92);
    --muted: rgba(255,255,255,0.60);

    /* removed */
    /* removed */

    --green: #30d158;
    --red: #ff453a;
    --amber: #ffd60a;
    --greenDay: #2f8f4e; /* darker green for day mode readability (but not too dark) */

    --shadow: 0 12px 30px rgba(0,0,0,0.35);
    --radius: 18px;
}

body.day {
    /* JL: day mode should be clearly brighter (light UI) */
    /* JL: unify the greys: use the SAME medium grey everywhere (bg + cards) */
    --bg: #d1d5db;

    /* Use the same grey inside panels as the wallpaper grey */
    --panel: #d1d5db;
    --panel2: #d1d5db;

    /* Darker green in day mode (readability on grey) */
    --green: var(--greenDay);

    /* Stronger borders + better contrast */
    --stroke: rgba(2,6,23,0.18);
    --text: rgba(2,6,23,0.92);
    --muted: rgba(2,6,23,0.72);

    /* Day header palette (slightly darker than bg) */
    /* Removed to keep headers dark blue */

    --shadow: 0 12px 30px rgba(2,6,23,0.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
                 "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Layout ------------------------------------------------ */

.wrap {
    max-width: var(--w);
    margin: 0 auto;
    padding: 18px 14px 40px;
}

header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: start;
    justify-content: space-between;
    padding: 10px 4px 16px;
}

.leftStack{display:flex; flex-direction:column; gap:10px; align-items:flex-start;}
.dateCenter{display:flex; justify-content:center;}

.title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.title h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: -0.02em;
    font-weight: 700;
}

/* Title pill + version */
.titleRow{
    display:flex;
    align-items:baseline;
    gap:10px;
}
.titlePill{
    display:inline-flex;
    align-items:center;
    gap:8px;
    padding:8px 10px;
    border:1px solid var(--stroke);
    background:var(--panel);
    border-radius:999px;
    color:var(--muted);
    font-size:12px;
    white-space:nowrap;
    user-select:none;
    transition: background 0.2s, border-color 0.2s;
}
.titlePill b{
    color: var(--text);
    font-size: 18px;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.ver{
    font-size:12px;
    color:var(--muted);
    font-weight:800;
    margin-left: 8px;
}

.subtitle {
    font-size: 13px;
    color: var(--muted);
}

/* Centered date/time pill (bigger font) */
.datePill{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:10px 14px;
    border:1px solid var(--stroke);
    background:var(--panel);
    border-radius:999px;
    color:var(--text);
    font-size:16px;
    font-weight:900;
    letter-spacing:-0.01em;
    text-align:center;
    width:fit-content;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--stroke);
    background: var(--panel);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s, border-color 0.2s;
}

.pill:hover {
    background: var(--panel2);
}

.progressBar {
    display: flex;
    gap: 3px;
    margin-left: auto;
}

.progressBar .seg {
    width: 6px;
    height: 10px;
    border-radius: 2px;
    background: var(--panel);
    transition: background 0.3s;
}

.progressBar .seg.on {
    background: var(--text);
    opacity: 0.55;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

/* Grand écran: Devises à gauche, Infos à droite */
@media (min-width: 1100px) {
  .grid{grid-template-columns: 1fr 1fr; align-items:start;}
  .grid .fullSpan{grid-column: 1 / -1;}
  .grid .fxCard{grid-column: 1 / 2;}
  .grid .infosCard{grid-column: 2 / 3;}
}

/* --- Cards ------------------------------------------------- */

.card {
    width: 100%;
    border: 1px solid var(--stroke);
    background: linear-gradient(180deg, var(--panel2), var(--panel));
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.cardHead {
    background: linear-gradient(180deg, #0b2a4a, #0a223a) !important;
    color: #ffffff !important;
    padding: 12px 16px !important;
    border: none !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cardHead h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #ffffff !important;
    opacity: 1;
    text-transform: none;
}

.cardBody { padding: 14px 16px 16px; }

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

/* --- Sous-coffres ------------------------------------------ */

.subvault {
    border: 1px solid var(--stroke);
    background: var(--panel);
    border-radius: 16px;
    overflow: hidden;
}

.subvaultHeader {
    background: linear-gradient(180deg, #0b2a4a, #0a223a) !important;
    color: #ffffff !important;
    padding: 12px 16px !important;
    border: none !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.subvaultName {
    color: #ffffff !important;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-size: 16px;
    margin: 0;
    padding: 0;
    text-transform: none;
    display: flex;
    gap: 10px;
    align-items: baseline;
    min-width: 120px;
}

.subvaultTotals {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    text-align: right;
}

/* --- Bulles ------------------------------------------------ */

.bubble {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 999px;
    background: var(--panel2);
    border: 1px solid var(--stroke);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.bubble .lbl {
    color: var(--muted);
    font-weight: 700;
}

/* --- Tables ------------------------------------------------ */

.table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-variant-numeric: tabular-nums;
}

.table th,
.table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--stroke);
    vertical-align: middle;
}

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

.table th {
    text-align: left;
    font-size: 11px;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.table td { font-size: 13px; }

.metal {
    font-weight: 800;
    letter-spacing: -0.01em;
}

.mainVal {
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.subVal {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

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

/* --- Table scroll wrapper ---------------------------------- */

.tableWrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
}

.tableWrap::-webkit-scrollbar { height: 8px; }
.tableWrap::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.18);
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,0);
    background-clip: padding-box;
}

.table.minWide5 { min-width: 860px; }
.table.minWide4 { min-width: 560px; }

/* --- Flags / Devises --------------------------------------- */

.flagLine {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--stroke);
}

.flagLine:last-child { border-bottom: none !important; }

.fxCol{
    display:flex;
    align-items:center;
    justify-content:flex-end; /* right-align inside each column */
    gap:8px;
    min-width: 0;
}

.fxCell{
    display:grid;
    grid-template-columns: 1fr 28px;
    align-items:center;
    gap:8px;
    width:100%;
}

/* Force perfect column alignment: value right-aligned, flag fixed */
.fxCell .fxTxt{
    justify-self:end;
    text-align:right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.fxCell .flag{justify-self:center;}

.flag {
    width: 22px;
    height: 16px;
    border-radius: 4px;
    overflow: hidden;
    flex: 0 0 auto;
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.14);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.fxTxt {
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* FX: make the thousandths (3 decimals) smaller and not bold */
.fxTxt .fxFrac{
    font-weight: 600;
    font-size: 0.85em;
    opacity: 0.9;
}

.fxSmall {
    color: var(--muted);
    font-size: 12px;
}

/* --- Spot tables ------------------------------------------- */

.spotTable th,
.spotTable td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--stroke);
}

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

.spotTable th {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.spotTable td { font-size: 13px; }

.wcol { width: 28%; }
.ccol { width: 24%; }

.money {
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Spot tables: right-align numeric columns (stable on mobile) */
.spotTable th:nth-child(n+2),
.spotTable td:nth-child(n+2) {
    text-align: right;
}
.spotTable .money{display:block; text-align:right;}

.nowrap { white-space: nowrap; }

/* --- Infos / Insights -------------------------------------- */

.insightBox {
    padding: 12px 12px;
    border: 1px solid var(--stroke);
    border-radius: 16px;
    background: var(--panel);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.insightRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.insightRow.center{justify-content:center;text-align:center;}
.ratioVal{font-weight:900;}
.ratioGood{color:var(--green);} /* < 51.1 */
.ratioBad{color:var(--red);}   /* >= 51.1 */

.deltaArrow{font-size:18px;margin-right:8px;}
.deltaVal{font-weight:900;}
.deltaGood{color:var(--green);} /* < 51.1 */
.deltaBad{color:var(--red);}    /* >= 51.1 */

.insightLbl {
    font-weight: 800;
    letter-spacing: -0.02em;
}

.insightBubble {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.16);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: -0.02em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* --- Error ------------------------------------------------- */

.err {
    padding: 14px 16px;
    border: 1px solid rgba(255,69,58,0.35);
    background: rgba(255,69,58,0.08);
    border-radius: 14px;
    color: rgba(255,255,255,0.9);
    margin-top: 10px;
}

/* --- Responsive -------------------------------------------- */

@media (max-width: 760px) {
    /* Header is a grid (not flex): switch to a clean single-column mobile header */
    header {
        grid-template-columns: 1fr;
        gap: 12px;
        align-items: start;
    }
    .dateCenter{justify-content:flex-start;}

    .subvaultHeader {
    background: linear-gradient(180deg, #0b2a4a, #0a223a) !important;
    color: #ffffff !important;
    padding: 12px 16px !important;
    border: none !important;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}
    .subvaultTotals { justify-content: flex-start; text-align: left; }

    /* FX: keep THREE currency columns on mobile (JL requirement).
       We tighten spacing + allow truncation instead of stacking. */
    .flagLine { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .fxCol{justify-content:flex-end;}
    .fxCell{grid-template-columns: 1fr 22px; gap: 6px;}
    .fxCell .fxTxt{font-size:12px;}
    .flag{width:20px; height:14px;}

    .table th, .table td { padding: 10px 8px; }
    .mainVal { font-size: 13px; }
}

.subvaultHeader .bubble, .cardHead .bubble {
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}
.subvaultHeader .bubble .lbl, .cardHead .bubble .lbl {
    color: rgba(255, 255, 255, 0.7) !important;
}
/* force sync */
