:root {
    --pf-ink: #14171b;
    --pf-rail: #14171b;
    --pf-rail-line: #262b31;
    --pf-rail-text: #aab2bd;
    --pf-rail-text-active: #ffffff;
    --pf-surface: #eef0f3;
    --pf-card: #ffffff;
    --pf-border: #dde1e7;
    --pf-text: #1b1f24;
    --pf-text-muted: #64707d;
    --pf-accent: #fa3413;
    --pf-accent-deep: #c22a10;
    --pf-accent-wash: #fdeae6;
    --pf-good: #1f8a5f;
    --pf-good-wash: #e5f4ee;
    --pf-warn: #b8790f;
    --pf-warn-wash: #faf1e0;
    --pf-critical: #b23a3a;
    --pf-critical-wash: #f8e9e9;
    --pf-info: #3865b0;
    --pf-info-wash: #e7edf7;
    --pf-shadow: 0 1px 2px rgba(20, 23, 27, 0.06), 0 8px 24px -16px rgba(20, 23, 27, 0.22);
}

body {
    background: var(--pf-surface);
    color: var(--pf-text);
    font-family: 'Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- app shell: rail + main ---- */
.app-shell {
    display: flex;
    min-height: 100%;
}

.app-rail {
    flex: 0 0 232px;
    background: var(--pf-rail);
    color: var(--pf-rail-text);
    display: flex;
    flex-direction: column;
    padding: 18px 12px;
}

.rail-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 6px 18px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--pf-rail-line);
}

.rail-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
}

.rail-brand img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    flex: none;
}

.rail-brand-text {
    font-family: 'Plex Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--pf-rail-text-active);
    text-transform: uppercase;
}

.rail-brand-text b {
    color: var(--pf-accent);
    font-weight: 600;
}

.rail-toggle {
    display: none;
    background: none;
    border: 0;
    color: var(--pf-rail-text-active);
    font-size: 1.1rem;
    padding: 4px 6px;
}

/* !important: the bundled bootstrap theme (styles/fresca/theme.css) loads after this file and
   restates bootstrap's default `.collapse:not(.show){display:none}`, which would otherwise hide
   the rail nav on desktop where it's not actually collapsed */
.rail-nav.collapse {
    display: flex !important;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    overflow-y: auto;
}

.rail-group-label {
    font-family: 'Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #566072;
    padding: 14px 10px 4px;
}

.rail-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--pf-rail-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    position: relative;
}

.rail-link .rail-ico {
    width: 17px;
    height: 17px;
    text-align: center;
    flex: none;
    opacity: 0.85;
}

svg.rail-ico {
    stroke: currentColor;
    fill: none;
}

.rail-link:hover {
    background: #1e2227;
    color: var(--pf-rail-text-active);
    text-decoration: none;
}

.rail-link.active {
    background: #1e2227;
    color: var(--pf-rail-text-active);
}

.rail-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--pf-accent);
}

.rail-sub {
    margin-left: 27px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-bottom: 2px;
}

.rail-sub .rail-link {
    font-size: 12.5px;
    padding: 5px 10px;
    font-weight: 400;
    color: #8891a0;
}

.rail-sub .rail-link.active {
    color: var(--pf-rail-text-active);
    font-weight: 500;
}


