/* =============================================================================
   Krea Healthcare Panel Management
   Stylesheet v1.3 — adds Panel module: status badges, accordions,
   filter bar, pagination, key-value grids, radio/checkbox pills, upload zone.
   ============================================================================= */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

:root {
    --bg: #ffffff;
    --bg-elev: #ffffff;
    --bg-canvas: color-mix(in srgb, var(--base, #0D7C7C) 4%, #f4f7f8);
    --surface-tint: color-mix(in srgb, var(--base, #0D7C7C) 5%, #ffffff);
    --surface-tint-strong: color-mix(in srgb, var(--base, #0D7C7C) 10%, #ffffff);

    --border: #e3e8eb;
    --border-strong: #cfd6db;
    --border-tinted: color-mix(in srgb, var(--base, #0D7C7C) 18%, #e3e8eb);

    --text: #0c1417;
    --text-muted: #56636c;
    --text-soft: #8a949d;

    --shadow-xs: 0 1px 2px rgba(15, 23, 28, 0.05);
    --shadow-sm: 0 2px 4px rgba(15, 23, 28, 0.04), 0 1px 2px rgba(15, 23, 28, 0.04);
    --shadow-md: 0 4px 18px rgba(15, 23, 28, 0.07);
    --shadow-lg: 0 16px 48px rgba(15, 23, 28, 0.10);
    --shadow-base: 0 6px 20px color-mix(in srgb, var(--base, #0D7C7C) 22%, transparent);

    --success: #0f9d6e;
    --warning: #c47800;
    --danger: #c8334b;
    --info: #2563eb;
    --neutral: #6b7780;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-pill: 999px;

    --font-display: 'Bricolage Grotesque', ui-serif, Georgia, serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --sidebar-width: 248px;
    --sidebar-width-collapsed: 72px;
    --topbar-height: 64px;
}

body {
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
}

/* ----- App shell ---------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 40;
    transition: width 180ms ease;
}

.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left 180ms ease;
}

/* ----- Brand -------------------------------------------------------------- */
.brand {
    padding: 22px 22px 18px;
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--base) 8%, #ffffff) 0%,
        transparent 100%);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.brand::after {
    content: '';
    position: absolute;
    left: 22px; right: 22px; bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, var(--base) 0%, transparent 60%);
    opacity: 0.5;
}

.brand-link { display: inline-flex; align-items: baseline; gap: 10px; }

.brand-mark {
    display: inline-block;
    width: 9px; height: 9px;
    background: var(--base);
    border-radius: 2px;
    transform: translateY(-2px);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--base) 22%, transparent);
}

.brand-text {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--text);
}

.brand-tagline {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 500;
}

/* ----- Navigation --------------------------------------------------------- */
.nav { padding: 14px 12px; flex: 1; }

.nav-group-label {
    padding: 16px 10px 6px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-soft);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    position: relative;
    transition: background 120ms ease, color 120ms ease;
}

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

.nav-item-active {
    background: color-mix(in srgb, var(--base) 14%, #ffffff);
    color: color-mix(in srgb, var(--base) 80%, #000000);
    font-weight: 600;
}

.nav-item-active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 6px; bottom: 6px;
    width: 3px;
    background: var(--base);
    border-radius: 0 3px 3px 0;
}

.nav-icon { display: inline-flex; color: currentColor; opacity: 0.8; }
.nav-item-active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-soft);
    letter-spacing: 0.04em;
    background: color-mix(in srgb, var(--base) 3%, #ffffff);
}

/* ----- Collapsed sidebar (desktop) ---------------------------------------- */
/* The collapsed flag is applied to <html> from an inline script in <head> so it
   takes effect before first paint (no flash on page load). The toggle button in
   the topbar flips it and persists the state in localStorage. */
html.sidebar-collapsed {
    --sidebar-width: var(--sidebar-width-collapsed);
}

html.sidebar-collapsed .app-sidebar { overflow-x: hidden; }

/* Brand collapses to just the mark */
html.sidebar-collapsed .brand {
    padding: 22px 0 18px;
    text-align: center;
}
html.sidebar-collapsed .brand-link { justify-content: center; gap: 0; }
html.sidebar-collapsed .brand-text,
html.sidebar-collapsed .brand-tagline { display: none; }

/* Group headings hidden */
html.sidebar-collapsed .nav-group-label { display: none; }

/* Nav padding tightens and items center */
html.sidebar-collapsed .nav { padding: 14px 8px; }
html.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 11px 8px;
    gap: 0;
}
html.sidebar-collapsed .nav-label { display: none; }

/* Active-state accent bar still aligned to sidebar edge */
html.sidebar-collapsed .nav-item-active::before {
    left: -8px;
}

/* Sidebar footer hidden (mostly text) */
html.sidebar-collapsed .sidebar-footer { display: none; }

/* ----- Top bar ------------------------------------------------------------ */
.app-topbar {
    height: var(--topbar-height);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky; top: 0;
    z-index: 30;
    box-shadow: var(--shadow-xs);
}

.app-topbar::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, var(--base) 0%, transparent 30%);
    opacity: 0.55;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.icon-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
}

.icon-btn:hover { background: var(--surface-tint); color: var(--text); }
.sidebar-toggle { display: inline-flex; }

.page-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* ----- User menu ---------------------------------------------------------- */
.user-menu { position: relative; }

.user-trigger {
    display: flex; align-items: center; gap: 10px;
    background: transparent; border: 1px solid transparent;
    padding: 6px 10px 6px 6px;
    border-radius: var(--radius);
    color: var(--text);
}

.user-trigger:hover { background: var(--surface-tint); }

.user-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--base) 0%, color-mix(in srgb, var(--base) 70%, #000000) 100%);
    color: var(--base-contrast);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px color-mix(in srgb, var(--base) 30%, transparent);
}

