/* ==========================================================================
   EUROPASS UI SYSTEM — v2 (Sidebar + Cards)
   Reference: QORE dashboard. Clean, light, generous whitespace.
   ========================================================================== */

:root {
    /* Palette */
    --bg-1: #e7edff;      /* soft blue */
    --bg-2: #efe7fd;      /* soft violet */
    --bg-3: #fde8f0;      /* soft peach-pink */

    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --surface-hover: #f1f5f9;

    --border: rgba(15, 23, 42, 0.06);
    --border-strong: rgba(15, 23, 42, 0.10);

    --text: #0f172a;
    --text-muted: #64748b;
    --text-soft: #94a3b8;

    --primary: #3b82f6;
    --primary-strong: #2563eb;
    --primary-soft: #e0edff;

    --success: #22c55e;
    --success-soft: #dcfce7;
    --warning: #f59e0b;
    --warning-soft: #fef3c7;
    --danger: #ef4444;
    --danger-soft: #fee2e2;
    --info: #0ea5e9;
    --info-soft: #e0f2fe;
    --neutral-soft: #f1f5f9;

    /* Radii */
    --r-xs: 8px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 22px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 6px 20px rgba(60, 80, 120, 0.07);
    --shadow-lg: 0 20px 45px rgba(60, 80, 120, 0.10);

    /* Layout */
    --sidebar-w: 248px;
    --sidebar-w-collapsed: 80px;
    --topbar-h: 72px;
    --gutter: 24px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background-color: #f4f6fb;
    background-image:
        radial-gradient(1100px 600px at -10% -10%, var(--bg-1), transparent 60%),
        radial-gradient(900px 700px at 110% 10%, var(--bg-3), transparent 60%),
        radial-gradient(1200px 800px at 50% 120%, var(--bg-2), transparent 60%);
    background-attachment: fixed;
    background-size: cover;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   APP SHELL — sidebar + main
   ========================================================================== */

.app-shell {
    display: flex;
    min-height: 100vh;
    padding: 16px;
    gap: 16px;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-md);

    position: sticky;
    top: 16px;
    align-self: flex-start;
    height: calc(100vh - 32px);

    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    z-index: 50;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 18px;
    text-decoration: none;
    color: var(--text);
}

.sidebar-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.01em;
    color: var(--text);
}

.sidebar-brand-tag {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary-strong);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.75;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
    padding: 16px 12px 8px;
}

.sidebar-section-label.has-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-section-label.has-chip .chip {
    /* Section-label chips are smaller and use the same letter-spacing as the
       label so the cap-height aligns with the title text. */
    font-size: 9px;
    letter-spacing: 0.06em;
    padding: 2px 8px;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.08); border-radius: 4px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13.5px;
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
    position: relative;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.sidebar-link > i,
.sidebar-link > .sidebar-icon {
    width: 20px;
    font-size: 16px;
    text-align: center;
    color: var(--text-soft);
    transition: color 0.18s ease;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sidebar-link:hover > i,
.sidebar-link:hover > .sidebar-icon {
    color: var(--primary);
}

.sidebar-link.is-active {
    background: var(--primary-soft);
    color: var(--primary-strong);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.18);
}

.sidebar-link.is-active > i,
.sidebar-link.is-active > .sidebar-icon {
    color: var(--primary-strong);
}

.sidebar-link .sidebar-caret {
    margin-left: auto;
    font-size: 11px;
    transition: transform 0.2s ease;
    color: var(--text-soft);
}

.sidebar-link[aria-expanded="true"] .sidebar-caret {
    transform: rotate(90deg);
}

.sidebar-subnav {
    list-style: none;
    margin: 2px 0 4px 0;
    padding: 2px 0 2px 40px;
    display: none;
    flex-direction: column;
    gap: 2px;
}

.sidebar-subnav.is-open {
    display: flex;
}

.sidebar-sublink {
    display: block;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-sublink:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sidebar-sublink.is-active {
    color: var(--primary-strong);
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    text-decoration: none;
    color: var(--text);
    background: transparent;
    border: none;
    width: 100%;
    cursor: pointer;
    transition: background 0.18s ease;
}

.sidebar-profile:hover {
    background: var(--surface-hover);
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.sidebar-profile-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
    text-align: left;
}

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

.sidebar-profile-role {
    font-size: 11px;
    color: var(--text-soft);
    font-weight: 500;
}

.sidebar-profile .sidebar-profile-caret {
    margin-left: auto;
    color: var(--text-soft);
    font-size: 11px;
}

/* ==========================================================================
   MAIN COLUMN
   ========================================================================== */

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 22px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 16px;
    z-index: 40;
}

.topbar-title {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    flex-shrink: 0;
}

.topbar-hello {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

.topbar-breadcrumb {
    font-size: 12px;
    color: var(--text-soft);
    display: flex;
    align-items: center;
    gap: 4px;
}

.topbar-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
}

.topbar-breadcrumb a:hover { color: var(--primary-strong); }

.topbar-breadcrumb .sep {
    color: var(--text-soft);
    font-size: 13px;
}

.topbar-search {
    flex: 1;
    max-width: 520px;
    margin: 0 auto;
    position: relative;
}

.topbar-search input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 38px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    font-size: 13px;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.topbar-search input::placeholder { color: var(--text-soft); }

.topbar-search input:focus {
    outline: none;
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.topbar-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-soft);
    font-size: 13px;
    pointer-events: none;
}

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

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    font-size: 14px;
}

.icon-btn:hover {
    color: var(--primary-strong);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.lang-btn {
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.mobile-menu-btn {
    display: none;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn-primary-solid {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary-solid:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(59, 130, 246, 0.38);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-ghost:hover {
    border-color: var(--primary);
    color: var(--primary-strong);
    background: var(--primary-soft);
}

.btn-ghost[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-ghost-sm {
    padding: 7px 12px;
    font-size: 12.5px;
}

/* ==========================================================================
   PAGE CONTENT + PANELS
   ========================================================================== */

.page {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-bottom: 40px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    padding: 0 10px ;
}

.page-title {
    margin: 0 0 4px 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.page-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 13.5px;
}

.panel {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-md);
    padding: 22px;
}

.panel-flat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.panel-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    margin: 0;
}

.panel-header .panel-title + .panel-actions { margin-left: auto; }

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

/* ==========================================================================
   STATUS TABS
   ========================================================================== */

.status-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
    list-style: none;
}

.status-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.status-tab:hover {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.status-tab.is-active {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    box-shadow: 0 6px 14px rgba(59, 130, 246, 0.3);
}

.status-tab .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
}

.status-tab.is-active .count {
    background: rgba(255, 255, 255, 0.28);
    color: #fff;
}

/* ==========================================================================
   TOOLBAR
   ========================================================================== */

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.toolbar-search {
    flex: 1;
    min-width: 220px;
    max-width: 420px;
    position: relative;
}

.toolbar-search input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 38px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 13px;
    color: var(--text);
    transition: all 0.15s ease;
}

.toolbar-search input::placeholder { color: var(--text-soft); }

.toolbar-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.toolbar-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-soft);
    font-size: 13px;
    pointer-events: none;
}

.toolbar-spacer { flex: 1; }

.view-toggle {
    display: inline-flex;
    padding: 3px;
    border-radius: 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    gap: 2px;
}

