:root {
    --rf-navy: #0a2540;
    --rf-blue: #1f6fe5;
    --rf-blue-dark: #1559c4;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --heading: #0a2540;
    --shadow: rgba(10, 37, 64, 0.08);
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
}

[data-theme="dark"] {
    --rf-navy: #e6edf6;
    --rf-blue: #5b9bf3;
    --rf-blue-dark: #78acf5;
    --bg: #0e1726;
    --surface: #16202e;
    --surface-2: #1d2a3a;
    --border: #2a3a4f;
    --text: #d8e0ea;
    --muted: #93a1b3;
    --heading: #e6edf6;
    --shadow: rgba(0, 0, 0, 0.45);
    --success: #2ecc71;
    --danger: #ff6b5e;
    --warning: #f5b041;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    font-weight: 700;
    color: var(--heading);
    text-decoration: none;
    font-size: 1.1rem;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem 0.7rem;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--text);
    cursor: pointer;
}

@media (max-width: 640px) {
    .nav-toggle {
        display: inline-flex;
    }
    .topnav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        padding: 0.6rem;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 6px 16px var(--shadow);
    }
    .topnav.is-open {
        display: flex;
    }
    .topnav .btn {
        width: 100%;
        justify-content: flex-start;
    }
    .topnav .icon-btn {
        align-self: flex-start;
    }
}

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem;
}

.container-wide {
    max-width: 90vw;
}

.container-day {
    max-width: 56rem;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.settings-link {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    text-decoration: none;
    color: var(--text);
}

.settings-link strong {
    color: var(--heading);
    font-size: 1.1rem;
}

.settings-link:hover {
    border-color: var(--rf-blue);
}

.harek-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}

.harek-fields label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.harek-fields input {
    width: 7rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
}

.harek-stojan {
    margin-top: 0.75rem;
}

.harek-grid input {
    width: 5rem;
}

.harek-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 2rem;
    font-size: 1.05rem;
}

.harek-summary b {
    color: var(--rf-blue);
}

.harek-badge {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.5rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.harek-badge.is-offline {
    background: var(--danger);
    color: #fff;
}

.harek-badge.is-pending {
    background: var(--warning);
    color: #1e293b;
}

.harek-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-left: 0.5rem;
    width: 1.8rem;
    height: 1.8rem;
    border: none;
    border-radius: 50%;
    background: var(--success);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
}

.harek-badge[hidden], .harek-refresh[hidden] {
    display: none;
}

.harek-zones {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 0.85fr) minmax(0, 1.25fr);
    gap: 0.6rem;
    align-items: start;
    margin-bottom: 1rem;
}

@media (max-width: 1100px) {
    .harek-zones {
        grid-template-columns: 1fr;
    }
}

.harek .card {
    padding: 0.5rem;
}

.harek > .card {
    max-width: 34rem;
}

.hz-left {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
}

.hz-left > .card {
    width: fit-content;
    margin-bottom: 0;
}

.hz-left > .card:last-child {
    flex-basis: 100%;
    width: auto;
}

.hz-right .card {
    margin-bottom: 0.6rem;
}

.fakt-boxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.fakt-box {
    width: fit-content;
    margin-bottom: 0;
}

