/*
 * Timetrack: one stylesheet, served by AssetMapper. Calm neutrals, one
 * accent colour, green for running timers. Light and dark follow the system.
 */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --text: #1b2130;
    --muted: #586174;
    --border: #d9dde5;
    --border-strong: #b9c0cc;
    --accent: #2456c9;
    --accent-hover: #1b459f;
    --accent-text: #ffffff;
    --accent-soft: #e8eefb;
    --running: #13734a;
    --running-soft: #e5f4ec;
    --running-border: #b5dcc6;
    --danger: #b42318;
    --danger-soft: #fdeceb;
    --warn: #7a4f00;
    --warn-soft: #fff2d6;
    --focus: #2f6fed;
    --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
    --radius: 10px;
    --radius-small: 8px;
    --gutter: 16px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111419;
        --surface: #1a1e26;
        --surface-2: #232834;
        --text: #e7eaf0;
        --muted: #a0a8b8;
        --border: #2f3644;
        --border-strong: #465063;
        --accent: #7ea6ff;
        --accent-hover: #a3bfff;
        --accent-text: #0d1424;
        --accent-soft: #1d2a47;
        --running: #5fd09a;
        --running-soft: #14281f;
        --running-border: #24513a;
        --danger: #ff8f85;
        --danger-soft: #3a1c1a;
        --warn: #f3c770;
        --warn-soft: #362a12;
        --focus: #8fb2ff;
        --shadow: none;
    }
}

/* Base */

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

h1,
h2,
p {
    margin: 0;
}

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

a:hover {
    color: var(--accent-hover);
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

turbo-frame {
    display: block;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: var(--gutter);
    top: -100px;
    z-index: 100;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: var(--radius-small);
}

.skip-link:focus {
    top: 8px;
}

.muted {
    color: var(--muted);
    font-weight: 400;
}

.icon {
    flex: none;
    vertical-align: -0.15em;
}

.container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* Header and navigation */

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    min-height: 56px;
    padding-top: 8px;
    padding-bottom: 8px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}

.brand .icon {
    width: 22px;
    height: 22px;
    color: var(--accent);
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.main-nav a,
.main-nav__button {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 6px 12px;
    border: 0;
    border-radius: var(--radius-small);
    background: none;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.main-nav a:hover,
.main-nav__button:hover {
    background: var(--surface-2);
    color: var(--text);
}

.main-nav a[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent);
}

.main-nav__logout {
    margin: 0;
}

.main-nav__button {
    color: var(--muted);
}

/* Running timers bar */

.running-bar {
    background: var(--running-soft);
    border-bottom: 1px solid var(--running-border);
}

.running-bar.is-idle {
    background: var(--surface-2);
    border-bottom-color: var(--border);
}

.running-bar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding-top: 8px;
    padding-bottom: 8px;
}

.running-bar__empty {
    flex: 1;
    color: var(--muted);
}

.running-bar__today {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-left: auto;
    white-space: nowrap;
}

.running-bar__today a {
    color: var(--muted);
    text-decoration: none;
}

.running-bar__today strong {
    font-size: 1.15rem;
}

.timers {
    flex: 1 1 480px;
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 4px 12px;
    padding: 6px 0;
}

.timer + .timer {
    border-top: 1px solid var(--running-border);
}

.timer__what {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    min-width: 0;
}

.timer__project {
    font-weight: 600;
}

.timer__task {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.timer__notes {
    color: var(--muted);
}

.timer__clock {
    font-size: 1.15rem;
}

.timer__stop {
    margin: 0;
}

.pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--running);
    animation: pulse 2s ease-in-out infinite;
}

.timer.is-long .pulse {
    background: var(--warn);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
    .pulse {
        animation: none;
    }
}

/* Clocks */

.clock {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}

.clock.is-running {
    color: var(--running);
}

.clock__secs {
    font-size: 0.75em;
    font-weight: 500;
    opacity: 0.75;
}

/* Page */

.page {
    padding-top: 20px;
    padding-bottom: 48px;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 16px;
}

.page-head h1 {
    font-size: 1.5rem;
    line-height: 1.2;
}

.page-head__sub {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 500;
}

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.pager__date {
    margin: 0;
}

.pager__date input {
    width: auto;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}

.card__title {
    font-size: 1rem;
    margin-bottom: 12px;
}

.empty {
    color: var(--muted);
    padding: 12px 0;
}

.hint {
    color: var(--muted);
    font-size: 0.875rem;
}

/* Flash messages */

.flashes:empty {
    display: none;
}

.flashes {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.flash {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-small);
}

.flash--success {
    background: var(--running-soft);
    border-color: var(--running-border);
}

.flash--error {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--text);
}

.flash--info {
    background: var(--accent-soft);
    border-color: var(--border-strong);
}

.flash__action {
    margin: 0;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 6px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.btn--primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--accent-text);
}

