/* ==========================================================
   CRM - design system
   Svetly, moderni, profesionalni vzhled. Svetle modra + tepla
   doplnkova barva. Horni navigace, plne responzivni.
   ========================================================== */

:root {
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;

    --accent-50: #fff7ed;
    --accent-100: #ffedd5;
    --accent-500: #f2994a;
    --accent-600: #e2780f;

    --green-50: #ecfdf5;
    --green-600: #059669;
    --red-50: #fef2f2;
    --red-600: #dc2626;
    --amber-50: #fffbeb;
    --amber-600: #d97706;
    --purple-50: #f5f3ff;
    --purple-600: #7c3aed;
    --slate-50: #f1f5f9;
    --slate-600: #475569;
    --lime-50: #14532d;
    --lime-600: #86efac;

    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --text: #1e2937;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);
    --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 8px; color: var(--text-muted); }
button { font-family: inherit; }

::selection { background: var(--blue-200); }

/* ---------------- Layout ---------------- */
.app-shell { min-height: 100%; display: flex; flex-direction: column; }
.container {
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: 0 24px;
}
.page {
    flex: 1;
    padding: 28px 0 60px;
}
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-head h1 { font-size: 1.6rem; }
.page-head .subtitle { margin: 0; font-size: 0.95rem; }

/* ---------------- Top navigace ---------------- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.navbar-inner {
    display: flex;
    align-items: center;
    height: 62px;
    gap: 20px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text);
    white-space: nowrap;
}
.brand-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--blue-500), var(--accent-500));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 1rem;
    flex-shrink: 0;
}
.brand:hover { text-decoration: none; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.nav-search {
    position: relative;
    flex: 1 1 auto;
    max-width: 300px;
    min-width: 130px;
}
.nav-search input[type="search"] {
    width: 100%;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.84rem;
    background: var(--surface-alt);
}
.nav-search input[type="search"]:focus { background: var(--surface); }
.nav-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 340px;
    overflow-y: auto;
    z-index: 60;
}
.nav-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.86rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.nav-search-item:last-child { border-bottom: none; }
.nav-search-item:hover, .nav-search-item.active { background: var(--blue-50); }
.nav-search-empty, .nav-search-loading {
    padding: 12px 14px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.nav-link {
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}
.nav-link:hover { background: var(--blue-50); color: var(--blue-700); text-decoration: none; }
.nav-link.active { background: var(--blue-50); color: var(--blue-700); }

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}
.nav-user .who { text-align: right; line-height: 1.25; }
.nav-user .who .name { font-weight: 800; font-size: 0.86rem; color: var(--blue-700); }
.nav-user .who .email { font-size: 0.74rem; color: var(--text-faint); }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-100); color: var(--accent-600);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.nav-toggle {
    display: none;
    border: none; background: transparent; cursor: pointer;
    padding: 8px; border-radius: var(--radius-sm);
}
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 5px 0; border-radius: 2px; }

@media (max-width: 880px) {
    .nav-toggle { display: block; }
    .nav-links {
        position: absolute;
        top: 62px; left: 0; right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        align-items: stretch;
        padding: 8px 16px 14px;
        gap: 2px;
        display: none;
        box-shadow: var(--shadow);
    }
    .nav-links.open { display: flex; }
    .nav-link { padding: 12px 14px; }
    .nav-user .who { display: none; }
    .nav-search { max-width: 120px; min-width: 90px; }
}

/* ---------------- Tlacitka ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-700); text-decoration: none; }
.btn-accent { background: var(--accent-500); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-600); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-alt); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-alt); text-decoration: none; color: var(--text); }
.btn-danger { background: var(--red-50); color: var(--red-600); }
.btn-danger:hover:not(:disabled) { background: #fde3e3; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; }
.btn-block { width: 100%; }
.btn-uppercase { text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------------- Formulare ---------------- */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}
.field .hint { font-size: 0.76rem; color: var(--text-faint); margin-top: 4px; }
.field .error-text { font-size: 0.76rem; color: var(--red-600); margin-top: 4px; display: none; }
.field.has-error .error-text { display: block; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red-600); }