.user-info { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.user-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-soft); }

.user-dropdown {
    position: absolute;
    right: 0; top: calc(100% + 8px);
    min-width: 220px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 140ms ease, transform 140ms ease, visibility 140ms;
}

.user-menu.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.user-dropdown-name { font-weight: 600; font-size: 13.5px; }
.user-dropdown-email { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

.user-dropdown-item {
    display: block;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text);
}

.user-dropdown-item:hover { background: var(--surface-tint); }
.user-dropdown-item.danger { color: var(--danger); }
.user-dropdown-item.danger:hover { background: rgba(200, 51, 75, 0.06); }

/* ----- Content & footer --------------------------------------------------- */
.app-content {
    flex: 1;
    padding: 32px clamp(20px, 5%, 64px) 60px;
    max-width: 100%;
    width: 100%;
}

.app-footer {
    padding: 14px clamp(20px, 5%, 64px);
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between;
    color: var(--text-soft); font-size: 12px;
    background: var(--bg);
}

/* ----- Section intros (with accent bar) ---------------------------------- */
.section-intro {
    margin-bottom: 28px;
    max-width: 760px;
    padding-left: 16px;
    border-left: 3px solid var(--base);
}

.section-intro.with-action {
    max-width: none;
    display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
}

.section-intro h2 {
    font-size: 28px;
    letter-spacing: -0.025em;
    margin-bottom: 6px;
}

.section-intro p {
    color: var(--text-muted);
    font-size: 15px;
    margin: 0;
}

/* ----- Breadcrumb -------------------------------------------------------- */
.breadcrumb {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12.5px;
    color: var(--text-soft);
    margin-bottom: 18px;
    padding: 6px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
}

.breadcrumb a {
    color: color-mix(in srgb, var(--base) 75%, #000000);
    font-weight: 600;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-soft); }

/* ----- Cards & sections --------------------------------------------------- */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
}

.card-tinted {
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--base) 8%, #ffffff) 0%,
        color-mix(in srgb, var(--base) 3%, #ffffff) 100%);
    border-color: var(--border-tinted);
}

