@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f0f4ff;
    --bg-mesh: #e8eeff;
    --surface: #ffffff;
    --surface-2: #f8faff;
    --border: #e2e8f4;
    --border-strong: #c8d4ea;
    --text: #0f172a;
    --text-soft: #475569;
    --muted: #64748b;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-glow: rgba(79, 70, 229, 0.25);
    --teal: #0d9488;
    --teal-light: #14b8a6;
    --teal-bg: rgba(20, 184, 166, 0.12);
    --coral: #f97316;
    --coral-bg: rgba(249, 115, 22, 0.1);
    --violet: #7c3aed;
    --gold: #d97706;
    --green: #059669;
    --green-bg: #ecfdf5;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 8px 30px rgba(79, 70, 229, 0.08);
    --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(79, 70, 229, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 90% 0%, rgba(20, 184, 166, 0.12), transparent),
        linear-gradient(180deg, var(--bg) 0%, #eef2ff 50%, var(--bg-mesh) 100%);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 3rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.75rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.brand-title {
    display: block;
    font-size: 1.15rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--violet) 50%, var(--teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.brand-meta {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 500;
}

.app-nav {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: wrap;
}

.app-nav a {
    color: var(--text-soft);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
}

.app-nav a:hover {
    background: var(--teal-bg);
    color: var(--primary);
}

.app-nav a.nav-payroll {
    background: linear-gradient(135deg, var(--primary), var(--violet));
    color: #fff !important;
}

.app-nav a.nav-payroll:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.logout-form { margin: 0; margin-left: 0.25rem; }

/* Page header */
.page-header,
.hero {
    margin: 0 0 1.75rem;
}

.page-header h1,
.hero h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0.25rem 0 0;
    color: var(--text);
}

.eyebrow {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--teal);
    margin: 0;
}

.hero p,
.subtitle {
    color: var(--muted);
    margin: 0.5rem 0 0;
    font-size: 0.95rem;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-md);
}

.card-accent {
    border-top: 3px solid transparent;
    border-image: linear-gradient(90deg, var(--primary), var(--teal), var(--coral)) 1;
}

.card h2,
.card h3 {
    margin-top: 0;
    color: var(--text);
    font-weight: 700;
}

.card h2 {
    font-size: 1.15rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--teal));
}

.stat-card:nth-child(2)::before { background: linear-gradient(90deg, var(--teal), var(--coral)); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, var(--coral), var(--violet)); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, var(--violet), var(--primary)); }

.stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.stat-value.stat-teal { color: var(--teal); }
.stat-value.stat-primary { color: var(--primary); }
.stat-value.stat-coral { color: var(--coral); }
.stat-value.stat-gold { color: var(--gold); }

.stat-label {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.25rem;
}

/* Info banner */
.info-banner {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.06), rgba(20, 184, 166, 0.08));
    border-color: rgba(79, 70, 229, 0.15);
}

.info-banner h3 {
    color: var(--primary);
    font-size: 0.95rem;
    margin-top: 0;
}

.info-list {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--text-soft);
    line-height: 1.8;
}

/* Menu */
.menu-list { list-style: none; padding: 0; margin: 0; }

.menu-list li { margin-bottom: 0.5rem; }

.menu-list a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    background: var(--surface-2);
    transition: all 0.2s;
}

.menu-list a:hover {
    border-color: var(--primary);
    background: #fff;
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.menu-list a.menu-highlight {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(124, 58, 237, 0.06));
    border-color: rgba(79, 70, 229, 0.25);
}

/* Forms */
fieldset.form-group {
    border: none;
    padding: 0;
    margin: 0 0 1rem;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-soft);
    font-size: 0.85rem;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

textarea {
    resize: vertical;
    min-height: 4rem;
    font-family: inherit;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.7rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.875rem;
    font-family: inherit;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}

.btn:hover { transform: translateY(-2px); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--violet) 100%);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover { box-shadow: 0 8px 24px var(--primary-glow); }

.btn-secondary {
    background: var(--surface);
    color: var(--text-soft);
    border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid #fecaca;
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

.btn-block { width: 100%; }
.btn-sm { padding: 0.45rem 0.8rem; font-size: 0.8rem; }

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th,
.table td {
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.table th {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--surface-2);
}

.table tbody tr:hover { background: var(--surface-2); }

.table tfoot td {
    font-weight: 700;
    background: var(--surface-2);
}

.pay-cell { color: var(--green); font-weight: 700; }
.pay-total {
    font-size: 2rem;
    font-weight: 800;
    color: var(--green);
    margin: 0;
    letter-spacing: -0.02em;
}

.row-pending td { background: rgba(255, 193, 7, 0.08); }
.row-processed td { opacity: 0.92; }

/* Chips */
.stat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.chip {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-soft);
}

