/* =========================================================
   Admin Systém – Apple iOS Glass UI
   ========================================================= */

:root {
    /* Apple System Colors */
    --primary: #007aff;
    --primary-hover: #0051d5;
    --primary-light: rgba(0, 122, 255, .12);

    --success: #34c759;
    --success-light: rgba(52, 199, 89, .12);
    --warning: #ff9500;
    --warning-light: rgba(255, 149, 0, .12);
    --danger: #ff3b30;
    --danger-light: rgba(255, 59, 48, .12);

    /* Apple System Grays */
    --gray-100: #f2f2f7;
    --gray-200: #e5e5ea;
    --gray-300: #d1d1d6;
    --gray-400: #c7c7cc;
    --gray-500: #aeaeb2;
    --gray-600: #8e8e93;

    /* Glass surfaces */
    --glass: rgba(255, 255, 255, .72);
    --glass-strong: rgba(255, 255, 255, .88);
    --glass-hover: rgba(255, 255, 255, .85);
    --glass-border: rgba(0, 0, 0, .06);

    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-hover: #f9f9fb;

    --border: var(--gray-200);
    --border-light: var(--gray-100);
    --text: #000000;
    --text-secondary: #3a3a3c;
    --text-tertiary: #8e8e93;

    --radius: 10px;
    --radius-lg: 14px;
    --radius-sm: 6px;
    --radius-xl: 20px;

    --shadow: 0 1px 3px rgba(0, 0, 0, .04), 0 1px 2px rgba(0, 0, 0, .02);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .03);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .08), 0 4px 12px rgba(0, 0, 0, .04);

    --sidebar-width: 230px;
    --topbar-height: 58px;
    --page-padding: 22px;

    --font: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.47059;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* =========================================================
   Layout
   ========================================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar (iOS glass) ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--glass);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 1px 0 8px rgba(0, 0, 0, .04);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height);
    padding: 0 18px;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(219, 234, 254, .55), rgba(191, 219, 254, .35));
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 17px;
}

.sidebar-logo-icon {
    width: 28px;
    height: 28px;
    background: transparent;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 15px;
}

.sidebar-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    border-radius: 6px;
}

.sidebar-toggle span {
    width: 18px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
}

/* ── Firma pod logem (glass) ── */
.firm-cell {
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, .35);
    flex-shrink: 0;
}

button.firm-cell-header,
.firm-cell-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 18px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    background: transparent;
    border: none;
    font: inherit;
    color: inherit;
    text-align: left;
}

.firm-cell-header:hover {
    background: rgba(0, 0, 0, .02);
}

.firm-cell.open .firm-cell-header {
    background: rgba(0, 0, 0, .03);
}

.firm-cell-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,.08);
}

.firm-cell-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.firm-cell-arrow {
    color: var(--gray-500);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.firm-cell.open .firm-cell-arrow {
    transform: rotate(180deg);
}

.firm-cell-body {
    display: none;
    padding: 4px 0;
    border-top: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, .5);
}

.firm-cell.open .firm-cell-body {
    display: block;
}

.firm-cell-option,
.firm-cell-option-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px 8px 36px;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
    border-radius: 0;
}

.firm-cell-option:hover {
    background: rgba(0, 0, 0, .03);
    color: var(--text);
}

.firm-cell-option.active {
    background: rgba(0, 0, 0, .05);
    color: var(--text);
    font-weight: 600;
}

.firm-cell-option-color {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,.06);
}

.firm-cell-option-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.firm-cell-option-check {
    font-size: 12px;
    color: var(--text);
}

.firm-cell-option-empty {
    color: var(--gray-500);
    font-style: italic;
}

.firm-cell-actions {
    display: flex;
    flex-direction: column;
    padding: 8px 18px;
    gap: 2px;
    border-top: 1px solid var(--glass-border);
}

.firm-cell-action {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 5px 0;
    transition: color 0.15s;
    font-weight: 500;
}

.firm-cell-action:hover {
    color: var(--text);
}