.view-toggle button {
    width: 34px;
    height: 32px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.view-toggle button:hover { color: var(--text); }

.view-toggle button.is-active {
    background: #fff;
    color: var(--primary-strong);
    box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   DOCUMENT CARDS
   ========================================================================== */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.doc-card {
    position: relative;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.doc-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(59, 130, 246, 0.3);
}

/* Completed cards — green-tinted border + soft glow so finalised mobilities
   are visually distinct from in-progress ones at a glance. The hover state
   keeps the green theme instead of switching to blue. */
.doc-card.is-completed {
    border-color: rgba(34, 197, 94, 0.45);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.10);
}

.doc-card.is-completed:hover {
    border-color: rgba(34, 197, 94, 0.65);
    box-shadow:
        0 12px 24px rgba(34, 197, 94, 0.14),
        0 0 0 1px rgba(34, 197, 94, 0.25);
}

.doc-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.doc-card-head-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.doc-card-num {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-card-num:hover { color: var(--primary-strong); }

.doc-card-project {
    font-size: 11.5px;
    color: var(--text-soft);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.doc-card-select {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.doc-card-select input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}

.doc-card-program {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    max-width: fit-content;
}

/* ECTS / ECVET enabled marker — small green pill in the program/status row.
   Only rendered when doc.use_ects_ecvet is True; absence means "not enabled". */
.doc-card-ects {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--success-soft);
    color: #15803d;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    max-width: fit-content;
}

.doc-card-holder {
    display: flex;
    align-items: center;
    gap: 10px;
}

.doc-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a5b4fc, #818cf8);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: -0.01em;
}

.doc-card-avatar.variant-1 { background: linear-gradient(135deg, #fca5a5, #f87171); }
.doc-card-avatar.variant-2 { background: linear-gradient(135deg, #fcd34d, #f59e0b); }
.doc-card-avatar.variant-3 { background: linear-gradient(135deg, #6ee7b7, #34d399); }
.doc-card-avatar.variant-4 { background: linear-gradient(135deg, #93c5fd, #3b82f6); }
.doc-card-avatar.variant-5 { background: linear-gradient(135deg, #c4b5fd, #8b5cf6); }
.doc-card-avatar.variant-6 { background: linear-gradient(135deg, #f9a8d4, #ec4899); }

.doc-card-holder-name {
    font-weight: 700;
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-card-holder-sub {
    font-size: 11.5px;
    color: var(--text-soft);
    font-weight: 500;
}

.doc-card-route {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--surface-muted);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    font-size: 12.5px;
    color: var(--text);
}

.doc-card-route-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.doc-card-route-divider {
    height: 1px;
    background: var(--border);
    opacity: 0.6;
}

.doc-card-route .route-node {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.doc-card-route .route-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
}

.doc-card-route .route-value {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.doc-card-route .route-arrow {
    color: var(--text-soft);
    font-size: 12px;
    flex-shrink: 0;
}

.doc-card-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    font-size: 12.5px;
}

.doc-card-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.doc-card-meta-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
}

.doc-card-meta-value {
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-card-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    gap: 8px;
}

.doc-card-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.doc-card-action {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    font-size: 13px;
}

.doc-card-action:hover {
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.doc-card-action.is-pdf:hover { background: var(--danger-soft); color: var(--danger); }
.doc-card-action.is-edit:hover { background: var(--warning-soft); color: var(--warning); }

.doc-card.is-selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12), var(--shadow-md);
}

/* ==========================================================================
   STATUS PILLS (card header)
   ========================================================================== */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    text-transform: capitalize;
}

.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.75;
}

/* When a status pill has an inline <i> icon, suppress the dot — the icon
   carries the same role visually. */
.status-pill > i {
    font-size: 10px;
    line-height: 1;
}

.status-pill.has-icon::before,
.status-pill.is-completed::before {
    display: none;
}

.status-pill.is-draft { background: var(--neutral-soft); color: var(--text-muted); }
.status-pill.is-registered { background: var(--info-soft); color: #0369a1; }
.status-pill.is-sent { background: var(--warning-soft); color: #b45309; }
.status-pill.is-accepted { background: var(--success-soft); color: #15803d; }
.status-pill.is-rejected { background: var(--danger-soft); color: #b91c1c; }
.status-pill.is-archived { background: #f3f4f6; color: #6b7280; }

/* Completed — strongest visual emphasis: filled green gradient with white
   text, soft green glow. Mirrors the "Finalize document" CTA on the detail
   page so the card status reads as the same end-state. */
.status-pill.is-completed {
    background: linear-gradient(135deg, #22c55e, #15803d);
    color: #ffffff;
    padding: 4px 11px;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.28);
}

.status-pill.is-completed > i {
    font-size: 10.5px;
    color: #ffffff;
    opacity: 0.95;
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-lg);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 14px;
}

.empty-state h3 {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.empty-state p {
    margin: 0 0 16px 0;
    color: var(--text-muted);
    font-size: 13px;
}

/* ==========================================================================
   TABLE VIEW (kept available via toggle)
   ========================================================================== */

.doc-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
}

.doc-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.doc-table thead th {
    background: var(--surface-muted);
    text-align: left;
    padding: 12px 14px;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

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

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

/* =========================================
   ТОЧКОВІ ЗМІНИ ДЛЯ EMAIL ТА ДІЙ
   ========================================= */

/* 1. Центруємо колонку EMAIL (5-та за рахунком) */
.doc-table th:nth-child(5),
.doc-table td:nth-child(5) {
    text-align: center;
    /* Дозволяємо перенесення довгих імейлів: */
    word-break: break-word;
    white-space: nowrap;
}

/* 2. Центруємо колонку ДІЇ (остання) */
.doc-table th:last-child,
.doc-table td:last-child {
    text-align: center !important;
}

/* 3. Центруємо самі іконки дій всередині стовпця */
.doc-table .row-actions {
    display: flex;
    gap: 2px;
    justify-content: center; /* БУЛО: flex-end */
}
/* =========================================
   ВИРІВНЮВАННЯ ДЛЯ ТАБЛИЦІ ДОКУМЕНТІВ
   ========================================= */

/* 1. Центруємо колонку з ЧЕКБОКСАМИ (1-ша) */
.doc-table th:nth-child(2),
.doc-table td:nth-child(2) {
    text-align: center;
}
.doc-table th:nth-child(1),
.doc-table td:nth-child(1) {
    text-align: center;
}
/* Примусово центруємо сам квадратик чекбокса, якщо він пручається */
.doc-table td:first-child input[type="checkbox"] {
    margin: 0 auto !important;
    display: block !important;
}
.doc-table th:nth-child(7),
.doc-table td:nth-child(7) {
    text-align: center;
}
/* 2. Центруємо колонку СТАТУС (8-ма за рахунком) */
.doc-table th:nth-child(8),
.doc-table td:nth-child(8) {
    text-align: center;
}

/* 3. Центруємо колонку ДІЇ (остання) */
.doc-table th:last-child,
.doc-table td:last-child {
    text-align: center !important;
}

/* 4. Центруємо самі іконки дій всередині стовпця */
.doc-table .row-actions {
    display: flex;
    gap: 2px;
    justify-content: center; /* БУЛО: flex-end */
}
/* ==========================================================================
   PAGINATION
   ========================================================================== */

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding-top: 18px;
    margin-top: 6px;
    border-top: 1px solid var(--border);
}

.pager-info {
    font-size: 12.5px;
    color: var(--text-muted);
}

.pager-info strong { color: var(--text); font-weight: 700; }

.pager-controls {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.pager-btn {
    min-width: 32px;
    height: 32px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 700;
    padding: 0 10px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.pager-btn:hover { background: #fff; color: var(--text); }

.pager-btn.is-current {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

/* ==========================================================================
   FILTER DRAWER (offcanvas)
   ========================================================================== */

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(4px);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.drawer-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.filter-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 90vw);
    background: #fff;
    box-shadow: -20px 0 60px rgba(15, 23, 42, 0.15);
    z-index: 1060;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.filter-drawer.is-open { transform: translateX(0); }

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

.filter-drawer-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.filter-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 20px
}

.filter-drawer-foot {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-field label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.filter-field input,
.filter-field select,
.filter-field textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 13px;
    color: var(--text);
    transition: all 0.15s ease;
    font-family: inherit;
}

.filter-field input:focus,
.filter-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.filter-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ==========================================================================
   MESSAGES / ALERTS
   ========================================================================== */

.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--r-md);
    background: var(--info-soft);
    color: #075985;
    border: 1px solid rgba(14, 165, 233, 0.2);
    font-size: 13.5px;
}

.flash.is-success { background: var(--success-soft); color: #15803d; border-color: rgba(34, 197, 94, 0.2); }
.flash.is-error { background: var(--danger-soft); color: #b91c1c; border-color: rgba(239, 68, 68, 0.2); }
.flash.is-warning { background: var(--warning-soft); color: #b45309; border-color: rgba(245, 158, 11, 0.2); }

.flash-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
    font-size: 14px;
}

.flash-close:hover { opacity: 1; }

/* ==========================================================================
   LANGUAGE MENU
   ========================================================================== */

.popover-menu {
    position: absolute;
    min-width: 180px;
    background: #fff;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 1000;
    display: none;
}

.popover-menu.is-open { display: block; }

.popover-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.15s ease;
}

.popover-item:hover { background: var(--surface-hover); color: var(--text); }

.popover-item.is-active {
    color: var(--primary-strong);
    background: var(--primary-soft);
}

.popover-item i { color: var(--text-soft); width: 16px; text-align: center; }
.popover-item.is-danger { color: var(--danger); }
.popover-item.is-danger:hover { background: var(--danger-soft); }

.popover-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
}

.popover-anchor {
    position: relative;
}
.popover-anchor { position: relative; display: inline-block; }

.popover-menu {
    position: absolute;
    min-width: 160px;
    background: #fff;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 1000;
    display: none; /* Сховано за замовчуванням */
}

.popover-menu.is-open {
    display: block;
    animation: popIn 0.2s ease-out;
}

.popover-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all 0.15s ease;
}

.popover-item:hover { background: var(--surface-hover); }
.popover-item.is-active { color: var(--primary-strong); background: var(--primary-soft); }

@keyframes popIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
/* ==========================================================================
   FORMS (style Django widgets rendered inside filter drawer)
   ========================================================================== */

.filter-drawer-body input[type="text"],
.filter-drawer-body input[type="date"],
.filter-drawer-body input[type="search"],
.filter-drawer-body input[type="number"],
.filter-drawer-body select,
.filter-drawer-body textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 13px;
    color: var(--text);
    transition: all 0.15s ease;
    font-family: inherit;
    box-shadow: none;
}

.filter-drawer-body textarea { height: auto; padding: 10px 12px; min-height: 70px; }

.filter-drawer-body input:focus,
.filter-drawer-body select:focus,
.filter-drawer-body textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1024px) {
    :root { --sidebar-w: 220px; }
    .topbar-search { display: none; }
}

@media (max-width: 860px) {
    .app-shell { padding: 10px; gap: 10px; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        border-radius: 0;
        border-right: 1px solid var(--border);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1080;
        width: 260px;
    }

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

    .app-main { width: 100%; }
    .mobile-menu-btn { display: inline-flex; }

    .topbar {
        padding: 10px 14px;
        border-radius: 16px;
    }

    .topbar-title { display: none; }

    .cards-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   MISC / UTILITIES
   ========================================================================== */

.text-muted-custom { color: var(--text-muted); }
.text-soft-custom { color: var(--text-soft); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--neutral-soft);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Hide legacy navbar styles that might leak in if someone loaded main.css */
.top-navbar { display: none !important; }

/* ==========================================================================
   FORM SYSTEM — Unified styling for Django-rendered widgets
   Applies to inputs with .form-control / .form-select (default Django+BS5 widget attrs)
   and to textareas / date inputs / Select2 wrappers inside .form-panel or .page.
   ========================================================================== */

.page .form-control,
.page .form-select,
.page textarea,
.page input[type="text"],
.page input[type="email"],
.page input[type="number"],
.page input[type="date"],
.page input[type="search"],
.page input[type="url"],
.page input[type="tel"],
.page input[type="password"],
.form-panel .form-control,
.form-panel .form-select,
.form-panel textarea,
.form-panel input[type="text"],
.form-panel input[type="email"],
.form-panel input[type="number"],
.form-panel input[type="date"],
.form-panel input[type="search"],
.form-panel input[type="url"],
.form-panel input[type="tel"],
.form-panel input[type="password"] {
    width: 100%;
    min-height: 42px;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 13.5px;
    color: var(--text);
    font-family: inherit;
    line-height: 1.35;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.page textarea,
.form-panel textarea {
    min-height: 90px;
    padding: 12px 14px;
    line-height: 1.5;
    resize: vertical;
}

.page .form-control:focus,
.page .form-select:focus,
.page textarea:focus,
.page input:focus,
.form-panel .form-control:focus,
.form-panel .form-select:focus,
.form-panel textarea:focus,
.form-panel input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
    background: #fff;
}

.page .form-control::placeholder,
.page textarea::placeholder,
.form-panel .form-control::placeholder,
.form-panel textarea::placeholder { color: var(--text-soft); }

.page .form-select,
.form-panel .form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%2364748b' d='M8 11.5 3.5 7h9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 36px;
}

/* ----- Native date inputs (client item 18) -----
   The whole field is clickable (JS calls showPicker() on click — see
   static/js/forms-ux.js) while manual typing stays possible. The calendar
   icon gets a larger, hoverable hit area consistent with the design system. */
.page input[type="date"],
.form-panel input[type="date"] {
    cursor: pointer;
}
.page input[type="date"]::-webkit-calendar-picker-indicator,
.form-panel input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    padding: 8px;
    margin: -4px 0;
    border-radius: 8px;
    opacity: 0.65;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.page input[type="date"]::-webkit-calendar-picker-indicator:hover,
.form-panel input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    background: var(--primary-soft);
}

.page .form-control.is-invalid,
.page .form-select.is-invalid,
.form-panel .form-control.is-invalid,
.form-panel .form-select.is-invalid,
.field.has-error .form-control,
.field.has-error .form-select,
.field.has-error textarea,
.field.has-error input {
    border-color: var(--danger) !important;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1) !important;
}

/* Clean labels + help text */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
}

.field-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.field-label .required {
    color: var(--danger);
    font-weight: 800;
}

.field-help {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.4;
}

.field-error {
    font-size: 11.5px;
    color: var(--danger);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.field-error::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--danger);
}

/* Form section headings */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px 20px;
    border-radius: var(--r-md);
    background: var(--surface-muted);
    border: 1px solid var(--border);
}

.form-section + .form-section { margin-top: 16px; }

.form-section-title {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section-title i { color: var(--primary); font-size: 14px; }

/* Grid helpers for 2-col / 3-col form rows */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.form-grid .field-full,
.form-grid-3 .field-full { grid-column: 1 / -1; }

@media (max-width: 700px) {
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}

/* Inline form-text (Django {{ field.help_text }}) */
.page .form-text,
.form-panel .form-text {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Django's ul.errorlist — flatten to our field-error look */
.page ul.errorlist,
.form-panel ul.errorlist {
    list-style: none;
    padding: 0;
    margin: 4px 0 0 0;
    font-size: 11.5px;
    color: var(--danger);
    font-weight: 600;
}

.page ul.errorlist li,
.form-panel ul.errorlist li { padding: 2px 0; }

/* Form panel wrapper (white card for the form) */
.form-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.form-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.form-panel-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.form-panel-title i { color: var(--primary); }

.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 22px;
    margin-top: 22px;
    border-top: 1px solid var(--border);
}

.form-actions-right { margin-left: auto; display: flex; gap: 8px; }

/* Mandatory-fields note */
.required-note {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.required-note .required { color: var(--danger); font-weight: 800; }

/* ==========================================================================
   WIZARD STEPPER — numbered steps with connector
   ========================================================================== */

.wizard {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 6px 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    box-shadow: var(--shadow-xs);
}

.wizard-step {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    color: var(--text-soft);
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

.wizard-step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--surface-muted);
    color: var(--text-muted);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.wizard-step.is-active {
    color: var(--text);
}

.wizard-step.is-active .wizard-step-num {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.wizard-step.is-done {
    color: var(--text);
}

.wizard-step.is-done .wizard-step-num {
    background: var(--success-soft);
    color: #15803d;
    border-color: rgba(34, 197, 94, 0.2);
}

.wizard-step.is-done .wizard-step-num::before {
    content: "\f00c"; /* Font Awesome check */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 11px;
}

.wizard-step.is-done .wizard-step-num-label { display: none; }

.wizard-connector {
    width: 36px;
    height: 2px;
    background: var(--border-strong);
    margin: 0 6px;
    flex-shrink: 0;
    border-radius: 2px;
    position: relative;
}

.wizard-connector.is-active {
    background: linear-gradient(90deg, #22c55e, var(--primary));
}

@media (max-width: 600px) {
    .wizard { padding: 4px 12px; }
    .wizard-step { padding: 6px 2px; font-size: 12px; gap: 6px; }
    .wizard-connector { width: 20px; margin: 0 4px; }
}

/* ==========================================================================
   TOGGLE SWITCH (for ECTS/ECVET etc.)
   ========================================================================== */

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    width: 100%;
    user-select: none;
    transition: all 0.15s ease;
}

.toggle:hover { border-color: var(--border-strong); }

.toggle.is-on {
    background: var(--primary-soft);
    border-color: rgba(59, 130, 246, 0.25);
}

.toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: #cbd5e1;
    position: relative;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
    margin: 0;
}

.toggle input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.toggle input[type="checkbox"]:checked {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.toggle input[type="checkbox"]:checked::after {
    transform: translateX(16px);
}

.toggle-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.toggle-label-title {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--text);
}

.toggle-label-hint {
    font-size: 11.5px;
    color: var(--text-muted);
}

/* ==========================================================================
   TWO-COLUMN WIZARD LAYOUT (Step 2)
   ========================================================================== */

.wizard-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 18px;
    align-items: flex-start;
}

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

/* ==========================================================================
   FORMSET / COURSES TABLE (Step 3)
   ========================================================================== */

.formset-table-wrap {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow-x: auto;
}

.formset-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
}

.formset-table thead th {
    text-align: left;
    padding: 10px 12px;
    background: var(--surface-muted);
    font-weight: 700;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.formset-table tbody td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.formset-table tbody input,
.formset-table tbody select,
.formset-table tbody textarea {
    min-height: 36px !important;
    padding: 6px 10px !important;
    font-size: 12.5px !important;
    border-radius: 8px !important;
}

.formset-table .row-remove {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.formset-table .row-remove:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-soft);
}

.formset-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px dashed var(--border-strong);
    background: transparent;
    color: var(--primary-strong);
    font-weight: 700;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: 12px;
}

.formset-add-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    border-style: solid;
}

/* ==========================================================================
   SIGNATURE UPLOAD CARDS
   ========================================================================== */

.signature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.signature-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 18px;
    text-align: center;
    transition: border-color 0.15s ease;
}

.signature-card.is-signed { border-color: rgba(34, 197, 94, 0.25); background: #f7fefb; }

.signature-card-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.signature-preview {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.signature-preview img {
    max-height: 100px;
    max-width: 100%;
    object-fit: contain;
}

.signature-empty {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    font-size: 22px;
}

/* ==========================================================================
   SELECT2 OVERRIDES (match our form inputs)
   ========================================================================== */

.page .select2-container,
.form-panel .select2-container { width: 100% !important; }

.page .select2-container--bootstrap-5 .select2-selection,
.form-panel .select2-container--bootstrap-5 .select2-selection,
.page .select2-container--default .select2-selection,
.form-panel .select2-container--default .select2-selection {
    min-height: 42px !important;
    padding: 5px 10px !important;
    border-radius: 10px !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    font-size: 13.5px !important;
    color: var(--text) !important;
    box-shadow: none !important;
    transition: all 0.15s ease !important;
    display: flex !important;
    align-items: center !important;
}

.page .select2-container--bootstrap-5.select2-container--focus .select2-selection,
.form-panel .select2-container--bootstrap-5.select2-container--focus .select2-selection,
.page .select2-container--default.select2-container--focus .select2-selection,
.form-panel .select2-container--default.select2-container--focus .select2-selection,
.page .select2-container--bootstrap-5.select2-container--open .select2-selection,
.form-panel .select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12) !important;
    background: #fff !important;
}

.select2-container--bootstrap-5 .select2-selection__rendered,
.select2-container--default .select2-selection__rendered {
    color: var(--text) !important;
    line-height: 1.35 !important;
    padding: 0 !important;
}

.select2-container--bootstrap-5 .select2-selection__placeholder,
.select2-container--default .select2-selection__placeholder { color: var(--text-soft) !important; }

.select2-container .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
    right: 10px !important;
}

.select2-dropdown {
    border-radius: 12px !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted,
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--primary-soft) !important;
    color: var(--primary-strong) !important;
}

