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

:root {
    --sidebar-w: 280px;
    --clr-bg: #f0f2f5;
    --clr-surface: #ffffff;
    --clr-sidebar-bg: #1a2236;
    --clr-sidebar-text: #c8d0e0;
    --clr-sidebar-active: #ffffff;
    --clr-sidebar-active-bg: #2d3f5e;
    --clr-accent: #3b7de9;
    --clr-border: #e2e6ed;
    --clr-text: #1e2940;
    --clr-text-muted: #6b7a99;
    --clr-error: #d94f4f;
    --clr-row-hover: #f5f7fb;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,.08);
}

html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; font-size: 15px; color: var(--clr-text); background: var(--clr-bg); }

/* ─── Layout ─────────────────────────────────────────────────────────── */
.layout { display: flex; height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--clr-sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
    text-decoration: none;
    opacity: 1;
    transition: opacity .15s;
}

.logo:hover { opacity: .75; }

nav { padding: 10px 0; flex: 1; }

.nav-loading, .nav-error {
    padding: 12px 20px;
    font-size: 13px;
    color: var(--clr-sidebar-text);
}

.nav-error { color: #e07a7a; }

.nav-section {
    padding: 18px 20px 7px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.45);
    user-select: none;
}

.nav-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 11px 10px 11px 20px;
    background: none;
    border: none;
    text-align: left;
    color: var(--clr-sidebar-text);
    font-size: 14px;
    cursor: pointer;
    border-radius: 0;
    transition: background .15s, color .15s;
}

.nav-type-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-right: 9px;
    color: rgba(255,255,255,.35);
}

.nav-type-icon svg { width: 14px; height: 14px; display: block; }

.nav-label { flex: 1; }

.nav-kiosk {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 4px 7px;
    color: rgba(255,255,255,.35);
    transition: color .15s;
    border-radius: 4px;
}

.nav-kiosk svg { width: 14px; height: 14px; display: block; }

.nav-item:hover .nav-kiosk { color: rgba(255,255,255,.55); }
.nav-kiosk:hover            { color: rgba(255,255,255,.95) !important; }

.nav-item:hover { background: rgba(255,255,255,.06); color: var(--clr-sidebar-active); }

.nav-item.active {
    background: var(--clr-sidebar-active-bg);
    color: var(--clr-sidebar-active);
    font-weight: 600;
    border-left: 3px solid var(--clr-accent);
    padding-left: 17px;
}

/* ─── Sidebar footer ─────────────────────────────────────────────────── */
.sidebar-footer {
    padding: 10px 20px 13px;
    font-size: 11px;
    color: rgba(255,255,255,.25);
    border-top: 1px solid rgba(255,255,255,.06);
    word-break: break-all;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toggle-hidden-btn {
    background: none;
    border: none;
    padding: 0;
    color: rgba(255,255,255,.28);
    font-size: 11px;
    cursor: pointer;
    text-align: left;
    transition: color .15s;
}

.toggle-hidden-btn:hover { color: rgba(255,255,255,.6); }

/* ─── Skryté dashboardy v menu ───────────────────────────────────────── */
.nav-item-hidden { opacity: .65; }
.nav-item-hidden:hover { opacity: 1; }

.nav-hidden-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0 4px;
    color: rgba(255,255,255,.3);
}

.nav-hidden-icon svg { width: 13px; height: 13px; display: block; }

/* ─── Main content ───────────────────────────────────────────────────── */
.content { flex: 1; overflow-y: auto; padding: 26px; }

/* ─── Dashboard panel ────────────────────────────────────────────────── */
.dashboard-panel { background: var(--clr-surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--clr-border);
}

.panel-title { font-size: 17px; font-weight: 600; }

.panel-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--clr-text-muted);
}

.refresh-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #eef3fd;
    color: var(--clr-accent);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.refresh-badge::before { content: ''; display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--clr-accent); }

.refresh-badge.refreshing::before { animation: pulse .6s ease-in-out infinite alternate; }

@keyframes pulse { to { opacity: .3; } }

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

