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

:root {
    --bg:           #0f1117;
    --surface:      #1a1d27;
    --surface2:     #22263a;
    --border:       #2e3350;
    --accent:       #5c79ff;
    --accent-dark:  #4560e0;
    --text:         #e8eaf6;
    --text-muted:   #8890b5;
    --danger:       #ff5c73;
    --success:      #3dd68c;
    --yellow:       #ffcf3d;
    --radius:       10px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100dvh;
}

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

/* ── Auth layout ─────────────────────────────────────────────────────────── */

.auth-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px 16px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
}

.auth-logo {
    margin-bottom: 4px;
}

.auth-logo img {
    height: 56px;
    width: auto;
    display: block;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"] {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 15px;
    padding: 10px 12px;
    outline: none;
    transition: border-color .15s;
    -webkit-appearance: none;
}

input:focus { border-color: var(--accent); }

input.code-input {
    font-size: 26px;
    letter-spacing: 10px;
    text-align: center;
    font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
    display: block;
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    padding: 11px 20px;
    cursor: pointer;
    text-align: center;
    transition: background .15s;
    margin-top: 8px;
}

.btn:hover { background: var(--accent-dark); text-decoration: none; }

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

/* ── Alerts ──────────────────────────────────────────────────────────────── */

.alert {
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-error   { background: rgba(255,92,115,.12); border: 1px solid rgba(255,92,115,.3); color: var(--danger); }
.alert-success { background: rgba(61,214,140,.10); border: 1px solid rgba(61,214,140,.3); color: var(--success); }

/* ── QR code ─────────────────────────────────────────────────────────────── */

.qr-center { text-align: center; }

.qr-wrap {
    display: inline-block;
    background: #fff;
    border-radius: 8px;
    padding: 14px;
    margin: 16px 0;
}

.qr-wrap img { display: block; }

.secret-key {
    font-size: 12px;
    word-break: break-all;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 4px;
}

/* ── Misc ────────────────────────────────────────────────────────────────── */

hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); font-size: 13px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }

/* ── Top navigation ──────────────────────────────────────────────────────── */

.topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    text-decoration: none;
    margin-right: 16px;
    flex-shrink: 0;
}

.nav-logo {
    display: block;
    height: 42px;
    width: auto;
}

.nav-links {
    display: flex;
    flex: 1;
    gap: 2px;
    overflow-x: auto;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 14px;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    transition: color .15s, background .15s;
}

.nav-links a:hover         { color: var(--text); background: var(--surface2); text-decoration: none; }
.nav-links a.active        { color: var(--text); background: var(--surface2); }

.nav-logout {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}
.nav-logout:hover { color: var(--text); }

/* ── Page layout ─────────────────────────────────────────────────────────── */

.page {
    max-width: 960px;
    margin: 0 auto;
    padding: 28px 20px 60px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* ── Card ────────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

/* ── Table ───────────────────────────────────────────────────────────────── */

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255,255,255,.02); }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 44px 16px !important;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.2px;
    vertical-align: middle;
}

.badge-hourly   { background: rgba(92,121,255,.15); color: #8a9fff; }
.badge-daily    { background: rgba(61,214,140,.12);  color: var(--success); }
.badge-inactive { background: rgba(136,144,181,.1);  color: var(--text-muted); }

/* ── Button variants ─────────────────────────────────────────────────────── */

.btn-sm {
    width: auto;
    font-size: 13px;
    padding: 7px 14px;
    margin-top: 0;
}

.btn-icon {
    display: inline-block;
    width: auto;
    background: none;
    color: var(--text-muted);
    border: none;
    padding: 4px 8px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 0;
    transition: color .15s, background .15s;
}

.btn-icon:hover        { color: var(--text); background: var(--surface2); text-decoration: none; }
.btn-icon.danger:hover { color: var(--danger); background: rgba(255,92,115,.08); }

.actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ── Modal ───────────────────────────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 200;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 480px;
    max-height: 90dvh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    z-index: 201;
}

.modal.open, .modal-overlay.open { display: block; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: auto;
    margin-top: 0;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px 24px; }

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.modal-footer .btn { width: auto; margin-top: 0; }

/* ── Extra form elements ─────────────────────────────────────────────────── */

textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
    outline: none;
    resize: vertical;
    transition: border-color .15s;
    -webkit-appearance: none;
}
textarea:focus { border-color: var(--accent); }