.fakt-add {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.fakt-add select {
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.fakt-add .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

.prodej-block h3, .hz-right h3 {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.harek .card h2 {
    font-size: 1rem;
}

.pl-grid.harek-dyn, .pl-grid.harek-grid, .pl-grid.summary-grid {
    width: auto;
}

.pl-grid.harek-dyn th,
.pl-grid.harek-dyn td,
.pl-grid.harek-grid th,
.pl-grid.harek-grid td,
.summary-grid td {
    padding: 0.15rem 0.3rem;
    font-size: 0.8rem;
}

.pl-grid.harek-dyn input,
.pl-grid.harek-grid input,
.summary-grid input {
    box-sizing: border-box;
    padding: 0.35rem 0.4rem;
    font-size: 0.9rem;
}

.harek input[data-f="price"],
.harek input[data-f="ks"] {
    width: 4rem;
}

.pl-grid.harek-grid input[data-f="price"],
.pl-grid.harek-grid input[data-f="ks"] {
    width: 7rem;
}

.harek input[data-f="amount"] {
    width: 6.5rem;
}

.harek input[data-f="label"] {
    width: 8rem;
}

.summary-grid input {
    width: 7rem;
}

.summary-grid .pl-name {
    text-align: left;
}

/* Šířky tabulek Hárku; faktury mají vlastní rozložení. */
.hz-left > .prodej-block {
    width: 11rem;
    max-width: 100%;
}

.prodej-block .harek-dyn,
.harek-grid[data-section="zaloha"],
.hz-mid .summary-grid,
.harek-dyn[data-dyn="firemni"],
.harek-dyn[data-dyn="ostatni"] {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.prodej-block .harek-dyn th:first-child,
.prodej-block .harek-dyn td:first-child {
    width: 60%;
}

.prodej-block .harek-dyn input,
.pl-grid.harek-grid[data-section="zaloha"] input[data-f],
.hz-mid .summary-grid input,
.harek-dyn[data-dyn="firemni"] input,
.harek-dyn[data-dyn="ostatni"] input {
    width: 100%;
    min-width: 0;
}

.harek-grid[data-section="zaloha"] th:first-child {
    width: 20%;
}

.harek-grid[data-section="zaloha"] th:not(:first-child) {
    width: 40%;
}

.hz-mid .summary-grid td:first-child {
    width: 35%;
}

.hz-mid .summary-grid .pl-sum {
    text-align: right;
    overflow-wrap: anywhere;
}

.harek-dyn[data-dyn="firemni"] th:first-child,
.harek-dyn[data-dyn="ostatni"] th:first-child {
    width: 70%;
}

@media (max-width: 640px) {
    .harek-page {
        max-width: 100%;
        padding: 0.75rem;
    }

    .harek-page .day-nav input[type="date"] {
        min-width: 0;
    }

    .hz-left > .prodej-block {
        width: calc((100% - 0.5rem) / 2);
    }

    .prodej-block .harek-dyn input,
    .pl-grid.harek-grid[data-section="zaloha"] input[data-f],
    .hz-mid .summary-grid input,
    .harek-dyn[data-dyn="firemni"] input,
    .harek-dyn[data-dyn="ostatni"] input {
        font-size: 1rem;
        padding: 0.4rem 0.2rem;
    }

    .hz-mid .summary-grid td:first-child {
        width: 40%;
    }
}

.summary-final .sf-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.35rem 0;
    font-size: 1.15rem;
}

.summary-final .sf-row b {
    color: var(--rf-blue);
}

.summary-final .sf-odvod {
    font-size: 1.4rem;
    font-weight: 700;
    border-top: 1px solid var(--border);
    margin-top: 0.25rem;
    padding-top: 0.5rem;
}

.fakt-box {
    margin-bottom: 0.9rem;
}

.fakt-name {
    font-weight: 700;
    background: var(--surface-2);
    padding: 0.3rem 0.5rem;
    border-radius: 6px 6px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
}

.harek-attach label.btn {
    cursor: pointer;
}

.attach-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.attach-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.attach-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.attach-dl,
.attach-actions .attach-del {
    font-size: 0.85rem;
    line-height: 1.2;
    padding: 0;
}

.attach-dl {
    color: var(--rf-blue);
    text-decoration: none;
}

.attach-item img {
    max-width: 11rem;
    max-height: 8rem;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.attach-file {
    display: inline-block;
    padding: 1.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.doch-grid input[type="text"], .doch-grid input[type="number"] {
    width: 3rem;
}

.doch-grid th, .doch-grid td {
    font-size: 0.85rem;
}

.doch-wk td.pl-name {
    color: var(--rf-blue);
    font-weight: 700;
}

.doch-saved {
    outline: 2px solid var(--rf-blue);
}

.doch-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 0.75rem;
    font-size: 0.95rem;
}

.doch-summary b {
    color: var(--rf-blue);
}

.doch-head {
    margin-bottom: 1rem;
}

.doch-head form {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 20rem;
}

.doch-head label {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.doch-plan summary {
    cursor: pointer;
    font-weight: 600;
}

.doch-plan[open] summary {
    margin-bottom: 0.75rem;
}

.doch-plan form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
}

.doch-plan .row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.doch-weekdays {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0;
}

.doch-weekdays label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.page-head select, .day-nav select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
}

h1, h2, h3 {
    color: var(--heading);
    margin-bottom: 0.75rem;
}

a {
    color: var(--rf-blue);
    text-decoration: none;
}

a:hover {
    color: var(--rf-blue-dark);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px var(--shadow);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1.1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--rf-blue);
    color: #fff;
    text-decoration: none;
}

.btn:hover {
    background: var(--rf-blue-dark);
    color: #fff;
}

.btn-block {
    width: 100%;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--text);
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.flash-error {
    background: rgba(231, 76, 60, 0.12);
    border-color: var(--danger);
    color: var(--danger);
}

.flash-success {
    background: rgba(39, 174, 96, 0.12);
    border-color: var(--success);
    color: var(--success);
}

.auth-wrap {
    max-width: 360px;
    margin: 3rem auto;
}

.text-center {
    text-align: center;
}

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

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    opacity: 0.9;
    color: #fff;
}

.tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    margin-left: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--rf-blue);
    color: #fff;
}

