:root {
    --teal: #00a99a;
    --teal-dark: #00877b;
    --teal-light: #e3f6f4;
    --bg: #f4f6f8;
    --card: #ffffff;
    --border: #e4e8ec;
    --text: #202b36;
    --muted: #71808f;
    --green: #1a9e5c;
    --green-light: #e6f6ee;
    --red: #d9463e;
    --red-light: #fceceb;
    --orange: #c98a1c;
    --orange-light: #fdf3e2;
    --sidebar-w: 224px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 21px; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
.page-subtitle { color: var(--muted); margin: 0 0 20px; font-size: 13.5px; }

/* ---------- App shell: sidebar + main ---------- */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 20px;
    font-weight: 700;
    font-size: 16.5px;
    color: var(--text);
}
.sidebar-logo .logo-mark {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 800;
    flex-shrink: 0;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    color: var(--text);
    text-decoration: none;
    padding: 9px 10px;
    border-radius: 7px;
    font-weight: 500;
    font-size: 14px;
}
.sidebar nav a .ic { width: 18px; text-align: center; opacity: .85; }
.sidebar nav a:hover { background: var(--teal-light); }
.sidebar nav a.active { background: var(--teal-light); color: var(--teal-dark); font-weight: 700; }

.sidebar-user {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--teal);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-info .uname { font-weight: 600; font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .logout-link { font-size: 12px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 0; font-family: inherit; }
.sidebar-user .logout-link:hover { color: var(--red); text-decoration: underline; }

.main { flex: 1; min-width: 0; }
.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 32px 32px 60px;
}

/* ---------- Cards / layout primitives ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 12px;
    flex-wrap: wrap;
}

/* ---------- Dashboard stat cards ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
}
.stat-card .stat-label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.stat-card .stat-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat-card.accent-red .stat-value { color: var(--red); }
.stat-card.accent-teal .stat-value { color: var(--teal-dark); }
.stat-card.accent-green .stat-value { color: var(--green); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    background: var(--teal);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
}
.btn:hover { background: var(--teal-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f0f2f5; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b8352e; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.icon-only { display: inline-flex; align-items: center; justify-content: center; padding: 7px; font-size: 15px; line-height: 1; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 11px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
tbody tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}
.badge.vystavena { background: var(--teal-light); color: var(--teal-dark); }
.badge.uhrazena { background: var(--green-light); color: var(--green); }
.badge.stornovana { background: #f1f2f4; color: var(--muted); }
.badge.po_splatnosti { background: var(--red-light); color: var(--red); }
.badge.nahlaseno { background: var(--green-light); color: var(--green); }
.badge.ceka { background: var(--orange-light); color: var(--orange); }

.guest-thumb {
    width: 40px; height: 40px; border-radius: 50%;
    object-fit: cover; background: var(--bg); border: 1px solid var(--border);
    display: block;
}
.guest-thumb-placeholder {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--bg); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 16px;
}
.group-row td { background: var(--bg); padding: 8px 10px; }
.group-title { font-weight: 700; }
.group-toggle-arrow { display: inline-block; width: 14px; color: var(--muted); }

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--teal-dark); }
th.sortable::after { content: ''; display: inline-block; width: 10px; }
th.sortable.sorted[data-dir="asc"]::after { content: '▲'; font-size: 9px; margin-left: 3px; }
th.sortable.sorted[data-dir="desc"]::after { content: '▼'; font-size: 9px; margin-left: 3px; }

.photo-preview {
    position: fixed;
    z-index: 1000;
    display: none;
    max-width: 420px;
    max-height: 420px;
    border: 3px solid var(--card);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
    pointer-events: none;
}

/* ---------- Forms ---------- */
.form-row { margin-bottom: 14px; }
.form-row label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 12.5px;
    color: var(--muted);
}
.form-row input, .form-row select, .form-row textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-light);
}
.form-row textarea { resize: vertical; min-height: 60px; }
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.checkbox-row input { width: auto; }
fieldset.section {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px 4px;
    margin: 0 0 18px;
}
fieldset.section legend {
    padding: 0 6px;
    font-weight: 700;
    font-size: 12.5px;
    color: var(--teal-dark);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.msg { padding: 10px 14px; border-radius: 7px; margin-bottom: 14px; font-size: 13.5px; }
.msg.error { background: var(--red-light); color: var(--red); }
.msg.success { background: var(--green-light); color: var(--green); }
.msg.warning { background: var(--orange-light); color: var(--orange); }

.items-table th, .items-table td { padding: 6px 4px; }
.items-table input { padding: 6px 8px; font-size: 13.5px; }
.items-table .col-popis { width: 40%; }
.items-table .col-num { width: 90px; }

.totals {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}
.totals table { width: 320px; }
.totals td { border: none; padding: 4px 8px; }
.totals tr.grand td { font-size: 18px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 10px; color: var(--teal-dark); }

/* ---------- Login ---------- */
.login-wrap {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--teal-light) 0%, var(--bg) 55%);
}
.login-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 340px;
    box-shadow: 0 12px 32px rgba(0,40,36,.08);
}
.login-box .logo-mark {
    width: 46px; height: 46px; border-radius: 12px;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800; margin: 0 auto 14px;
}
.login-box h1 { text-align: center; margin-bottom: 24px; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,25,30,.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    width: 560px;
    max-width: 92vw;
    max-height: 88vh;
    overflow-y: auto;
}
.modal .modal-actions {
    display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px;
}

