/* Clocki — palette + utilities alignées Clockify. */

:root {
    /* Clockify-aligned palette */
    --bg:           #F2F6F8;
    --bg-card:      #FFFFFF;
    --bg-sunken:    #F8FAFB;
    --bg-hover:     #E4EDF1;
    --fg:           #0A0E10;
    --fg-muted:     #546E7A;
    --fg-soft:      #90A4AE;
    --border:       #E4EDF1;
    --border-strong:#B4C6D0;
    --primary:      #03A9F4;
    --primary-dark: #026897;
    --primary-tint: #E1F5FE;
    --danger:       #BC3232;
    --danger-bg:    #fee2e2;
    --ok:           #4caf50;
    --ok-bg:        #ecfdf5;
    --warn:         #ff9800;
    --warn-bg:      #fff3e0;
    --info-bg:      #E1F5FE;
    --shadow:       0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-md:    0 2px 8px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
    --radius:       2px;
    --radius-md:    4px;
    --radius-lg:    8px;
    --gap:          16px;

    /* Sidebar */
    --sidebar-w:    220px;
    --sidebar-w-collapsed: 56px;
    --sidebar-bg:   #FFFFFF;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "Helvetica Neue", Arial, sans-serif;
    color: var(--fg);
    background: var(--bg);
    line-height: 1.5;
    font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------- *
 * Sidebar (Clockify-style vertical nav)
 * --------------------------------------------------------------------- */
.cl-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: width .15s ease;
}
body.sidebar-collapsed .cl-sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .cl-nav-label,
body.sidebar-collapsed .cl-nav-section,
body.sidebar-collapsed .cl-brand-name,
body.sidebar-collapsed .cl-user-meta { display: none; }
body.sidebar-collapsed .cl-user-card { padding: 8px 6px; justify-content: center; }
body.sidebar-collapsed .cl-nav-item { justify-content: center; padding: 10px; }

.cl-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}
.cl-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-weight: 600;
    font-size: 1.05rem;
    text-decoration: none;
}
.cl-brand:hover { text-decoration: none; }
.cl-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
    font-size: .9rem;
}
.cl-sidebar-toggle {
    background: transparent;
    border: 0;
    padding: 4px;
    cursor: pointer;
    opacity: .5;
}
.cl-sidebar-toggle:hover { opacity: 1; }
.cl-sidebar-toggle img { width: 18px; height: 18px; }

.cl-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cl-nav-section {
    margin: 12px 12px 4px;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--fg-soft);
}
.cl-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    color: var(--fg);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: .9rem;
    transition: background-color .1s;
}
.cl-nav-item:hover {
    background: var(--bg-hover);
    text-decoration: none;
}
.cl-nav-item.is-active {
    background: var(--primary-tint);
    color: var(--primary-dark);
    font-weight: 500;
}
.cl-nav-item.is-active .cl-nav-icon { opacity: 1; }
.cl-nav-icon {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: .55;
    transition: opacity .12s;
}
.cl-nav-item:hover .cl-nav-icon { opacity: .9; }

.cl-sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 10px 12px;
}
.cl-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cl-user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .85rem;
    flex-shrink: 0;
}
.cl-user-meta {
    flex: 1;
    min-width: 0;
    line-height: 1.2;
}
.cl-user-name {
    font-size: .85rem;
    font-weight: 500;
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cl-user-email {
    font-size: .72rem;
    color: var(--fg-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cl-logout-form button {
    background: transparent;
    border: 0;
    color: var(--fg-soft);
    font-size: 1.1rem;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: var(--radius-md);
}
.cl-logout-form button:hover {
    background: var(--bg-hover);
    color: var(--danger);
}

button {
    font: inherit;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--fg);
    padding: 6px 14px;
    border-radius: var(--radius);
    transition: background .12s, border-color .12s;
}
button:hover { background: var(--bg-hover); border-color: var(--border-strong); }
button.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
button.primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}
button.danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--border);
}
button.danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
input[type="datetime-local"], input[type="color"], select, textarea {
    font: inherit;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--fg);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    border-color: var(--primary);
}