/* ── Firma v topbaru (vpravo nahoře) ── */
.firm-cell-topbar {
    position: relative;
    border-bottom: none;
    background: transparent;
    flex-shrink: 0;
}

.firm-cell-topbar .firm-cell-header {
    width: auto;
    padding: 6px 12px 6px 10px;
    border-radius: 20px;
    background: rgba(255,255,255,0.7);
    border: 1.5px solid rgba(19,44,92,0.1);
    transition: all 0.15s;
}

.firm-cell-topbar .firm-cell-header:hover {
    background: #fff;
    border-color: rgba(19,44,92,0.2);
}

.firm-cell-topbar.open .firm-cell-header {
    background: #fff;
    border-color: #132C5C;
    box-shadow: 0 0 0 3px rgba(19,44,92,0.08);
}

.firm-cell-topbar .firm-cell-name {
    max-width: 160px;
    font-size: 13px;
}

.firm-cell-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
}

.firm-cell-option-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 3px;
}

.firm-cell-topbar .firm-cell-body {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 240px;
    border: 1px solid rgba(19,44,92,0.08);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.06);
    background: #fff;
    padding: 6px;
    border-top: none;
    z-index: 200;
}

.firm-cell-topbar .firm-cell-option,
.firm-cell-topbar .firm-cell-option-empty {
    padding: 8px 12px 8px 28px;
    border-radius: 8px;
}

.firm-cell-topbar .firm-cell-option:hover {
    background: #eff6ff;
}

.firm-cell-topbar .firm-cell-option.active {
    background: #e0e7ff;
}

.firm-cell-topbar .firm-cell-actions {
    border-top: 1px solid #f1f5f9;
    padding: 6px 12px;
}

.firm-cell-topbar .firm-cell-action {
    padding: 6px 0;
    border-radius: 6px;
}

@media (max-width: 768px) {
    .firm-cell-topbar .firm-cell-name {
        max-width: 90px;
    }
    .firm-cell-topbar .firm-cell-body {
        min-width: 200px;
    }
}

/* ── Sidebar nav ── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item:hover {
    background: rgba(0, 0, 0, .04);
    color: var(--text);
}

.nav-item.active {
    background: rgba(0, 0, 0, .05);
    color: var(--text);
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.6;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-item.active .nav-icon {
    opacity: 1;
}

.nav-label-pdf {
    font-size: 9px;
    opacity: 0.75;
    margin-left: 3px;
    vertical-align: 1px;
    white-space: nowrap;
}

/* ── Nav oddělovač ── */
.nav-separator {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 10px 12px;
}

/* ── Nav s podpoložkami ── */
.nav-parent {
    cursor: pointer;
}
.nav-arrow {
    margin-left: auto;
    transition: transform 0.2s ease;
    opacity: 0.6;
}
.nav-group.open .nav-arrow {
    transform: rotate(180deg);
}
.nav-children {
    padding-left: 16px;
}
.nav-child {
    font-size: 13px;
    padding: 8px 12px;
    opacity: 0.85;
}
.nav-child .nav-icon svg {
    width: 16px;
    height: 16px;
}

/* ── Hover-expand skupina (rozbaluje se jen šipkou) ── */
.nav-hover-group.open > .nav-children {
    display: block !important;
}
.nav-hover-group.open .nav-arrow {
    transform: rotate(180deg);
}
.nav-hover-group .nav-parent {
    cursor: default;
}
.nav-hover-group .nav-arrow {
    cursor: pointer;
}

/* ── Info panel v záhlaví: na mobilu skrýt ── */
.topbar-info { overflow: hidden; }
.topbar-info svg { flex-shrink: 0; }
@media (max-width: 900px) {
    .topbar-info { display: none !important; }
}

/* ── User footer ── */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, .45);
    backdrop-filter: blur(16px);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-name {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: var(--gray-500);
    font-size: 11px;
}

.logout-btn {
    color: var(--gray-500);
    padding: 7px;
    border-radius: 8px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .25);
    backdrop-filter: blur(2px);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* ── Main content ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar (glass) ── */