.radio-group { display: flex; gap: 20px; }

.radio-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    font-weight: 400;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
}
.radio-label input[type="radio"] { width: auto; cursor: pointer; }

select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 15px;
    padding: 10px 12px;
    outline: none;
    cursor: pointer;
    transition: border-color .15s;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238890b5' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
select:focus { border-color: var(--accent); }
select option { background: var(--surface); }

/* ── Filter bar ──────────────────────────────────────────────────────────── */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.filter-bar select,
.filter-bar input[type="date"] {
    width: auto;
    font-size: 13px;
    padding: 7px 10px;
    flex-shrink: 0;
}

.filter-bar select { padding-right: 28px; }

/* ── Summary bar ─────────────────────────────────────────────────────────── */

.summary-bar {
    display: flex;
    gap: 20px;
    align-items: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding: 0 2px;
}

.summary-bar span:not(:first-child) {
    font-weight: 600;
    color: var(--text);
}

/* ── Table extras ────────────────────────────────────────────────────────── */

.td-date   { white-space: nowrap; }
.td-time   { display: block; font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.td-client { color: var(--text-muted); font-size: 13px; }
.td-desc   { max-width: 220px; }
.td-mono   { font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge-invoiced,
.badge-uninvoiced {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    margin-top: 0;
    width: auto;
}

.badge-invoiced   { background: rgba(61,214,140,.12); color: var(--success); }
.badge-uninvoiced { background: rgba(255,207,61,.12); color: var(--yellow); }
.badge-invoiced:hover   { background: rgba(61,214,140,.22); }
.badge-uninvoiced:hover { background: rgba(255,207,61,.22); }

.row-selected td { background: rgba(108,123,255,.07); }

.totaal-row td       { border-top: 2px solid var(--border); padding: 10px 16px; }
.totaal-label        { font-weight: 600; }
.totaal-cell         { font-weight: 600; }
.totaal-dec          { font-size: 12px; font-weight: 400; color: var(--text-muted); }

/* ── Timer card ──────────────────────────────────────────────────────────── */

.timer-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    transition: border-color .2s;
}

.timer-card.running { border-color: var(--yellow); }

.timer-idle-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}

.timer-idle-row input { flex: 1; margin-bottom: 0; }
.timer-start-btn      { white-space: nowrap; flex-shrink: 0; }

/* Running state */
.timer-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.timer-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--yellow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timer-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--yellow);
    animation: blink 1.4s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.2; }
}

.timer-project-name {
    font-size: 15px;
    font-weight: 600;
}

.timer-desc-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.timer-elapsed {
    font-size: 54px;
    font-weight: 700;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
    text-align: center;
    margin: 16px 0 20px;
}

.timer-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.timer-stop-btn { background: var(--danger); }
.timer-stop-btn:hover { background: #e04a5f; }

/* ── Section header ──────────────────────────────────────────────────────── */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-title { font-size: 15px; font-weight: 600; }

#week-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 4px;
    align-items: center;
    margin-bottom: 10px;
    min-height: 0;
}

.week-client {
    font-size: 13px;
    color: var(--text-muted);
}

.week-client strong {
    color: var(--text);
    font-weight: 600;
}

.week-sep {
    font-size: 12px;
    color: var(--border);
    margin: 0 4px;
}

/* ── Entry list ──────────────────────────────────────────────────────────── */

.entry-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
}

.entry-item:last-child { border-bottom: none; }
.entry-item:hover        { background: rgba(255,255,255,.02); }
.entry-clickable         { cursor: pointer; }
.entry-clickable:hover   { background: rgba(108,123,255,.06); }

.entry-time {
    font-size: 13px;
    color: var(--text-muted);
    min-width: 40px;
    flex-shrink: 0;
}

.entry-info  { flex: 1; min-width: 0; }

.entry-project {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.entry-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-duration {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.entry-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 44px 16px;
    font-size: 14px;
}

.day-group + .day-group { border-top: 1px solid var(--border); }

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(255,255,255,.02);
}

.day-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.day-total {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ── Date input ──────────────────────────────────────────────────────────── */

input[type="date"],
input[type="time"] {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 15px;
    padding: 10px 12px;
    outline: none;
    color-scheme: dark;
}
input[type="date"]:focus,
input[type="time"]:focus { border-color: var(--accent); }