.select2-container--bootstrap-5 .select2-search__field,
.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 8px 10px !important;
    font-size: 13px !important;
}

/* ---- Multi-select: let the box grow and wrap chips on multiple rows ---- */
.page .select2-container--bootstrap-5 .select2-selection--multiple,
.form-panel .select2-container--bootstrap-5 .select2-selection--multiple,
.page .select2-container--default .select2-selection--multiple,
.form-panel .select2-container--default .select2-selection--multiple {
    display: block !important;          /* override the single-select flex/center */
    align-items: initial !important;
    padding: 5px 8px !important;
    height: auto !important;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered,
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice,
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    display: inline-flex !important;
    align-items: center !important;
    flex-direction: row-reverse !important;  /* text first, × after */
    gap: 6px !important;
    margin: 0 !important;
    padding: 3px 9px !important;
    background: var(--primary-soft) !important;
    color: var(--primary-strong) !important;
    border: 1px solid rgba(59, 130, 246, 0.18) !important;
    border-radius: 999px !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    line-height: 1.5 !important;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove,
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--primary-strong) !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 15px !important;
    line-height: 1 !important;
    opacity: 0.65;
    transition: opacity 0.12s ease;
}
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove:hover,
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    opacity: 1;
    background: transparent !important;
    color: var(--danger, #ef4444) !important;
}