.topbar {
    height: var(--topbar-height);
    background: linear-gradient(135deg, rgba(219, 234, 254, .5), rgba(191, 219, 254, .3)), var(--glass-strong);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 var(--page-padding);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(0,0,0,.02);
}

.topbar-menu-btn {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    border-radius: 6px;
}

.topbar-menu-btn span {
    width: 18px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    letter-spacing: -0.022em;
}

.topbar-icon {
    width: 22px;
    height: 22px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 1.7;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ── Rychlé hledání v topbaru ── */
.topbar-search {
    position: relative;
    flex: 0 1 360px;
    max-width: 360px;
}

.topbar-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.85);
    border: 1.5px solid rgba(19,44,92,0.12);
    border-radius: 24px;
    padding: 2px 4px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar-search-wrap:focus-within {
    border-color: #132C5C;
    box-shadow: 0 0 0 4px rgba(19,44,92,0.08), 0 2px 8px rgba(19,44,92,0.1);
    background: #fff;
}

.topbar-search-icon {
    position: absolute;
    left: 12px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    pointer-events: none;
    transition: color 0.15s;
}

.topbar-search-wrap:focus-within .topbar-search-icon {
    color: #132C5C;
}

.topbar-search-input {
    width: 100%;
    padding: 8px 14px 8px 38px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    background: transparent;
    color: #1e293b;
    outline: none;
}

.topbar-search-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.topbar-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid rgba(19,44,92,0.08);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.06);
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
    overflow: hidden;
}

.search-result-item {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.12s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: linear-gradient(90deg, #eff6ff, #f0f4ff);
}

.search-result-name {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-result-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    background: #e2e8f0;
    padding: 3px 8px;
    border-radius: 10px;
}

.search-result-sub {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 3px;
}

.search-no-result {
    padding: 18px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

@media (max-width: 768px) {
    .topbar-search {
        flex: 1 1 auto;
        max-width: none;
    }
}

/* ── Klienti: sloupce Firmy / Fyzické osoby ── */
.klienti-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.sortable-table th.sortable {
    user-select: none;
    position: relative;
    padding-right: 18px;
}

.sortable-table th.sortable:hover {
    color: var(--primary, #4f46e5);
}

.sortable-table th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 2px;
    opacity: .35;
    font-size: 11px;
}

.sortable-table th.sortable.sort-asc::after {
    content: '↑';
    opacity: 1;
}

.sortable-table th.sortable.sort-desc::after {
    content: '↓';
    opacity: 1;
}

/* ── Globální tlačítko Zpět (glass, pravý horní roh) ── */
.global-back-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--glass-strong);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    cursor: pointer;
    transition: transform .15s ease, background .15s ease;
}

.global-back-btn:hover {
    background: var(--glass-hover);
    transform: scale(1.06);
}

.global-back-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
}

@media (max-width: 768px) {
    .global-back-btn {
        bottom: 16px;
        right: 12px;
        width: 36px;
        height: 36px;
    }
}

/* ── Page content ── */
.page-content {
    padding: var(--page-padding);
    flex: 1;
}

/* ── Patička ── */
.app-footer {
    padding: 10px var(--page-padding);
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    border-top: 1px solid rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.app-footer a {
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.15s;
}

.app-footer a:hover {
    color: #132C5C;
}

.app-footer-sep {
    color: #cbd5e1;
}

/* =========================================================
   Cards (iOS style)
   ========================================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
    background: var(--surface);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.021em;
}

.card-body {
    padding: 16px;
}

/* ── Stat cards ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    margin-bottom: 2px;
    letter-spacing: -0.024em;
}

.stat-label {
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* =========================================================
   Tables
   ========================================================= */
.data-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.table th {
    text-align: left;
    padding: 11px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: none;
    letter-spacing: -0.01em;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    vertical-align: middle;
}

.table tr:hover td {
    background: var(--surface-hover);
}

.table tr:last-child td {
    border-bottom: none;
}

/* ── Status badges (iOS style) ── */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 100px;
    white-space: nowrap;
    background: var(--gray-100);
    color: var(--text-secondary);
}

.status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.status-paid {
    background: var(--success-light);
    color: #137a2a;
}