main, main.cl-main {
    margin-left: var(--sidebar-w);
    padding: 24px 28px;
    transition: margin-left .15s ease;
    min-height: 100vh;
}
body.sidebar-collapsed main,
body.sidebar-collapsed main.cl-main { margin-left: var(--sidebar-w-collapsed); }
body.no-sidebar main, body.no-sidebar main.cl-main {
    margin-left: 0;
    max-width: 480px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .cl-sidebar {
        transform: translateX(-100%);
        transition: transform .15s ease;
    }
    body.sidebar-mobile-open .cl-sidebar { transform: translateX(0); }
    main, main.cl-main { margin-left: 0; padding: 16px; }
}

.flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin: 16px 0;
}
.flash-info    { background: var(--info-bg); }
.flash-error   { background: var(--danger-bg); color: var(--danger); }
.flash-success { background: var(--ok-bg);     color: var(--ok); }
.flash-warn    { background: var(--warn-bg);   color: var(--warn); }

.flash.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    max-width: 420px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
    transform: translateY(20px);
    opacity: 0;
    transition: transform .2s, opacity .2s;
}
.flash.toast.toast-visible {
    transform: translateY(0);
    opacity: 1;
}

.stack > * + * { margin-top: 14px; }
.muted { color: var(--fg-muted); }
.small { font-size: .875rem; }

/* Login card */
.login-card {
    max-width: 380px;
    margin: 60px auto;
    padding: 32px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.login-card h1 {
    color: var(--primary);
    margin: 0 0 4px;
    font-size: 1.6rem;
}
.login-card .lede { margin: 0 0 24px; color: var(--fg-muted); }
.login-card label { display: block; }
.login-card label > span {
    display: block;
    margin-bottom: 4px;
    font-size: .875rem;
    color: var(--fg-muted);
}
.login-card button.primary { width: 100%; padding: 10px; }

/* Page heading + filter row */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.page-head h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 400;
    color: var(--fg);
}
.page-head h1 .muted { font-weight: 300; }
.page-head p { margin: 4px 0 0; }
.page-head .actions { display: flex; gap: 8px; align-items: center; }

.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: none;
}
.filter-bar input[type="text"] { flex: 1; }
label.inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--fg-muted);
    font-size: .9rem;
}

/* Action buttons inside lists */
a.button, .actions a {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--fg);
    border-radius: 6px;
    text-decoration: none;
    font-size: .875rem;
}
a.button:hover { background: var(--bg); text-decoration: none; }
a.button.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
a.button.primary:hover { background: var(--primary-dark); }
.actions { display: flex; gap: 6px; }
.right { text-align: right; }