.card-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 16px;
    gap: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-sub {
    font-size: 12.5px;
    color: var(--text-soft);
    margin-top: 2px;
}

/* ----- Stat tiles --------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-top: 3px solid var(--base);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

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

.stat::after {
    content: '';
    position: absolute;
    right: -36px; top: -36px;
    width: 130px; height: 130px;
    background: radial-gradient(circle, color-mix(in srgb, var(--base) 22%, #ffffff) 0%, transparent 70%);
    opacity: 0.9;
}

.stat-icon {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--base) 14%, #ffffff);
    color: color-mix(in srgb, var(--base) 80%, #000000);
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
    position: relative; z-index: 1;
}

.stat-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--text-soft);
    position: relative; z-index: 1;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-top: 6px;
    color: var(--text);
    position: relative; z-index: 1;
}

.stat-trend {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    position: relative; z-index: 1;
}

.stat-trend a { color: color-mix(in srgb, var(--base) 75%, #000000); font-weight: 600; }

/* ----- Forms -------------------------------------------------------------- */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }

.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.01em;
}

.form-hint { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

.input, .select, .textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font: inherit;
    color: var(--text);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--base);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--base) 18%, transparent);
}

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

.color-input { display: flex; align-items: center; gap: 14px; }

.color-input input[type="color"] {
    width: 56px; height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 4px;
    background: var(--bg);
}

/* ----- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 13.5px;
    letter-spacing: 0.005em;
    transition: background 120ms ease, transform 60ms ease, box-shadow 120ms ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--base);
    color: var(--base-contrast);
    box-shadow: var(--shadow-base);
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--base) 88%, #000000);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--surface-tint);
    border-color: var(--base);
    color: color-mix(in srgb, var(--base) 80%, #000000);
}

.btn-danger { background: var(--danger); color: #ffffff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-tint); }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ----- Tables ------------------------------------------------------------- */
.table-wrap {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.table th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--text-soft);
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-tint);
}

.table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-tint); }

/* ----- Badges ------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11.5px; font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
}

.badge-active { background: rgba(15, 157, 110, 0.12); color: var(--success); border-color: rgba(15, 157, 110, 0.22); }
.badge-inactive { background: var(--surface-tint); color: var(--text-soft); }
.badge-role { background: color-mix(in srgb, var(--base) 14%, #ffffff); color: color-mix(in srgb, var(--base) 80%, #000000); border-color: color-mix(in srgb, var(--base) 25%, transparent); }

.badge-tier-mandatory   { background: rgba(200, 51, 75, 0.10);  color: var(--danger);  border-color: rgba(200, 51, 75, 0.22); }
.badge-tier-recommended { background: color-mix(in srgb, var(--base) 12%, #ffffff); color: color-mix(in srgb, var(--base) 80%, #000000); border-color: color-mix(in srgb, var(--base) 25%, transparent); }
.badge-tier-optional    { background: rgba(36, 99, 235, 0.10);  color: var(--info);    border-color: rgba(36, 99, 235, 0.22); }
.badge-tier-conditional { background: rgba(196, 120, 0, 0.12);  color: var(--warning); border-color: rgba(196, 120, 0, 0.22); }
.badge-tier-cross-cutting { background: rgba(15, 157, 110, 0.10); color: var(--success); border-color: rgba(15, 157, 110, 0.22); }

/* ----- Empty states ------------------------------------------------------- */
.empty {
    padding: 56px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-desc { font-size: 13.5px; max-width: 380px; margin: 0 auto; }

/* ----- Flash messages ----------------------------------------------------- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
}

.flash-success { background: rgba(15, 157, 110, 0.08); color: var(--success); border-color: rgba(15, 157, 110, 0.25); }
.flash-error   { background: rgba(200, 51, 75, 0.07); color: var(--danger); border-color: rgba(200, 51, 75, 0.25); }
.flash-info    { background: color-mix(in srgb, var(--base) 7%, #ffffff); color: color-mix(in srgb, var(--base) 75%, #000000); border-color: color-mix(in srgb, var(--base) 28%, transparent); }

/* ----- Pill tabs --------------------------------------------------------- */
.pill-tabs {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 4px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    gap: 2px;
}

.pill-tab {
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    transition: background 140ms ease, color 140ms ease;
    white-space: nowrap;
}

.pill-tab:hover { color: var(--text); background: var(--surface-tint); }

.pill-tab.active {
    background: var(--base);
    color: var(--base-contrast);
    box-shadow: var(--shadow-base);
}

.pill-tab.active span { color: var(--base-contrast) !important; opacity: 0.75 !important; }

.pill-tab.disabled { opacity: 0.5; cursor: not-allowed; }

/* ----- Module grid (Profilers) ------------------------------------------- */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 16px;
}

