:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #61708a;
    --border: #d6dce5;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-soft: #e8f0fe;
    --ok-bg: #e7f6ec;
    --ok-border: #9ad8b0;
    --ok-text: #14532d;
    --err-bg: #fdecec;
    --err-border: #eeaaaa;
    --err-text: #7f1d1d;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.25rem 2.5rem;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

h1,
h2,
h3 {
    line-height: 1.25;
}

h1 {
    font-size: 1.65rem;
    margin: 0 0 1rem;
}

h2 {
    font-size: 1.2rem;
    margin: 1.75rem 0 0.75rem;
}

p {
    margin: 0.6rem 0;
}

a {
    color: var(--accent-dark);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    color: var(--accent);
}

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Hlavička */

header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

header > a {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
}

header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
}

header nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 0.15rem 0;
    border-bottom: 2px solid transparent;
}

header nav a:hover {
    color: var(--accent-dark);
    border-bottom-color: var(--accent);
}

header .user-email {
    margin-left: auto;
    color: var(--muted);
    font-size: 0.9rem;
}

header form {
    margin: 0;
}

header button {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
    font-weight: 500;
}

header button:hover {
    background: #fff;
    border-color: var(--accent);
    color: var(--accent-dark);
}

/* Obsah */

main > section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.4rem;
}

section section {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

/* Tabuľky */

.table-wrap {
    overflow-x: auto;
    margin: 0.75rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

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

thead th {
    background: #f1f4f8;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr:hover {
    background: #f9fbfd;
}

tfoot th {
    background: #f1f4f8;
}

td.quantity,
th.quantity {
    text-align: right;
    white-space: nowrap;
}

tr.is-editing {
    background: var(--accent-soft);
}

/* Kalendár */

.calendar {
    table-layout: fixed;
}

.calendar th {
    text-align: center;
}

.calendar td {
    height: 4.3rem;
    padding: 0;
}

.calendar-empty {
    background: #fafbfc;
}

.calendar-day a {
    display: flex;
    align-items: flex-start;
    height: 100%;
    padding: 0.45rem 0.55rem;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.calendar-day a:hover {
    background: var(--accent-soft);
}

.calendar-day.is-weekend {
    background: #fbfcfe;
}

.calendar-day.is-today {
    background: var(--accent-soft);
}

.calendar-day.is-today a {
    color: var(--accent-dark);
    font-weight: 700;
}

/* Formuláre */

form {
    margin: 0.75rem 0;
}

label {
    display: inline-block;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    font-weight: 600;
}

input,
select,
textarea {
    max-width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="month"],
input[type="date"],
input[type="number"],
select {
    width: min(22rem, 100%);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
}

button {
    display: inline-block;
    padding: 0.5rem 0.95rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

button:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

button[data-confirm] {
    background: #b91c1c;
    border-color: #b91c1c;
}

button[data-confirm]:hover {
    background: #991b1b;
    border-color: #991b1b;
}

.inline-form {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin: 0.15rem 0.4rem 0.15rem 0;
}

.inline-form label {
    margin-bottom: 0;
}

.entry-form p,
.catalog-add-form p {
    margin: 0.7rem 0;
}

.field-error {
    display: block;
    margin-top: 0.3rem;
    color: var(--err-text);
    font-size: 0.85rem;
}

/* Hlásenia */

[role="status"],
[role="alert"] {
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    border: 1px solid;
    margin: 0.75rem 0;
}

[role="status"] {
    background: var(--ok-bg);
    border-color: var(--ok-border);
    color: var(--ok-text);
}

[role="alert"] {
    background: var(--err-bg);
    border-color: var(--err-border);
    color: var(--err-text);
}

/* Číselníky */

.catalog-table input {
    width: min(13rem, 100%);
}

/* Responzívne a tlačové úpravy */

@media (max-width: 700px) {
    body {
        padding: 0 0.75rem 2rem;
    }

    main > section {
        padding: 1rem;
    }

    header .user-email {
        width: 100%;
        margin-left: 0;
    }

    .calendar td {
        height: 3.6rem;
    }
}

@media print {
    body {
        max-width: none;
        padding: 0;
        background: #fff;
        color: #000;
    }

    header,
    nav,
    form,
    button,
    [role="status"],
    [role="alert"],
    .field-error,
    .no-print {
        display: none !important;
    }

    main > section {
        border: 0;
        box-shadow: none;
        padding: 0;
    }

    a {
        color: #000;
        text-decoration: none;
    }

    thead {
        display: table-header-group;
    }

    .calendar-day.is-today {
        background: #e8e8e8 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .entries th:last-child,
    .entries td:last-child {
        display: none;
    }
}