/* Inline search field blends into the chip row */
.select2-container--bootstrap-5 .select2-selection--multiple .select2-search--inline .select2-search__field,
.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
    margin: 0 !important;
    height: 28px !important;
    border: none !important;
    font-size: 13.5px !important;
    color: var(--text) !important;
}

/* ---- Dropdown result rows: comfortable + consistent across single/multi ---- */
.select2-container--bootstrap-5 .select2-results__option,
.select2-container--default .select2-results__option {
    padding: 9px 12px !important;
    font-size: 13.5px !important;
    line-height: 1.3 !important;
}
.select2-container--bootstrap-5 .select2-results__option--selected,
.select2-container--default .select2-results__option[aria-selected="true"] {
    background: var(--surface-muted) !important;
    color: var(--text-soft) !important;
}

/* ==========================================================================
   ALERT (used in instruction banners, server error banners)
   ========================================================================== */

.alert-callout {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: var(--info-soft);
    color: #075985;
    border: 1px solid rgba(14, 165, 233, 0.2);
    font-size: 13px;
    align-items: flex-start;
    line-height: 1.5;
}

.alert-callout.is-warning { background: var(--warning-soft); color: #b45309; border-color: rgba(245, 158, 11, 0.2); }
.alert-callout.is-danger { background: var(--danger-soft); color: #b91c1c; border-color: rgba(239, 68, 68, 0.2); }
.alert-callout.is-success { background: var(--success-soft); color: #15803d; border-color: rgba(34, 197, 94, 0.2); }

.alert-callout i { font-size: 15px; margin-top: 1px; }

/* ==========================================================================
   BUTTONS (extra variants)
   ========================================================================== */

.btn-subtle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 12px;
    background: var(--surface-muted);
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-subtle:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger-soft {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 12px;
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 600;
    font-size: 13px;
    border: 1px solid rgba(239, 68, 68, 0.15);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-danger-soft:hover { background: #fecaca; color: #b91c1c; }

/* ==========================================================================
   FLAG COMPONENTS (rectangular — usable in sidebar, landing, footer)
   ========================================================================== */

.flag-rect {
    display: inline-block;
    width: 28px;
    height: 20px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
    border: 1px solid rgba(15, 23, 42, 0.08);
    vertical-align: middle;
}

.flag-rect svg {
    display: block;
    width: 100%;
    height: 100%;
}

.flag-rect-ua {
    background: linear-gradient(to bottom, #005bbb 50%, #ffd500 50%);
}

.sidebar-flags {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    margin-top: 6px;
    background: var(--surface-muted);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

.sidebar-flags-stack {
    display: inline-flex;
    gap: 4px;
}

.sidebar-flags-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.sidebar-flags-text strong {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.sidebar-flags-text span {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ==========================================================================
   AUTH PAGES (login / register / forgot / reset / activation)
   Centered card on the pastel gradient.
   ========================================================================== */

.auth-shell {
    min-height: calc(100vh - 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
}

/* On mobile the auth screen looked off-centre because the parent
   <main class="container py-5"> in base.html adds 48px of top padding
   (Bootstrap's py-5), which the desktop centring math assumes is zero.
   On a short viewport that pushes the form well below the visual centre.
   Fix: on narrow viewports anchor the stack near the top with a
   comfortable gap, instead of trying to vertically centre. */
@media (max-width: 720px) {
    .auth-shell {
        min-height: auto;
        align-items: flex-start;
        padding: 32px 16px 24px;
    }
}

.auth-stack {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.auth-brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}

.auth-brand-name {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.auth-brand-name strong {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
}

.auth-brand-name span {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary-strong);
    opacity: 0.8;
}

.auth-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--r-xl);
    padding: 30px 28px;
    box-shadow: var(--shadow-lg);
}

.auth-heading {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.015em;
    color: var(--text);
    margin: 0 0 6px 0;
    text-align: center;
}

.auth-sub {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin: 0 0 24px 0;
}

.auth-input {
    position: relative;
}

.auth-input > i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-soft);
    font-size: 14px;
    pointer-events: none;
}

.auth-input input[type="email"],
.auth-input input[type="text"],
.auth-input input[type="password"] {
    width: 100%;
    height: 44px;
    padding: 0 14px 0 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 14px;
    color: var(--text);
    transition: all 0.15s ease;
}

.auth-input input::placeholder { color: var(--text-soft); }

.auth-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
    background: #fff;
}

.auth-input-trailing {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.auth-input-trailing:hover {
    color: var(--primary-strong);
    background: var(--primary-soft);
}

.auth-input.has-trailing input { padding-right: 46px; }

.auth-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.auth-label-row label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.auth-label-row a {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-strong);
    text-decoration: none;
}

.auth-label-row a:hover { text-decoration: underline; }

.auth-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    margin: 16px 0 20px 0;
}

.auth-remember input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}

.auth-footer {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary-strong);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover { text-decoration: underline; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 4px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Two-column field row inside an auth card (e.g., first/last name). */
.auth-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

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

/* Styled checkbox row for auth (T&C, consent). */
.auth-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 14px 0 20px 0;
    font-size: 12.5px;
    color: var(--text);
    line-height: 1.55;
}

.auth-consent input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 2px 0 0 0;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.auth-consent label { cursor: pointer; }

.auth-consent .consent-help {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ==========================================================================
   SEARCH-INPUT ICON OFFSET (must win over .page input[type="search"])
   ========================================================================== */

.page .toolbar-search input[type="search"],
.page .topbar-search input[type="search"],
.toolbar-search input[type="search"],
.topbar-search input[type="search"] {
    padding-left: 38px;
}

/* ==========================================================================
   READ-ONLY DETAIL BLOCKS (used on competence / document detail pages)
   ========================================================================== */

.detail-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-block + .detail-block { margin-top: 16px; }

.detail-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.detail-label i { color: var(--primary); font-size: 13px; }

.detail-value {
    font-size: 13.5px;
    color: var(--text);
    line-height: 1.6;
    /* NB: don't use `white-space: pre-wrap` here — it would preserve the
       indentation whitespace that sits between the opening tag and the value
       in templates. Multi-line content should use Django's `|linebreaksbr`
       filter to emit <br> tags. */
}

.detail-value.is-empty {
    color: var(--text-soft);
    font-style: italic;
}

.detail-block-card {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-block-card .detail-label { margin-bottom: 2px; }


/* ==========================================================================
   SweetAlert2 — design system theme
   Applied globally to every Swal.fire() call.
   For richer modals use customClass: { popup: 'app-swal app-swal--<flavor>' }
   ========================================================================== */

.swal2-container {
    backdrop-filter: blur(2px);
}

.swal2-container.swal2-backdrop-show {
    background: rgba(15, 23, 42, 0.45);
}

.swal2-popup {
    border-radius: var(--r-lg);
    padding: 28px 28px 22px;
    box-shadow: var(--shadow-lg);
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    width: 460px;
    max-width: calc(100vw - 32px);
}

.swal2-popup .swal2-title {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    padding: 0 4px;
    margin-top: 4px;
}

.swal2-popup .swal2-html-container {
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.55;
    padding: 0 6px;
    margin-top: 6px;
}

/* Static icons (question / info / warning) — safe to resize, no animation. */
.swal2-popup .swal2-icon.swal2-question,
.swal2-popup .swal2-icon.swal2-info,
.swal2-popup .swal2-icon.swal2-warning {
    width: 56px;
    height: 56px;
    margin: 4px auto 14px;
    border-width: 2.5px;
}

.swal2-popup .swal2-icon.swal2-question .swal2-icon-content,
.swal2-popup .swal2-icon.swal2-info .swal2-icon-content,
.swal2-popup .swal2-icon.swal2-warning .swal2-icon-content {
    font-size: 28px;
}

/* Animated icons (success / error) — KEEP default 80x80. SweetAlert2's
   success/error animations use hardcoded pixel offsets for the masking
   elements that assume the default size. Resizing breaks the animation
   end-state (broken check / mis-rotated ring). Just tighten the margin. */
.swal2-popup .swal2-icon.swal2-success,
.swal2-popup .swal2-icon.swal2-error {
    margin: 8px auto 18px;
}

/* Color overrides — these are safe and only retint, no positioning impact. */
.swal2-popup .swal2-icon.swal2-question { border-color: var(--primary); color: var(--primary-strong); }
.swal2-popup .swal2-icon.swal2-success { border-color: var(--success); }
.swal2-popup .swal2-icon.swal2-error   { border-color: var(--danger); }
.swal2-popup .swal2-icon.swal2-warning { border-color: var(--warning); color: var(--warning); }
.swal2-popup .swal2-icon.swal2-info    { border-color: var(--primary); color: var(--primary-strong); }

.swal2-popup .swal2-icon.swal2-success [class^=swal2-success-line] { background-color: var(--success); }
.swal2-popup .swal2-icon.swal2-success .swal2-success-ring { border-color: rgba(34, 197, 94, 0.25); }

/* The success animation hides parts of the ring using white masking elements
   (circular-line-left/right, success-fix). These rely on `background: white`
   matching the popup background. Our popup uses var(--surface) which resolves
   to #ffffff at :root, so the masks blend correctly — but force the value
   here defensively in case --surface is ever themed darker. */
.swal2-popup .swal2-icon.swal2-success .swal2-success-circular-line-left,
.swal2-popup .swal2-icon.swal2-success .swal2-success-circular-line-right,
.swal2-popup .swal2-icon.swal2-success .swal2-success-fix {
    background-color: var(--surface) !important;
}

.swal2-popup .swal2-actions {
    margin-top: 22px;
    gap: 8px;
}

.swal2-popup .swal2-styled {
    border-radius: 12px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.swal2-popup .swal2-styled:focus { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); }

.swal2-popup .swal2-styled.swal2-confirm {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong)) !important;
    color: #fff !important;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
}
.swal2-popup .swal2-styled.swal2-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(59, 130, 246, 0.38);
}

.swal2-popup .swal2-styled.swal2-cancel {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border-strong) !important;
}
.swal2-popup .swal2-styled.swal2-cancel:hover {
    background: var(--surface-hover) !important;
    border-color: var(--primary) !important;
    color: var(--primary-strong) !important;
}

/* "Danger" flavor — used by Swal.fire({ ..., customClass: { popup: 'app-swal app-swal--danger' } }) */
.app-swal--danger .swal2-styled.swal2-confirm {
    background: linear-gradient(135deg, #f87171, var(--danger)) !important;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3) !important;
}
.app-swal--danger .swal2-styled.swal2-confirm:hover {
    box-shadow: 0 10px 22px rgba(239, 68, 68, 0.38) !important;
}

/* "Success" flavor — for completed-action confirmations */
.app-swal--success .swal2-styled.swal2-confirm {
    background: linear-gradient(135deg, #4ade80, var(--success)) !important;
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.3) !important;
}

/* Loader styling so the "Sending…" state matches our look */
.swal2-popup .swal2-loader {
    border-color: var(--primary) transparent var(--primary) transparent;
    width: 38px;
    height: 38px;
    border-width: 3px;
}

/* ----- Send-to-NEC modal: rich body shipped via html: ----- */
.swal-nec-card {
    margin: 4px 0 0;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-muted);
    padding: 14px 16px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.swal-nec-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.swal-nec-row .swal-nec-icon {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.swal-nec-row.is-warning .swal-nec-icon {
    background: var(--warning-soft);
    color: var(--warning);
}

.swal-nec-row .swal-nec-text {
    flex: 1;
    min-width: 0;
}

.swal-nec-row .swal-nec-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    font-weight: 700;
    margin-bottom: 2px;
}

.swal-nec-row .swal-nec-value {
    font-size: 13.5px;
    color: var(--text);
    font-weight: 600;
    word-break: break-word;
}

.swal-nec-row .swal-nec-value .muted {
    color: var(--text-muted);
    font-weight: 500;
}

.swal-nec-foot {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.5;
    text-align: left;
    padding: 0 4px;
}

.swal-nec-foot i { color: var(--text-soft); margin-right: 6px; }


/* ==========================================================================
   NEC Verification page — full-bleed layout used by documents/review.html
   ========================================================================== */

/* Full-bleed escape from the public-mode <main class="container py-5"> */
body.review-fullbleed main.container {
    max-width: 100% !important;
    padding: 0 !important;
}

.review-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: linear-gradient(180deg, #f1f5fb 0%, #f8fafc 280px);
    color: var(--text);
}

.review-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 0;
    z-index: 5;
    flex-wrap: wrap;
}

.review-topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.review-topbar-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
    flex-shrink: 0;
}

