:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --border: #e3e8ee;
    --text: #1f2933;
    --muted: #7b8794;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --ok: #16a34a;
    --warn: #d97706;
    --danger: #dc2626;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }

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

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.brand { font-weight: 700; font-size: 16px; }
.brand span { color: var(--muted); font-weight: 500; }

/* Page navigation. The active item is underlined rather than filled, so it stays quiet next to the brand. */
.topnav { display: flex; gap: 4px; margin-right: auto; margin-left: 32px; }
.topnav a {
    padding: 6px 12px; border-radius: 6px; text-decoration: none;
    color: var(--muted); font-weight: 600; font-size: 13px;
    border-bottom: 2px solid transparent;
}
.topnav a:hover { color: var(--text); background: #f1f5f9; }
.topnav a.active { color: var(--primary); border-bottom-color: var(--primary); border-radius: 6px 6px 0 0; }

/* Layout */
.container { max-width: 1120px; margin: 24px auto; padding: 0 24px; }
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 4px; font-size: 16px; }
.muted { color: var(--muted); }
.card p.muted { margin-top: 0; }

/* Forms */
.row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.grow { flex: 1; min-width: 240px; }
.field.field-btn { justify-content: flex-end; }
label { font-weight: 600; font-size: 12px; color: var(--muted); }
input, select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
}
select { min-width: 220px; }
input:focus, select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
input[type="checkbox"] { padding: 0; border: 0; width: auto; margin: 0; }

/* Checkbox line below a form row */
.checkbox-inline {
    display: inline-flex; align-items: center; gap: 8px;
    margin-top: 12px; font-size: 13px; font-weight: 500;
    color: var(--muted); text-transform: none; letter-spacing: 0; cursor: pointer;
}

/* Buttons */
.btn {
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: #eef2f7;
    color: var(--text);
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }

/* Weekly overview */
.overview-wrap { margin-top: 16px; overflow-x: auto; }
.week-head {
    display: flex; align-items: center; justify-content: space-between;
    margin: 8px 0 12px; gap: 12px; flex-wrap: wrap;
}
.week-head .muted { margin-left: 8px; }
.week-nav { display: flex; gap: 8px; }

table.overview { width: 100%; border-collapse: collapse; min-width: 860px; }
table.overview th, table.overview td {
    text-align: left; padding: 5px 10px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.overview th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
table.overview tr.weekend td { background: #fafbfc; color: var(--muted); }
.actions-col { text-align: right; }
.actions-col .btn { margin-left: 4px; }
.select-col { width: 32px; text-align: center; }
.select-col input { vertical-align: middle; }

/* Batch action toolbar */
.batch-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 10px 12px; margin-bottom: 8px;
    background: #f1f5f9; border: 1px solid var(--border); border-radius: 8px;
}
/* The two display switches above the table, side by side rather than stacked. */
.view-options { display: flex; gap: 20px; flex-wrap: wrap; }

.batch-label { font-size: 13px; color: var(--muted); margin-right: 4px; }
.batch-count { font-weight: 700; color: var(--text); }
.batch-group { display: inline-flex; gap: 6px; }
.batch-divider { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }

/* Loading overlay shown during htmx actions */
#loading-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .6);
}
#loading-overlay[hidden] { display: none; }
.spinner {
    width: 40px; height: 40px; border-radius: 50%;
    border: 4px solid rgba(37, 99, 235, .25);
    border-top-color: var(--primary);
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.diff-warn { color: var(--danger); font-weight: 700; }
/* The Δ column sits between the two values it compares, so keep it visually secondary. */
table.overview th.diff-col, table.overview td.diff-col {
    width: 70px; padding-left: 6px; padding-right: 6px; font-size: 13px;
}
/* Marks an attendance day that reaches past midnight, where Personio's day and the calendar disagree. */
.midnight-flag {
    margin-left: 6px; padding: 1px 5px; border-radius: 4px; cursor: help;
    background: #fef3c7; color: #92400e; font-size: 11px; font-weight: 700;
}
/* Marks project times that overlap each other and so could not be sent to Personio at all. */
.overlap-flag {
    margin-left: 6px; padding: 1px 5px; border-radius: 4px; cursor: help; white-space: nowrap;
    background: #fee2e2; color: var(--danger); font-size: 11px; font-weight: 700;
}
table.overview table.entries tr.entry-overlapping td {
    color: var(--danger); text-decoration: line-through;
}
table.overview table.entries tr.entry-overlapping td.entry-lock { text-decoration: none; }

/* Expandable working-time text */
.row-toggle {
    border: 0; background: transparent; cursor: pointer; color: var(--muted);
    font-size: 12px; padding: 0 6px 0 0; line-height: 1;
}
.row-toggle:hover { color: var(--text); }
table.overview tr.detail-row td {
    background: #f8fafc; white-space: normal; padding: 2px 12px 6px 30px;
}
/* The day's project times — one row each, or one per task when grouped. The raw data everything derives from.
   Selectors are qualified past `table.overview tr.detail-row td`, which would otherwise win on specificity
   and re-enable wrapping in the time column. */
table.overview table.entries { width: 100%; border-collapse: collapse; font-size: 12px; }
table.overview table.entries td {
    padding: 1px 10px 1px 0; border: 0; vertical-align: baseline; color: var(--text);
    white-space: nowrap; line-height: 1.45;
}
table.overview table.entries td.entry-time,
table.overview table.entries td.entry-count {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; width: 1%;
}
table.overview table.entries td.entry-count { text-align: right; color: var(--muted); }
table.overview table.entries td.entry-duration { font-weight: 600; width: 1%; text-align: right; }
table.overview table.entries td.entry-task { color: var(--muted); width: 1%; }
table.overview table.entries td.entry-notes {
    white-space: normal; word-break: break-word; width: 100%;
}
table.overview table.entries td.entry-lock { width: 1%; text-align: right; }
/* How much of a grouped task did not reach Personio, shown next to the task's full total. */
table.overview table.entries .entry-skipped {
    margin-left: 4px; color: var(--danger); font-weight: 600; cursor: help;
}

/* Badges */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.badge-absence { background: #ede9fe; color: #6d28d9; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-weight: 600; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-ok { background: #dcfce7; color: #166534; }

/* htmx indicator */
.htmx-indicator { opacity: 0; transition: opacity .2s; margin-left: 8px; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    padding: 32px; width: 320px; box-shadow: var(--shadow); text-align: center;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card .subtitle { color: var(--muted); margin: 4px 0 20px; }
.login-card form { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.login-card label { margin-top: 8px; }
.login-card .btn { margin-top: 18px; width: 100%; }
