/* ÚČETNÍ — Modulární fakturační systém */
:root {
    --bg: #1a1a2e;
    --bg2: #16213e;
    --bg3: #0f3460;
    --surface: #1e2a4a;
    --surface2: #253456;
    --border: #2a3a5c;
    --text: #e8e8e8;
    --text2: #a0a8c0;
    --orange: #ffa726;
    --green: #66bb6a;
    --red: #ef5350;
    --blue: #42a5f5;
    --yellow: #ffee58;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}
a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === TOPNAV === */
.topnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
}
.topnav-brand a {
    color: var(--text);
    font-size: 18px;
}
.topnav-brand strong { color: var(--orange); font-size: 22px; }
.firma-name { color: var(--text2); font-size: 14px; margin-left: 8px; }
.topnav-user { display: flex; align-items: center; gap: 16px; color: var(--text2); font-size: 14px; }
.btn-logout {
    background: var(--red);
    color: #fff;
    padding: 4px 14px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
}
.btn-logout:hover { opacity: 0.9; text-decoration: none; }

/* === TABS === */
.tabs-bar {
    display: flex;
    gap: 0;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    color: var(--text2);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.03); text-decoration: none; }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }
.tab-icon { font-size: 16px; }
.mail-badge {
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 4px;
    animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* === CONTENT === */
.content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}
.content h1 { font-size: 24px; margin-bottom: 20px; }
.content h2 { font-size: 18px; margin: 24px 0 12px; color: var(--text2); }

/* === STAT CARDS === */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 36px; font-weight: 700; margin: 4px 0; }
.stat-value.orange { color: var(--orange); }
.stat-value.red { color: var(--red); }
.stat-value.green { color: var(--green); }
.stat-value.blue { color: var(--blue); }
.stat-sub { font-size: 13px; color: var(--text2); }

/* === TABLE === */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.data-table th {
    background: var(--surface2);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text2);
    font-weight: 600;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table .text-right { text-align: right; }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn-primary { background: var(--orange); color: #1a1a2e; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #1a1a2e; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* === FORMS === */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 4px; font-weight: 500; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 2px rgba(255,167,38,0.2);
}
.field textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.field-inline { display: flex; align-items: center; gap: 8px; }

/* === FLASH MESSAGES === */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}
.flash-error { background: rgba(239,83,80,0.15); color: var(--red); border: 1px solid rgba(239,83,80,0.3); }
.flash-success { background: rgba(102,187,106,0.15); color: var(--green); border: 1px solid rgba(102,187,106,0.3); }
.flash-info { background: rgba(66,165,245,0.15); color: var(--blue); border: 1px solid rgba(66,165,245,0.3); }
.flash-warning { background: rgba(255,167,38,0.15); color: var(--orange); border: 1px solid rgba(255,167,38,0.3); }

/* === LOGIN === */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg);
}
.login-box, .install-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.login-box h1, .install-box h1 { text-align: center; color: var(--orange); font-size: 28px; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text2); font-size: 14px; margin-bottom: 24px; }
.install-box { max-width: 540px; }
.install-box ul { margin: 8px 0 8px 20px; color: var(--text2); }
.install-box hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text2);
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

/* === TOOLBAR === */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.toolbar .search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}
.toolbar .search-input:focus { outline: none; border-color: var(--orange); }

/* === FOOTER === */
.footer {
    text-align: center;
    padding: 16px;
    color: var(--text2);
    font-size: 12px;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* === RESPONSIVE — sticky nav + tabs, tabulky scrollovatelné, větší tap targets === */
.topnav { position: sticky; top: 0; z-index: 30; }
.tabs-bar { position: sticky; top: 56px; z-index: 25; }

/* Tabulky vždy v horizontálně scrollovatelném kontejneru */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table-wrap .data-table { min-width: 600px; }

@media (max-width: 1024px) {
    .content { padding: 20px 16px; }
}

@media (max-width: 768px) {
    body { -webkit-text-size-adjust: 100%; }
    .topnav { padding: 10px 14px; }
    .topnav-brand strong { font-size: 18px; }
    .firma-name { display: none; }
    .topnav-user span { display: none; }
    .topnav-user { gap: 8px; }
    .btn-logout { min-height: 36px; display: inline-flex; align-items: center; padding: 4px 12px; }

    .content { padding: 16px 12px; }
    .content h1 { font-size: 20px; margin-bottom: 16px; }

    /* Taby — kompaktní, ikony+text vedle sebe, scroll horizontálně */
    .tabs-bar { padding: 0; top: 52px; }
    .tab { padding: 10px 10px; font-size: 12px; min-height: 44px; gap: 4px; }
    .tab-icon { font-size: 18px; }
    .tab-label { font-size: 11px; }

    /* Tabulky kompaktní */
    .data-table { font-size: 13px; }
    .data-table th, .data-table td { padding: 8px 8px; }
    .data-table th { font-size: 11px; }

    /* Stat karty 1 sloupec na malých mobilech, 2 na větších */
    .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 24px; }

    /* Formuláře vždy v jednom sloupci */
    .field-row { grid-template-columns: 1fr; gap: 12px; }
    .field input, .field select, .field textarea { font-size: 16px; min-height: 44px; padding: 10px 12px; } /* 16px = no zoom on iOS */
    .field textarea { min-height: 88px; }

    /* Buttony — větší tap targets */
    .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
    .btn-sm { min-height: 36px; padding: 8px 12px; font-size: 12px; }

    /* Toolbar full-width search */
    .toolbar { gap: 8px; }
    .toolbar .search-input { min-height: 44px; font-size: 16px; }

    /* Detail faktury grid → jeden sloupec */
    .content > div[style*="grid-template-columns:2fr 1fr"],
    .content > div[style*="grid-template-columns: 2fr 1fr"] { display: block !important; }
    .content > div[style*="grid-template-columns:2fr 1fr"] > * { margin-bottom: 16px; }

    .login-box, .install-box { margin: 16px; padding: 24px; }
}

@media (max-width: 480px) {
    .stat-cards { grid-template-columns: 1fr; }
    .tab-label { display: none; }
    .tab { padding: 12px 14px; }
    .tab-icon { font-size: 22px; }
    .topnav-brand strong { font-size: 16px; }
    .content h1 { font-size: 18px; }
}

/* Bezpečné insety pro iPhone notch/home bar */
@supports (padding: env(safe-area-inset-top)) {
    .topnav { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
    .footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* === BADGE === */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}
.badge-orange { background: var(--orange); color: #1a1a2e; }
.badge-green { background: var(--green); color: #1a1a2e; }
.badge-red { background: var(--red); }
.badge-blue { background: var(--blue); }
.badge-gray { background: #78909c; }

/* === CARD === */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

/* === PAGINATION === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text2);
}
.pagination a:hover { border-color: var(--orange); color: var(--orange); text-decoration: none; }
.pagination .active { background: var(--orange); color: #1a1a2e; border-color: var(--orange); font-weight: 600; }
