/* LEK PLG — stylesheet (mobile-first, no build step). Brand: #0069B4 / #9D9D9C */
:root {
    --brand: #0069b4;
    --brand-dark: #00528f;
    --brand-light: #e8f1f9;
    --grey: #9d9d9c;
    --ink: #182230;
    --muted: #5d6671;
    --bg: #eef1f6;
    --surface: #ffffff;
    --border: #e4e8ef;
    --border-strong: #d3dae4;
    --ok: #1b7a43;
    --ok-bg: #e7f5ec;
    --danger: #b3261e;
    --danger-bg: #fdecea;
    --warn-bg: #fff4e5;
    --warn: #8a5300;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(16, 30, 54, .06);
    --shadow: 0 1px 3px rgba(16, 30, 54, .06), 0 8px 24px rgba(16, 30, 54, .07);
    --maxw: 1040px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, #f6f8fb 0%, var(--bg) 100%);
    background-attachment: fixed;
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }
h1, h2, h3 { letter-spacing: -.01em; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--brand);
    color: #fff;
    padding: .6rem 1rem;
    z-index: 100;
    border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .6rem 1rem;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    border-top: 3px solid var(--brand);
    position: sticky;
    top: 0;
    z-index: 10;
}
.app-header__brand { display: inline-flex; align-items: center; }
.app-header__logo { display: block; height: 38px; width: auto; }
.app-header__actions { display: flex; align-items: center; gap: 1rem; }

.lang-switch { display: flex; align-items: center; gap: .3rem; font-size: .82rem; color: var(--grey); }
.lang-switch a { text-decoration: none; color: var(--muted); padding: .15rem .35rem; border-radius: 6px; }
.lang-switch a:hover { background: var(--brand-light); color: var(--brand); }
.lang-switch a.is-active { color: var(--brand); font-weight: 700; background: var(--brand-light); }

.logout-form { margin: 0; }

/* Layout */
.app-main {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
    animation: rise .25s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Cards */
.card, .auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.6rem;
}
.card + .card { margin-top: 1.1rem; }
.card__title, .auth-card__title { margin: 0 0 1rem; font-size: 1.4rem; font-weight: 700; }
.card__subtitle { margin: 0 0 .9rem; font-size: 1.08rem; font-weight: 650; color: var(--ink); }
.card__body { margin-bottom: 0; }
.muted { color: var(--muted); margin: .25rem 0; }

.card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.card__head .card__title { margin: 0; }
.head-actions { display: inline-flex; flex-wrap: wrap; gap: .5rem; }

/* Auth (login / password reset) */
.auth-card {
    max-width: 440px;
    margin: 7vh auto 0;
    border-top: 4px solid var(--brand);
    padding: 2rem 1.8rem;
}
.auth-card__title { text-align: center; }