.review-topbar-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.review-topbar-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.005em;
}

.review-topbar-subtitle {
    font-size: 11.5px;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.review-topbar-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.review-topbar-doc {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-weight: 700;
    font-size: 12.5px;
    letter-spacing: 0.01em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.review-topbar-doc i { font-size: 11px; }

/* Two-column body: PDF preview + review panel */
.review-body {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(360px, 1fr);
    gap: 0;
    flex: 1;
    min-height: 0;
}

.review-pdf {
    background: #e2e8f0;
    border-right: 1px solid var(--border);
    min-height: calc(100vh - 76px);
    position: relative;
}

.review-pdf iframe {
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 76px);
    border: 0;
    display: block;
}

.review-aside {
    background: var(--surface);
    padding: 26px 26px 32px;
    overflow-y: auto;
    max-height: calc(100vh - 76px);
}

.review-aside-section + .review-aside-section { margin-top: 18px; }

/* Document summary card */
.review-summary {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 18px;
}

.review-summary-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.review-summary-row.is-full { grid-column: 1 / -1; }

.review-summary-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    font-weight: 700;
}

.review-summary-value {
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
    word-break: break-word;
    line-height: 1.4;
}

.review-summary-value.is-empty { color: var(--text-soft); font-weight: 500; font-style: italic; }