.rail-user {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--pf-rail-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.rail-user-info {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.rail-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--pf-accent-wash);
    color: var(--pf-accent-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Plex Mono', monospace;
    font-weight: 600;
    font-size: 11.5px;
    flex: none;
}

.rail-user-name {
    font-size: 12.5px;
    color: var(--pf-rail-text-active);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}

.rail-user-name:hover {
    color: var(--pf-rail-text-active);
    text-decoration: underline;
}

.rail-logout {
    color: var(--pf-rail-text);
    flex: none;
    padding: 4px;
}

.rail-logout:hover {
    color: var(--pf-rail-text-active);
}

/* ---- main column ---- */
.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

@media (max-width: 767.98px) {
    .app-shell {
        flex-direction: column;
    }
    .app-rail {
        flex: none;
        flex-direction: column;
        padding: 10px 14px;
    }
    .rail-top {
        border-bottom: 0;
        margin-bottom: 0;
        padding-bottom: 2px;
    }
    .rail-toggle {
        display: block;
    }
    .rail-nav.collapse:not(.show) {
        display: none !important;
    }
    .rail-nav {
        padding-top: 10px;
        border-top: 1px solid var(--pf-rail-line);
        margin-top: 10px;
    }
    .rail-user {
        border-top: 1px solid var(--pf-rail-line);
    }
}

/* ---- KPI cards (existing .kpi-card/.kpi-label/.kpi-value markup, restyled) ---- */
.kpi-card {
    border: 1px solid var(--pf-border);
    border-left: 3px solid var(--pf-border);
    border-radius: 8px;
    box-shadow: var(--pf-shadow);
}

.kpi-card.kpi-primary,
.kpi-card.kpi-brand { border-left-color: var(--pf-accent); }
.kpi-card.kpi-success { border-left-color: var(--pf-good); }
.kpi-card.kpi-warning { border-left-color: var(--pf-warn); }
.kpi-card.kpi-danger { border-left-color: var(--pf-critical); }
.kpi-card.kpi-secondary { border-left-color: var(--pf-text-muted); }

.kpi-label {
    font-size: 12px;
    color: var(--pf-text-muted);
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
}

.kpi-value {
    font-family: 'Plex Mono', monospace;
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    color: var(--pf-text);
}

.kpi-icon {
    color: var(--pf-text-muted);
}

/* ---- generic surfaces ---- */
.card {
    border-radius: 8px;
    border-color: var(--pf-border);
    box-shadow: var(--pf-shadow);
}

.section-navbar {
    border-radius: 8px;
    box-shadow: var(--pf-shadow);
    border: 1px solid var(--pf-border);
}

.section-title {
    font-family: 'Plex Sans', sans-serif;
    font-weight: 600;
    color: var(--pf-text);
}

.table-responsive {
    border-radius: 8px;
    box-shadow: var(--pf-shadow);
    border: 1px solid var(--pf-border);
}

/* ---- simple list panels (a .card wrapping a title + table, e.g. "Últims registres") ---- */
.panel-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--pf-text);
    margin: 0 0 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--pf-border);
}

.panel-title a {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--pf-accent-deep);
    text-decoration: none;
}

.panel-title a:hover {
    text-decoration: underline;
}

table.table {
    font-size: 13.5px;
}

table.table thead th {
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--pf-text-muted);
    font-weight: 600;
    padding: 8px 12px;
    border-top: 0;
    border-bottom-width: 1px;
    background: var(--pf-surface);
}

table.table tbody td {
    padding: 10px 12px;
    vertical-align: middle;
}

table.table tbody tr:hover {
    background: var(--pf-surface);
}

/* the tempusdominus datepicker's calendar grid also carries bootstrap's .table.table-sm classes;
   keep its native compact sizing so the 7-day grid doesn't outgrow the dropdown's fixed width and
   overflow past its own white background (weekend columns were bleeding through the page behind it) */
.bootstrap-datetimepicker-widget table.table {
    font-size: 0.875rem;
}

.bootstrap-datetimepicker-widget table.table td,
.bootstrap-datetimepicker-widget table.table th {
    padding: 0.3rem;
}

/* neutralize bootstrap's zebra striping app-wide: rows are told apart by hover + borders instead */
table.table-striped tbody tr:nth-of-type(odd) {
    background-color: transparent;
}

table.table td.mono,
table.table .mono {
    font-family: 'Plex Mono', monospace;
    font-variant-numeric: tabular-nums;
}

/* ---- chip: small pill with a colored dot, for origin/status/type badges ---- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
}

.chip::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.chip.chip-worker { background: var(--pf-good-wash); color: var(--pf-good); }
.chip.chip-admin { background: var(--pf-accent-wash); color: var(--pf-accent-deep); }
.chip.chip-muted { background: var(--pf-surface); color: var(--pf-text-muted); }

/* ---- chip variants for clocking type (Entrada/Sortida/Pausa/Retorn) ---- */
.chip.chip-in { background: var(--pf-good-wash); color: var(--pf-good); }
.chip.chip-out { background: var(--pf-surface); color: var(--pf-text-muted); }
.chip.chip-pause { background: var(--pf-warn-wash); color: var(--pf-warn); }
.chip.chip-return { background: var(--pf-info-wash); color: var(--pf-info); }

.row-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--pf-surface);
    border: 1px solid var(--pf-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Plex Mono', monospace;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--pf-text-muted);
    flex: none;
}

/* ---- auth screens (login / password recovery) ---- */
.auth-split {
    min-height: 100vh;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.auth-brand {
    background: var(--pf-ink);
    color: #fff;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px;
}

.auth-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 42px 42px;
    -webkit-mask-image: radial-gradient(circle at 25% 30%, black, transparent 65%);
    mask-image: radial-gradient(circle at 25% 30%, black, transparent 65%);
}