/* Data tables — Clockify flat style */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: none;
}
.data-table th, .data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
    font-size: .875rem;
}
.data-table thead { background: var(--bg-sunken); }
.data-table th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--fg-muted);
    font-weight: 500;
    padding: 9px 14px;
}
.data-table tbody tr { transition: background-color .1s; }
.data-table tbody tr:hover { background: var(--bg-sunken); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr.archived td { color: var(--fg-muted); }
.data-table tbody tr.archived td a { color: var(--fg-muted); }

/* Badges */
.badge {
    display: inline-block;
    padding: 1px 8px;
    background: var(--bg);
    color: var(--fg-muted);
    font-size: .75rem;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Forms */
form.form {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 640px;
}
form.form label { display: block; }
form.form label > span {
    display: block;
    margin-bottom: 4px;
    font-size: .875rem;
    color: var(--fg-muted);
}
form.form textarea { font-family: inherit; resize: vertical; }
form.form .actions { margin-top: 8px; }

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

.color-chip {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    vertical-align: middle;
    border: 1px solid rgba(0,0,0,.1);
}

/* Project list progress bar */
.progress-bar {
    position: relative;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
    height: 16px;
    min-width: 100px;
    max-width: 160px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    transition: width .25s;
}
.progress-bar.is-over .progress-fill {
    background: linear-gradient(90deg, #f59e0b, #dc2626);
}
.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 600;
    color: #111827;
    text-shadow: 0 0 2px rgba(255,255,255,.7);
}

.projects-filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.projects-filter-bar .filter-group select { padding: 5px 8px; min-width: 110px; }

.rates-section { margin-top: 32px; max-width: 720px; }
.rates-section h2 { font-size: 1.1rem; margin-bottom: 4px; }
form.inline-rate {
    display: flex;
    gap: 6px;
    align-items: center;
}
form.inline-rate input[type="number"] {
    width: 120px;
}
form.inline-rate button {
    padding: 6px 10px;
    font-size: .875rem;
}

/* Time entries */
.day-head .totals-header { text-align: right; }

/* Day separator inside the entries table — Clockify-style band */
tr.day-header td {
    background: #f3f4f6;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 2;
}
tr.day-header .day-label {
    /* date à gauche */
}
tr.day-header .day-totals {
    float: right;
    font-weight: 700;
    color: #111827;
    font-variant-numeric: tabular-nums;
}
.totals { display: flex; gap: 18px; align-items: baseline; }
.totals .kpi { font-size: 1rem; }
.totals .kpi strong { font-size: 1.25rem; }

.timer-widget {
    background: var(--bg-card);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    box-shadow: none;
    margin-bottom: 16px;
    transition: border-left-color .2s;
}
.timer-widget.is-running { border-left-color: var(--ok); }
.timer-widget form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 0;
}
.timer-widget select { min-width: 180px; flex: 0 0 auto; }
.timer-widget input[type="text"] { flex: 1; min-width: 200px; }
.timer-widget label.inline { color: var(--fg); margin: 0; font-size: .9rem; }
.timer-widget .elapsed {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--ok);
    min-width: 110px;
    text-align: left;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.no-entries { margin-top: 12px; }

/* Historique / multi-day tracker view */
.history-window-picker {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.history-day-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: none;
    margin-bottom: 12px;
    overflow: hidden;
}
.history-day-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: #f3f4f6;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
    font-weight: 600;
    color: #374151;
}
.history-day-head .day-name {
    color: #374151;
    text-decoration: none;
    text-transform: capitalize;
}
.history-day-head .day-name:hover { color: var(--primary); text-decoration: underline; }
.history-day-head .day-totals {
    color: #111827;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
.history-empty { padding: 14px; text-align: center; }
.history-entries { border-radius: 0; box-shadow: none; margin: 0; }
.period-totals-card {
    text-align: right;
}
.history-pager {
    margin-top: 18px;
    text-align: center;
}
.history-pager .button { padding: 10px 22px; }

/* Week view */
.week-head .totals-header { text-align: right; }
.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-top: 10px;
}
.week-col {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 10px;
    box-shadow: var(--shadow);
    min-height: 200px;
    display: flex;
    flex-direction: column;
}
.week-col.is-today { border: 2px solid var(--primary); }
.week-col-head {
    border-bottom: 1px solid var(--border);
    padding: 8px 4px;
    margin: -10px -10px 8px;
    border-radius: 8px 8px 0 0;
}
.week-col-link {
    display: block;
    color: var(--fg);
    text-decoration: none;
    transition: background-color .15s;
}
.week-col-link:hover {
    background: var(--bg);
    text-decoration: none;
}
.week-col-link:hover strong { color: var(--primary); }
.week-col-link > div:first-child {
    display: flex; align-items: baseline; gap: 6px;
}
.day-total { margin-top: 4px; }
.week-entries {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: .875rem;
}
.week-entries li {
    padding: 6px 8px;
    background: var(--bg);
    border-radius: 6px;
}
.week-entries .project { font-weight: 500; }
.week-entries .meta { margin-top: 2px; font-size: .75rem; }
.week-entries .desc { margin-top: 4px; color: var(--fg-muted); }
.week-entries .tag-chips { margin-top: 4px; }

@media (max-width: 1080px) {
    .week-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Dashboard */
.scope-toggle .button { padding: 6px 12px; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}
.kpi-tile {
    background: var(--bg-card);
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: none;
}
.kpi-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--fg-muted);
    font-weight: 500;
}
.kpi-value {
    font-size: 1.6rem;
    font-weight: 500;
    color: var(--fg);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}
.kpi-value .unit {
    font-size: 1rem;
    color: var(--fg-muted);
    font-weight: 400;
}
.kpi-sub { margin-top: 4px; }

.dashboard-section { margin-bottom: 28px; }
.dashboard-section h2 {
    font-size: 1rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 0 0 12px;
}