/* Info banner */
.review-info {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    background: var(--primary-soft);
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: var(--r-md);
    color: var(--primary-strong);
    font-size: 12.5px;
    line-height: 1.5;
}

.review-info i {
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Action buttons */
.review-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-approve {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4ade80, var(--success));
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-approve:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(34, 197, 94, 0.36);
    color: #fff;
}

.btn-approve i { font-size: 14px; }

.btn-reject-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    border: 1px solid var(--border-strong);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-reject-toggle:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: #fff5f5;
}

.btn-confirm-reject {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f87171, var(--danger));
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-confirm-reject:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(239, 68, 68, 0.38);
    color: #fff;
}

/* Reject form panel */
.review-reject-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.review-reject-panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--danger);
    font-weight: 700;
    font-size: 13.5px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.review-reject-panel-head i { font-size: 14px; }

.review-reject-panel label {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    margin-bottom: 6px;
}

.review-reject-panel textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.review-reject-panel textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.review-reject-panel textarea.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.review-reject-error {
    display: none;
    color: var(--danger);
    font-size: 12px;
    margin-top: -4px;
}

.review-reject-error.is-visible { display: block; }

.review-flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--r-md);
    font-size: 12.5px;
    line-height: 1.5;
    border: 1px solid var(--border);
}

.review-flash.is-error {
    background: var(--danger-soft);
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.25);
}

.review-flash.is-warning {
    background: var(--warning-soft);
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.25);
}

/* Mobile / tablet */
@media (max-width: 1024px) {
    .review-body {
        grid-template-columns: 1fr;
    }
    .review-pdf {
        min-height: 60vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .review-pdf iframe { min-height: 60vh; }
    .review-aside { max-height: none; }
}

@media (max-width: 720px) {
    .review-topbar { padding: 12px 16px; }
    .review-aside { padding: 20px 18px 28px; }
    .review-summary { grid-template-columns: 1fr; }
}


/* ==========================================================================
   Host Review page (documents/host_review.html) — extends the .review-*
   shell with signature-upload widget + cropper modal.
   ========================================================================== */

/* "Pending Your Approval" pill in the topbar — yellow/amber to signal action */
.review-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: var(--warning-soft);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.review-status-pill.is-pending {
    background: var(--warning-soft);
    color: #92400e;
}

.review-status-pill .review-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--warning);
    animation: review-pulse 1.6s ease-in-out infinite;
}

