:root {
    --bg:#eceff9;
    --ink:#17191f;
    --muted:#606779;
    --line:#cbd3e5;
    --blue:#2879bd;
    --red:#d81826;
}

* {
    box-sizing:border-box;
}

[hidden] {
    display:none!important;
}

body {
    margin:0;
    background:var(--bg);
    color:var(--ink);
    font:15px/1.5 Arial,Helvetica,sans-serif;
}

header {
    background:#fff;
    border-bottom:1px solid var(--line);
    display:flex;
    align-items:center;
    gap:24px;
    padding:16px 32px;
}

header img {
    width:190px;
    height:auto;
    display:block;
}

header span {
    font-weight:bold;
    color:var(--red);
}

header>a:last-child {
    margin-left:auto;
}

a {
    color:var(--blue);
}

main {
    max-width:1540px;
    margin:auto;
    padding:36px 28px;
}

h1 {
    font-size:32px;
    line-height:1.2;
    margin:8px 0;
}

h2 {
    font-size:20px;
    margin:0 0 10px;
}

h3 {
    font-size:17px;
    margin:0;
}

p {
    margin:8px 0;
}

.eyebrow {
    font-size:12px;
    letter-spacing:1.6px;
    color:var(--red);
    font-weight:bold;
}

.intro {
    margin-bottom:24px;
}

.intro>p:last-child,small {
    color:var(--muted);
}

.panel,.item {
    background:#fff;
    border:1px solid var(--line);
    border-radius:8px;
    padding:24px;
    margin-bottom:20px;
}

.upload {
    display:flex;
    align-items:end;
    gap:18px;
    flex-wrap:wrap;
}

.upload small {
    flex-basis:100%;
}

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

button {
    border:1px solid transparent;
    border-radius:4px;
    padding:11px 16px;
    background:var(--red);
    color:white;
    cursor:pointer;
    font-weight:bold;
}

button.secondary {
    background:white;
    color:var(--ink);
    border-color:var(--line);
}

button:disabled {
    opacity:.55;
    cursor:default;
}

button:focus-visible,summary:focus-visible,a:focus-visible {
    outline:3px solid var(--blue);
    outline-offset:3px;
}

input,textarea,select {
    width:100%;
    border:1px solid var(--line);
    border-radius:4px;
    padding:10px;
    background:white;
    color:var(--ink);
}

input[readonly],textarea[readonly] {
    background:#f8f9fd;
}

label {
    display:flex;
    flex-direction:column;
    gap:6px;
    font-size:13px;
    font-weight:bold;
}

input[type=checkbox] {
    width:auto;
}

label.check {
    flex-direction:row;
    align-items:start;
    font-weight:normal;
}

.workspace {
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(0,1.12fr);
    gap:24px;
}

.preview {
    position:sticky;
    top:20px;
    height:calc(100vh - 40px);
}

iframe {
    width:100%;
    height:calc(100% - 78px);
    border:0;
    margin-top:16px;
    background:#f4f5f9;
}

.progress {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
}

.item header {
    padding:0 0 16px;
    border:0;
    gap:12px;
    flex-wrap:wrap;
}

.badge {
    display:inline-block;
    padding:4px 9px;
    border-radius:4px;
    font-size:12px;
    font-weight:bold;
    background:#edf2fa;
    color:#245a88;
}

.badge.ok {
    background:#e8f4ec;
    color:#24683e;
}

.badge.warn {
    background:#fff3dc;
    color:#825811;
}

.grid {
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:14px;
}

.wide {
    grid-column:1/-1;
}

.reason {
    padding:12px;
    background:#f3f5fb;
    border-radius:4px;
    margin-bottom:16px;
}

.actions {
    display:flex;
    flex-wrap:wrap;
    gap:10px;
    margin-top:18px;
}

.item details {
    margin-top:16px;
}

.item summary,.supplementary summary {
    cursor:pointer;
    font-weight:bold;
    margin-bottom:12px;
}

.item .check {
    margin-top:16px;
}

.error {
    color:#ab1420;
}

.item.confirmed {
    border-left:4px solid #3b8b57;
}

.item-message {
    white-space:pre-wrap;
}

