:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f1f4;
    --border: #e3e5ea;
    --text: #1d2130;
    --muted: #6b7183;
    --primary: #0b6cb3;
    --primary-fill: #0b6cb3; /* backgrounds behind white text */
    --primary-hover: #095a96;
    --primary-soft: #e6f0f8;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --success: #15803d;
    --success-soft: #e8f6ed;
    --warning-soft: #fff6e0;
    --radius: 10px;
    --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.04);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12141a;
        --surface: #1b1e26;
        --surface-2: #232733;
        --border: #2e3240;
        --text: #e6e8ee;
        --muted: #9096a8;
        --primary: #4ea3e0;
        --primary-fill: #0b6cb3;
        --primary-hover: #0d7ccc;
        --primary-soft: #14304a;
        --danger: #f26b6b;
        --danger-soft: #3a2024;
        --success: #4ade80;
        --success-soft: #1d3326;
        --warning-soft: #3a3120;
        --shadow: none;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; margin-bottom: .75rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: .5rem 0 0; }
.nowrap { white-space: nowrap; }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.page-header { margin-bottom: 1.25rem; }
.page-header h1 { margin-top: .25rem; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar__inner { max-width: 1100px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand--large { display: flex; font-size: 1.5rem; justify-content: center; margin-bottom: 1.25rem; }
.brand__mark { width: 1.1em; height: 1.1em; border-radius: 50%; background: var(--primary); box-shadow: inset 0 0 0 .2em var(--surface), 0 0 0 .1em var(--primary); }
.nav { display: flex; gap: .25rem; flex: 1; }
.nav a, .usermenu a { padding: .35rem .7rem; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav a:hover, .usermenu a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.is-active, .usermenu a.is-active { color: var(--primary); background: var(--primary-soft); }
.usermenu { display: flex; gap: .25rem; }

.running-pill { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .8rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-variant-numeric: tabular-nums; font-weight: 600; }
.running-pill:hover { text-decoration: none; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card--narrow { max-width: 480px; }

/* Flash messages */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: var(--primary-soft); }
.flash--success { background: var(--success-soft); color: var(--success); }
.flash--error, .flash--danger { background: var(--danger-soft); color: var(--danger); }
.flash--warning { background: var(--warning-soft); }

/* Forms */
label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=time], select {
    width: 100%;
    padding: .55rem .7rem;
    min-height: 2.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400; color: var(--text); font-size: .9rem; margin: .75rem 0 1rem; }
.checkbox input { margin: 0; }
.field { margin-bottom: .75rem; }
.field ul, form > ul { list-style: none; margin: .3rem 0 0; padding: 0; color: var(--danger); font-size: .85rem; }
.help-text, .form-help { color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.form-actions { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }

.grid { display: grid; gap: 0 1rem; }
.grid--entry { grid-template-columns: 2fr 2fr 1fr 1fr 1fr; }
.grid--entry .field--wide { grid-column: span 1; }
.grid--filters { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; border: 1px solid transparent; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn--primary { background: var(--primary-fill); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); filter: none; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--block { width: 100%; }
.btn--round { width: 2.75rem; height: 2.75rem; padding: 0; border-radius: 50%; font-size: 1rem; flex-shrink: 0; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: .9rem; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }

.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .3rem .75rem; border-radius: 999px; font: inherit; font-size: .85rem; cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip.is-active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* Project colour dot */
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--dot, var(--primary)); margin-right: .4rem; flex-shrink: 0; }
.dot--pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth__card { width: 100%; max-width: 380px; padding: 2rem; }
.auth__card input:not([type=checkbox]) { margin-bottom: .9rem; }

/* Timer */
.timer__form { display: flex; gap: .75rem; align-items: center; }
.timer__input { flex: 2; font-size: 1.05rem; }
.timer__task { flex: 1.3; }
.timer--running .timer__form { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
.timer__running { display: flex; align-items: center; gap: 1rem; }
.timer__info { flex: 1; min-width: 0; }
.timer__description { font-size: 1.1rem; font-weight: 600; }
.timer__clock { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }
.timer--running .hint { margin-top: .25rem; }

.manual { margin-top: 1rem; }
.manual summary { cursor: pointer; color: var(--muted); font-size: .9rem; font-weight: 500; }
.manual summary:hover { color: var(--text); }
.manual__form { margin-top: 1rem; }

/* Week */
.weekbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 1.75rem 0 1rem; flex-wrap: wrap; }
.weekbar__nav { display: flex; align-items: center; gap: .5rem; }
.weekbar__title { font-size: 1.2rem; min-width: 12rem; text-align: center; }
.weekbar__total { color: var(--muted); }
.weekbar__total strong { color: var(--text); font-size: 1.2rem; margin-left: .4rem; font-variant-numeric: tabular-nums; }

.day { padding: 0; overflow: hidden; }
.day__header { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1.25rem; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.day__header h2 { margin: 0; font-size: .95rem; }
.day__total { font-weight: 700; font-variant-numeric: tabular-nums; }

.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: grid; grid-template-columns: 1fr auto 6rem auto; gap: 1rem; align-items: center; padding: .7rem 1.25rem; border-bottom: 1px solid var(--border); }
.entry:last-child { border-bottom: 0; }
.entry--running { background: var(--primary-soft); }
.entry__main { min-width: 0; }
.entry__description { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry__meta { color: var(--muted); font-size: .85rem; display: flex; align-items: center; flex-wrap: wrap; gap: 0 .3rem; }
.entry__meta strong { color: var(--text); font-weight: 500; }
.entry__time { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry__duration { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.entry__actions { display: flex; gap: .1rem; }
.entry__actions form { margin: 0; }

.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* Reports */
.filters .presets { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat__label { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat__value { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat__value--small { font-size: 1.05rem; padding-top: .55rem; }
.stat__sub { color: var(--muted); font-size: .85rem; }

.bars { display: grid; grid-template-columns: repeat(var(--bars), 1fr); gap: 3px; height: 160px; align-items: end; }
.bars__col { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bars__bar { background: var(--primary); border-radius: 3px 3px 0 0; min-height: 1px; opacity: .85; }
.bars__col:hover .bars__bar { opacity: 1; }
.bars__label { font-size: .7rem; color: var(--muted); text-align: center; height: 1.2rem; line-height: 1.2rem; overflow: hidden; }
.bars__label.is-weekend { opacity: .5; }

.report-columns { display: grid; grid-template-columns: 3fr 2fr; gap: 1rem; align-items: start; }
.report-columns > .card:only-child { grid-column: 1 / -1; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row--client th { padding-top: .9rem; }
.row--project td:first-child { padding-left: 1.25rem; }
.row--task td { border-bottom-style: dashed; }
.row--task td:first-child { padding-left: 2.7rem; color: var(--muted); }
.share { width: 40%; }
.share__bar { display: block; height: .5rem; border-radius: 99px; background: var(--primary); }
.table-scroll { overflow-x: auto; }

/* Searchable selects (Symfony UX Autocomplete / Tom Select), styled like the other inputs */
.ts-wrapper { width: 100%; }
.ts-wrapper .ts-control, .ts-wrapper.single .ts-control { background-image: none; }
/* Selectors match the specificity of Tom Select's own (e.g. ".ts-wrapper.single .ts-control"), so these win. */
.ts-wrapper .ts-control, .ts-wrapper.single .ts-control { min-height: 2.6rem; padding: .55rem 2rem .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; box-shadow: none; }
.ts-wrapper .ts-control, .ts-wrapper .ts-control input, .ts-dropdown { font-size: inherit; line-height: normal; }
.ts-wrapper .ts-control input { color: var(--text); }
.ts-wrapper .ts-control input::placeholder { color: var(--muted); }
.ts-wrapper.focus .ts-control, .ts-wrapper.plugin-dropdown_input.focus.dropdown-active .ts-control { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; box-shadow: none; }
.ts-wrapper.single .ts-control::after { border-color: var(--muted) transparent transparent; right: .9rem; }
.ts-wrapper.single.dropdown-active .ts-control::after { border-color: transparent transparent var(--muted); }
.ts-wrapper.single.input-active .ts-control { background: var(--surface); }
.ts-wrapper.single .ts-control { flex-wrap: nowrap; }
.ts-wrapper.single .ts-control .item { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.ts-dropdown .dropdown-input-wrap { padding: .5rem; border-bottom: 1px solid var(--border); }
.ts-dropdown .dropdown-input { width: 100%; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.ts-dropdown .dropdown-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.ts-dropdown .dropdown-input::placeholder { color: var(--muted); }
.ts-wrapper .clear-button { color: var(--muted); right: 1.9rem; }
.ts-dropdown, .ts-dropdown.single { margin-top: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: 0 8px 24px rgb(16 24 40 / .14); overflow: hidden; z-index: 20; }
.ts-dropdown .ts-dropdown-content { max-height: 22rem; }
.ts-dropdown .optgroup-header { padding: .5rem .75rem .25rem; background: var(--surface); color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.ts-dropdown .option { padding: .45rem .75rem .45rem 1.25rem; }
.ts-dropdown .active { background: var(--primary-soft); color: var(--text); }
.ts-dropdown .highlight { background: rgb(250 204 21 / .35); border-radius: 2px; color: inherit; }
.ts-dropdown .no-results { padding: .6rem .75rem; color: var(--muted); }

/* Rates */
.rate { font-size: .8rem; margin-left: .4rem; }
.rates__label { display: flex; align-items: center; margin: 0; font-size: .92rem; font-weight: 400; color: var(--text); }
.rates__input { width: 12rem; }
.rates__input input { text-align: right; }

/* Tasks */
.btn--small { padding: .3rem .65rem; font-size: .82rem; }
.task-add, .task-filters { display: grid; grid-template-columns: 1fr 1.5fr auto; gap: 0 1rem; align-items: end; }
.task-filters { grid-template-columns: 1.5fr 1fr 10rem auto; }
.task-add .btn, .task-filters .form-actions { margin-bottom: .75rem; }
.task-filters .form-actions { margin-top: 0; }
.day__header h2 { display: flex; align-items: center; }
.entry.task { grid-template-columns: 1fr auto; }
.entry__actions { align-items: center; }

@media (max-width: 820px) {
    .grid--entry { grid-template-columns: 1fr 1fr 1fr; }
    .grid--entry .field--wide { grid-column: 1 / -1; }
    .timer__form { flex-wrap: wrap; }
    .timer__input, .timer__task { flex: 1 1 100%; }
    .timer__running { flex-wrap: wrap; }
    .timer__info { flex: 1 1 100%; }
    .timer__clock { margin-right: auto; }
    .entry { grid-template-columns: 1fr auto; }
    .entry__time { grid-column: 1; }
    .report-columns, .stats { grid-template-columns: 1fr; }
    .nav { order: 3; flex-basis: 100%; }
    .task-add, .task-filters { grid-template-columns: 1fr; }
    .entry.task { grid-template-columns: 1fr; }
}
