:root {
    --background: #f5f7f8;
    --surface: #ffffff;
    --text: #172126;
    --muted: #5c6b73;
    --border: #d7e0e4;
    --primary: #006b7d;
    --primary-hover: #005564;
    --danger: #a72828;
    --danger-hover: #861e1e;
    --warning: #8a5a00;
    --success: #176b3a;
    --focus: #ffbf47;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

/* HTML hidden attribute must win over any display rule (e.g. .login-layout's
   display:grid), otherwise the login screen stays rendered behind other views). */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--background);
    line-height: 1.5;
}

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

button,
a {
    touch-action: manipulation;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.skip-link {
    position: fixed;
    top: -4rem;
    left: 1rem;
    z-index: 100;
    padding: .75rem 1rem;
    color: white;
    background: var(--text);
}

.skip-link:focus {
    top: 1rem;
}

.login-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.login-panel {
    width: min(100%, 28rem);
    display: grid;
    gap: 1.25rem;
}

.site-header {
    min-height: 4.5rem;
    padding: .75rem clamp(1rem, 3vw, 2rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.header-actions,
.toolbar,
.dialog-actions,
.pagination {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.app-layout {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    min-height: calc(100vh - 4.5rem);
}

.main-nav {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.main-nav button {
    padding: .75rem;
    border: 0;
    border-radius: .35rem;
    text-align: left;
    color: var(--text);
    background: transparent;
    cursor: pointer;
}

.main-nav button:hover {
    background: #eaf1f3;
}

.main-nav button[aria-current="page"] {
    color: white;
    background: var(--primary);
    font-weight: 700;
}

#main-content {
    min-width: 0;
    padding: clamp(1rem, 3vw, 2rem);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.page-header {
    margin-bottom: 1.5rem;
}

.eyebrow {
    margin-bottom: .15rem;
    color: var(--primary);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

.panel {
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .5rem;
}

.grid {
    display: grid;
    gap: 1rem;
}

.action-grid {
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.action-card {
    min-height: 9rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.action-card strong {
    display: block;
    font-size: 2rem;
}

.stack {
    display: grid;
    gap: 1rem;
}

label {
    display: grid;
    gap: .35rem;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    padding: .65rem .75rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid #95a5ad;
    border-radius: .3rem;
}

textarea {
    resize: vertical;
}

.button {
    min-height: 2.6rem;
    padding: .55rem .9rem;
    border: 1px solid transparent;
    border-radius: .3rem;
    font-weight: 700;
    cursor: pointer;
}

.button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.primary {
    color: white;
    background: var(--primary);
}

.primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.secondary {
    color: var(--text);
    background: var(--surface);
    border-color: #95a5ad;
}

.danger {
    color: white;
    background: var(--danger);
}

.danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.message {
    margin-bottom: 1rem;
    padding: .75rem 1rem;
    background: #e8f4f7;
    border-left: .3rem solid var(--primary);
}

.message.error {
    background: #fbeaea;
    border-left-color: var(--danger);
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .5rem;
}

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

th,
td {
    padding: .75rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

th {
    background: #edf2f4;
    font-size: .88rem;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.col-product {
    max-width: 22rem;
    min-width: 12rem;
}

.col-product strong {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 999px;
    background: #e4eaed;
    font-size: .82rem;
    font-weight: 700;
}

.badge.success {
    color: var(--success);
    background: #e4f4ea;
}

.badge.warning {
    color: var(--warning);
    background: #fff2d5;
}

.badge.danger {
    color: var(--danger);
    background: #fbe4e4;
}

.correction-card {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    gap: 1rem;
}

.correction-card img {
    width: 9rem;
    height: 9rem;
    object-fit: cover;
    border: 1px solid var(--border);
    border-radius: .35rem;
}

.timeline {
    margin: 0;
    padding-left: 1.2rem;
}

.timeline li {
    margin-bottom: .75rem;
}

dialog {
    width: min(34rem, calc(100% - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: .5rem;
}

.wide-dialog {
    width: min(64rem, calc(100% - 2rem));
}

dialog::backdrop {
    background: rgb(0 0 0 / .45);
}

.dialog-actions {
    justify-content: flex-end;
    margin-top: 1rem;
}

.two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

/* ---- Restauracje (mapa + lista) ---- */

.restaurants-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.places-map {
    height: min(72vh, 640px);
    min-height: 26rem;
    border: 1px solid var(--border);
    border-radius: .5rem;
    overflow: hidden;
    background: #eef2f3;
    position: sticky;
    top: 1rem;
}

/* Leaflet wraps our marker html in .leaflet-div-icon; reset its default box. */
.leaflet-div-icon {
    background: transparent;
    border: 0;
}

.place-marker {
    display: block;
    width: .85rem;
    height: .85rem;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgb(0 0 0 / .25);
    cursor: pointer;
}

.places-list-panel {
    max-height: min(72vh, 640px);
    display: flex;
    flex-direction: column;
}

.places-list {
    overflow-y: auto;
    flex: 1;
    margin: 0 -.25rem;
}

.places-list table {
    margin: 0;
}

.places-list td {
    cursor: pointer;
}

.places-list tr:hover td {
    background: #eaf1f3;
}

.leaflet-popup-content .hours-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: .82rem;
}

.leaflet-popup-content .hours-day {
    color: var(--muted);
}

.leaflet-popup-content details {
    margin-top: .4rem;
}

@media (max-width: 980px) {
    .restaurants-layout {
        grid-template-columns: 1fr;
    }

    .places-map {
        position: relative;
        top: 0;
        height: 52vh;
        min-height: 20rem;
    }

    .places-list-panel {
        max-height: none;
    }
}

/* ---- Synchronizacje: karty wersji i changelog ---- */

.version-list {
    display: grid;
    gap: .75rem;
}

.version-card {
    padding: .75rem 1rem;
    border: 1px solid var(--border);
    border-radius: .4rem;
    background: #fbfcfd;
}

.version-card .toolbar {
    flex-wrap: wrap;
}

.diff-add { color: var(--success); font-weight: 700; }
.diff-remove { color: var(--danger); font-weight: 700; }
.diff-change { color: var(--warning); font-weight: 700; }

.changelog-detail {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
    display: grid;
    gap: .75rem;
}

.changelog-group h3 {
    font-size: .85rem;
    margin-bottom: .25rem;
}

.changelog-list {
    margin: 0;
    padding-left: 1.1rem;
    display: grid;
    gap: .2rem;
}

.changelog-list li {
    margin-bottom: .15rem;
}

@media (max-width: 760px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .main-nav {
        position: sticky;
        top: 0;
        z-index: 10;
        flex-direction: row;
        overflow-x: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .main-nav button {
        flex: 0 0 auto;
    }

    .correction-card,
    .two-column {
        grid-template-columns: 1fr;
    }

    .site-header {
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

/* Two-factor sign-in */
.enroll-steps {
    margin: 0;
    padding-left: 1.25rem;
    line-height: 1.6;
}

.enroll-qr {
    display: block;
    margin: 0 auto;
    border: 1px solid #d8dee6;
    border-radius: 8px;
    background: #fff;
}

.enroll-secret,
.recovery-codes {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    word-break: break-all;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 1.05rem;
}