.module-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
    cursor: pointer;
    display: block;
    box-shadow: var(--shadow-sm);
}

.module-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--base) 0%, transparent) 0%,
        color-mix(in srgb, var(--base) 8%, transparent) 100%);
    opacity: 0;
    transition: opacity 220ms ease;
    pointer-events: none;
}

.module-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 0;
    background: var(--base);
    transition: height 220ms ease;
    border-radius: 0 3px 3px 0;
}

.module-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-tinted);
}

.module-card:hover::before { opacity: 1; }
.module-card:hover::after { height: 100%; }

.module-card-num {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: color-mix(in srgb, var(--base) 78%, #000000);
    letter-spacing: 0.08em;
    margin-bottom: 10px;
    padding: 3px 10px;
    background: color-mix(in srgb, var(--base) 10%, #ffffff);
    border-radius: var(--radius-pill);
    border: 1px solid color-mix(in srgb, var(--base) 22%, transparent);
    font-weight: 600;
    position: relative; z-index: 1;
}

.module-card-name {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.3;
    position: relative; z-index: 1;
}

.module-card-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 16px;
    min-height: 38px;
    position: relative; z-index: 1;
}

.module-card-meta {
    display: flex; justify-content: space-between; align-items: center;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    position: relative; z-index: 1;
}

.module-card-count {
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px;
}

.module-card-count::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--base);
    opacity: 0.8;
}

.module-card-count span { color: var(--text-soft); font-weight: 500; }

/* ----- Question list (Profilers) ----------------------------------------- */
.question-list { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }

.question-row {
    display: grid;
    grid-template-columns: 36px 1fr auto auto;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 120ms ease;
}

.question-row:last-child { border-bottom: none; }
.question-row:hover { background: var(--surface-tint); }

