:root {
    --primary: #0051ad; /* Cloudflare modrá */
    --primary-hover: #003d82;
    --bg: #f9fafb; /* Velmi světle šedá na pozadí */
    --panel-bg: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --radius: 8px;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: var(--panel-bg);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

h1 {
    color: var(--primary);
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 1.1rem;
}

/* Skupiny polí */
fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 25px;
    padding: 25px;
    background: var(--panel-bg);
    transition: box-shadow 0.2s;
}

fieldset:hover {
    box-shadow: var(--shadow);
}

legend {
    font-weight: 600;
    color: var(--primary);
    padding: 0 10px;
    font-size: 1.1rem;
}

/* Grid systém pro responzivitu */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* Form prvky */
.form-group {
    display: flex;
    flex-direction: column;
}

label {
    font-size: 0.9rem;
    margin-bottom: 8px;
    font-weight: 500;
    color: #4b5563;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
    transition: all 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(0,81,173,0.1);
}

/* Tlačítka a akce */
.actions {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 30px;
    z-index: 100;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:active {
    transform: translateY(1px);
}

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

.btn-export {
    background: var(--success);
    color: white;
}
.btn-export:hover { background: var(--success-hover); }

.btn-import {
    background: #f3f4f6;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-import:hover { background: #e5e7eb; }

.btn-print {
    background: #4b5563;
    color: white;
}
.btn-print:hover { background: #374151; }

button[type="reset"] {
    background: transparent;
    color: var(--text-muted);
}
button[type="reset"]:hover { color: var(--danger); }

footer {
    text-align: center;
    margin-top: 40px;
    font-size: 0.85rem;
    color: #9ca3af;
    padding-bottom: 20px;
}

/* Responzivita */
@media (max-width: 768px) {
    body { padding: 10px; }
    
    .container {
        padding: 20px;
    }
    
    .actions {
        padding: 15px;
        margin-left: -20px;
        margin-right: -20px;
        width: calc(100% + 40px);
    }
    
    button {
        width: 100%;
    }
}

/* ===== TISKOVÝ DOKUMENT ===== */

.print-document {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }
    
    .print-document,
    .print-document * {
        visibility: visible;
    }
    
    .print-document {
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white;
        padding: 12mm 15mm;
        font-size: 9pt;
        line-height: 1.3;
        color: black;
    }
    
    /* Hlavička dokumentu - kompaktní */
    .print-header {
        text-align: center;
        border-bottom: 2px solid #000;
        padding-bottom: 8px;
        margin-bottom: 12px;
    }
    
    .print-header h1 {
        font-size: 16pt;
        margin: 0 0 3px 0;
        color: #000;
        font-weight: bold;
    }
    
    .print-year {
        font-size: 11pt;
        margin: 0;
        font-weight: 600;
    }
    
    /* Sekce - minimální mezery */
    .print-section {
        margin-bottom: 10px;
        page-break-inside: avoid;
    }
    
    .print-section h2 {
        font-size: 11pt;
        font-weight: bold;
        margin: 8px 0 5px 0;
        color: #000;
        border-bottom: 1.5px solid #333;
        padding-bottom: 3px;
    }
    
    .print-section h3 {
        font-size: 9.5pt;
        font-weight: 600;
        margin: 6px 0 4px 0;
        color: #000;
    }
    
    /* Tabulky - kompaktní */
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin: 4px 0 8px 0;
        font-size: 8.5pt;
    }
    
    .print-table td,
    .print-table th {
        padding: 3px 6px;
        border: 0.5px solid #666;
        text-align: left;
        line-height: 1.2;
    }
    
    .print-table thead {
        background: #e8e8e8;
        font-weight: bold;
    }
    
    .print-table .label {
        width: 68%;
        font-weight: 500;
        background: #f5f5f5;
    }
    
    .print-table .value {
        width: 32%;
        font-weight: 600;
    }
    
    .print-table.compact td {
        padding: 2px 6px;
    }
    
    .print-table .right {
        text-align: right;
    }
    
    /* Hodnoty mimo tabulky */
    .print-value {
        margin: 2px 0 6px 15px;
        font-weight: 600;
        font-size: 8.5pt;
    }
    
    /* Patička dokumentu - kompaktní */
    .print-footer {
        margin-top: 15px;
        padding-top: 10px;
        border-top: 1.5px solid #333;
        page-break-inside: avoid;
    }
    
    .signature-block {
        margin: 10px 0;
    }
    
    .signature-line {
        margin: 8px 0;
        display: flex;
        align-items: baseline;
        gap: 10px;
        font-size: 8.5pt;
    }
    
    .signature-line > span:first-child {
        font-weight: 600;
        white-space: nowrap;
    }
    
    .underline {
        flex: 1;
        border-bottom: 1px solid #000;
        min-width: 150px;
        padding: 0 8px 2px 8px;
    }
    
    .signature-space {
        min-width: 250px;
    }
    
    .print-meta {
        font-size: 7.5pt;
        color: #666;
        text-align: center;
        margin-top: 10px;
    }
    
    /* Stránkování - minimální okraje */
    @page {
        size: A4;
        margin: 10mm 12mm;
    }
    
    /* Zabránění rozdělení důležitých bloků */
    .print-section,
    .signature-block {
        page-break-inside: avoid;
    }
    
    /* Tabulky mohou být rozděleny, ale ne řádky */
    .print-table {
        page-break-inside: auto;
    }
    
    .print-table tr {
        page-break-inside: avoid;
    }
    
    h2 {
        page-break-after: avoid;
    }
    
    h3 {
        page-break-after: avoid;
        orphans: 3;
    }
}


/* ===== REŽIM NÁHLEDU (volitelné) ===== */
body.print-preview .container {
    display: none;
}

body.print-preview .print-document {
    display: block;
    max-width: 210mm;
    margin: 20px auto;
    padding: 20mm;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    font-size: 11pt;
    line-height: 1.6;
}

body.print-preview .print-header {
    text-align: center;
    border-bottom: 3px solid #000;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

body.print-preview .print-header h1 {
    font-size: 20pt;
    margin: 0 0 5px 0;
    color: #000;
    font-weight: bold;
}

body.print-preview .print-year {
    font-size: 14pt;
    margin: 0;
    font-weight: 600;
}

body.print-preview .print-section {
    margin-bottom: 20px;
}

body.print-preview .print-section h2 {
    font-size: 14pt;
    font-weight: bold;
    margin: 15px 0 10px 0;
    color: #000;
    border-bottom: 2px solid #333;
    padding-bottom: 5px;
}

body.print-preview .print-section h3 {
    font-size: 12pt;
    font-weight: 600;
    margin: 12px 0 8px 0;
    color: #000;
}

body.print-preview .print-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 10pt;
}

body.print-preview .print-table td,
body.print-preview .print-table th {
    padding: 8px 10px;
    border: 1px solid #333;
    text-align: left;
}

body.print-preview .print-table thead {
    background: #f0f0f0;
    font-weight: bold;
}

body.print-preview .print-table .label {
    width: 65%;
    font-weight: 500;
    background: #f9f9f9;
}

body.print-preview .print-table .value {
    width: 35%;
    font-weight: 600;
}

body.print-preview .print-table.compact td {
    padding: 5px 10px;
}

body.print-preview .print-table .right {
    text-align: right;
}

body.print-preview .print-value {
    margin: 5px 0 15px 20px;
    font-weight: 600;
    font-size: 10pt;
}

body.print-preview .print-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid #333;
}

body.print-preview .signature-block {
    margin: 20px 0;
}

body.print-preview .signature-line {
    margin: 15px 0;
    display: flex;
    align-items: baseline;
    gap: 15px;
}

body.print-preview .signature-line > span:first-child {
    font-weight: 600;
    white-space: nowrap;
}

body.print-preview .underline {
    flex: 1;
    border-bottom: 1px solid #000;
    min-width: 200px;
    padding: 0 10px 2px 10px;
}

body.print-preview .signature-space {
    min-width: 300px;
}

body.print-preview .print-meta {
    font-size: 9pt;
    color: #666;
    text-align: center;
    margin-top: 20px;
}