.user-row {
    margin-bottom: 0.75rem;
}

.inline-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.inline-form input {
    flex: 1;
    min-width: 140px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text);
}

.checkbox-label input {
    width: auto;
}

select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.segmented {
    display: flex;
    gap: 0.5rem;
}

.seg-option {
    flex: 1;
    margin: 0;
}

.seg-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.seg-option span {
    display: block;
    text-align: center;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

.seg-option input:checked + span {
    background: var(--rf-blue);
    border-color: var(--rf-blue);
    color: #fff;
}


.user-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.user-edit {
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
}

.user-edit + .inline-form {
    margin-top: 0.75rem;
}

.user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.role-opts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.role-opt {
    margin: 0;
}

.role-opt input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.role-opt span {
    display: inline-block;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

.role-opt input:checked + span {
    background: var(--rf-blue);
    border-color: var(--rf-blue);
    color: #fff;
}

.group-title {
    margin-top: 1.25rem;
    font-size: 1.1rem;
    color: var(--muted);
}

.price-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.price-current {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--rf-blue);
}

.price-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.price-form input[type="text"],
.price-form input[type="date"] {
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
}

.price-form input[name="value"],
.price-form input[name="name"] {
    flex: 1;
    min-width: 100px;
}

[data-theme="dark"] .price-form input[type="date"] {
    color-scheme: dark;
}

[data-theme="light"] .price-form input[type="date"] {
    color-scheme: light;
}

.price-history {
    margin-top: 0.75rem;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.price-ver {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
}

.price-ver:last-child {
    border-bottom: none;
}

.fakturanti-head {
    margin-bottom: 0.75rem;
}

.inv-col-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    font-size: 1.05rem;
    cursor: pointer;
}

.inv-col-row input {
    width: 1.3rem;
    height: 1.3rem;
}

.fakturant-row {
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.fakturant-row > span {
    overflow-wrap: anywhere;
}

.fakturant-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-left: auto;
}

.btn-link-danger {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}

.pl-day-head {
    margin-bottom: 0.75rem;
}

.pl-month-head + .day-nav {
    margin-top: 0.75rem;
}

.day-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.day-nav input[type="date"],
.day-nav .month-label {
    flex: 0 1 14rem;
    max-width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
}

[data-theme="dark"] .day-nav input[type="date"] {
    color-scheme: dark;
}

[data-theme="light"] .day-nav input[type="date"] {
    color-scheme: light;
}

.pl-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pl-grid {
    border-collapse: collapse;
    width: 100%;
    min-width: max-content;
}

.pl-grid.pl-day {
    width: auto;
}

.pl-grid.pl-day th, .pl-grid.pl-day td {
    width: 4.4rem;
}

.pl-grid.pl-day th:first-child, .pl-grid.pl-day td:first-child {
    width: 9.5rem;
}

.pl-rowform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.pl-rowform:last-child {
    margin-bottom: 0;
}

.pl-rowform .pl-scroll {
    min-width: 0;
}

.pl-save {
    display: inline-flex;
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.pl-kgks {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.5rem;
    margin-top: 0.6rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.pl-kgks b {
    color: var(--rf-blue);
}

.container-day h2, .container-day h3 {
    text-align: center;
}

.container-day .pl-grid {
    width: auto;
    margin-left: auto;
    margin-right: auto;
}

.unsaved-list {
    margin: 0.5rem 0 1rem;
    padding-left: 1.25rem;
}

.unsaved-list li {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.modal-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.modal-actions .btn {
    flex: 1;
}

.pl-grid th, .pl-grid td {
    border: 1px solid var(--border);
    padding: 0.25rem;
    text-align: center;
    font-size: 0.9rem;
}

.pl-grid th {
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
    font-size: 0.78rem;
}

.pl-grid input {
    width: 3.2rem;
    padding: 0.4rem 0.2rem;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    touch-action: manipulation;
}

.pl-name {
    text-align: left;
    white-space: nowrap;
    font-weight: 600;
}

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

.pl-sum {
    font-weight: 700;
    color: var(--rf-blue);
    background: var(--surface-2);
}

.inventura-head {
    margin-bottom: 0.75rem;
}

.inventura-meta {
    margin-bottom: 1rem;
}

.inv-grid input {
    width: 4rem;
}

.inv-diff {
    color: #fff;
    background: var(--danger);
    font-weight: 700;
}

.month-label {
    text-align: center;
}

.pl-grid tfoot td {
    border-top: 2px solid var(--muted);
    font-weight: 700;
}

/* ===== počítací modal (přeneseno z inventury - na chlup stejné) ===== */
.item-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 1.05rem;
    cursor: pointer;
    text-align: left;
    touch-action: manipulation;
}

.item-btn:active {
    background: var(--border);
}

.item-count {
    min-width: 2.5rem;
    text-align: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--rf-blue);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.2rem 0.5rem;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(10, 37, 64, 0.55);
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.modal.is-open {
    display: flex;
}

.modal-box {
    background: var(--surface);
    width: 100%;
    max-width: 480px;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    padding: 1rem;
    box-shadow: 0 -4px 20px var(--shadow);
}

.calc-nav {
    max-height: 28vh;
    overflow-y: auto;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.nav-group {
    margin-bottom: 0.5rem;
}

.nav-group-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.nav-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
    touch-action: manipulation;
}

.nav-item.active {
    background: var(--rf-blue);
    border-color: var(--rf-blue);
    color: #fff;
}

.ni-count {
    min-width: 1.3rem;
    text-align: center;
    font-weight: 700;
    background: var(--surface);
    color: var(--rf-blue);
    border-radius: 999px;
    padding: 0 0.3rem;
}

.nav-item.active .ni-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

@media (min-width: 560px) {
    .modal {
        align-items: center;
    }
    .modal-box {
        border-radius: 16px;
    }
}

.modal-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--heading);
    text-align: center;
    margin-bottom: 0.75rem;
}

.calc-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.calc-pm {
    width: 3.2rem;
    height: 3.2rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 1.8rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

.calc-pm:active {
    background: var(--border);
}

.calc-value {
    flex: 1;
    text-align: center;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--rf-blue);
}

.calc-display {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.75rem;
    min-height: 3.4rem;
    text-align: right;
}

.calc-expr {
    font-size: 1.1rem;
    color: var(--text);
    min-height: 1.4rem;
    word-break: break-all;
}

.calc-result {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--muted);
    min-height: 1.6rem;
}