.chip-teal {
    background: var(--teal-bg);
    border-color: rgba(20, 184, 166, 0.3);
    color: var(--teal);
}

.chip-primary {
    background: rgba(79, 70, 229, 0.1);
    border-color: rgba(79, 70, 229, 0.25);
    color: var(--primary);
}

/* Alerts */
.alert {
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success {
    background: var(--green-bg);
    border: 1px solid #a7f3d0;
    color: var(--green);
}

.alert-error {
    background: var(--red-bg);
    border: 1px solid #fecaca;
    color: var(--red);
}

.validation-summary-errors {
    color: var(--red);
    margin-bottom: 1rem;
    padding: 0.85rem;
    background: var(--red-bg);
    border-radius: var(--radius-sm);
    border: 1px solid #fecaca;
    list-style: none;
}

.actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 1rem;
}

.field-validation-error { color: var(--red); font-size: 0.8rem; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-wrap { max-width: 420px; width: 100%; }

.login-wrap .card {
    border-top: none;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
}

.login-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-brand h1 {
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, var(--primary), var(--teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-hint {
    margin-top: 1.25rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
    line-height: 1.6;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-header-row h2 { margin: 0; border: none; padding: 0; }

.filter-bar { align-items: flex-end; }
.filter-bar select,
.filter-bar input[type="text"] { width: auto; min-width: 160px; }

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 2.5rem;
}

.report-form .form-group { max-width: 340px; }

/* Formula builder */
.formula-builder {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border);
}

.formula-builder h3 {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
}

.formula-start-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.formula-start-row select { flex: 1; min-width: 200px; }

.formula-steps {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin: 1rem 0;
}

.formula-step-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.step-connector {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    min-width: 2.5rem;
}

.formula-step-row select { width: auto; min-width: 140px; flex: 1; }

.formula-step-row .step-constant {
    width: auto;
    min-width: 90px;
    flex: 0 0 100px;
}

.formula-preview-box {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.06), rgba(20, 184, 166, 0.08));
    border-radius: var(--radius-sm);
    border: 1px solid rgba(79, 70, 229, 0.15);
}

.formula-preview-box code {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-soft);
    line-height: 1.6;
}

.chip-primary {
    background: rgba(79, 70, 229, 0.12);
    border-color: rgba(79, 70, 229, 0.25);
    color: var(--primary);
}

.card-inset {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.card-inset h3 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
}

.row-rate-override td {
    background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.ledger-section {
    scroll-margin-top: 5rem;
}

.table-scroll {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.table-scroll .table {
    min-width: 900px;
}

/* Pay period & calendar */
.pay-period-banner {
    margin: 0.5rem 0 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.week-toolbar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.week-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.65rem;
    margin-bottom: 1.5rem;
}

.week-day-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.week-day-today {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.week-day-has-entries {
    border-color: rgba(20, 184, 166, 0.35);
}

.week-day-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    gap: 0.15rem;
}

.week-day-name {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
}

.week-day-date {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
}

.week-day-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 0.8rem;
}

.muted-link {
    color: var(--muted);
    text-decoration: none;
}

.muted-link:hover { color: var(--primary); }

.week-day-entries {
    list-style: none;
    margin: 0;
    padding: 0.35rem;
    flex: 1;
}

.week-day-entries li {
    font-size: 0.75rem;
    padding: 0.35rem 0.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

.entry-times { font-weight: 600; }
.entry-hours { color: var(--teal); font-weight: 600; }
.entry-pay { color: var(--green); font-weight: 700; margin-left: auto; }

.calendar-toolbar { margin-bottom: 1rem; }

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.calendar-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
}

.calendar-grid {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.calendar-weekdays span {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.35rem;
}

.calendar-day {
    min-height: 96px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0;
    color: inherit;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface-2);
}

.calendar-day-main {
    flex: 1;
    padding: 0.4rem;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    transition: background 0.15s;
}

.calendar-day-main:hover {
    background: rgba(79, 70, 229, 0.06);
}

.calendar-day-log {
    display: block;
    text-align: center;
    padding: 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--primary);
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.calendar-day-log:hover {
    background: rgba(79, 70, 229, 0.1);
}

.calendar-day-has-note .calendar-day-main {
    background: rgba(249, 115, 22, 0.06);
}

.calendar-day-note-sick .cal-day-badge { background: var(--red-bg); color: var(--red); }
.calendar-day-note-dayoff .cal-day-badge { background: rgba(79, 70, 229, 0.12); color: var(--primary); }
.calendar-day-note-vacation .cal-day-badge { background: var(--teal-bg); color: var(--teal); }
.calendar-day-note-holiday .cal-day-badge { background: rgba(217, 119, 6, 0.12); color: var(--gold); }

.cal-day-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    letter-spacing: 0.04em;
}