input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="search"], input[type="number"], input[type="file"], input[type="datetime-local"],
input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input[type="datetime-local"], input[type="date"], input[type="time"] {
    color-scheme: light;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px var(--blue-100);
}
textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.checkbox-line { display: flex; align-items: center; gap: 8px; }
.checkbox-line input { width: auto; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------------- Karty ---------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap;
}
.card-header h3 { font-size: 1rem; }
.card-header .count { font-size: 0.8rem; color: var(--text-faint); font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat-card .num { font-size: 1.7rem; font-weight: 800; }
.stat-card .label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tile {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
    display: flex; flex-direction: column; gap: 10px;
}
.tile:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.tile-title { font-weight: 700; font-size: 1.02rem; }
.tile-meta { display: flex; gap: 14px; font-size: 0.8rem; color: var(--text-muted); flex-wrap: wrap; }
.tile-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ---------------- Tabulky ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 0.88rem; }
table.data-table th {
    text-align: left; padding: 12px 16px; background: var(--surface-alt);
    color: var(--text-muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr { transition: background var(--transition); }
table.data-table tbody tr:hover { background: var(--blue-50); }
table.data-table tbody tr.clickable-row { cursor: pointer; }
table.data-table tbody tr:last-child td { border-bottom: none; }
.col-actions { text-align: right; white-space: nowrap; }
.td-name { font-weight: 600; }
.td-muted { color: var(--text-muted); }

@media (max-width: 760px) {
    table.data-table thead { display: none; }
    table.data-table, table.data-table tbody, table.data-table tr, table.data-table td { display: block; width: 100%; }
    table.data-table tr {
        border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; padding: 6px 4px;
        background: var(--surface); box-shadow: var(--shadow-sm);
    }
    table.data-table td {
        display: flex; justify-content: space-between; align-items: center; gap: 12px;
        border-bottom: 1px dashed var(--border); padding: 10px 14px; text-align: right;
    }
    table.data-table td:last-child { border-bottom: none; }
    table.data-table td::before {
        content: attr(data-label); font-weight: 700; color: var(--text-faint);
        font-size: 0.72rem; text-transform: uppercase; text-align: left; letter-spacing: 0.03em;
    }
    table.data-table td.col-actions { justify-content: flex-end; }
    table.data-table td.col-actions::before { display: none; }
}

/* ---------------- Odznaky (stavy) ---------------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 0.74rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-new { background: var(--blue-50); color: var(--blue-700); }
.badge-taken { background: var(--purple-50); color: var(--purple-600); }
.badge-progress { background: var(--amber-50); color: var(--amber-600); }
.badge-success { background: var(--green-50); color: var(--green-600); }
.badge-danger { background: var(--red-50); color: var(--red-600); }
.badge-default { background: var(--surface-alt); color: var(--text-muted); }
.badge-warning { background: var(--accent-100); color: var(--accent-600); }
.badge-returned { background: var(--slate-50); color: var(--slate-600); }
.badge-free { background: var(--lime-50); color: var(--lime-600); }
.badge-free::before { animation: badge-free-pulse 1.6s ease infinite; }
@keyframes badge-free-pulse {
    0% { box-shadow: 0 0 0 0 rgba(134, 239, 172, 0.6); }
    70% { box-shadow: 0 0 0 5px rgba(134, 239, 172, 0); }
    100% { box-shadow: 0 0 0 0 rgba(134, 239, 172, 0); }
}

/* ---------------- Modaly ---------------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
    display: flex; align-items: center; justify-content: center;
    padding: 20px; z-index: 100; opacity: 0; pointer-events: none;
    transition: opacity var(--transition);
    backdrop-filter: blur(2px);
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column;
    transform: translateY(14px) scale(0.98); opacity: 0; transition: transform var(--transition), opacity var(--transition);
}
.modal-backdrop.open .modal { transform: translateY(0) scale(1); opacity: 1; }
.modal.modal-lg { max-width: 800px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1.08rem; }
.modal-close { border: none; background: transparent; font-size: 1.3rem; line-height: 1; color: var(--text-faint); cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--surface-alt); color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------- Toasty ---------------- */
.toast-stack {
    position: fixed; top: 78px; right: 20px; z-index: 200;
    display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
    background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--blue-500);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 12px 16px;
    font-size: 0.86rem; display: flex; align-items: flex-start; gap: 10px;
    animation: toast-in 220ms ease;
}
.toast.success { border-left-color: var(--green-600); }
.toast.error { border-left-color: var(--red-600); }
.toast.warning { border-left-color: var(--accent-500); }
.toast .toast-msg { flex: 1; }
.toast .toast-close { cursor: pointer; color: var(--text-faint); background: none; border: none; font-size: 1rem; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast.leaving { animation: toast-out 180ms ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

@media (max-width: 640px) {
    .toast-stack { left: 12px; right: 12px; max-width: none; top: auto; bottom: 16px; }
}

/* ---------------- Skeleton loading ---------------- */
.skeleton {
    background: linear-gradient(90deg, var(--surface-alt) 25%, #eef2f7 37%, var(--surface-alt) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: 6px;
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-row { height: 44px; margin-bottom: 10px; border-radius: var(--radius-sm); }
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-tile { height: 140px; border-radius: var(--radius); }

/* ---------------- Prazdne / chybove stavy ---------------- */
.empty-state, .error-state {
    text-align: center; padding: 56px 24px; color: var(--text-muted);
}
.empty-state .icon, .error-state .icon {
    width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px;
    background: var(--blue-50); display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
}
.error-state .icon { background: var(--red-50); }
.empty-state h4, .error-state h4 { color: var(--text); margin-bottom: 6px; }

/* ---------------- Ostatni pomucky ---------------- */
.fade-in { animation: fade-in 220ms ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab-btn {
    border: none; background: transparent; padding: 11px 16px; font-weight: 700; font-size: 0.88rem;
    color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab-btn.active { color: var(--blue-700); border-bottom-color: var(--blue-600); }
.pill-select { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
    padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
    font-size: 0.8rem; font-weight: 600; cursor: pointer; color: var(--text-muted); transition: all var(--transition);
}
.pill.active { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.spinner {
    width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
}
.spinner.dark { border-color: var(--border); border-top-color: var(--blue-600); }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--blue-600); transition: width 200ms ease; }
.stepper { display: flex; flex-direction: column; gap: 10px; }
.step {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface-alt); font-size: 0.85rem; font-weight: 600;
}
.step.current { border-color: var(--blue-500); background: var(--blue-50); color: var(--blue-700); }
.step.done { color: var(--green-600); }
.step .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.step.current .dot { background: var(--blue-600); }
.step.done .dot { background: var(--green-600); }
.dropzone {
    border: 2px dashed var(--border); border-radius: var(--radius); padding: 34px 20px; text-align: center;
    color: var(--text-muted); cursor: pointer; transition: border-color var(--transition), background var(--transition);
}
.dropzone.drag { border-color: var(--blue-500); background: var(--blue-50); }
.select-checkbox { width: 18px; height: 18px; cursor: pointer; }
.bulk-bar {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--blue-50);
    border: 1px solid var(--blue-200); border-radius: var(--radius-sm); margin-bottom: 14px; flex-wrap: wrap;
}
.link-btn { background: none; border: none; color: var(--blue-600); font-weight: 600; cursor: pointer; padding: 0; font-size: 0.86rem; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--red-600); }

/* ---------------- Zvyrazneni hledani (jako Ctrl+F) ---------------- */
mark.search-highlight {
    background: var(--accent-500);
    color: #fff;
    padding: 0 3px;
    border-radius: 3px;
    font-weight: 700;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* ---------------- Skladany prehled projektu na kontaktu ---------------- */
.projekt-stack { display: flex; flex-direction: column; gap: 10px; }
.projekt-stack-item { padding: 6px 0; }
.projekt-stack-item + .projekt-stack-item { border-top: 1px dashed var(--border); padding-top: 10px; }
.projekt-stack-item-disallowed { opacity: 0.55; }

/* ---------------- Omezena vyska seznamu poznamek (karta kontaktu) ---------------- */
.notes-scroll {
    max-height: 480px;
    overflow-y: auto;
    padding-right: 6px;
}

/* ---------------- Radek projektu mimo opravneni (karta kontaktu) ---------------- */
table.data-table tbody tr.row-disallowed { background: var(--red-50); }
table.data-table tbody tr.row-disallowed:hover { background: var(--red-50); }
.perm-lock-icon { cursor: help; margin-left: 4px; }

/* ---------------- Prubeh zpracovani (timeline) ---------------- */
.history-timeline { display: flex; flex-direction: column; }
.history-item { display: flex; gap: 14px; position: relative; padding-bottom: 20px; }
.history-item:last-child { padding-bottom: 0; }
.history-item:not(:last-child)::before {
    content: ""; position: absolute; left: 15px; top: 34px; bottom: 0; width: 2px; background: var(--border);
}
.history-dot {
    width: 32px; height: 32px; border-radius: 50%; background: var(--blue-50); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 0.95rem; z-index: 1;
}
.history-content { padding-top: 4px; }

/* ---------------- Zivy indikator (Trziste) ---------------- */
.live-indicator {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
    padding: 6px 14px; white-space: nowrap; align-self: flex-start;
}
.live-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--green-600);
    box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.55);
    animation: live-pulse 1.8s ease infinite;
}
@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.55); }
    70% { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
    100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

/* ---------------- Automatizace: graficky stavitel ---------------- */
.automation-flow {
    display: flex; flex-direction: column; align-items: stretch;
    max-width: 640px; margin: 0 auto;
}
.flow-connector {
    display: flex; flex-direction: column; align-items: center;
    height: 40px; position: relative;
}
.flow-connector::before {
    content: ""; width: 2px; flex: 1; background: var(--border);
}
.flow-connector-add {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--surface); border: 2px dashed var(--border);
    color: var(--text-muted); font-size: 1.1rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all var(--transition);
}
.flow-connector-add:hover { border-color: var(--blue-500); color: var(--blue-600); background: var(--blue-50); border-style: solid; }

