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

:root {
    --bg: #f7f4ef;
    --surface: #fffefa;
    --text: #2c2a25;
    --text-muted: #8a8578;
    --primary: #4a6fa5;
    --primary-hover: #3d5d8a;
    --primary-light: rgba(74, 111, 165, 0.08);
    --success: #5a8a5e;
    --warning: #c4922a;
    --danger: #b54a3f;
    --border: #e8e3d8;
    --rule: #e4dfd4;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(44, 42, 37, 0.06);
    --shadow-hover: 0 3px 8px rgba(44, 42, 37, 0.1);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "SF Mono", Monaco, Consolas, "Liberation Mono", monospace;
}

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
}

#app {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px 80px;
}

/* ── Header ── */
#app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
}

#breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: nowrap;
}

#breadcrumbs a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dotted var(--primary);
}

#breadcrumbs a:hover {
    border-bottom-style: solid;
}

#breadcrumbs .sep {
    color: var(--border);
    font-size: 0.75rem;
}

#breadcrumbs .current {
    color: var(--text);
    font-weight: 600;
}

#user-menu {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

#user-menu a {
    color: var(--danger);
    text-decoration: none;
    cursor: pointer;
    border-bottom: 1px dotted var(--danger);
}

/* ── Cards (clients, projects) ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.15s, transform 0.15s;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

.card-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    flex: 1;
    min-width: 0;
}

.card-actions-wrap {
    flex-shrink: 0;
    margin: 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-gear {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s;
}

.card-gear:hover {
    color: var(--text);
}

.card-actions {
    display: flex;
    gap: 4px;
}

.card-actions button {
    background: none;
    border: 1px solid var(--border);
    font-size: 0.72rem;
    font-family: var(--font);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.1s, border-color 0.1s;
}

.card-actions .btn-edit-project { color: var(--text-muted); }
.card-actions .btn-archive-project { color: var(--danger); }

.card-actions button:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.card-archived {
    opacity: 0.55;
    border-left-color: var(--border);
}

.card-archived:hover {
    opacity: 0.8;
}

.card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    flex-shrink: 0;
    margin-left: 12px;
}

.card-meta .hours {
    font-weight: 600;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.card-meta .unsubmitted {
    color: var(--warning);
    font-size: 0.7rem;
    margin-top: 2px;
}

/* ── Entry cards (with ruled lines) ── */
.entry-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}

.entry-card .entry-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.entry-card .entry-task {
    font-weight: 600;
    font-size: 0.95rem;
}

.entry-card .entry-duration {
    font-weight: 600;
    font-size: 0.9rem;
    font-family: var(--font-mono);
    flex-shrink: 0;
    margin-left: 12px;
    color: var(--primary);
}

.entry-card .entry-notes {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}

.entry-card .entry-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.8rem;
}

.entry-card .entry-date {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-draft {
    background: #fdf6e3;
    color: #92710a;
    border: 1px solid #f0e0a8;
}

.badge-submitted {
    background: #eef6ee;
    color: #3d6b40;
    border: 1px solid #c5dfc6;
}

.entry-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.entry-actions button {
    background: none;
    border: none;
    font-size: 0.78rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font);
    transition: background 0.1s;
}

.entry-actions button:hover {
    background: var(--primary-light);
}

.entry-actions .btn-status { color: var(--primary); }
.entry-actions .btn-edit { color: var(--text-muted); }
.entry-actions .btn-delete { color: var(--danger); }

/* ── Report summary ── */
.report-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    text-align: center;
    box-shadow: var(--shadow);
}

.report-stat-link {
    text-decoration: none;
    color: inherit;
    display: block;
    padding: 4px;
    border-radius: var(--radius);
    transition: background 0.15s;
}

.report-stat-link:hover {
    background: var(--primary-light);
    text-decoration: none;
}

.report-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
    font-family: var(--font-mono);
}

.report-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
}

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

.section-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

/* ── Filter tabs ── */
.filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.filter-tab {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.filter-tab:hover {
    color: var(--text);
    text-decoration: none;
}

.filter-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ── Project group (client entries view) ── */
.project-group {
    margin-bottom: 20px;
}

.project-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--rule);
}

.project-group-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dotted var(--primary);
}

.project-group-title:hover {
    border-bottom-style: solid;
}

.project-group-hours {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

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

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

.btn-block { width: 100%; }

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

select.form-control {
    height: 44px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a8578'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

.form-control::placeholder {
    color: var(--border);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ── Day picker ── */
.day-picker {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.day-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    user-select: none;
}

.day-btn input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.day-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.day-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.day-btn.active .day-today {
    color: rgba(255, 255, 255, 0.7);
}

.day-today {
    display: block;
    font-size: 0.6rem;
    font-weight: 400;
    font-style: normal;
    color: var(--primary);
    line-height: 1;
    margin-top: 2px;
}

/* ── Autocomplete ── */
.autocomplete-wrapper { position: relative; }

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(44, 42, 37, 0.12);
    z-index: 20;
    max-height: 200px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--rule);
}

.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--primary-light);
}

/* ── Auth screen ── */
.auth-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70dvh;
    text-align: center;
}

.auth-screen h1 {
    font-size: 2.2rem;
    margin-bottom: 6px;
    color: var(--text);
    letter-spacing: -0.02em;
}

.auth-screen .tagline {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 1rem;
}

.auth-box {
    width: 100%;
    max-width: 340px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.token-display {
    background: #faf8f0;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 12px;
    margin: 12px 0;
    word-break: break-all;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    user-select: all;
    color: var(--text);
    line-height: 1.5;
}

.token-warning {
    font-size: 0.78rem;
    color: var(--warning);
    margin-top: 8px;
}

.auth-footer {
    margin-top: 32px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dotted var(--primary);
}

/* ── Key reveal ── */
.key-reveal {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.key-warning {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.5;
}

.key-timer {
    font-size: 0.75rem;
    color: var(--warning);
    margin-top: 8px;
    font-family: var(--font-mono);
}

/* ── Empty states ── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state p { margin-bottom: 16px; }

/* ── Page title ── */
.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* ── Inline edit ── */
.inline-edit {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}

.inline-edit input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.3rem;
    font-weight: 700;
    font-family: var(--font);
}

/* ── Loading ── */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 0.85rem;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(44, 42, 37, 0.2);
    animation: toast-in 0.25s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 400px) {
    .form-row { grid-template-columns: 1fr; }
    .report-summary { grid-template-columns: 1fr; gap: 8px; }
    #app { padding: 0 14px 80px; }
}