.btn--start {
    color: var(--running);
    border-color: var(--running-border);
}

.btn--stop {
    background: var(--text);
    border-color: var(--text);
    color: var(--surface);
}

.btn--stop:hover {
    background: var(--muted);
    border-color: var(--muted);
    color: var(--surface);
}

.btn--quiet {
    border-color: transparent;
    background: none;
    color: var(--muted);
}

.btn--quiet:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.btn--small {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 0.875rem;
}

.btn--icon {
    width: 40px;
    padding: 0;
}

.btn--icon .icon {
    width: 20px;
    height: 20px;
}

/* Form fields */

label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

input[type="text"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 0;
    border-color: var(--focus);
}

input[disabled] {
    background: var(--surface-2);
    color: var(--muted);
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
}

.field-error {
    margin-top: 4px;
    color: var(--danger);
    font-size: 0.875rem;
    font-weight: 600;
}

.entry-form > .field-error {
    grid-column: 1 / -1;
    margin: 0;
}

.entry-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 7.5rem;
    gap: 12px;
    margin: 0;
}

.field--project { grid-column: 1; }
.field--task { grid-column: 2; }
.field--hours { grid-column: 3; grid-row: 1; }
.field--notes { grid-column: 1 / -1; }

.field--hours input {
    font-variant-numeric: tabular-nums;
}

.field--check {
    display: flex;
    align-items: center;
    gap: 8px;
    grid-column: 1 / -1;
}

.field--check label {
    margin: 0;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    grid-column: 1 / -1;
}

/* Day entries */

.entry-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--border);
}

.entry-list > li {
    border-bottom: 1px solid var(--border);
}

.entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px 16px;
    padding: 12px 0;
}

.entry.is-running {
    box-shadow: inset 3px 0 0 var(--running);
    padding-left: 12px;
}

.entry.is-editing {
    display: block;
    padding: 16px 0;
}

.entry__project strong {
    font-weight: 600;
}

.entry__task {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
}

.entry__notes {
    margin-top: 2px;
    color: var(--muted);
    white-space: pre-line;
}

.entry__time {
    font-size: 1.2rem;
    text-align: right;
}

.entry__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
}

.entry__actions form {
    margin: 0;
}

.entry__locked {
    display: inline-flex;
    padding: 8px;
    color: var(--muted);
}

.notice {
    margin-top: 6px;
    color: var(--warn);
    font-weight: 600;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge--locked {
    background: var(--warn-soft);
    color: var(--warn);
}

.badge--warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.day-total {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 12px;
    padding-top: 12px;
    color: var(--muted);
}

.day-total strong {
    color: var(--text);
    font-size: 1.25rem;
}

/* Week grid */

.table-scroll {
    overflow-x: auto;
    margin: -4px -4px 16px;
    padding: 4px;
}

.week-grid {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.week-grid th,
.week-grid td {
    padding: 6px 4px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    vertical-align: middle;
}

.week-grid thead th {
    font-size: 0.875rem;
    font-weight: 600;
}

.week-grid__day a {
    display: block;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-small);
    padding: 2px;
}

.week-grid__day a span {
    display: block;
}

.week-grid__day.is-today a {
    background: var(--accent-soft);
    color: var(--accent);
}

.week-grid__label {
    text-align: left !important;
    min-width: 180px;
}

tbody .week-grid__label {
    font-weight: 400;
}

.week-grid__project {
    display: block;
    font-weight: 600;
}

.week-grid__task {
    display: block;
    color: var(--muted);
    font-size: 0.875rem;
}

.week-grid__cell.is-today {
    background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
}

.week-grid__total {
    font-weight: 700;
    white-space: nowrap;
}

.week-grid tfoot th,
.week-grid tfoot td {
    border-bottom: 0;
    padding-top: 10px;
}

.week-grid__grand .clock {
    font-size: 1.1rem;
}

.cell-form {
    margin: 0;
}

.cell-input {
    width: 4.5rem !important;
    min-height: 36px !important;
    padding: 4px 6px !important;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.cell-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 4.5rem;
    min-height: 36px;
    padding: 4px 6px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-small);
    color: var(--text);
    text-decoration: none;
}

.cell-link:hover {
    background: var(--surface-2);
    color: var(--text);
}

.is-locked .cell-link {
    border-style: solid;
    background: var(--warn-soft);
}

.cell-count {
    min-width: 1.4em;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.75rem;
}

.add-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 12px;
}

/* Sign in */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--gutter);
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 32px 28px;
}

.login-card h1 {
    margin-bottom: 4px;
    font-size: 1.5rem;
}

.login-card .lede {
    margin-bottom: 8px;
    color: var(--muted);
}

.login-card label {
    margin: 16px 0 6px;
}

