/* =========================================================
   Suivi Trésorerie — charte inspirée de jolifish.fr
   ========================================================= */

:root {
    --color-navy: #0F2E4C;
    --color-navy-soft: #1A3A5F;
    --color-turquoise: #2EC4B6;
    --color-turquoise-soft: #E6F8F6;
    --color-orange: #FF9F1C;
    --color-orange-soft: #FFF1DA;
    --color-coral: #FF6B6B;
    --color-violet: #5E60CE;
    --color-sky: #48BFE3;
    --color-green: #2DD4BF;
    --color-green-deep: #14b8a6;
    --color-red: #EF4444;
    --color-amber: #F59E0B;

    --text-primary: #0F2E4C;
    --text-secondary: #4A5568;
    --text-muted: #94A3B8;
    --text-inverse: #FFFFFF;

    --bg-app: #F7F8FA;
    --bg-card: #FFFFFF;
    --bg-soft: #EEF2F7;
    --bg-sidebar: #0F2E4C;

    --border: #E2E8F0;
    --border-strong: #CBD5E1;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(15, 46, 76, 0.05);
    --shadow: 0 4px 16px rgba(15, 46, 76, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 46, 76, 0.12);

    --sidebar-width: 260px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-app);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-turquoise);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
    color: var(--text-primary);
    margin: 0 0 0.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 0.75rem; }

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

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

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #cbd5e1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}
.sidebar__logo {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--color-turquoise), var(--color-orange));
    display: grid; place-items: center;
    color: #fff;
    font-weight: 700;
}
.sidebar__title {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}
.sidebar__subtitle {
    color: #94A3B8;
    font-size: 0.75rem;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.sidebar__nav a {
    color: #CBD5E1;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar__nav a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
    text-decoration: none;
}
.sidebar__nav a.is-active {
    background: rgba(46, 196, 182, 0.18);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--color-turquoise);
}
.sidebar__nav .icon { width: 18px; height: 18px; opacity: 0.85; }

.sidebar__footer {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 1rem;
    font-size: 0.78rem;
    color: #94A3B8;
}
.sidebar__user {
    display: flex; align-items: center; gap: 0.6rem;
    margin-bottom: 0.5rem;
}
.sidebar__avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--color-turquoise);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 600;
    font-size: 0.8rem;
}
.sidebar__logout {
    background: none;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    padding: 0;
    font: inherit;
    font-size: 0.78rem;
}
.sidebar__logout:hover { color: var(--color-turquoise); text-decoration: underline; }

.main {
    flex: 1;
    padding: 2rem 2.25rem;
    overflow-x: hidden;
}

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-header__title h1 { margin: 0 0 0.15rem; }
.page-header__subtitle { color: var(--text-muted); font-size: 0.88rem; }

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

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.4rem;
    border: 1px solid var(--border);
}
.card--padded { padding: 1.5rem 1.75rem; }
.card__header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem;
    gap: 0.75rem;
}
.card__title { font-size: 1rem; font-weight: 600; }
.card__hint { font-size: 0.8rem; color: var(--text-muted); }

.grid {
    display: grid;
    gap: 1.25rem;
}
.grid--kpi   { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--2col  { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grid--3col  { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* ---------- KPI ---------- */

.kpi {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
    overflow: hidden;
}
.kpi__label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.kpi__value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.kpi__hint { font-size: 0.78rem; color: var(--text-muted); }
.kpi__accent {
    position: absolute;
    top: 0; right: 0;
    width: 60px; height: 60px;
    border-radius: 50%;
    transform: translate(30%, -30%);
    opacity: 0.15;
}
.kpi--turquoise .kpi__accent { background: var(--color-turquoise); }
.kpi--orange    .kpi__accent { background: var(--color-orange); }
.kpi--violet    .kpi__accent { background: var(--color-violet); }
.kpi--coral     .kpi__accent { background: var(--color-coral); }
.kpi--sky       .kpi__accent { background: var(--color-sky); }

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

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
}
table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    font-size: 0.88rem;
}
table.data th, table.data td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data thead th {
    background: var(--bg-soft);
    color: var(--text-secondary);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
table.data tbody tr:hover { background: rgba(46, 196, 182, 0.04); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--color-navy);
    color: #fff;
    padding: 0.55rem 0.95rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--color-navy);
    cursor: pointer;
    transition: transform 0.06s ease, box-shadow 0.15s ease, background 0.15s ease;
    text-decoration: none;
}
.btn:hover { background: var(--color-navy-soft); text-decoration: none; box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }

.btn--turquoise { background: var(--color-turquoise); border-color: var(--color-turquoise); color: #fff; }
.btn--turquoise:hover { background: #25a99c; border-color: #25a99c; }

.btn--orange { background: var(--color-orange); border-color: var(--color-orange); color: #fff; }
.btn--orange:hover { background: #e88c10; border-color: #e88c10; }

.btn--ghost {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn--ghost:hover { background: var(--bg-soft); }

.btn--danger {
    background: transparent;
    color: var(--color-red);
    border-color: rgba(239, 68, 68, 0.4);
}
.btn--danger:hover { background: rgba(239, 68, 68, 0.08); border-color: var(--color-red); }

.btn--sm { padding: 0.32rem 0.7rem; font-size: 0.78rem; }
.btn--block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.25rem;
}
.form-grid--full > * { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field__full { grid-column: 1 / -1; }

label, .field__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=month], select, textarea {
    font: inherit;
    color: var(--text-primary);
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
    font-size: 0.88rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    width: 100%;
    line-height: 1.3;
}
input:hover:not(:focus):not(:disabled),
select:hover:not(:focus):not(:disabled),
textarea:hover:not(:focus):not(:disabled) {
    border-color: var(--color-turquoise);
    background-color: #FAFEFE;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-turquoise);
    box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.2);
    background-color: #fff;
}

/* Select : flèche personnalisée + padding adapté */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4.5l4 4 4-4' stroke='%230F2E4C' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 12px;
    padding-right: 2rem;
    cursor: pointer;
}
select:disabled {
    background-color: var(--bg-soft);
    cursor: not-allowed;
    opacity: 0.65;
}

/* Date / month : icône calendrier teintée + cursor cohérent */
input[type=date], input[type=month] {
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}
input[type=date]::-webkit-calendar-picker-indicator,
input[type=month]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.55;
    filter: invert(18%) sepia(20%) saturate(1500%) hue-rotate(180deg);
    transition: opacity 0.15s ease;
    padding: 2px;
    border-radius: 4px;
}
input[type=date]::-webkit-calendar-picker-indicator:hover,
input[type=month]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    background-color: var(--color-turquoise-soft);
}
input[type=date]::-webkit-datetime-edit,
input[type=month]::-webkit-datetime-edit {
    color: var(--text-primary);
}
input[type=date]:invalid::-webkit-datetime-edit,
input[type=month]:invalid::-webkit-datetime-edit {
    color: var(--text-muted);
}
input[type=number] {
    font-variant-numeric: tabular-nums;
}

input[type=color] {
    width: 50px; height: 40px;
    padding: 2px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
}

textarea { min-height: 80px; resize: vertical; }

.field__hint { font-size: 0.75rem; color: var(--text-muted); }