.bar-chart {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.bar-chart svg { width: 100%; height: auto; display: block; }
.bar-chart .bar rect { transition: opacity .15s; }
.bar-chart .bar:hover rect { opacity: .85 !important; }

/* Stacked bar chart (Reports + enriched Dashboard) */
.stacked-bar-chart {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stacked-bar-chart svg { width: 100%; height: auto; display: block; }
.stacked-bar-chart .bar:hover rect { opacity: .8; }
.chart-legend {
    display: flex;
    gap: 18px;
    font-size: .85rem;
    color: var(--fg-muted);
    margin-bottom: 8px;
}
.legend-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 6px;
}
.legend-billable     { background: #10b981; }
.legend-non-billable { background: #9ca3af; }

/* Donut chart */
.donut-chart {
    display: flex;
    align-items: center;
    gap: 18px;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.donut-chart svg { width: 160px; height: 160px; flex: 0 0 160px; }
.donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    font-size: .85rem;
}
.donut-legend li {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.donut-legend .legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex: 0 0 10px;
}
.donut-legend .label { overflow: hidden; text-overflow: ellipsis; }
.donut-legend .pct {
    color: var(--fg-muted);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* Reports module — sub-nav tabs (Résumé / Détaillé / Hebdo / …) */
.reports-subnav {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}
.reports-subnav .subtab {
    display: inline-block;
    padding: 10px 18px;
    color: var(--fg-muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: color .12s, border-color .12s;
    font-size: .92rem;
}
.reports-subnav .subtab:hover {
    color: var(--primary);
    text-decoration: none;
}
.reports-subnav .subtab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.reports-subnav .subtab-soon {
    opacity: .55;
}
.reports-subnav .subtab-soon:hover {
    opacity: 1;
}

/* Reports filter bar (under period picker) */
.reports-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.reports-filter-bar label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
}
.reports-filter-bar select { padding: 6px 8px; }

/* Reports KPI row */
.reports-kpi-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}
.reports-kpi-row > div {
    background: var(--bg-card);
    padding: 16px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: none;
}
.reports-total-card { border-left: 3px solid var(--primary); }
.reports-billable-card { border-left: 3px solid #10b981; }
.reports-nonbillable-card { border-left: 3px solid #9ca3af; }

/* Reports charts row */
.reports-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
}
.chart-card {
    background: var(--bg-card);
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: none;
}
.chart-card h2 {
    margin: 0 0 10px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 500;
}
.chart-card.chart-donut { padding: 16px; }
.chart-card.chart-donut .donut-chart {
    box-shadow: none;
    padding: 0;
    background: transparent;
}
.chart-card.chart-bar .stacked-bar-chart {
    box-shadow: none;
    padding: 0;
    background: transparent;
}

.reports-table-section h2 {
    margin: 0 0 8px;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--fg-muted);
}

.reports-soon {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}
.reports-soon h2 { margin-top: 0; }

@media (max-width: 900px) {
    .reports-kpi-row { grid-template-columns: 1fr; }
    .reports-charts { grid-template-columns: 1fr; }
}

.dashboard-section.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

/* --------------------------------------------------------------------- *
 * Calendar (drag-to-create)
 * --------------------------------------------------------------------- */

.cal-head .totals-header { text-align: right; }

/* Layout: 1 axis column + N day columns. Each column is a CSS-grid of slots.
   Slot height is configurable via --slot-h. Week mode uses 14px slots, day
   mode bumps to 18px for readability since there's more horizontal room. */
.cal-grid {
    --slot-h: 14px;
    display: grid;
    grid-template-columns: 50px repeat(7, 1fr);
    gap: 4px;
    background: var(--bg-card);
    padding: 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: none;
    user-select: none;
}
.cal-grid.cal-mode-day {
    --slot-h: 18px;
    grid-template-columns: 60px 1fr;
}
.cal-grid.cal-mode-day .cal-entry { font-size: .85rem; }
.cal-grid.cal-mode-day .cal-entry-desc { font-size: .75rem; }
.cal-mode-toggle {
    display: inline-flex;
    gap: 4px;
    margin-bottom: 6px;
}

.cal-axis {
    display: grid;
    grid-template-rows: 28px repeat(var(--slot-count, 64), var(--slot-h));
    color: var(--fg-muted);
    font-size: .75rem;
    position: relative;
}
.cal-axis-row {
    border-top: 1px solid var(--border);
    padding-left: 4px;
    padding-top: 2px;
    line-height: 1;
}

.cal-col {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
}
.cal-col.is-today { background: rgba(79, 70, 229, 0.04); }

.cal-day-head {
    height: 28px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
}
.cal-day-head a { color: var(--fg); text-decoration: none; }

.cal-day-body {
    position: relative;
    display: grid;
    grid-template-rows: repeat(var(--slot-count, 64), var(--slot-h));
    height: calc(var(--slot-count, 64) * var(--slot-h));
    cursor: crosshair;
    background-image: linear-gradient(
        to bottom,
        transparent calc((var(--slot-h) * 4) - 1px),
        var(--border) calc((var(--slot-h) * 4) - 1px),
        var(--border) calc(var(--slot-h) * 4)
    );
    background-size: 100% calc(var(--slot-h) * 4);
}

/* Per-grid override for slot count (Jinja sets it in HTML via inline style
   on .cal-grid; the JS reads data-slot-count). We also expose it for CSS. */
.cal-grid {
    --slot-count: 64;
}

.cal-drag-overlay {
    position: absolute;
    left: 1px;
    right: 1px;
    background: rgba(79, 70, 229, .25);
    border: 1px dashed var(--primary);
    border-radius: 3px;
    pointer-events: none;
    font-size: .7rem;
    color: var(--primary);
    padding: 2px 4px;
    z-index: 5;
}

.cal-entry {
    position: relative;
    margin: 0 2px;
    background: var(--bg-card);
    border-left: 4px solid var(--proj-color, #94a3b8);
    border-radius: 3px;
    padding: 2px 4px;
    font-size: .7rem;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
    z-index: 2;
    line-height: 1.15;
}
.cal-entry:hover { box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.cal-entry-times { color: var(--fg-muted); }
.cal-entry-project { font-weight: 600; }
.cal-entry-desc { color: var(--fg-muted); }
.cal-entry-badge {
    position: absolute;
    right: 2px;
    top: 2px;
}

/* --------------------------------------------------------------------- *
 * Modal
 * --------------------------------------------------------------------- */

dialog.entry-modal {
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    padding: 0;
    width: min(560px, 92vw);
    max-height: 92vh;
    background: var(--bg-card);
    color: var(--fg);
}
dialog.entry-modal::backdrop {
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(2px);
}
dialog.entry-modal form { padding: 20px 24px; box-shadow: none; }
dialog.entry-modal .modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
dialog.entry-modal .modal-head h2 { margin: 0; font-size: 1.1rem; }
dialog.entry-modal .modal-close {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--fg-muted);
}
dialog.entry-modal .modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}
dialog.entry-modal .modal-actions .grow { flex: 1; }
dialog.entry-modal label.inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--fg-muted);
    font-size: .9rem;
}

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

/* Weekly grid (Reports/Hebdomadaire) */
.week-nav {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.week-nav strong {
    font-size: 1rem;
    color: var(--fg);
    font-weight: 500;
}
.weekly-grid-wrapper { overflow-x: auto; }
.weekly-grid-table th, .weekly-grid-table td {
    white-space: nowrap;
}
.weekly-grid-table th .small { font-weight: 400; }
.weekly-grid-table .cell-empty { color: var(--fg-soft); }
.weekly-grid-table .cell-row-total {
    background: var(--bg-sunken);
    border-left: 1px solid var(--border);
}
.weekly-grid-table tfoot .weekly-col-totals td {
    background: var(--bg-sunken);
    border-top: 2px solid var(--border-strong);
}
.weekly-grid-table tfoot .cell-grand-total {
    background: var(--primary-tint);
    color: var(--primary-dark);
}

/* Combobox (typeahead enhancement of <select data-combobox>) */
.combobox {
    position: relative;
    display: block;
}
select.combobox-hidden {
    /* Keep in DOM for form submission, but invisible/inaccessible by tab. */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    margin: 0;
    padding: 0;
    border: 0;
}
.combobox-input {
    width: 100%;
}
.combobox-list {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
.combobox-list:empty { display: none; }
.combobox-list li {
    padding: 6px 12px;
    cursor: pointer;
    font-size: .92rem;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.combobox-list li:hover,
.combobox-list li.highlight {
    background: var(--primary);
    color: #fff;
}

.log-pane {
    background: #1f2937;
    color: #e5e7eb;
    padding: 16px;
    border-radius: var(--radius);
    max-height: 70vh;
    overflow: auto;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: .8rem;
    line-height: 1.4;
    white-space: pre;
    box-shadow: var(--shadow);
}

/* Scrollable inner panel (e.g. long monthly breakdown) */
.scroll-pane {
    max-height: 360px;
    overflow-y: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.scroll-pane > .data-table {
    box-shadow: none;
    border-radius: 0;
}
.scroll-pane > .data-table thead {
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 1;
}

/* Period picker — reusable between Dashboard and Reports */
.period-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px 14px;
    margin-bottom: 18px;
}
.period-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.period-presets .preset-btn {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--fg);
    font-size: .85rem;
    text-decoration: none;
    transition: background-color .12s, color .12s, border-color .12s;
}
.period-presets .preset-btn:hover {
    background: var(--bg);
    text-decoration: none;
}
.period-presets .preset-btn.is-active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.period-custom {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    margin-bottom: 0;
}
.period-custom input[type="date"] { width: 140px; padding: 5px 8px; }
.period-custom .sep { color: var(--fg-muted); }
.period-custom button { padding: 5px 12px; font-size: .85rem; }
.period-label { flex-basis: 100%; }

/* Pager (project detail) */
nav.pager {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
    justify-content: center;
}

.error-page {
    max-width: 500px;
    margin: 80px auto;
    text-align: center;
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.error-page h1 {
    color: var(--primary);
    font-size: 3rem;
    margin: 0 0 8px;
}
@media (max-width: 900px) {
    .dashboard-section.split { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
.entry-create-card {
    background: var(--bg-card);
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.entry-create-card h2 { margin: 0 0 12px; font-size: 1rem; color: var(--fg-muted); }

.grid-entry-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
}
.grid-entry-form label { display: block; min-width: 120px; flex: 0 0 auto; }
.grid-entry-form label.grow { flex: 1; min-width: 200px; }
.grid-entry-form label.inline {
    display: flex; align-items: center; gap: 6px;
    font-size: .9rem; color: var(--fg-muted);
    margin-bottom: 8px;
}
.grid-entry-form button { margin-bottom: 0; }

/* `position: sticky` on table cells requires:
     - no `overflow: hidden` ancestor (else sticky-in-clipped) — we override
       `.data-table { overflow: hidden }` here
     - `border-collapse: separate` (Chrome/Edge break sticky on td with
       border-collapse:collapse — known engine limitation)
   We pay the cost of slightly thicker visual borders by setting
   `border-spacing: 0` so cells stay adjacent.
   See https://issues.chromium.org/issues/40485862 (kept open since 2014). */
.entries-table {
    overflow: visible;
    border-collapse: separate;
    border-spacing: 0;
}
.entries-table .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.entries-table .row-actions {
    white-space: nowrap;
    text-align: right;
    width: 1%;       /* shrink to button content */
    padding-right: 12px;
}

/* Non-facturable: a discreet "NF" prefix in muted, with the amount itself
   kept right-aligned in mono. The TD also gets a subtle desaturation so the
   row reads as "lighter" without breaking the column's numeric alignment. */
.entries-table td.nf-amount { color: var(--fg-muted); }
.entries-table .nf-mark {
    display: inline-block;
    margin-right: 6px;
    padding: 0 4px;
    font-size: .65rem;
    line-height: 1.5;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--fg-muted);
    background: var(--bg);
    vertical-align: 1px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.entries-table .row-actions button {
    padding: 4px 8px;
    font-size: 1rem;
    line-height: 1;
    opacity: .2;
    transition: opacity .15s, background-color .15s, border-color .15s;
    border-color: transparent;
    background: transparent;
    margin-left: 2px;
}
.entries-table tbody tr:hover .row-actions button,
.entries-table .row-actions button:focus-visible { opacity: 1; }
.entries-table tbody tr:hover .row-actions button { border-color: var(--border); }
.entries-table .row-actions button:hover { background: var(--bg); }
/* Danger (delete) button: red icon at rest (the row-actions transparent-bg
   rule has higher specificity than button.danger so we re-state colour here),
   filled red wash on hover. */
.entries-table .row-actions button.danger { color: var(--danger); }
.entries-table .row-actions button.danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}
tr.entry-edit-row form.inline-edit { display: block; }
tr.entry-edit-row td { background: var(--bg); }

.tag-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.tag-chip {
    display: inline-block;
    padding: 1px 8px;
    font-size: .75rem;
    border-radius: 999px;
    color: #1f2937;
}