.trigger-card {
    background: linear-gradient(135deg, var(--blue-50), var(--surface));
    border: 1px solid var(--blue-200); border-radius: var(--radius-lg);
    padding: 18px 22px; display: flex; align-items: center; gap: 16px;
    cursor: pointer; transition: box-shadow var(--transition), transform var(--transition);
}
.trigger-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.trigger-card .trigger-icon {
    width: 48px; height: 48px; border-radius: 14px; background: var(--surface);
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
    box-shadow: var(--shadow-sm); flex-shrink: 0;
}
.trigger-card .trigger-body { flex: 1; }
.trigger-card .trigger-label { font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--blue-600); }
.trigger-card .trigger-title { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.trigger-card .trigger-meta { font-size: 0.82rem; color: var(--text-muted); }

.step-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px 20px; display: flex; align-items: center; gap: 14px;
    cursor: pointer; transition: box-shadow var(--transition), transform var(--transition);
}
.step-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.step-card .step-icon {
    width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
    background: var(--accent-100); color: var(--accent-600);
}
.step-card .step-body { flex: 1; min-width: 0; }
.step-card .step-title { font-weight: 700; font-size: 0.92rem; color: var(--text); }
.step-card .step-preview {
    font-size: 0.82rem; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.step-card .step-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.step-card .step-actions button {
    border: none; background: transparent; color: var(--text-faint); cursor: pointer;
    padding: 6px; border-radius: var(--radius-sm); font-size: 0.95rem; line-height: 1;
    transition: background var(--transition), color var(--transition);
}
.step-card .step-actions button:hover { background: var(--surface-alt); color: var(--text); }
.step-card .step-actions button.danger:hover { background: var(--red-50); color: var(--red-600); }
.step-card .step-actions button:disabled { opacity: 0.3; cursor: not-allowed; }
.step-card .step-actions button:disabled:hover { background: transparent; color: var(--text-faint); }

.flow-end-add {
    align-self: center; margin-top: 6px;
}

/* Panel znacek pro vkladani do textu SMS/e-mailu */
.merge-tag-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; }
.merge-tag-toolbar select.pill {
    -webkit-appearance: none; appearance: none;
    padding-right: 26px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.148l3.71-3.918a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 6px center; background-size: 14px;
}
.char-counter { font-size: 0.76rem; color: var(--text-faint); text-align: right; margin-top: -12px; margin-bottom: 14px; }
.char-counter.warn { color: var(--accent-600); }

