:root {
    color-scheme: light;
    --bg: #f5f7f4;
    --panel: #ffffff;
    --ink: #17211b;
    --muted: #637068;
    --line: #dce3dd;
    --primary: #116a5c;
    --primary-dark: #0a4f44;
    --danger: #b42318;
    --danger-bg: #fde7e5;
    --warning: #9a5b00;
    --warning-bg: #fff0cf;
    --ok: #187044;
    --ok-bg: #ddf5e8;
    --shadow: 0 18px 45px rgba(23, 33, 27, .08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
}

button,
input,
select,
textarea {
    font: inherit;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.topbar,
.toolbar,
.dialog-head,
.dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1;
}

h2 {
    font-size: 22px;
}

.actions {
    display: flex;
    gap: 10px;
}

.button,
.icon-button {
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    min-height: 42px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    color: var(--ink);
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
}

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

.button.primary:hover {
    background: var(--primary-dark);
}

.button.ghost {
    background: var(--panel);
    border-color: var(--line);
}

.button.ghost:hover {
    border-color: var(--primary);
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 28px 0 16px;
}

.metric {
    min-height: 104px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.metric:hover,
.metric.active {
    border-color: var(--primary);
}

.metric:focus-visible {
    outline: 3px solid rgba(17, 106, 92, .22);
    outline-offset: 2px;
}

.metric span {
    display: block;
    font-size: 38px;
    font-weight: 850;
    line-height: 1;
}

.metric small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-weight: 700;
}

.metric.danger span {
    color: var(--danger);
}

.metric.warning span {
    color: var(--warning);
}

.metric.ok span {
    color: var(--ok);
}

.toolbar {
    margin: 18px 0 12px;
}

.toolbar input,
.toolbar select {
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.toolbar input {
    width: 100%;
    padding: 0 14px;
}

.toolbar select {
    width: 180px;
    padding: 0 10px;
}

.table-wrap {
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

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

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #f9fbf8;
}

.vehicle-title {
    display: grid;
    gap: 3px;
}

.vehicle-title strong {
    font-size: 16px;
}

.vehicle-title span,
.sub {
    color: var(--muted);
    font-size: 13px;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 850;
}

.pill.expired {
    background: var(--danger-bg);
    color: var(--danger);
}

.pill.soon {
    background: var(--warning-bg);
    color: var(--warning);
}

.pill.ok {
    background: var(--ok-bg);
    color: var(--ok);
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.link-button {
    background: transparent;
    border: 0;
    color: var(--primary);
    cursor: pointer;
    font-weight: 850;
}

.empty {
    display: none;
    padding: 34px;
    color: var(--muted);
    text-align: center;
}

.empty.visible {
    display: block;
}

dialog {
    width: min(720px, calc(100% - 28px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 26px 80px rgba(0, 0, 0, .28);
}

dialog::backdrop {
    background: rgba(10, 20, 16, .45);
}

form {
    padding: 22px;
}

.icon-button {
    width: 42px;
    background: var(--bg);
    border-color: var(--line);
    color: var(--muted);
    font-weight: 900;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 22px 0 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

label input,
label textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    color: var(--ink);
    font-weight: 550;
}

label textarea {
    resize: vertical;
}

.error {
    min-height: 22px;
    margin: 12px 0;
    color: var(--danger);
    font-weight: 800;
}

#archiveVehicle {
    visibility: hidden;
}

#archiveVehicle.visible {
    visibility: visible;
}

@media (max-width: 760px) {
    .shell {
        width: min(100% - 20px, 1180px);
        padding: 16px 0;
    }

    .topbar,
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .actions,
    .toolbar select {
        width: 100%;
    }

    .button,
    .toolbar select {
        flex: 1;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .table-wrap {
        overflow-x: auto;
    }

    table {
        min-width: 900px;
    }

    .grid {
        grid-template-columns: 1fr;
    }
}

.renew-summary {
    display: grid;
    gap: 4px;
    margin: 20px 0 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbf8;
}

.renew-summary strong,
.renew-summary span {
    display: block;
}

.renew-summary span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.notice {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    min-height: 46px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbf8;
    color: var(--muted);
}

.notice:empty {
    display: none;
}

.notice::before {
    content: "!";
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
}

.notice.success {
    color: var(--ok);
    border-color: rgba(24, 112, 68, .25);
    background: var(--ok-bg);
}

.notice.success::before {
    content: "";
    background:
        linear-gradient(45deg, transparent 45%, #fff 45% 58%, transparent 58%) 8px 10px / 9px 7px no-repeat,
        linear-gradient(-45deg, transparent 40%, #fff 40% 56%, transparent 56%) 4px 11px / 8px 7px no-repeat,
        var(--ok);
}


@media (max-width: 760px) {
    body {
        background: #eef3ef;
    }

    .shell {
        width: 100%;
        padding: 12px 10px 22px;
    }

    .topbar {
        gap: 12px;
    }

    h1 {
        font-size: 32px;
        line-height: 1.05;
    }

    .actions {
        display: grid;
        grid-template-columns: 96px minmax(0, 1fr);
        gap: 8px;
    }

    .button {
        min-height: 48px;
        padding: 0 12px;
    }

    .stats {
        gap: 8px;
        margin: 18px 0 12px;
    }

    .metric {
        min-height: 78px;
        padding: 12px;
        box-shadow: none;
    }

    .metric span {
        font-size: 30px;
    }

    .metric small {
        margin-top: 5px;
        font-size: 12px;
    }

    .toolbar {
        gap: 8px;
        margin: 12px 0;
    }

    .toolbar input,
    .toolbar select {
        width: 100%;
        height: 48px;
        font-size: 16px;
    }

    .table-wrap {
        overflow: visible;
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    table,
    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    thead {
        display: none;
    }

    tbody tr {
        padding: 12px;
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: 0 10px 28px rgba(23, 33, 27, .07);
    }

    tbody tr:hover {
        background: var(--panel);
    }

    td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        padding: 9px 0;
        border-bottom: 1px solid #edf1ed;
    }

    td:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }

    td::before {
        color: var(--muted);
        font-size: 12px;
        font-weight: 850;
        text-transform: uppercase;
    }

    td:nth-child(1)::before { content: "Auto"; }
    td:nth-child(2)::before { content: "OC"; }
    td:nth-child(3)::before { content: "Przeglad"; }
    td:nth-child(4)::before { content: "Wlasciciel"; }
    td:nth-child(5)::before { content: "Ubezp."; }
    td:nth-child(6)::before { content: "Status"; }
    td:nth-child(7)::before { content: "Akcje"; }

    .vehicle-title strong {
        font-size: 18px;
    }

    .pill {
        justify-self: start;
        min-height: 30px;
    }

    .row-actions {
        display: grid;
        grid-template-columns: 1fr;
        justify-content: stretch;
        gap: 8px;
    }

    .link-button {
        min-height: 42px;
        padding: 0 10px;
        border: 1px solid rgba(17, 106, 92, .22);
        border-radius: 8px;
        background: #f4faf7;
        text-align: center;
    }

    dialog {
        width: calc(100% - 16px);
        max-height: calc(100dvh - 16px);
        margin: auto;
    }

    form {
        max-height: calc(100dvh - 16px);
        overflow: auto;
        padding: 16px;
    }

    .dialog-head {
        align-items: flex-start;
    }

    .dialog-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    #archiveVehicle {
        order: 2;
    }

    label input,
    label textarea {
        min-height: 46px;
        font-size: 16px;
    }
}


/* Visual refresh */
:root {
    --bg: #eef2f5;
    --panel: #ffffff;
    --ink: #111827;
    --muted: #64748b;
    --line: #d8e0e8;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #1d4ed8;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --warning: #a16207;
    --warning-bg: #fef3c7;
    --ok: #15803d;
    --ok-bg: #dcfce7;
    --shadow: 0 18px 50px rgba(15, 23, 42, .10);
}

body {
    min-height: 100vh;
    background:
        linear-gradient(180deg, #0f172a 0, #0f172a 240px, transparent 240px),
        radial-gradient(circle at 20% 0, rgba(20, 184, 166, .22), transparent 34%),
        var(--bg);
}

[hidden] {
    display: none !important;
}

.shell {
    padding: 34px 0 42px;
}

.topbar {
    min-height: 118px;
    padding: 24px;
    color: #fff;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(15, 23, 42, .96), rgba(15, 118, 110, .82));
    box-shadow: 0 24px 70px rgba(2, 6, 23, .22);
}

.topbar .eyebrow {
    color: #99f6e4;
}

.topbar h1 {
    font-size: clamp(32px, 4vw, 54px);
}

.actions {
    align-items: center;
}

.button {
    border-radius: 8px;
    transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.button:hover,
.link-button:hover,
.metric:hover {
    transform: translateY(-1px);
}

.button.primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 12px 26px rgba(15, 118, 110, .22);
}

.button.primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), #1e40af);
}

.topbar .button.ghost {
    color: #e2e8f0;
    background: rgba(255,255,255,.10);
    border-color: rgba(255,255,255,.22);
}

.stats {
    margin-top: 18px;
}

.metric {
    position: relative;
    overflow: hidden;
    min-height: 112px;
    border-color: rgba(148, 163, 184, .28);
}

.metric::after {
    content: "";
    position: absolute;
    inset: auto 16px 14px 16px;
    height: 3px;
    border-radius: 99px;
    background: var(--line);
}

.metric.danger::after { background: var(--danger); }
.metric.warning::after { background: var(--warning); }
.metric.ok::after { background: var(--ok); }
.metric.neutral::after { background: var(--accent); }

.metric.active {
    box-shadow: 0 18px 40px rgba(15, 118, 110, .14);
}

.toolbar {
    padding: 12px;
    border: 1px solid rgba(148, 163, 184, .30);
    border-radius: 8px;
    background: rgba(255,255,255,.82);
    box-shadow: 0 12px 35px rgba(15, 23, 42, .06);
    backdrop-filter: blur(12px);
}

.toolbar input,
.toolbar select,
label input,
label textarea {
    border-color: #cbd5e1;
    background: #fff;
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease;
}

.toolbar input:focus,
.toolbar select:focus,
label input:focus,
label textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, .12);
}

.table-wrap {
    border-color: rgba(148, 163, 184, .32);
}

thead {
    background: #f8fafc;
}

tbody tr:hover {
    background: #f8fbfb;
}

.pill {
    border-radius: 8px;
}

.link-button {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid rgba(15, 118, 110, .18);
    border-radius: 8px;
    background: #f0fdfa;
    color: var(--primary-dark);
}

dialog {
    border-radius: 8px;
}

form {
    background: #fff;
}

.dialog-head {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.icon-button {
    border-radius: 8px;
    background: #f8fafc;
}

.renew-summary {
    background: linear-gradient(135deg, #f8fafc, #ecfeff);
}

.login-screen {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 50% 8%, rgba(45, 212, 191, .22), transparent 32%),
        linear-gradient(145deg, #0f172a, #111827 48%, #0f766e);
}

.login-card {
    width: min(420px, 100%);
    display: grid;
    gap: 16px;
    padding: 26px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 8px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 28px 90px rgba(2, 6, 23, .34);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 4px;
}

.login-brand h1 {
    font-size: 30px;
}

.auth-card {
    width: min(440px, 100%);
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f1f5f9;
}

.auth-tab {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 850;
}

.auth-tab.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 8px 18px rgba(15, 23, 42, .10);
}

.auth-form {
    display: grid;
    gap: 16px;
    padding: 0;
    background: transparent;
}

.brand-mark {
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 900;
}

.login-card .button {
    width: 100%;
    min-height: 48px;
}

@media (max-width: 760px) {
    body {
        background: #eef2f5;
    }

    .topbar {
        padding: 18px;
    }

    .actions {
        grid-template-columns: 1fr 1fr;
    }

    .actions .primary {
        grid-column: 1 / -1;
    }

    .toolbar {
        padding: 10px;
    }

    tbody tr {
        border-color: rgba(148, 163, 184, .36);
    }

    .login-screen {
        padding: 14px;
    }

    .login-card {
        padding: 20px;
    }
}


.archive-panel {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, .32);
    border-radius: 8px;
    background: rgba(255,255,255,.88);
    box-shadow: 0 16px 42px rgba(15, 23, 42, .08);
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.archive-table {
    box-shadow: none;
}

#archiveCount {
    display: inline-grid;
    min-width: 24px;
    height: 24px;
    margin-left: 6px;
    place-items: center;
    border-radius: 8px;
    background: rgba(15, 118, 110, .16);
    color: inherit;
    font-size: 12px;
    font-weight: 900;
}

@media (max-width: 760px) {
    .archive-panel {
        padding: 12px;
    }

    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .archive-panel td:nth-child(1)::before { content: "Auto"; }
    .archive-panel td:nth-child(2)::before { content: "OC"; }
    .archive-panel td:nth-child(3)::before { content: "Przeglad"; }
    .archive-panel td:nth-child(4)::before { content: "Archiwum"; }
    .archive-panel td:nth-child(5)::before { content: "Akcje"; }
}


.archive-toolbar {
    margin: 0 0 12px;
    box-shadow: none;
}

.archive-toolbar input {
    width: 100%;
}

.danger-link {
    border-color: rgba(185, 28, 28, .20);
    background: #fef2f2;
    color: var(--danger);
}

.danger-link:hover {
    border-color: rgba(185, 28, 28, .38);
}