.week-day-note-link {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--muted);
    text-decoration: none;
    margin-top: 0.15rem;
}

.week-day-note-link:hover { color: var(--primary); }

.calendar-legend { padding: 0.85rem 1.15rem; }

.calendar-day-pad {
    background: transparent;
    border: none;
    min-height: 0;
}

.calendar-day-today {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 2px var(--primary-glow);
}

.calendar-day-open-period {
    background: rgba(79, 70, 229, 0.06);
}

.calendar-day-pending {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}

.calendar-day-done {
    border-color: var(--teal);
    background: var(--teal-bg);
}

.cal-day-num {
    font-weight: 800;
    font-size: 1rem;
}

.cal-day-hours {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--teal);
}

.cal-day-count {
    font-size: 0.65rem;
    color: var(--muted);
}

/* Workflow */
.workflow-card {
    margin-bottom: 1.25rem;
}

.workflow-card-inset {
    margin-top: 1.25rem;
    padding: 1rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.workflow-steps {
    list-style: none;
    margin: 0.75rem 0 1rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.workflow-steps-compact .workflow-step-text {
    font-size: 0.7rem;
}

.workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.65rem 0.35rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    text-align: center;
    opacity: 0.55;
}

.workflow-step.current {
    opacity: 1;
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.workflow-step.done {
    opacity: 1;
    border-color: rgba(20, 184, 166, 0.4);
    background: var(--teal-bg);
}

.workflow-step-num {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    background: var(--surface);
    border: 1px solid var(--border);
}

.workflow-step.current .workflow-step-num {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.workflow-step.done .workflow-step-num {
    background: var(--teal);
    color: #fff;
    border-color: var(--teal);
}

.workflow-step-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-soft);
    line-height: 1.2;
}

.workflow-actions {
    margin-top: 0.5rem;
}

.workflow-form {
    margin: 0;
    width: 100%;
}

.workflow-done-msg {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 0.5rem;
}

.workflow-danger {
    margin-top: 0.75rem;
    font-size: 0.85rem;
}

.workflow-danger summary {
    cursor: pointer;
    color: var(--muted);
    font-weight: 600;
}

.actions-bar {
    flex-direction: column;
    align-items: stretch;
}

.actions-bar .btn,
.actions-bar .workflow-form {
    width: 100%;
}

.actions-secondary {
    margin-top: 0.5rem;
}

.actions-secondary .btn {
    flex: 1;
    min-width: 0;
}

/* Week switcher tabs */
.week-switcher { padding: 1rem 1.25rem; }

.week-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
}

.week-tab {
    flex: 0 0 auto;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-soft);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.week-tab-active,
.week-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
}

.open-week-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.open-week-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}

.open-week-item:last-child { border-bottom: none; }

.inline-form {
    display: inline;
    margin: 0;
}

.btn-danger-text {
    color: var(--red) !important;
}

.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0.35rem 0 0;
}

@media (max-width: 900px) {
    .week-grid { grid-template-columns: repeat(2, 1fr); }
    .workflow-steps { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .container { padding: 1rem 1rem 2.5rem; }

    .app-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        padding: 0.75rem 1rem;
    }

    .app-nav {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
    }

    .app-nav a,
    .app-nav .logout-form .btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .page-header h1,
    .hero h1 { font-size: 1.5rem; }

    .pay-total { font-size: 1.5rem; }

    .card-header-row {
        flex-direction: column;
        align-items: stretch;
    }

    .card { padding: 1.15rem; }

    .week-grid { grid-template-columns: 1fr; }

    .calendar-day { min-height: 64px; font-size: 0.85rem; }

    .calendar-weekdays span { font-size: 0.65rem; }

    .workflow-steps { grid-template-columns: 1fr 1fr; }

    .formula-step-row select,
    .formula-step-row .step-constant { width: 100%; min-width: 0; }

    .filter-bar select,
    .filter-bar input[type="text"] { width: 100%; min-width: 0; }

    .table-mobile-stack thead { display: none; }

    .table-mobile-stack tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 0.5rem 0.75rem;
        background: var(--surface-2);
    }

    .table-mobile-stack td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.5rem 0;
        border: none;
        text-align: right;
    }

    .table-mobile-stack td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.72rem;
        text-transform: uppercase;
        color: var(--muted);
        text-align: left;
    }

    .table-mobile-stack td.actions-cell {
        flex-direction: column;
        align-items: stretch;
    }

    .table-mobile-stack td.actions-cell::before { display: none; }

    .table-mobile-stack td.actions-cell .btn {
        width: 100%;
    }
}

@media (min-width: 769px) {
    .actions-bar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .actions-bar .btn-block {
        width: auto;
        min-width: 12rem;
    }
}