@keyframes review-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.55; transform: scale(0.85); }
}

/* Signature upload widget */
.signature-uploader {
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-md);
    padding: 18px 16px;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.signature-uploader:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.signature-uploader-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: 12px;
    background: var(--surface);
    color: var(--primary-strong);
    font-weight: 600;
    font-size: 13px;
    border: 1px solid var(--primary);
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
}

.signature-uploader-btn:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    border-color: var(--primary-strong);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.28);
}

.signature-uploader-hint {
    font-size: 12px;
    color: var(--text-soft);
    margin-top: 10px;
    line-height: 1.5;
}

.signature-uploader-hint i {
    color: var(--text-soft);
    margin-right: 4px;
}

/* Signature preview after crop */
.signature-preview-card {
    background: #f7fefb;
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: var(--r-md);
    padding: 12px 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.signature-preview-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--success);
}

.signature-preview-label i { font-size: 10px; }

.signature-preview-frame {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.signature-preview-frame img {
    max-height: 100px;
    max-width: 100%;
    mix-blend-mode: multiply;
}

.signature-remove-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--surface);
    color: var(--danger);
    border: 1px solid var(--border-strong);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.signature-remove-btn:hover {
    border-color: var(--danger);
    background: var(--danger-soft);
}

/* ==========================================================================
   Bootstrap modal — global hardening. Every Bootstrap modal in this app
   should be a clearly opaque white panel sitting above a dark dim. Apply
   here at .modal-content level (no class scoping) so even modals that
   forgot to add a custom class still render correctly. The app shell
   uses a lot of backdrop-filter glass effects on sidebars/cards; we
   explicitly disable those on .modal-content and create our own
   stacking context with `isolation: isolate` so nothing inherits in.
   ========================================================================== */
:root {
    --bs-modal-bg: #ffffff;
    --bs-modal-color: var(--text);
    --bs-modal-border-color: var(--border);
    --bs-backdrop-bg: #0f172a;
    --bs-backdrop-opacity: 0.6;
}

.modal-content {
    background-color: #ffffff !important;
    background: #ffffff !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28), 0 8px 20px rgba(15, 23, 42, 0.18) !important;
    opacity: 1 !important;
    isolation: isolate;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    filter: none !important;
    mix-blend-mode: normal !important;
}

/* Cropper modal — Bootstrap modal restyled to match the design system */
.ep-cropper-modal .modal-dialog {
    max-width: 720px;
}

.ep-cropper-modal .modal-content {
    border-radius: var(--r-lg);
    overflow: hidden;
}

.ep-cropper-modal .modal-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}

.ep-cropper-modal .modal-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.ep-cropper-modal .modal-title i {
    color: var(--primary-strong);
    font-size: 14px;
}

.ep-cropper-modal .modal-body {
    background: #ffffff;
    padding: 0;
    text-align: center;
    overflow: hidden !important;
    /* Bootstrap's .modal-body is flex:1 by default and grows to its content.
       Pin it to a fixed height so the cropper canvas inside is clipped. */
    flex: 0 0 420px !important;
    height: 420px !important;
    max-height: 420px !important;
}

.ep-cropper-modal .modal-body-inner {
    height: 420px;
    width: 100%;
    max-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Pre-Cropper image (before init): constrain to fit the modal body. */
.ep-cropper-modal .modal-body-inner > img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

/* Post-Cropper: Cropper.js wraps the image in .cropper-container which uses
   !important rules that ignore max-width/max-height on the image. We override
   that here so the cropper canvas always fits within the 420px modal body. */
.ep-cropper-modal .modal-body-inner .cropper-container {
    max-width: 100% !important;
    max-height: 420px !important;
    width: 100% !important;
}

.ep-cropper-modal .modal-body-inner .cropper-container .cropper-wrap-box,
.ep-cropper-modal .modal-body-inner .cropper-container .cropper-canvas,
.ep-cropper-modal .modal-body-inner .cropper-container .cropper-drag-box,
.ep-cropper-modal .modal-body-inner .cropper-container .cropper-crop-box {
    max-height: 420px !important;
}

.ep-cropper-modal .modal-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Bootstrap modal backdrop — make sure it sits above our app shell and is
   opaque enough to clearly separate the modal from the page behind it.
   Bootstrap adds .modal-open to <body> when any modal is shown; the previous
   .ep-cropper-modal-open selector never matched, leaving the cropper modal almost
   invisible against the white review-aside panel. */
body.modal-open .modal-backdrop,
body.modal-open .modal-backdrop.show,
.modal-backdrop.show {
    background-color: #0f172a !important;
    opacity: 0.6 !important;
}

/* Make sure the cropper modal layer rises above the sticky review topbar
   (z-index: 5) and any other in-page sticky UI. Bootstrap defaults are
   already high enough for ordinary modals; we only restate them for the
   cropper modal where the in-page UI underneath is dense.

   IMPORTANT: scope the backdrop z-index bump to ONLY the cropper modal's
   own backdrop (adjacent sibling). A previous version used
   `body.modal-open > .modal-backdrop`, which matched every modal's
   backdrop — pushing them to 1075 while non-cropper modals stayed at the
   default 1055, so the backdrop ended up on top of the dialog and
   intercepted clicks. */
.ep-cropper-modal {
    z-index: 1080;
}

.ep-cropper-modal + .modal-backdrop {
    z-index: 1075;
}


/* ==========================================================================
   Feedback page — centered status card shown after approve/reject and on
   invalid tokens. Used by documents/host_feedback.html.
   ========================================================================== */

body.feedback-fullbleed main.container {
    max-width: 100% !important;
    padding: 0 !important;
}

.feedback-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(180deg, #f1f5fb 0%, #f8fafc 280px);
    position: relative;
}

.feedback-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(800px 320px at 50% -120px, rgba(59, 130, 246, 0.10), transparent 70%);
    pointer-events: none;
}

.feedback-card {
    position: relative;
    width: 100%;
    max-width: 460px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px 28px;
    text-align: center;
    overflow: hidden;
}

.feedback-card::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-strong));
}