/* ─── Table ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
    padding: 12px 18px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--clr-text-muted);
    background: #f8f9fb;
    border-bottom: 1px solid var(--clr-border);
    white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--clr-border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--clr-row-hover); }

td { padding: 12px 18px; font-size: 14px; }

/* ─── Chart ──────────────────────────────────────────────────────────── */
.chart-wrap {
    padding: 26px;
    display: flex;
    justify-content: center;
}

.chart-wrap canvas {
    max-width: 100%;
    max-height: 480px;
}

/* ─── States ─────────────────────────────────────────────────────────── */
.empty-state, .loading-state, .error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--clr-text-muted);
    gap: 10px;
    font-size: 14px;
}

.error-state { color: var(--clr-error); }

.spinner {
    width: 30px; height: 30px;
    border: 3px solid var(--clr-border);
    border-top-color: var(--clr-accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

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

/* ─── Standalone card ────────────────────────────────────────────────── */
.standalone-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
    text-align: center;
    color: #fff;
    transition: background .3s;
}

.standalone-card .card-value {
    font-size: 72px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -2px;
    margin-bottom: 14px;
    text-shadow: 0 2px 12px rgba(0,0,0,.18);
}

.standalone-card .card-description {
    font-size: 20px;
    font-weight: 500;
    opacity: .9;
    margin-bottom: 20px;
}

.standalone-card .card-refresh {
    font-size: 13px;
    opacity: .55;
}

/* ─── Layout container ───────────────────────────────────────────────── */
.layout-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.layout-panel {
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.panel-row-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    margin-bottom: 12px;
    opacity: .8;
}

.layout-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.layout-col {
    min-width: 0;
}

.layout-cell {
    min-height: 80px;
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
}

/* card inside layout */
.layout-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    padding: 20px 16px;
    text-align: center;
    color: #fff;
    border-radius: calc(var(--radius) - 2px);
    box-shadow: 0 1px 5px rgba(0,0,0,.12);
    transition: background .3s;
}

.layout-card .card-value {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1.5px;
    margin-bottom: 8px;
    text-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.layout-card .card-description {
    font-size: 15px;
    font-weight: 600;
    opacity: .9;
    margin-bottom: 8px;
}

.layout-card .card-refresh {
    font-size: 12px;
    opacity: .45;
}

/* table/chart inside layout cell */
.cell-panel { font-size: 13px; }

.cell-panel .panel-header { padding: 12px 16px; }
.cell-panel .panel-title  { font-size: 14px; }

.cell-refresh-badge {
    font-size: 11px;
    color: var(--clr-text-muted);
}

.cell-panel thead th { padding: 9px 12px; font-size: 11px; }
.cell-panel td       { padding: 8px 12px; font-size: 13px; }

.cell-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

.cell-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 80px;
    padding: 16px;
    text-align: center;
}

.cell-error-msg {
    color: var(--clr-error);
    font-size: 12px;
}

.cell-error-refresh {
    font-size: 11px;
    color: var(--clr-text-muted);
}

/* Inline loading/error indikátor v oblasti odpočtu */
.cell-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid rgba(0,0,0,.12);
    border-top-color: var(--clr-accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
}

.layout-card .cell-spinner {
    border-color: rgba(255,255,255,.25);
    border-top-color: rgba(255,255,255,.8);
}

.cell-refresh-err {
    color: var(--clr-error);
    font-size: 11px;
}

/* ─── Kiosk mode (?kiosk=1) ──────────────────────────────────────────── */
body.kiosk .sidebar   { display: none; }
body.kiosk .content   { padding: 18px; }

body.kiosk .panel-title  { font-size: 22px; }
body.kiosk thead th      { font-size: 14px; padding: 14px 20px; }
body.kiosk td            { font-size: 18px; padding: 15px 20px; }
body.kiosk .panel-header { padding: 20px 24px; }

body.kiosk .layout-card .card-value { font-size: 64px; }
body.kiosk .layout-card .card-description { font-size: 16px; }
body.kiosk .layout-card { min-height: 180px; }
