/* ============================================================
   Budget — budget.golf-cup.fr
   Thème sombre, mobile-first
   ============================================================ */

:root {
    --bg:        #0F1117;
    --card:      #1A1D27;
    --border:    #2A2D3E;
    --text:      #E5E7EB;
    --text-dim:  #9CA3AF;
    --green:     #2DD4BF;
    --red:       #F87171;
    --orange:    #FB923C;
    --radius:    14px;
}

* { box-sizing: border-box; }

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}

.num, .cur, input[type="number"], .reste, .static-amount {
    font-variant-numeric: tabular-nums;
}

a { color: var(--green); }

/* --- Carte générique --- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.1rem;
    max-width: 560px;
    margin: 0 auto;
}
.topbar-nav { display: flex; gap: 1.1rem; }
.link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}
.link:hover { color: var(--text); }

.save-status {
    font-size: 0.82rem;
    color: var(--text-dim);
    min-height: 1.2em;
    transition: opacity 0.3s, color 0.3s;
}
.save-status[data-state="idle"]   { opacity: 0; }
.save-status[data-state="saving"] { opacity: 1; color: var(--text-dim); }
.save-status[data-state="saved"]  { opacity: 1; color: var(--green); }
.save-status[data-state="error"]  { opacity: 1; color: var(--red); }

/* ============================================================
   Dashboard
   ============================================================ */
.dash {
    max-width: 560px;
    margin: 0 auto;
    padding: 0.5rem 1.1rem 3rem;
}

.bilan-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 1.25rem;
    text-align: center;
}

.line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.line label {
    color: var(--text-dim);
    font-size: 0.95rem;
    font-weight: 500;
}

/* Champ montant avec € collé */
.amount-input {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0.35rem 0.6rem;
    transition: border-color 0.15s;
}
.amount-input:focus-within { border-color: var(--green); }
.amount-input input[type="number"] {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 600;
    width: 7.5ch;
    text-align: right;
    -moz-appearance: textfield;
}
.amount-input.small input[type="number"] { width: 6ch; font-size: 1rem; }
.amount-input input::-webkit-outer-spin-button,
.amount-input input::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}
.amount-input .cur { color: var(--text-dim); font-size: 0.95rem; }

/* Ligne statique (récurrentes) */
.line-static { justify-content: space-between; }
.static-amount { font-weight: 600; font-size: 1.05rem; color: var(--text); }

.rec-toggle {
    background: none;
    border: none;
    color: var(--text-dim);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0;
}
.rec-toggle:hover { color: var(--text); }
.rec-toggle .chevron { transition: transform 0.2s; font-size: 0.8rem; }
.rec-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }

.rec-detail { padding: 0.25rem 0 0.5rem; }
.rec-list { list-style: none; margin: 0; padding: 0.25rem 0; }
.rec-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-size: 0.88rem;
    color: var(--text-dim);
}
.rec-list .num { color: var(--text); }
.rec-empty { color: var(--text-dim); font-size: 0.88rem; }

/* Dépenses exceptionnelles (liste éditable sur le tableau de bord) */
.exc-detail { padding: 0.25rem 0 0.6rem; }
.exc-list { list-style: none; margin: 0; padding: 0; }
.exc-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
}
.exc-libelle {
    flex: 1;
    min-width: 0;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    outline: none;
}
.exc-libelle:focus { border-color: var(--green); }
.exc-add {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--border);
    flex-wrap: wrap;
}
.exc-add input[type="text"] {
    flex: 1;
    min-width: 7rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.5rem;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    outline: none;
}
.exc-add input[type="text"]:focus { border-color: var(--green); }
.exc-add .btn { padding: 0.5rem 0.9rem; }

/* Champ date (dépenses exceptionnelles) */
.exc-date {
    flex: none;
    width: 8.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem 0.45rem;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    outline: none;
    color-scheme: dark;
}
.exc-date:focus { border-color: var(--green); }

/* Reste estimé */
.reste-wrap { text-align: center; margin-top: 1.5rem; }
.reste-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-bottom: 0.3rem;
}
.reste {
    font-size: 2.7rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--green);
    transition: color 0.25s;
}
.reste.is-negative { color: var(--red); }
.reste.is-warning  { color: var(--orange); }

/* Crédit nécessaire (affiché seulement en cas de déficit) */
.credit-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    border-top: 1px dashed var(--border);
}
.credit-wrap[hidden] { display: none; }
.credit-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.78rem;
    color: var(--text-dim);
}
.credit {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--orange);
}

/* Sélecteur de jour (le [JJ]) */
.day-pick {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: 400;
    white-space: nowrap;
}
.day-input {
    width: 3ch;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.15rem 0.25rem;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}
.day-input::-webkit-outer-spin-button,
.day-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.day-input:focus { border-color: var(--green); }

/* Projection : courbe + curseur */
.proj { margin-top: 1.5rem; }
.spark {
    width: 100%;
    height: 80px;
    display: block;
    margin-bottom: 0.5rem;
    overflow: visible;
}
.slider-wrap { margin-top: 0.8rem; }
.day-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 6px;
    background: var(--border);
    outline: none;
}
.day-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--green);
    border: 3px solid var(--card);
    cursor: pointer;
    box-shadow: 0 0 0 1px var(--green);
}
.day-slider::-moz-range-thumb {
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--green);
    border: 3px solid var(--card);
    cursor: pointer;
}
.slider-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 0.4rem;
    font-size: 0.72rem;
    color: var(--text-dim);
}
.slider-hint { font-style: italic; opacity: 0.7; }