.auth-brand-mark {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.auth-brand-mark img {
    width: 30px;
    height: 30px;
    border-radius: 7px;
}

.auth-brand-mark span {
    font-family: 'Plex Mono', monospace;
    font-size: 13.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.auth-brand-mark b {
    color: var(--pf-accent);
    font-weight: 600;
}

.auth-brand-copy {
    position: relative;
    max-width: 380px;
}

.auth-eyebrow {
    font-family: 'Plex Mono', monospace;
    font-size: 11.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #ff8064;
    margin-bottom: 14px;
}

.auth-brand-copy h1 {
    font-size: 26px;
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 14px;
    text-wrap: balance;
}

.auth-brand-copy p {
    font-size: 14.5px;
    line-height: 1.6;
    color: #aab2bd;
    margin: 0;
}

.auth-brand-foot {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Plex Mono', monospace;
    font-size: 11.5px;
    color: #566072;
}

.auth-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2fb673;
    box-shadow: 0 0 0 3px rgba(47, 182, 115, 0.18);
    flex: none;
}

.auth-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 32px;
    background: var(--pf-card);
}

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

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--pf-text-muted);
    text-decoration: none;
    margin-bottom: 22px;
}

.auth-back-link:hover {
    color: var(--pf-text);
    text-decoration: none;
}

.auth-tabs {
    display: inline-flex;
    padding: 3px;
    background: var(--pf-surface);
    border-radius: 8px;
    margin-bottom: 28px;
    gap: 2px;
}

.auth-tabs a {
    font-family: 'Plex Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--pf-text-muted);
    padding: 7px 14px;
    border-radius: 6px;
    text-decoration: none;
}

.auth-tabs a:hover {
    color: var(--pf-text);
    text-decoration: none;
}

.auth-tabs a.active {
    background: var(--pf-card);
    color: var(--pf-text);
    box-shadow: 0 1px 2px rgba(20, 23, 27, 0.08);
}

.auth-form-wrap h2 {
    font-size: 21px;
    font-weight: 600;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
    color: var(--pf-text);
}

.auth-form-wrap .auth-sub {
    font-size: 13.5px;
    color: var(--pf-text-muted);
    margin: 0 0 26px;
    line-height: 1.5;
}

.auth-form .control-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--pf-text);
}

.auth-form .form-control {
    font-family: 'Plex Sans', sans-serif;
    font-size: 14.5px;
    padding: 10px 12px;
    height: auto;
    border: 1px solid var(--pf-border);
    border-radius: 7px;
}

.auth-form .form-control:focus {
    border-color: var(--pf-accent);
    box-shadow: 0 0 0 3px var(--pf-accent-wash);
}

.auth-form .form-control-static {
    font-family: 'Plex Mono', monospace;
    font-size: 13.5px;
    color: var(--pf-text-muted);
}

.auth-form .has-error .form-control {
    border-color: var(--pf-critical);
}

.auth-form .has-error .form-control:focus {
    box-shadow: 0 0 0 3px var(--pf-critical-wash);
}

.auth-form-row {
    margin: -8px 0 20px;
    text-align: right;
}

.auth-link {
    font-size: 13px;
    color: var(--pf-accent-deep);
    font-weight: 500;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
    color: var(--pf-accent-deep);
}

.auth-submit.btn-primary {
    background-color: var(--pf-accent);
    border-color: var(--pf-accent);
    font-weight: 600;
    padding: 11px;
    border-radius: 7px;
}

.auth-submit.btn-primary:hover,
.auth-submit.btn-primary:focus {
    background-color: var(--pf-accent-deep);
    border-color: var(--pf-accent-deep);
}

@media (max-width: 860px) {
    .auth-split {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    .auth-brand {
        padding: 28px;
        min-height: 160px;
    }
    .auth-brand-copy h1 {
        font-size: 21px;
    }
    .auth-form-panel {
        padding: 36px 28px;
    }
}

/* ---- primary buttons app-wide use the brand accent, not bootstrap's default blue ---- */
.btn-primary {
    background-color: var(--pf-accent);
    border-color: var(--pf-accent);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:not(:disabled):not(.disabled):active {
    background-color: var(--pf-accent-deep);
    border-color: var(--pf-accent-deep);
}

.btn-primary:focus,
.btn-primary.focus {
    box-shadow: 0 0 0 0.2rem var(--pf-accent-wash);
}