.checkbox {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--bg-soft);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid var(--border);
}
.badge--success  { background: rgba(46, 196, 182, 0.15); color: #14746a; border-color: rgba(46, 196, 182, 0.3); }
.badge--warning  { background: rgba(255, 159, 28, 0.18); color: #b76e0b; border-color: rgba(255, 159, 28, 0.35); }
.badge--danger   { background: rgba(239, 68, 68, 0.15); color: #b91c1c; border-color: rgba(239, 68, 68, 0.3); }
.badge--info     { background: rgba(72, 191, 227, 0.15); color: #155e75; border-color: rgba(72, 191, 227, 0.3); }
.badge--violet   { background: rgba(94, 96, 206, 0.15); color: #3c3eb8; border-color: rgba(94, 96, 206, 0.3); }
.badge--amber    { background: rgba(245, 158, 11, 0.15); color: #92400e; border-color: rgba(245, 158, 11, 0.35); }
.badge--muted    { background: var(--bg-soft); color: var(--text-muted); }
.badge--status   { min-width: 92px; justify-content: center; }

/* Tabs (sous-navigation) */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs__link {
    padding: 0.55rem 0.95rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.tabs__link:hover { color: var(--text-primary); text-decoration: none; }
.tabs__link.is-active {
    color: var(--color-navy);
    border-bottom-color: var(--color-turquoise);
}
.tabs__count {
    background: var(--bg-soft);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
}
.tabs__link.is-active .tabs__count { background: var(--color-turquoise); color: #fff; }
.tabs__count--warning { background: rgba(245, 158, 11, 0.18); color: #92400e; }
.tabs__count--danger  { background: rgba(239, 68, 68, 0.15); color: #b91c1c; }

/* Bouton PDF compact */
.btn--pdf {
    background: rgba(94, 96, 206, 0.1);
    color: #3c3eb8;
    border-color: rgba(94, 96, 206, 0.35);
}
.btn--pdf:hover { background: rgba(94, 96, 206, 0.18); color: #2a2b9e; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- Flash ---------- */

.flash {
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid;
    font-size: 0.88rem;
    display: flex; align-items: center; gap: 0.5rem;
}
.flash--success { background: rgba(46, 196, 182, 0.1); color: #0e6b5f; border-color: rgba(46, 196, 182, 0.3); }
.flash--error   { background: rgba(239, 68, 68, 0.08); color: #991b1b; border-color: rgba(239, 68, 68, 0.3); }
.flash--info    { background: rgba(72, 191, 227, 0.1); color: #155e75; border-color: rgba(72, 191, 227, 0.3); }
.flash--warning { background: rgba(255, 159, 28, 0.12); color: #92400e; border-color: rgba(255, 159, 28, 0.3); }

/* ---------- Auth ---------- */

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
    background:
        radial-gradient(ellipse at top left, rgba(46, 196, 182, 0.16), transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(255, 159, 28, 0.12), transparent 55%),
        var(--bg-app);
}
.auth-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.25rem 2.25rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}
.auth-card__brand {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.auth-card__logo {
    width: 48px; height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--color-turquoise), var(--color-orange));
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 1.1rem;
}
.auth-card h1 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.auth-card__subtitle { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.5rem; }

/* ---------- Utilities ---------- */

.stack > * + * { margin-top: 0.75rem; }
.stack-lg > * + * { margin-top: 1.5rem; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.74rem; }
.font-mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.amount-positive { color: #0e6b5f; font-weight: 600; }
.amount-negative { color: #b91c1c; font-weight: 600; }

.chart-wrap { position: relative; height: 320px; }
.chart-wrap--tall { height: 380px; }
.chart-wrap--short { height: 200px; }

.empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}
.empty__icon { font-size: 2rem; margin-bottom: 0.5rem; }

.divider {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
    border: 0;
}

.inline-form { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; transition: background-color 0.4s ease; border-radius: var(--radius-sm); padding: 1px; }
.inline-form input, .inline-form select {
    padding: 0.28rem 0.5rem;
    font-size: 0.8rem;
    min-width: 0;
}
.inline-form select { padding-right: 1.7rem; background-size: 10px; background-position: right 0.45rem center; }
.inline-form--saved { background-color: rgba(46, 196, 182, 0.18); box-shadow: 0 0 0 2px rgba(46, 196, 182, 0.35); }

/* Catégorisation : vert si catégorisée, rouge sinon */
select.is-categorized {
    background-color: rgba(46, 196, 182, 0.10);
    border-color: rgba(46, 196, 182, 0.45);
    color: #0e6b5f;
    font-weight: 500;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4.5l4 4 4-4' stroke='%230e6b5f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
}
select.is-categorized:hover:not(:focus) {
    background-color: rgba(46, 196, 182, 0.18);
    border-color: var(--color-turquoise);
}
select.is-uncategorized {
    background-color: rgba(239, 68, 68, 0.07);
    border-color: rgba(239, 68, 68, 0.4);
    color: #b91c1c;
    font-weight: 500;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4.5l4 4 4-4' stroke='%23b91c1c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
}
select.is-uncategorized:hover:not(:focus) {
    background-color: rgba(239, 68, 68, 0.14);
    border-color: var(--color-red);
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 0.7rem 1.1rem;
    background: var(--color-navy);
    color: #fff;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(15, 46, 76, 0.25);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    pointer-events: none;
    max-width: 90vw;
}
.toast--show {
    opacity: 1;
    transform: translateY(0);
}
.toast--success { background: var(--color-turquoise); }
.toast--error   { background: var(--color-red); }
.toast--info    { background: var(--color-navy); }

.confirm-link { color: var(--color-red); cursor: pointer; }
.confirm-link:hover { text-decoration: underline; }

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

@media (max-width: 960px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        align-items: center;
        padding: 0.75rem 1rem;
    }
    .sidebar__brand { margin-bottom: 0; flex: 1; }
    .sidebar__nav {
        flex-direction: row;
        overflow-x: auto;
    }
    .sidebar__nav a { white-space: nowrap; }
    .sidebar__footer { display: none; }
    .main { padding: 1.25rem; }
}