.feedback-card.is-success::after { background: linear-gradient(90deg, #4ade80, var(--success)); }
.feedback-card.is-danger::after  { background: linear-gradient(90deg, #f87171, var(--danger)); }
.feedback-card.is-warning::after { background: linear-gradient(90deg, #fbbf24, var(--warning)); }

.feedback-icon {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    margin: 4px auto 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    border: 4px solid var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.feedback-card.is-success .feedback-icon {
    background: var(--success-soft);
    color: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
}

.feedback-card.is-danger .feedback-icon {
    background: var(--danger-soft);
    color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-soft);
}

.feedback-card.is-warning .feedback-icon {
    background: var(--warning-soft);
    color: var(--warning);
    box-shadow: 0 0 0 3px var(--warning-soft);
}

.feedback-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.015em;
    line-height: 1.25;
    margin: 0 0 10px;
}

.feedback-message {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0 0 24px;
}

.feedback-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    text-align: left;
}

.feedback-status-block { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.feedback-status-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
}

.feedback-status-value {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.feedback-status-value .feedback-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-soft);
    flex-shrink: 0;
}

.feedback-status-value.is-success { color: var(--success); }
.feedback-status-value.is-success .feedback-status-dot { background: var(--success); }

.feedback-status-value.is-danger { color: var(--danger); }
.feedback-status-value.is-danger .feedback-status-dot { background: var(--danger); }

.feedback-status-value.is-warning { color: var(--warning); }
.feedback-status-value.is-warning .feedback-status-dot { background: var(--warning); }

.feedback-status-value.is-primary { color: var(--primary-strong); }
.feedback-status-value.is-primary .feedback-status-dot { background: var(--primary); }

.feedback-status-time {
    font-size: 11.5px;
    color: var(--text-soft);
    font-weight: 500;
    flex-shrink: 0;
    text-align: right;
    line-height: 1.4;
}

.feedback-doc-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 14px;
    word-break: break-all;
}

.feedback-foot {
    margin-top: 22px;
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.5;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.feedback-foot i { font-size: 11px; }

@media (max-width: 480px) {
    .feedback-card { padding: 28px 22px 22px; }
    .feedback-title { font-size: 19px; }
    .feedback-icon { width: 64px; height: 64px; font-size: 26px; }
    .feedback-status { flex-direction: column; align-items: flex-start; }
    .feedback-status-time { text-align: left; }
}


/* ==========================================================================
   HELP CENTER — long-form guides page (documents/help_center.html)

   Two-column layout: sticky table-of-contents on the left, scrolling main
   content on the right. Sections are filterable via the search box at the
   top of the main column.
   ========================================================================== */

.help-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 28px;
    align-items: flex-start;
}

@media (max-width: 960px) {
    .help-shell { grid-template-columns: 1fr; }
}

/* ----- TOC (sticky left aside) ----- */
.help-toc {
    position: sticky;
    top: 96px;            /* clear the topbar */
    align-self: flex-start;
}

@media (max-width: 960px) {
    .help-toc {
        position: static;
        top: auto;
    }
}

.help-toc-inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 14px;
    box-shadow: var(--shadow-sm);
}

.help-toc-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
    padding: 4px 10px 10px;
}

.help-toc-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.help-toc-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
}

.help-toc-link > i {
    width: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-soft);
}

.help-toc-link:hover {
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.help-toc-link:hover > i { color: var(--primary-strong); }

.help-toc-link.is-active {
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.help-toc-link.is-active > i { color: var(--primary-strong); }

.help-toc-footer {
    margin-top: 14px;
    padding: 12px;
    border-top: 1px dashed var(--border);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.45;
}

.help-toc-footer > i { font-size: 14px; margin-top: 2px; color: var(--primary); }

/* ----- Main content column ----- */
.help-main {
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-width: 0;
}

/* ----- Search ----- */
.help-search {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 6px 10px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.help-search-icon {
    color: var(--text-soft);
    font-size: 14px;
    margin-left: 6px;
    flex-shrink: 0;
}

.help-search input[type="search"] {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: var(--text);
    padding: 8px 4px;
    font-family: inherit;
}

.help-search input[type="search"]::placeholder { color: var(--text-soft); }

/* Strip the native browser ✕ on type=search */
.help-search input[type="search"]::-webkit-search-cancel-button { display: none; }
.help-search input[type="search"]::-ms-clear { display: none; }

.help-search-clear {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--surface-muted);
    color: var(--text-soft);
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.help-search-clear:hover {
    background: var(--neutral-soft);
    color: var(--text);
}

.help-search-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--surface-muted);
    border: 1px dashed var(--border);
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-size: 13.5px;
}

.help-search-empty > i { font-size: 16px; color: var(--text-soft); }

/* ----- Section ----- */
.help-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 28px 32px;
    box-shadow: var(--shadow-sm);
    scroll-margin-top: 96px;       /* offset for sticky topbar when anchor-jumping */
}

@media (max-width: 720px) {
    .help-section { padding: 22px 18px; }
}

.help-section.is-hidden { display: none; }

.help-section-head {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin: 0 0 22px 0;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.help-section-num {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.25);
}

.help-section-title {
    margin: 0 0 4px 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.015em;
    color: var(--text);
}

.help-section-sub {
    margin: 0;
    color: var(--text-muted);
    font-size: 13.5px;
}

/* ----- Topic (article inside a section) ----- */
.help-topic {
    margin-top: 22px;
}

.help-topic:first-of-type { margin-top: 0; }

.help-topic.is-hidden { display: none; }

.help-topic h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
}

.help-topic p {
    margin: 0 0 12px 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.help-topic p:last-child { margin-bottom: 0; }

.help-topic ul,
.help-topic ol {
    margin: 0 0 12px 0;
    padding-left: 22px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.help-topic ul li,
.help-topic ol li {
    margin-bottom: 6px;
}

.help-topic ul li:last-child,
.help-topic ol li:last-child {
    margin-bottom: 0;
}

/* ----- Role list (Coordinator / NEC / Host / Holder) ----- */
.help-role-list {
    list-style: none;
    margin: 0 !important;
    padding: 0 !important;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}

.help-role-list li {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0 !important;
}

.help-role-list strong {
    font-size: 13.5px;
    color: var(--text);
}

.help-role-list span {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ----- Lifecycle list (status sequence) ----- */
.help-lifecycle {
    list-style: none;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.help-lifecycle li {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 10px 14px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin: 0 !important;
}

@media (max-width: 600px) {
    .help-lifecycle li { grid-template-columns: 1fr; gap: 6px; }
}

.help-lifecycle li > span:last-child {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}

.help-lifecycle-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    width: fit-content;
}

.help-lifecycle-pill.is-draft     { background: var(--neutral-soft); color: var(--text-muted); }
.help-lifecycle-pill.is-registered { background: var(--info-soft);    color: #0369a1; }
.help-lifecycle-pill.is-sent      { background: var(--warning-soft); color: #b45309; }
.help-lifecycle-pill.is-accepted  { background: var(--success-soft); color: #15803d; }
.help-lifecycle-pill.is-completed {
    background: linear-gradient(135deg, #22c55e, #15803d);
    color: #fff;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.25);
}

.help-lifecycle-pill > i { font-size: 10px; }

/* ----- Step list (numbered create flow) ----- */
.help-step-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.help-step {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 14px;
    align-items: flex-start;
    padding: 14px 16px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.help-step-num {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-weight: 800;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.help-step strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text);
}

.help-step p {
    margin: 0 0 8px 0;
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.55;
}

.help-step p:last-child { margin-bottom: 0; }

/* ----- Signature list ----- */
.help-sig-list {
    list-style: none;
    margin: 0 !important;
    padding: 0 !important;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
    counter-reset: sig;
}

.help-sig-list li {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px 12px 42px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0 !important;
    counter-increment: sig;
}

.help-sig-list li::before {
    content: counter(sig);
    position: absolute;
    left: 12px;
    top: 12px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.help-sig-list strong {
    font-size: 13.5px;
    color: var(--text);
}

.help-sig-list span {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ----- Callout (info / warning) ----- */
.help-callout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    margin-top: 14px;
    font-size: 13px;
    line-height: 1.55;
}

.help-callout > i {
    font-size: 15px;
    margin-top: 2px;
    flex-shrink: 0;
}

.help-callout strong {
    display: block;
    font-weight: 700;
    margin-bottom: 2px;
}

.help-callout.is-info {
    background: var(--info-soft);
    color: #0c4a6e;
    border-color: rgba(14, 165, 233, 0.2);
}

.help-callout.is-info > i { color: #0369a1; }

.help-callout.is-warning {
    background: var(--warning-soft);
    color: #78350f;
    border-color: rgba(245, 158, 11, 0.25);
}

.help-callout.is-warning > i { color: #b45309; }

.modal-title{
    position: relative ;
    z-index: 99999 ; /* Максимальний пріоритет */
    pointer-events: auto ; /* Гарантує, що клік спрацює */
}