.status-paid::before { background: var(--success); }

.status-unpaid {
    background: var(--danger-light);
    color: #b91c1c;
}

.status-unpaid::before { background: var(--danger); }

.status-draft {
    background: var(--warning-light);
    color: #9a3412;
}

.status-draft::before { background: var(--warning); }

.status-active {
    background: var(--primary-light);
    color: var(--primary-hover);
}

.status-active::before { background: var(--primary); }

/* ── Action menu (3 dots) ── */
.actions-cell {
    position: relative;
    text-align: right;
    white-space: nowrap;
    width: 1%;
}
.actions-cell .btn,
.actions-cell .btn-sm,
.actions-cell button {
    padding: 4px 8px;
    font-size: 12px;
    white-space: nowrap;
}

.action-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    color: #000;
    cursor: pointer;
    transition: all 0.15s;
}

.action-menu-toggle:hover {
    background: var(--gray-100);
    color: #000;
}

.action-menu-toggle::after {
    content: '⋯';
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-top: -2px;
}

.action-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 180px;
    background: var(--glass-strong);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: 6px 0;
    text-align: left;
    overflow: hidden;
}

.action-menu.open {
    display: block;
}

.action-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    font-size: 14px;
    color: var(--text);
    transition: background 0.15s;
    font-weight: 500;
}

.action-menu a:hover {
    background: rgba(0, 0, 0, .04);
    color: var(--primary);
}

.action-menu a.danger {
    color: #dc2626;
}

.action-menu a.danger:hover {
    background: #fee2e2;
    color: #991b1b;
}

/* =========================================================
   Buttons (iOS style)
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 122, 255, .25);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(0, 122, 255, .35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--gray-200);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #e02e24;
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    font-weight: 600;
}

.btn-ghost:hover {
    background: var(--primary-light);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    font-size: 15px;
}

.btn-block {
    width: 100%;
}

/* =========================================================
   Forms (iOS style)
   ========================================================= */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 15px;
    color: var(--text);
    background: var(--surface);
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    resize: vertical;
    min-height: 70px;
}

.firmy-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.firmy-form-grid .form-group.full-width {
    grid-column: 1 / -1;
}

.firmy-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.firmy-color-input {
    width: 48px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* =========================================================
   Placeholder / Empty state
   ========================================================= */
.empty-state {
    text-align: center;
    padding: 44px 24px;
    color: var(--text-tertiary);
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    background: var(--gray-100);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 24px;
}

.empty-state h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.021em;
}

.empty-state p {
    font-size: 14px;
}

/* =========================================================
   Login (iOS glass)
   ========================================================= */
.login-body {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--glass-strong);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 36px;
    width: 100%;
    max-width: 360px;
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    background: transparent;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 24px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.024em;
}

.login-subtitle {
    color: var(--text-tertiary);
    font-size: 14px;
}

.login-error {
    background: var(--danger-light);
    color: #b91c1c;
    border: 1px solid rgba(255, 59, 48, .2);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 16px;
    font-weight: 500;
}

.login-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid rgba(52, 211, 153, .3);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 16px;
    font-weight: 500;
}

.login-links {
    text-align: center;
    margin-top: 14px;
    font-size: 13px;
}

.login-links a {
    color: #132C5C;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}

.login-links a:hover {
    color: #1e40af;
    text-decoration: underline;
}

.login-footer {
    text-align: center;
    margin-top: 18px;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* =========================================================
   Pagination
   ========================================================= */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px;
    border-top: 1px solid var(--border-light);
}

.pagination a,
.pagination span {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    border: 1px solid transparent;
    background: transparent;
    transition: all 0.15s;
    font-weight: 500;
}

.pagination a:hover {
    background: var(--gray-100);
    color: var(--text);
}

.pagination .current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 700;
}

/* =========================================================
   Responsive
   ========================================================= */
@supports not (backdrop-filter: blur(24px)) {
    .sidebar,
    .topbar,
    .login-card,
    .action-menu,
    .sidebar-footer {
        background: var(--surface) !important;
    }
}