.search {
    display:flex;
    gap:8px;
    margin:12px 0;
}

.search input {
    min-width:0;
}

.search-results {
    max-height:300px;
    overflow:auto;
    display:grid;
    gap:8px;
}

.search-results button {
    text-align:left;
    font-size:13px;
}

.history-row {
    display:flex;
    gap:16px;
    justify-content:space-between;
    align-items:center;
    padding:12px 0;
    border-top:1px solid var(--line);
}

pre {
    white-space:pre-wrap;
    overflow-wrap:anywhere;
    font-size:12px;
}

#status {
    white-space:pre-wrap;
    margin:16px 0;
}

.supplementary {
    margin-top:12px;
}

.count {
    color:var(--muted);
    font-size:13px;
}

.warning-list {
    color:#825811;
    font-size:13px;
}

@media(max-width:950px) {
    .workspace {
        grid-template-columns:1fr;
    }

    .preview {
        position:static;
        height:550px;
    }

    header {
        padding:12px 16px;
        gap:12px;
    }

    header img {
        width:140px;
    }

    header span {
        font-size:12px;
    }

    main {
        padding:24px 16px;
    }

    .panel,.item {
        padding:18px;
    }

}

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

    .wide {
        grid-column:auto;
    }

    .progress {
        display:block;
    }

    .progress button {
        margin-top:10px;
    }

    header>a:last-child {
        font-size:12px;
    }

}

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

table {
    width:100%;
    border-collapse:collapse;
    font-size:14px;
}

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

th {
    background:#f1f3fb;
}

.detail-row>td {
    padding:18px;
    background:#f8f9fd;
}

.detail-row .item {
    margin-bottom:12px;
}

.preview iframe {
    height:calc(100% - 112px);
}

#result,#save-preview {
    white-space:pre-wrap;
}

#party-fields {
    margin-top:20px;
}

#party-fields fieldset {
    border:1px solid var(--line);
    border-radius:4px;
    padding:14px;
}

#party-fields fieldset label {
    margin-bottom:10px;
}

#header-warning {
    margin-top:12px;
}

.item .grid {
    margin-top:14px;
}

.actions {
    align-items:center;
}

.card-choice {
    margin-bottom:12px;
}

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

.badge.review {
    background:#fde9eb;
    color:#ad1123;
    border:1px solid #efb4bc;
}

.badge.proposal {
    background:#edf2fa;
    color:#245a88;
}

.delivery-heading {
    border-top:1px solid var(--line);
    padding-top:18px;
    margin:12px 0 0;
    font-size:15px;
}

.item .grid input {
    min-width:0;
}

#result {
    font-weight:600;
}

/* Stav zpracování vedle tlačítka importu */
.import-status {
    display: inline-flex;
    align-items: center;
    align-self: flex-end;
    gap: 8px;
    min-height: 46px;
    color: var(--muted);
    font-size: 13px;
    font-weight: normal;
}

.import-spinner {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    border: 2px solid var(--line);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: import-spin 0.9s linear infinite;
}

#import-elapsed {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

@keyframes import-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .import-spinner {
        animation: none;
    }
}

/* Přihlášení */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
}

.login-shell {
    width: 100%;
    max-width: 460px;
    padding: 28px 20px;
    margin: auto;
}

.login-card {
    padding: 40px 32px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(35, 57, 97, 0.06);
}

.login-logo {
    display: block;
    width: 230px;
    max-width: 100%;
    height: auto;
    margin: 0 auto 30px;
}

.login-card h1 {
    text-align: center;
    font-size: 24px;
    margin: 0 0 8px;
}

.login-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-form {
    display: grid;
    gap: 8px;
}

.login-form input {
    margin-bottom: 12px;
    min-height: 46px;
}

.login-form input:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

.login-form button {
    width: 100%;
    min-height: 46px;
}

.login-error {
    color: #ad1123;
    font-size: 13px;
    margin: 0 0 8px;
}

.login-error:empty {
    display: none;
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.header-actions form {
    margin: 0;
}

@media (max-width: 520px) {
    .login-card {
        padding: 30px 22px;
    }

    .app-header {
        flex-wrap: wrap;
    }
}