/* ---------- Supplier cards (Nastaveni) ---------- */
.supplier-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.supplier-card .supplier-name { font-weight: 700; font-size: 15px; }
.supplier-card .supplier-meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.6; }
.supplier-card .supplier-meta b { color: var(--text); }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}
.empty-state .emoji { font-size: 32px; display: block; margin-bottom: 10px; }

.muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .app-shell { display: block; }
    .container { max-width: none; margin: 0; padding: 0; }
    .card { border: none; padding: 0; }
}

/* Mobilni horni lista s hamburger tlacitkem - na desktopu vzdy skryta (viz min-width blok nize) */
.mobile-topbar {
    display: none;
    align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 60;
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: 10px 14px;
}
.mobile-topbar button {
    background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer;
    padding: 4px 6px; color: var(--text);
}
.mobile-topbar .logo-mark {
    width: 26px; height: 26px; border-radius: 7px;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; flex-shrink: 0;
}
.mobile-topbar-title { font-weight: 700; font-size: 15.5px; }
.mobile-menu-backdrop { display: none; }

@media (max-width: 860px) {
    .app-shell { flex-direction: column; }
    .container { padding: 16px 14px 40px; }
    .mobile-topbar { display: flex; }

    /* Sidebar -> klasicky vysouvaci panel (drawer) zpoza hamburger tlacitka, misto sloupce
       natrvalo zabirajiciho polovinu uzke obrazovky. Skryty mimo obrazovku vlevo, dokud .open
       (viz mountShell() v app.js, ktere zapina/vypina tuhle tridu). */
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 260px; max-width: 82vw; height: 100vh;
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 80;
        box-shadow: 2px 0 16px rgba(15,25,30,.18);
    }
    .sidebar.open { transform: translateX(0); }

    .mobile-menu-backdrop.open {
        display: block;
        position: fixed; inset: 0;
        background: rgba(15,25,30,.45);
        z-index: 70;
    }

    /* Tabulky - horizontalni scroll misto premacknuti/preteceni sloupcu mimo obrazovku */
    table { display: block; overflow-x: auto; white-space: nowrap; }

    .modal { padding: 16px; width: auto; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar > div { width: 100%; flex-wrap: wrap; }
    .supplier-card { flex-direction: column; }

    .stat-grid { grid-template-columns: 1fr; }
    .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
}