/* Prilohy e-mailu */
.attachment-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.attachment-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-alt); font-size: 0.84rem;
}
.attachment-chip .attachment-icon { font-size: 1.1rem; }
.attachment-chip .attachment-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.attachment-chip .attachment-size { color: var(--text-faint); font-size: 0.76rem; white-space: nowrap; }
.attachment-chip button {
    border: none; background: transparent; color: var(--text-faint); cursor: pointer;
    padding: 2px 6px; border-radius: 6px; font-size: 0.95rem;
}
.attachment-chip button:hover { background: var(--red-50); color: var(--red-600); }

.automation-preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.automation-preset-card {
    border: 2px solid var(--border); border-radius: var(--radius-lg); padding: 18px 14px;
    text-align: center; cursor: pointer; transition: all var(--transition); background: var(--surface);
}
.automation-preset-card:hover { border-color: var(--blue-500); box-shadow: var(--shadow); transform: translateY(-2px); }
.automation-preset-card.active { border-color: var(--blue-600); background: var(--blue-50); }
.automation-preset-card .preset-icon { font-size: 2rem; margin-bottom: 8px; }
.automation-preset-card .preset-title { font-weight: 700; font-size: 0.88rem; color: var(--text); }

/* ---------------- Trziste: prepinac Vlastni / Sdilene ---------------- */
.scope-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.scope-tile {
    display: flex; align-items: center; gap: 14px; padding: 16px 20px;
    border: 2px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
    cursor: pointer; text-align: left; transition: all var(--transition); font-family: inherit;
}
.scope-tile:hover { border-color: var(--blue-500); box-shadow: var(--shadow); transform: translateY(-1px); }
.scope-tile.active { border-color: var(--blue-600); background: linear-gradient(135deg, var(--blue-50), var(--surface)); }
.scope-tile .scope-icon {
    width: 46px; height: 46px; border-radius: 14px; background: var(--surface-alt);
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0;
    transition: background var(--transition);
}
.scope-tile.active .scope-icon { background: var(--blue-100); }
.scope-tile .scope-title { font-weight: 800; font-size: 1rem; color: var(--text); }
.scope-tile .scope-desc { font-size: 0.8rem; color: var(--text-muted); }
.scope-tile .scope-count { font-weight: 700; font-size: 0.78rem; color: var(--blue-600); margin-left: auto; padding-left: 10px; white-space: nowrap; }

@media (max-width: 640px) {
    .scope-switch { grid-template-columns: 1fr; }
}