.question-num {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: color-mix(in srgb, var(--base) 78%, #000000);
    background: color-mix(in srgb, var(--base) 10%, #ffffff);
    border: 1px solid color-mix(in srgb, var(--base) 20%, transparent);
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600;
}

.question-text { font-size: 14px; color: var(--text); font-weight: 500; line-height: 1.4; }

.question-meta { font-size: 11.5px; color: var(--text-soft); margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.question-meta code {
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 1px 7px;
    background: var(--surface-tint);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
}

.question-type-pill {
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: var(--surface-tint);
    color: var(--text-muted);
    letter-spacing: 0.02em;
    border: 1px solid var(--border);
}

.question-actions { display: flex; gap: 6px; }

/* ----- Toolbar ------------------------------------------------------------ */
.toolbar {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

/* =============================================================================
   PANEL MODULE — new in v1.3
   ============================================================================= */

/* ----- Combined status badge (table) ------------------------------------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    font-family: var(--font-mono);
    border: 1px solid transparent;
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}

.status-valid       { background: rgba(15, 157, 110, 0.10); color: var(--success); border-color: rgba(15, 157, 110, 0.30); }
.status-pending     { background: rgba(196, 120, 0, 0.10);  color: var(--warning); border-color: rgba(196, 120, 0, 0.28); }
.status-invalid     { background: rgba(200, 51, 75, 0.08);  color: var(--danger);  border-color: rgba(200, 51, 75, 0.28); }
.status-incomplete  { background: rgba(107, 119, 128, 0.10); color: var(--neutral); border-color: rgba(107, 119, 128, 0.30); }
.status-suspended   { background: rgba(15, 23, 28, 0.92);   color: #ffffff;        border-color: rgba(15, 23, 28, 0.92); }
.status-suspended::before { opacity: 1; }

/* ----- Inline thin badges (per-field email/phone status in detail view) -- */
.badge-thin {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-family: var(--font-mono);
    border: 1px solid transparent;
    vertical-align: middle;
}

.badge-thin-valid,
.badge-thin-validphone        { background: rgba(15, 157, 110, 0.10); color: var(--success); border-color: rgba(15, 157, 110, 0.28); }
.badge-thin-pending,
.badge-thin-pendingphone      { background: rgba(196, 120, 0, 0.10);  color: var(--warning); border-color: rgba(196, 120, 0, 0.26); }
.badge-thin-invalid,
.badge-thin-invalidphone      { background: rgba(200, 51, 75, 0.08);  color: var(--danger);  border-color: rgba(200, 51, 75, 0.26); }
.badge-thin-incomplete,
.badge-thin-nophone           { background: rgba(107, 119, 128, 0.10); color: var(--neutral); border-color: rgba(107, 119, 128, 0.28); }
.badge-thin-suspended         { background: rgba(15, 23, 28, 0.90);   color: #ffffff;        border-color: rgba(15, 23, 28, 0.90); }

/* ----- Module section accordion (<details>) ------------------------------ */
.module-section {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.module-section[open] {
    border-color: var(--border-tinted);
    box-shadow: var(--shadow-md);
}

.module-section > summary {
    list-style: none;
    cursor: pointer;
    padding: 16px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    user-select: none;
    background: var(--bg-elev);
    transition: background 120ms ease;
}

.module-section > summary::-webkit-details-marker { display: none; }

.module-section > summary:hover {
    background: var(--surface-tint);
}

.module-section > summary::after {
    content: '';
    width: 10px; height: 10px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(-45deg);
    margin-left: auto;
    transition: transform 200ms ease;
}

.module-section[open] > summary::after {
    transform: rotate(45deg);
}

.module-section-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: color-mix(in srgb, var(--base) 80%, #000000);
    background: color-mix(in srgb, var(--base) 12%, #ffffff);
    border: 1px solid color-mix(in srgb, var(--base) 24%, transparent);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.06em;
    min-width: 44px;
}

.module-section-name {
    font-family: var(--font-display);
    font-size: 15.5px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    flex: 1;
    min-width: 0;
}

.module-section-body {
    padding: 4px 22px 22px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--base) 2%, #ffffff);
}

.module-section-body .form-row:last-child { margin-bottom: 0; }

/* ----- Key-value display (member detail) --------------------------------- */
.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px 24px;
    margin-top: 16px;
}

.kv {
    min-width: 0;
}

.kv-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 4px;
}

.kv-value {
    font-size: 14px;
    color: var(--text);
    line-height: 1.45;
    word-break: break-word;
}

/* ----- Filter bar (Panel list) ------------------------------------------- */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: var(--shadow-sm);
}

.filter-search {
    flex: 1;
    min-width: 240px;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 0 12px;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.filter-search:focus-within {
    border-color: var(--base);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--base) 18%, transparent);
}

.filter-search svg {
    color: var(--text-soft);
    flex-shrink: 0;
}

.filter-search input {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    outline: none;
    font: inherit;
    color: var(--text);
}

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

.filter-select {
    width: auto;
    min-width: 160px;
    flex: 0 0 auto;
}

/* ----- Pagination -------------------------------------------------------- */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 12px 18px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    flex-wrap: wrap;
    gap: 12px;
}

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

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ----- Upload zone (CSV upload) ------------------------------------------ */
.upload-zone {
    background: color-mix(in srgb, var(--base) 4%, #ffffff);
    border: 2px dashed color-mix(in srgb, var(--base) 35%, var(--border-strong));
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    transition: background 140ms ease, border-color 140ms ease;
}

.upload-zone:hover {
    background: color-mix(in srgb, var(--base) 8%, #ffffff);
    border-color: var(--base);
}

.upload-zone input[type="file"] {
    width: 100%;
    font: inherit;
    color: var(--text);
}

/* ----- Radio pills / checkbox pills (form inputs) ------------------------ */
.radio-group, .checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.radio-pill, .checkbox-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
    user-select: none;
}

.radio-pill:hover, .checkbox-pill:hover {
    background: var(--surface-tint);
    border-color: var(--base);
}

.radio-pill input, .checkbox-pill input {
    margin: 0;
    accent-color: var(--base);
}

.radio-pill:has(input:checked),
.checkbox-pill:has(input:checked) {
    background: color-mix(in srgb, var(--base) 12%, #ffffff);
    border-color: var(--base);
    color: color-mix(in srgb, var(--base) 80%, #000000);
    font-weight: 600;
}

/* ----- Auth & install screens -------------------------------------------- */
.auth-shell { min-height: 100vh; display: flex; background: var(--bg-canvas); }

.auth-aside {
    flex: 1;
    background: linear-gradient(140deg, var(--base) 0%, color-mix(in srgb, var(--base) 65%, #000000) 100%);
    color: var(--base-contrast);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 56px 56px;
    position: relative;
    overflow: hidden;
}

.auth-aside::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.15) 0%, transparent 50%);
    pointer-events: none;
}

.auth-aside-brand {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 700;
    letter-spacing: -0.04em;
    position: relative;
}

.auth-aside-brand::after {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    background: var(--base-contrast);
    border-radius: 2px;
    margin-left: 6px;
    transform: translateY(-2px);
}

.auth-aside-headline {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 500;
    letter-spacing: -0.025em;
    line-height: 1.25;
    max-width: 420px;
    position: relative;
}

.auth-aside-footer { font-size: 13px; opacity: 0.75; position: relative; }

.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 48px; }
.auth-card { width: 100%; max-width: 420px; }

.auth-title {
    font-family: var(--font-display);
    font-size: 28px;
    letter-spacing: -0.025em;
    margin-bottom: 6px;
}

.auth-sub { color: var(--text-muted); margin-bottom: 28px; font-size: 14.5px; }

/* ----- Responsive --------------------------------------------------------- */
@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
    :root { --sidebar-width: 0px; }
    html.sidebar-collapsed { --sidebar-width: 0px; }
    .app-sidebar {
        transform: translateX(-100%);
        width: 248px;
        transition: transform 200ms ease;
    }
    /* On mobile the drawer always shows full labels — undo collapsed-state hides */
    html.sidebar-collapsed .brand { padding: 22px 22px 18px; text-align: left; }
    html.sidebar-collapsed .brand-link { justify-content: flex-start; gap: 10px; }
    html.sidebar-collapsed .brand-text,
    html.sidebar-collapsed .brand-tagline { display: block; }
    html.sidebar-collapsed .brand-link { display: inline-flex; }
    html.sidebar-collapsed .nav-group-label { display: block; }
    html.sidebar-collapsed .nav { padding: 14px 12px; }
    html.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 9px 10px; gap: 12px; }
    html.sidebar-collapsed .nav-label { display: inline; }
    html.sidebar-collapsed .sidebar-footer { display: block; }

    .app-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .app-content { padding: 24px 20px 60px; }
    .auth-aside { display: none; }
    .auth-shell { min-height: 100vh; }
    .section-intro.with-action { flex-direction: column; align-items: stretch; }
    .pill-tabs { display: flex; overflow-x: auto; }
    .question-row { grid-template-columns: 36px 1fr auto; }
    .question-type-pill { display: none; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-select { width: 100%; min-width: 0; }
    .kv-grid { grid-template-columns: 1fr; }
    .pagination { flex-direction: column; align-items: stretch; text-align: center; }
    .pagination-controls { justify-content: center; }
    .module-section > summary { flex-wrap: wrap; }
}