@media (max-width: 1024px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .firmy-form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .main-content {
        margin-left: 0;
    }

    .topbar-menu-btn {
        display: flex;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding: 14px;
    }

    .table {
        font-size: 13px;
    }

    .table th,
    .table td {
        padding: 10px;
    }

    .hide-mobile {
        display: none;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    .dashboard-docs-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ── ARES vyhledávání firem ── */
.ares-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.ares-input-wrap .form-input {
    width: 100%;
    padding-right: 38px;
}

.ares-search-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: 8px;
    padding: 0;
    transition: color 0.2s, background 0.2s;
}

.ares-search-btn:hover {
    color: var(--primary);
    background: var(--gray-100);
}

.ares-search-btn.ares-loading {
    opacity: 0.5;
    cursor: default;
}

.ares-autocomplete {
    position: relative;
}

.ares-suggestions {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--surface);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 220px;
    overflow-y: auto;
}

.ares-suggestion {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    overflow: hidden;
}

.ares-suggestion-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ares-suggestion-meta {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.ares-suggestion:last-child {
    border-bottom: none;
}

.ares-suggestion:hover,
.ares-suggestion:focus {
    background: var(--gray-100);
    outline: none;
}

.ares-suggestion.ares-no-results,
.ares-suggestion.ares-error {
    color: var(--text-secondary);
    font-style: italic;
    cursor: default;
}

.ares-suggestion.ares-error {
    color: var(--danger);
    font-style: normal;
}

.ares-suggestion.ares-loading-msg {
    color: var(--text-secondary);
    font-style: italic;
    cursor: default;
    background: var(--gray-50);
}

.ares-suggestion.ares-no-results:hover,
.ares-suggestion.ares-error:hover,
.ares-suggestion.ares-loading-msg:hover {
    background: transparent;
}

@media (max-width: 480px) {
    :root {
        --page-padding: 12px;
    }

    .topbar-title {
        font-size: 16px;
    }

    .login-card {
        padding: 24px;
    }
}

/* ── Kalendář ── */
.kalendar-table {
    table-layout: fixed;
}

.kalendar-table th {
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    padding: 8px 4px;
    border-bottom: 2px solid #e0e0e0;
}

.kalendar-table th.kalendar-weekend {
    color: #c084fc;
}

.kalendar-table td {
    height: 90px;
    vertical-align: top;
    border: 1px solid #f0f0f0;
    padding: 4px;
    font-size: 12px;
    transition: background 0.15s;
    cursor: pointer;
}

.kalendar-table td:hover {
    background: #f8fafc;
}

.kalendar-empty {
    cursor: default;
}

.kalendar-empty:hover {
    background: #f9f9f9;
}

.kalendar-holiday {
    background: #fef2f2 !important;
}

.kalendar-holiday .kalendar-day-num {
    color: #dc2626;
}

.kalendar-holiday-name {
    font-size: 10px;
    color: #dc2626;
    font-weight: 600;
    padding: 1px 3px;
    margin-bottom: 2px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kalendar-day-num {
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 2px;
    font-size: 13px;
}

.kalendar-today {
    background: #eff6ff !important;
}

.kalendar-today .kalendar-day-num {
    color: #3b82f6;
    font-size: 15px;
}

.kalendar-weekend-bg {
    background: #fafafa;
}

.kalendar-empty {
    background: #f9f9f9;
}

.kalendar-event {
    background: #3b82f6;
    color: white;
    border-radius: 4px;
    padding: 2px 5px;
    margin-bottom: 2px;
    font-size: 11px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.kalendar-event:hover {
    background: #2563eb;
}

.kalendar-event-done {
    background: #cbd5e1;
    text-decoration: line-through;
}

.kalendar-more {
    font-size: 10px;
    color: #64748b;
    padding: 1px 5px;
    font-weight: 600;
}

.kalendar-day.kal-selected {
    background: #dbeafe !important;
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

.kal-day-cell.kal-selected {
    background: #dbeafe !important;
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

/* Výběr barvy akce v modálu */
.ukol-color-radio {
    display: none;
}

.ukol-color-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: transform .12s, border-color .12s;
}

.ukol-color-radio:checked + .ukol-color-dot {
    border-color: #1e293b;
    transform: scale(1.5);
}

/* Vícedenní akce – souvislý pruh přes více dní */
.kalendar-event.kal-seg-mid,
.kalendar-event.kal-seg-last {
    margin-left: -5px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    position: relative;
    z-index: 1;
}

.kalendar-event.kal-seg-mid,
.kalendar-event.kal-seg-first {
    margin-right: -5px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.kalendar-event.kal-seg-first {
    position: relative;
    z-index: 2;
    overflow: visible;
    text-overflow: clip;
}

/* ── Mini kalendář na nástěnce – kompaktní varianta ── */
.kalendar-mini th {
    padding: 5px 2px;
    font-size: 11px;
}

.kalendar-mini td {
    height: 80px;
    padding: 3px 4px;
    font-size: 12px;
}

.kalendar-mini .kalendar-day-num {
    font-size: 12px;
    margin-bottom: 2px;
}

.kalendar-mini .kalendar-today .kalendar-day-num {
    font-size: 13px;
}

.kalendar-mini .kalendar-holiday-name {
    font-size: 9px;
    padding: 0 3px;
    margin-bottom: 1px;
}

.kalendar-mini .kalendar-event {
    font-size: 10px;
    padding: 1px 4px;
    margin-bottom: 1px;
}

.kalendar-mini .kalendar-more {
    font-size: 10px;
    padding: 0 4px;
}

.kalendar-mini .kalendar-event.kal-seg-mid,
.kalendar-mini .kalendar-event.kal-seg-last {
    margin-left: -5px;
}

.kalendar-mini .kalendar-event.kal-seg-mid,
.kalendar-mini .kalendar-event.kal-seg-first {
    margin-right: -5px;
}

@media (max-width: 768px) {
    .kalendar-grid {
        grid-template-columns: 1fr !important;
    }

    .kalendar-table td {
        height: 60px;
        padding: 2px;
        font-size: 10px;
    }

    .kalendar-day-num {
        font-size: 11px;
    }

    .kalendar-event {
        font-size: 9px;
        padding: 1px 3px;
    }
}

/* ── Oddělovač sekcí v přehledu klienta ── */
.prehled-divider {
    border: none;
    border-top: 2px solid #3b82f6;
    margin: 20px 0 4px;
    opacity: .35;
}

/* ── Responzivní formulář pro připomenutí/úkoly ── */
.ukol-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
}

.ukol-form .ukol-text {
    flex: 1;
    min-width: 120px;
}

/* Desktop: datum/čas na dalším řádku pod textareou */
.ukol-datetime-wrap {
    display: flex;
    gap: 6px;
    width: 100%;
    flex-wrap: wrap;
}

.ukol-form .ukol-date,
.ukol-form .ukol-time {
    width: auto;
}

/* Extra řádek: skrytý, zobrazen při focus */
.ukol-extra-row {
    display: none;
    width: 100%;
    gap: 6px;
    align-items: center;
}

.ukol-form.ukol-expanded .ukol-extra-row {
    display: flex;
}

.ukol-form .ukol-klient {
    width: auto;
}

@media (max-width: 768px) {
    .ukol-form {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
        width: 100%;
        box-sizing: border-box;
    }

    .ukol-form .ukol-text {
        width: 100%;
    }

    /* Mobil: datum/čas skryté, zobrazené při rozbalení jako řádek */
    .ukol-datetime-wrap {
        display: none;
    }

    .ukol-form.ukol-expanded .ukol-datetime-wrap {
        display: flex;
        gap: 8px;
    }

    .ukol-form.ukol-expanded .ukol-date,
    .ukol-form.ukol-expanded .ukol-time {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
    }

    /* Extra řádek na mobilu: zalamování, vše se vejdé */
    .ukol-form.ukol-expanded .ukol-extra-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .ukol-form .ukol-klient,
    .ukol-form .ukol-kolega {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
    }

    .ukol-form .ukol-btn {
        flex: 1 1 100%;
        white-space: nowrap;
    }
}