/* Forms */
.form__group { margin-bottom: 1.15rem; }
.form__group--inline { display: flex; align-items: center; }
.form__label { display: block; font-weight: 600; margin-bottom: .4rem; font-size: .9rem; color: #2a3442; }
.form__hint { margin: .35rem 0 0; font-size: .82rem; line-height: 1.4; }
.form__input {
    width: 100%;
    padding: .72rem .85rem;
    font-size: 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
.form__input::placeholder { color: #9aa4b1; }
.form__input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(0, 105, 180, .16);
}
textarea.form__input { resize: vertical; }
.checkbox { display: inline-flex; align-items: center; gap: .5rem; font-size: .92rem; cursor: pointer; user-select: none; }
.checkbox input { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); }
.form__actions { display: flex; gap: .6rem; margin-top: .5rem; flex-wrap: wrap; }
.form--inline { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.form--inline .form__input { width: auto; flex: 1 1 220px; }

/* Buttons (min 44px touch target) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: .6rem 1.2rem;
    font-size: 1rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(0, 105, 180, .3); }
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(0, 82, 143, .35); }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: #fff; border-color: var(--border-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--brand-light); border-color: var(--brand); color: var(--brand); }
.btn--block { width: 100%; }

/* Text / icon links + inline button-links */
.link { color: var(--brand); text-decoration: none; margin-right: .7rem; background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }
.link--danger { color: var(--danger); }
.inline { display: inline; }

/* Alerts */
.alert { border-radius: var(--radius-sm); padding: .85rem 1rem; margin-bottom: 1.15rem; font-size: .92rem; border: 1px solid transparent; }
.alert--error { background: var(--danger-bg); color: var(--danger); border-color: #f1c4c0; }
.alert--success { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cc; }
.alert__list { margin: 0; padding-left: 1.1rem; }

/* Admin tab nav */
/* Admin secondary navigation — a labelled pill bar, visually distinct from the
   top tab nav so it reads as an "Administracja" sub-menu, not a duplicate. */
.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .7rem; margin-bottom: 1.4rem; padding: .55rem .7rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.admin-nav__label { font-size: .7rem; letter-spacing: .09em; text-transform: uppercase; font-weight: 700; color: var(--muted); padding: 0 .3rem; }
.admin-nav__links { display: flex; flex-wrap: wrap; gap: .3rem; }
.admin-nav a { padding: .42rem .85rem; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; border-radius: 999px; border: 1px solid transparent; transition: background .12s, color .12s, border-color .12s; }
.admin-nav a:hover { color: var(--brand); background: var(--brand-light); }
.admin-nav a.is-active { color: #fff; background: var(--brand); border-color: var(--brand); }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { text-align: left; padding: .65rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; white-space: nowrap; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover { background: #f7f9fc; }
.table td.actions { white-space: nowrap; text-align: right; }

/* Badges + chips */
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: #eef1f5; color: var(--muted); }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--muted { background: var(--danger-bg); color: var(--danger); }
.badge--warn { background: #fff4cc; color: #7a5b00; }

/* Training: one book-row per searched driver (name + session + level + button) */
.book-row { align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.book-row__driver { flex: 1 1 220px; min-width: 180px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; }
.chip { background: var(--brand-light); color: #20496a; border: 1px solid #cfe1f1; border-radius: 7px; padding: .15rem .55rem; font-size: .76rem; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* Tiles (dashboard) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.tile {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    min-height: 76px; padding: .9rem 1rem;
    text-align: center; text-decoration: none;
    color: var(--ink); background: #fff;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-weight: 650; box-shadow: var(--shadow-sm);
    transition: transform .12s, box-shadow .12s, border-color .12s, color .12s;
    overflow: hidden;
}
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); opacity: .85; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); color: var(--brand); }

/* Misc layout helpers */
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 1.1rem; }
.role-block { padding: .8rem 0; border-bottom: 1px solid var(--border); }
.role-block:last-child { border-bottom: 0; }

/* Pager */
.pager { display: flex; align-items: center; gap: .75rem; margin-top: 1.2rem; }
.pager__link { display: inline-flex; min-width: 40px; min-height: 40px; align-items: center; justify-content: center; padding: 0 .7rem; border: 1px solid var(--border-strong); border-radius: 8px; text-decoration: none; color: var(--brand); background: #fff; }
.pager__link:hover { background: var(--brand-light); }
.pager__link.is-disabled { color: var(--grey); border-color: var(--border); pointer-events: none; background: transparent; }
.pager__info { color: var(--muted); font-size: .9rem; }

/* Lookup results */
.lookup-list { list-style: none; margin: 0; padding: 0; }
.lookup-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .85rem 0; border-bottom: 1px solid var(--border); }
.lookup-item:last-child { border-bottom: 0; }
.lookup-item__name { font-weight: 650; text-decoration: none; color: var(--brand); margin-right: .5rem; font-size: 1.05rem; }
.status { margin: 0; font-weight: 650; padding: .3rem .7rem; border-radius: 999px; font-size: .85rem; }
.status--ok { color: var(--ok); background: var(--ok-bg); }
.status--bad { color: var(--danger); background: var(--danger-bg); }

/* Larger screens */
/* ---- Header bar + primary navigation ---- */
.app-header { display: block; padding: 0; }
.app-header__bar { display: flex; align-items: center; gap: .9rem; padding: .55rem 1rem; }
.app-header__brand { display: inline-flex; align-items: center; }
.app-header__actions { display: flex; align-items: center; gap: .85rem; margin-left: auto; }
.user-chip { font-size: .85rem; font-weight: 600; color: var(--muted); max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn--sm { min-height: 36px; padding: .35rem .8rem; font-size: .85rem; }

.app-nav { display: flex; flex-wrap: wrap; gap: .1rem; padding: 0 .6rem; border-top: 1px solid var(--border); }
.app-nav a { padding: .7rem .95rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; font-size: .95rem; }
.app-nav a:hover { color: var(--brand); background: var(--brand-light); }
.app-nav a.is-active { color: var(--brand); border-bottom-color: var(--brand); }

/* Hamburger toggle */
.nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 1px solid var(--border-strong); border-radius: 9px; background: #fff; cursor: pointer; }
.nav-toggle__bars { position: relative; display: block; width: 18px; height: 2px; background: var(--ink); }
.nav-toggle__bars::before, .nav-toggle__bars::after { content: ""; position: absolute; left: 0; width: 18px; height: 2px; background: var(--ink); transition: transform .2s, opacity .2s; }
.nav-toggle__bars::before { top: -6px; }
.nav-toggle__bars::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after { transform: translateY(-6px) rotate(-45deg); }

/* Flash auto-dismiss + live-search refresh hint */
.alert.is-dismissing { opacity: 0; transition: opacity .4s; }
[data-results].is-refreshing { opacity: .45; transition: opacity .15s; }

@media (max-width: 767px) {
    .app-nav { flex-direction: column; padding: 0; }
    .app-nav:not(.is-open) { display: none; }
    .app-nav a { padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
    .app-nav a.is-active { border-bottom-color: var(--border); background: var(--brand-light); }
}
@media (min-width: 768px) {
    .nav-toggle { display: none; }
    .app-header__bar { padding: .55rem 1.75rem; }
    .app-nav { padding: 0 1.25rem; }
    .app-main { padding: 2.25rem 1.75rem 4rem; }
    .grid2 { grid-template-columns: 1fr 1fr; }
}

/* ---- Dashboard ---- */
.hero {
    background: linear-gradient(120deg, var(--brand) 0%, #0a86d8 100%);
    color: #fff; border-radius: var(--radius); padding: 1.7rem 1.8rem;
    box-shadow: var(--shadow); margin-bottom: 1.4rem;
}
.hero__eyebrow { margin: 0 0 .3rem; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.hero__title { margin: 0 0 .7rem; font-size: 1.65rem; }
.hero__meta { display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: center; margin: 0; font-size: .9rem; opacity: .95; }
.hero__badge { background: rgba(255, 255, 255, .18); padding: .2rem .65rem; border-radius: 999px; font-weight: 600; }

.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.5rem 0 .75rem; font-weight: 700; }

/* richer tiles (override base centred layout) */
.tile { flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; min-height: 88px; padding: 1rem 1.1rem 1rem 1.35rem; gap: .25rem; }
.tile__title { font-weight: 700; font-size: 1.03rem; }
.tile__desc { font-weight: 500; font-size: .82rem; color: var(--muted); line-height: 1.35; }
.tile:hover .tile__desc { color: var(--brand); }

/* ---- Error pages ---- */
.error-page { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.error-card { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.2rem; text-align: center; max-width: 460px; }
.error-card__logo { height: 46px; width: auto; margin-bottom: 1rem; }
.error-card__code { margin: 0; font-size: 3rem; font-weight: 800; color: var(--brand); line-height: 1; }
.error-card__title { margin: .4rem 0 .5rem; font-size: 1.15rem; font-weight: 600; color: var(--ink); }
.error-card__hint { margin: 0 0 1.4rem; font-size: .92rem; line-height: 1.5; color: var(--muted); }

/* ---- Permit level badges (spec §4.1 colours) ---- */
.lvl { display: inline-block; padding: .12rem .55rem; border-radius: 6px; font-size: .76rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.lvl--yellow { background: #fff4cc; color: #7a5b00; border-color: #f0dca0; }
.lvl--green { background: #e3f6e8; color: #1b6b39; border-color: #bfe3cc; }
.lvl--red { background: #fde7e6; color: #a3271f; border-color: #f3c2bf; }
.lvl--grey { background: #eef1f5; color: var(--muted); }
.select-xs { padding: .2rem .3rem; border: 1px solid var(--border-strong); border-radius: 6px; font-size: .8rem; max-width: 6.5rem; }

/* ---- Filter bar (search + multi-status + per-page) ---- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .9rem; margin-bottom: 1.1rem; padding: .85rem 1rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.filter-bar__search { flex: 1 1 240px; min-width: 170px; }
.filter-status { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; border: 0; margin: 0; padding: 0; }
.filter-status__label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.select-pp { width: auto; flex: 0 0 auto; }
.filter-date { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--muted); }
.filter-date .form__input { width: auto; }

/* ---- Training: contextual action buttons + hints + attendance ---- */
.btn--xs { display: inline-flex; align-items: center; min-height: 30px; padding: .25rem .6rem; font-size: .78rem; font-weight: 600; border: 1px solid transparent; border-radius: 6px; cursor: pointer; text-decoration: none; }
.btn--ok { background: #e3f6e8; color: #1b6b39; border-color: #bfe3cc; }
.btn--danger { background: #fde7e6; color: #a3271f; border-color: #f3c2bf; }
.btn--warn { background: #fff4cc; color: #7a5b00; border-color: #f0dca0; }
.btn--info { background: #e8f1f9; color: #20496a; border-color: #cfe1f1; }
.row-actions { display: flex; flex-wrap: wrap; gap: .3rem; }
.muted-danger { color: var(--danger); font-size: .72rem; font-weight: 600; margin-left: .3rem; }
.row-hint td { background: #fff8f6; color: var(--danger); font-size: .82rem; }

.attendance__head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.attendance__head h1 { margin: 0; }
.attendance__head .btn { margin-left: auto; }
.sign-cell { min-width: 160px; border-bottom: 1px solid var(--ink); }

/* ---- Cases: status timeline + penalty/evidence (Phase 5/6) ---- */
.timeline { list-style: none; margin: .6rem 0 0; padding: 0; border-left: 2px solid var(--border); }
.timeline-item { position: relative; padding: .5rem 0 .85rem 1.1rem; }
.timeline-item::before { content: ""; position: absolute; left: -7px; top: .8rem; width: 11px; height: 11px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.timeline-item__meta { font-size: .76rem; color: var(--muted); }
.timeline-item__action { font-weight: 600; }
.timeline-item__comment { margin: .15rem 0 0; }

.case-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.case-actions form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

/* Case action cards — one bordered box per action, stacked inputs + full button */
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; margin-top: .6rem; }
.action-box { display: flex; flex-direction: column; gap: .55rem; padding: .85rem .9rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.action-box__title { margin: 0; font-size: .82rem; font-weight: 700; color: var(--ink); }
.action-box form { display: flex; flex-direction: column; gap: .5rem; margin: 0; }
.action-box .btn { width: 100%; justify-content: center; }

/* Cases as chips + the active-points stat on the driver profile */
.case-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .55rem; margin: 0 .35rem .35rem 0; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--ink); }
.case-chip:hover { border-color: var(--brand); background: var(--brand-light); }
.case-chip__id { font-weight: 700; font-size: .82rem; }
.stat { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1; padding: .25rem .9rem; background: var(--brand-light); border-radius: var(--radius-sm); }
.stat__value { font-size: 1.7rem; font-weight: 800; color: var(--brand); }
.stat__label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.table tr.row-muted td { opacity: .55; }

/* ---- Notifications ---- */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { padding: .7rem .9rem; border-bottom: 1px solid var(--border); display: flex; gap: .8rem; align-items: baseline; }
.notif-list li.is-unread { background: var(--brand-light); border-left: 3px solid var(--brand); }
.notif-list .notif-time { font-size: .74rem; color: var(--muted); margin-left: auto; white-space: nowrap; }

@media print {
    .app-header, .no-print, .pager, .filter-bar { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 0; padding: 0; }
}