.calc-keys {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.calc-key {
    height: 3.4rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
}

.calc-key:active {
    background: var(--surface-2);
}

.calc-op {
    background: var(--surface-2);
    color: var(--rf-blue);
}

.calc-fn {
    background: var(--surface-2);
    color: var(--muted);
}

.calc-zero {
    grid-column: span 2;
}

.calc-actions {
    display: flex;
    gap: 0.5rem;
}

.calc-actions .btn {
    flex: 1;
    height: 3.2rem;
    font-size: 1.1rem;
}

@media (max-height: 740px) {
    .modal-box {
        padding: 0.6rem;
    }
    .calc-nav {
        max-height: 17vh;
        margin-bottom: 0.5rem;
    }
    .modal-title {
        font-size: 1rem;
        margin-bottom: 0.4rem;
    }
    .calc-top {
        margin-bottom: 0.5rem;
    }
    .calc-pm {
        width: 2.8rem;
        height: 2.8rem;
        font-size: 1.5rem;
    }
    .calc-value {
        font-size: 1.9rem;
    }
    .calc-display {
        min-height: 2.6rem;
        padding: 0.4rem 0.6rem;
        margin-bottom: 0.5rem;
    }
    .calc-expr {
        font-size: 1rem;
        min-height: 1.2rem;
    }
    .calc-result {
        font-size: 1.1rem;
        min-height: 1.3rem;
    }
    .calc-keys {
        gap: 0.35rem;
        margin-bottom: 0.5rem;
    }
    .calc-key {
        height: 2.8rem;
        font-size: 1.2rem;
    }
    .calc-actions .btn {
        height: 2.8rem;
        font-size: 1rem;
    }
}

.sync-status {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.sync-status.is-ok {
    background: rgba(39, 174, 96, 0.15);
    color: var(--success);
}

.sync-status.is-pending {
    background: rgba(243, 156, 18, 0.15);
    color: var(--warning);
}

.sync-status.is-offline {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
}

.item-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
}

.item-sub {
    font-size: 0.78rem;
    color: var(--muted);
}

.item-btn.has-diff .item-sub {
    color: var(--danger);
    font-weight: 600;
}

.item-btn.has-diff {
    border-color: var(--danger);
}

.month-grid th, .month-grid td {
    padding: 0.15rem 0.3rem;
    font-size: 0.72rem;
    white-space: nowrap;
}

.month-grid .pl-stav {
    background: var(--surface-2);
    font-weight: 600;
}

.month-grid [class^="sec-"] { color: #1e293b; }
.month-grid .sec-stav     { background: #f9d5d3; }
.month-grid .sec-fill0    { background: #fff3b0; }
.month-grid .sec-fill1    { background: #ffe08a; }
.month-grid .sec-fill2    { background: #e2f0cb; }
.month-grid .sec-pumpa    { background: #cdeccd; }
.month-grid .sec-jarek    { background: #fde1b8; }
.month-grid .sec-pocerny  { background: #f8c9a0; }
.month-grid .sec-vyr      { background: #ffd0a6; }
.month-grid .sec-zap      { background: #cdeccd; }
.month-grid .sec-vykup    { background: #e0d4fb; }
.month-grid thead th[class^="sec-"] { font-weight: 700; }

.month-grid .grp-full,
.month-grid .grp-empty {
    background: #e74c3c;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.month-grid .divider-col {
    background: #111;
    padding: 0;
    width: 4px;
    min-width: 4px;
    border: none;
}

.month-grid .month-start td {
    background: #fbe9d0;
    font-weight: 600;
}

.month-grid .month-start .divider-col {
    background: #111;
}
.month-grid .month-start td { color: #1e293b; }
.month-grid .sec-odvoz { background: #ffbe9b; }