/* ============================================================
   Login
   ============================================================ */
.login-page { display: flex; min-height: 100vh; }
.login-wrap {
    margin: auto;
    width: 100%;
    max-width: 360px;
    padding: 1.25rem;
}
.login-card { display: flex; flex-direction: column; gap: 1rem; }
.login-title { text-align: center; margin: 0; font-size: 1.6rem; }
.login-sub { text-align: center; margin: -0.4rem 0 0.4rem; color: var(--text-dim); }

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field span { font-size: 0.85rem; color: var(--text-dim); font-weight: 500; }
.field input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0.7rem 0.8rem;
    color: var(--text);
    font: inherit;
    outline: none;
}
.field input:focus { border-color: var(--green); }

.alert {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: var(--red);
    border-radius: 9px;
    padding: 0.6rem 0.8rem;
    font-size: 0.88rem;
    text-align: center;
}

/* ============================================================
   Boutons
   ============================================================ */
.btn {
    border: none;
    border-radius: 9px;
    padding: 0.7rem 1.1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary { background: var(--green); color: #06302b; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-block { width: 100%; }

.btn-icon {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem 0.4rem;
    border-radius: 7px;
}
.btn-icon:hover { color: var(--red); background: rgba(248,113,113,0.1); }

/* ============================================================
   Paramètres — récurrentes
   ============================================================ */
.rec-rows { list-style: none; margin: 0 0 1rem; padding: 0; }
.rec-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
}
.rec-row.is-inactive { opacity: 0.45; }

.rec-move { display: flex; flex-direction: column; gap: 1px; }
.arrow {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.6rem;
    line-height: 1;
    padding: 1px 2px;
}
.arrow:hover { color: var(--text); }

.rec-libelle {
    flex: 1;
    min-width: 0;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.45rem 0.55rem;
    color: var(--text);
    font: inherit;
    outline: none;
}
.rec-libelle:focus { border-color: var(--green); }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0;
    background: var(--border);
    border-radius: 22px;
    cursor: pointer;
    transition: background 0.2s;
}
.slider::before {
    content: "";
    position: absolute;
    height: 16px; width: 16px;
    left: 3px; top: 3px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .slider { background: rgba(45, 212, 191, 0.35); }
.toggle input:checked + .slider::before { transform: translateX(16px); background: var(--green); }

.rec-total-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 0;
    margin-bottom: 1rem;
    font-weight: 500;
    color: var(--text-dim);
}
.rec-total-bar .strong { color: var(--text); font-size: 1.15rem; font-weight: 700; }

.rec-add {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    flex-wrap: wrap;
}
.rec-add input[type="text"] {
    flex: 1;
    min-width: 8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.6rem;
    color: var(--text);
    font: inherit;
    outline: none;
}
.rec-add input[type="text"]:focus { border-color: var(--green); }

/* ============================================================
   Page salaire
   ============================================================ */
.dash.wide { max-width: 760px; }

.mini-link { font-size: 0.78rem; color: var(--text-dim); text-decoration: none; }
.mini-link:hover { color: var(--green); }

.sal-params {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    margin-bottom: 1.25rem;
}
.field-inline {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 240px;
    justify-content: space-between;
}
.field-inline > span:first-child { color: var(--text-dim); font-size: 0.9rem; }

.year-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    margin: 0.5rem 0 1rem;
}
.year-current { font-size: 1.2rem; font-weight: 700; }
.btn-year {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.btn-year:hover { color: var(--text); border-color: var(--green); }

.sal-table-wrap { overflow-x: auto; }
.sal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.sal-table th, .sal-table td {
    padding: 0.45rem 0.5rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.sal-table th {
    color: var(--text-dim);
    font-weight: 500;
    font-size: 0.8rem;
    text-align: right;
}
.sal-table th:first-child, .sal-mois { text-align: left; color: var(--text-dim); }
.sal-table .sal-imp, .sal-table th:nth-child(4) { text-align: center; }
.sal-table .prime-percu { color: var(--green); font-weight: 600; }
.sal-table tfoot td {
    border-top: 2px solid var(--border);
    border-bottom: none;
    font-weight: 600;
    color: var(--text);
    padding-top: 0.7rem;
}
.sal-table tfoot .strong { color: var(--green); font-size: 1.05rem; font-weight: 700; }

.prime-libelle {
    width: 11rem;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 0.35rem 0.45rem;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    outline: none;
    text-align: left;
}
.prime-libelle:focus { border-color: var(--green); }
.prime-imposable { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }

.sal-note {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.5;
}

/* ============================================================
   Install
   ============================================================ */
.install-wrap { max-width: 440px; margin: 3rem auto; padding: 0 1.1rem; }
.install-wrap .ok { color: var(--green); }
.install-wrap ul { padding-left: 1.2rem; color: var(--text-dim); }

@media (max-width: 480px) {
    .reste { font-size: 2.3rem; }
    .line { flex-wrap: wrap; }
}