.login-card input[type="email"],
.login-card input[type="password"] {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.login-card .remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.login-card .btn {
    width: 100%;
    min-height: 44px;
    margin-top: 24px;
}

.login-error {
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: var(--radius-small);
    background: var(--danger-soft);
    color: var(--text);
    border: 1px solid var(--danger);
}

/* OAuth consent (Claude connector) */

.consent-card {
    max-width: 440px;
}

.consent-scopes {
    margin: 12px 0;
    padding-left: 18px;
}

.consent-scopes li {
    margin-bottom: 6px;
}

.consent-redirect {
    color: var(--muted);
    font-size: 0.9rem;
}

.consent-warning {
    padding: 10px 12px;
    border-radius: var(--radius-small);
    background: var(--warn-soft);
    color: var(--text);
    border: 1px solid var(--warn);
    font-size: 0.9rem;
}

.consent-client {
    color: var(--muted);
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

.consent-actions {
    display: flex;
    gap: 12px;
}

.consent-actions .btn {
    flex: 1;
}

/* Reports */

.report-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.report-tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 6px 12px;
    margin-bottom: -1px;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}

.report-tabs a:hover {
    color: var(--text);
}

.report-tabs a[aria-current="page"] {
    border-bottom-color: var(--accent);
    color: var(--accent);
}

.report-filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr));
    align-items: end;
    gap: 12px;
    margin: 0 0 8px;
}

.preset-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    grid-column: 1 / -1;
}

.preset-bar .btn.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.report-filters__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

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

.report-table th,
.report-table td {
    padding: 8px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    /* Words stay whole in table cells; the table scrolls in its container instead. */
    overflow-wrap: normal;
}

.report-table .report-notes {
    overflow-wrap: anywhere;
}

.report-table thead th {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.report-table tbody th {
    font-weight: 400;
}

.report-table .num {
    text-align: right;
    white-space: nowrap;
}

.report-table .nowrap {
    white-space: nowrap;
}

.report-table--grid {
    min-width: 960px;
}

.report-table--entries {
    min-width: 1120px;
}

.report-table--tree,
.report-table--lines {
    min-width: 560px;
}

.report-table--entries .report-notes {
    min-width: 22rem;
}

.report-notes {
    white-space: pre-line;
}

.report-row--client th,
.report-row--client td {
    background: var(--surface-2);
    font-weight: 700;
}

.report-row--client .report-name {
    font-weight: 700;
}

.report-row--project .report-name {
    padding-left: 24px;
    font-weight: 600;
}

.report-row--task .report-name {
    padding-left: 44px;
}

.report-row--task td {
    color: var(--muted);
}

.report-total th,
.report-total td,
.report-currency-total th,
.report-currency-total td {
    font-weight: 700;
    border-bottom: 0;
}

.report-currency-total th {
    font-weight: 600;
}

.report-strong {
    font-weight: 700;
}

.report-sub {
    display: block;
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 400;
}

.report-table .money {
    display: block;
}

.report-table .hint {
    display: block;
}

.report-table tr.is-running th,
.report-table tr.is-running td {
    background: var(--running-soft);
}

.report-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 32px;
    margin: 0 0 16px;
}

.report-totals dt {
    color: var(--muted);
    font-size: 0.875rem;
}

.report-totals dd {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.report-totals .money {
    display: block;
}

.report-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.report-list li + li {
    margin-top: 4px;
}

.report-lines summary {
    cursor: pointer;
    font-weight: 600;
    min-height: 32px;
}

.report-lines summary .money {
    margin-left: 4px;
}

.report-lines[open] summary {
    margin-bottom: 12px;
}

.report-back {
    margin-top: 12px;
}

.badge--running {
    background: var(--running-soft);
    color: var(--running);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

/* Small screens */

@media (max-width: 640px) {
    .page {
        padding-top: 16px;
    }

    .page-head h1 {
        font-size: 1.3rem;
    }

    .card {
        padding: 12px;
    }

    .entry-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .field--project,
    .field--task,
    .field--notes,
    .field--hours {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .field--hours input {
        max-width: 8rem;
    }

    .entry {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .entry__actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .timer {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .timer__stop {
        grid-column: 2 / -1;
        justify-self: start;
    }

    .running-bar__today {
        margin-left: 0;
    }

    .add-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Month-end invoice preview */

.invoice-settings {
    display: grid;
    grid-template-columns: minmax(8rem, max-content) 1fr;
    gap: 6px 16px;
    margin: 0 0 12px;
}

.invoice-settings dt {
    color: var(--muted);
}

.invoice-settings dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.invoice-push {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.invoice-problems li + li,
.invoice-warnings li + li {
    margin-top: 8px;
}

@media (max-width: 480px) {
    .invoice-settings {
        grid-template-columns: 1fr;
    }

    .invoice-settings dd {
        margin-bottom: 6px;
    }
}

/* Error pages (templates/bundles/TwigBundle/Exception) */

.error-card .error-code {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.error-actions .btn {
    width: 100%;
    min-height: 44px;
    margin-top: 16px;
}
