/* ==========================================================================
   PXC Hub – Styles (bright mode only)
   ========================================================================== */

:root {
    /* Typography */
    --font-body: 'Roboto', system-ui, sans-serif;
    --font-heading: 'Roboto Condensed', 'Roboto', system-ui, sans-serif;
    --font-mono: 'Roboto Mono', ui-monospace, monospace;

    /* Surfaces */
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-muted: #f8f9fc;
    --surface-hover: #f1f3f9;
    --border: #e6e8f0;
    --border-strong: #d5d9e5;

    /* Text */
    --text: #171a26;
    --text-soft: #3d4255;
    --text-muted: #6d7288;
    --text-faint: #9a9fb3;

    /* Brand & states */
    --primary: #3b4cf0;
    --primary-hover: #2f3fd9;
    --primary-soft: #eceefe;
    --violet: #7b4cf2;
    --violet-soft: #f1ecfe;
    --success: #149266;
    --success-hover: #0f7d57;
    --success-soft: #e5f6ef;
    --warning: #c97a06;
    --warning-soft: #fdf3e2;
    --danger: #d63d4a;
    --danger-hover: #bf2f3c;
    --danger-soft: #fdeced;
    --info: #2b7bd6;
    --info-soft: #e8f1fc;

    --gradient-brand: linear-gradient(135deg, var(--primary) 0%, var(--violet) 100%);

    /* Shape */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(23, 26, 38, 0.05);
    --shadow-md: 0 8px 24px -10px rgba(23, 26, 38, 0.14);
    --shadow-lg: 0 24px 64px -20px rgba(23, 26, 38, 0.28);

    /* Layout */
    --sidebar-width: 280px;
    --gutter: clamp(20px, 3vw, 48px);
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

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

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
    margin: 0;
}

p { margin: 0; }

a { color: var(--primary); text-decoration: none; }

button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

.mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--text-muted); }

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Brand
   -------------------------------------------------------------------------- */

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 17px;
    background: var(--gradient-brand);
    box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary) 70%, transparent);
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.brand-name strong { font-weight: 700; }

.brand-light { color: #fff; }
.brand-light .brand-mark { background: rgba(255, 255, 255, 0.18); box-shadow: none; backdrop-filter: blur(8px); }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 24px 24px;
}

.sidebar .sidebar-close { display: none; }

.nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.nav-group { display: flex; flex-direction: column; gap: 4px; }

.nav-group-label {
    padding: 0 14px 6px;
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-faint);
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-soft);
    transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

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

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

.nav-link.is-active .nav-icon { font-weight: 400; }

.nav-icon {
    width: 22px;
    text-align: center;
    font-size: 18px;
}

.nav-badge {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    background: var(--surface-muted);
    border: 1px solid var(--border);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

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

.main .topbar { display: none; }

.content {
    flex: 1;
    width: 100%;
    padding: clamp(28px, 4vw, 56px) var(--gutter) 64px;
    animation: content-in 0.45s var(--ease) both;
}

@keyframes content-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

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

.user-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s var(--ease);
}

.user-button:hover, .user-menu.is-open .user-button { background: var(--surface-hover); }

.avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--primary);
    background: var(--primary-soft);
}

.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-caret { color: var(--text-faint); font-size: 12px; transition: transform 0.2s var(--ease); }
.user-menu.is-open .user-caret { transform: rotate(180deg); }

/* Generic popover menu */
.menu {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 20;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0.18s;
}

.menu-up { bottom: calc(100% + 8px); }

.is-open > .menu { opacity: 1; visibility: visible; transform: none; }

.menu form { margin: 0; }

.menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-soft);
    font-size: 15px;
    cursor: pointer;
    text-align: left;
}

.menu-item i { width: 18px; text-align: center; color: var(--text-muted); }
.menu-item:hover { background: var(--surface-hover); color: var(--text); }

/* Icon button */
.icon-button {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.icon-button:hover { background: var(--surface-hover); color: var(--text); }

.sidebar-scrim { display: none; }

/* --------------------------------------------------------------------------
   Page structure
   -------------------------------------------------------------------------- */

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px 32px;
    margin-bottom: clamp(28px, 3vw, 44px);
}

.page-heading { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.page-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.eyebrow-link { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); }
.eyebrow-link:hover { color: var(--primary); }

.page-title { font-size: clamp(30px, 3.2vw, 42px); font-weight: 600; }

.page-description { max-width: 70ch; color: var(--text-muted); font-size: 17px; }

.page-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.section { margin-top: clamp(40px, 4vw, 64px); }

.section-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.section-title { font-size: 20px; }
.section-text { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
    position: relative;
    display: block;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    color: inherit;
}

.card-padded { padding: clamp(22px, 2vw, 32px); }

.card-link {
    cursor: pointer;
    transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.card-link:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }

.card-head { display: flex; align-items: center; gap: 16px; }
.card-head + * { margin-top: 24px; }

.card-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    font-size: 20px;
    color: var(--primary);
    background: var(--primary-soft);
}

.card-title { font-size: 18px; }
.card-subtitle { margin-top: 4px; color: var(--text-muted); font-size: 15px; }
.card-title + .card-subtitle + * { margin-top: 22px; }
.card-arrow { margin-left: auto; color: var(--text-faint); transition: color 0.2s var(--ease); }
.card-link:hover .card-arrow { color: var(--primary); }

/* Inset status bar – never a coloured side border */
.card-status { padding-left: calc(clamp(22px, 2vw, 32px) + 14px); }

.card-status::before {
    content: '';
    position: absolute;
    top: 14px;
    bottom: 14px;
    left: 14px;
    width: 4px;
    border-radius: 4px;
    background: var(--text-faint);
}

.card-status-success::before { background: var(--success); }
.card-status-warning::before { background: var(--warning); }
.card-status-danger::before { background: var(--danger); }
.card-status-info::before { background: var(--info); }

.card-empty { padding: clamp(40px, 6vw, 88px) var(--gutter); }

/* Details list */
.details { margin: 0; display: flex; flex-direction: column; }

.details > div {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px 24px;
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.details > div:first-child { border-top: 0; padding-top: 0; }
.details dt { color: var(--text-muted); }
.details dd { margin: 0; font-weight: 500; text-align: right; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 22px;
    border: 0;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.btn-lg { min-height: 54px; font-size: 16px; }
.btn-block { width: 100%; }

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

.btn-secondary { background: var(--surface-hover); color: var(--text); }
.btn-secondary:hover { background: #e6e9f3; }

.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

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

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

.btn:disabled, .btn.is-loading { cursor: not-allowed; background: var(--border); color: var(--text-faint); }

.btn.is-loading { position: relative; color: transparent; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--text-faint);
    border-top-color: transparent;
    animation: spin 0.7s linear infinite;
}

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

/* --------------------------------------------------------------------------
   Pills
   -------------------------------------------------------------------------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    width: fit-content;
}

.pill i { font-size: 12px; }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--primary-soft); color: var(--primary); }
.pill-muted { background: var(--surface-hover); color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

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

.field-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-soft);
}

.field-hint { font-weight: 400; color: var(--text-faint); }

.input {
    width: 100%;
    min-height: 50px;
    padding: 0 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.input::placeholder { color: var(--text-faint); }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent); }

.input-icon { position: relative; display: block; }
.input-icon > i { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; transition: color 0.2s var(--ease); }
.input-icon .input { padding-left: 48px; }
.input-icon:focus-within > i { color: var(--primary); }
.input-icon .input:has(+ .input-action) { padding-right: 52px; }

.input-action {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
}

.input-action:hover { color: var(--text); background: var(--surface-hover); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 20px 24px;
}

/* Custom checkbox */
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    color: var(--text-soft);
}

.checkbox input { position: absolute; opacity: 0; pointer-events: none; }

.checkbox-box {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: 2px solid var(--border-strong);
    border-radius: 7px;
    background: var(--surface);
    transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.checkbox-box i { font-size: 12px; color: #fff; transform: scale(0); transition: transform 0.2s var(--ease); }
.checkbox input:checked + .checkbox-box { background: var(--primary); border-color: var(--primary); }
.checkbox input:checked + .checkbox-box i { transform: scale(1); }
.checkbox input:focus-visible + .checkbox-box { outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Dropdown (custom, inline)
   -------------------------------------------------------------------------- */

.dropdown { position: relative; display: inline-block; max-width: 100%; }

.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    min-height: 50px;
    padding: 0 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.dropdown-toggle:hover { border-color: var(--border-strong); }
.dropdown.is-open .dropdown-toggle { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent); }

/* All options share one grid cell → width of the longest option, no jumping */
.dropdown-value { display: grid; }
.dropdown-value > * { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.dropdown-sizer { visibility: hidden; }
.dropdown-value i { width: 18px; text-align: center; color: var(--text-muted); }

.dropdown-caret { font-size: 12px; color: var(--text-faint); transition: transform 0.2s var(--ease); }
.dropdown.is-open .dropdown-caret { transform: rotate(180deg); }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    min-width: 100%;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0.18s;
}

.dropdown.is-open .dropdown-menu { opacity: 1; visibility: visible; transform: none; }
.dropdown.is-upward .dropdown-menu { top: auto; bottom: calc(100% + 8px); }

.dropdown-menu li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    color: var(--text-soft);
    cursor: pointer;
    outline: none;
}

.dropdown-menu li > i:first-child { width: 18px; text-align: center; color: var(--text-muted); }
.dropdown-menu li:hover, .dropdown-menu li:focus { background: var(--surface-hover); color: var(--text); }
.dropdown-menu li[aria-selected="true"] { color: var(--primary); font-weight: 500; }
.dropdown-menu li[aria-selected="true"] > i:first-child { color: var(--primary); }

.dropdown-check { margin-left: auto; padding-left: 16px; font-size: 12px; color: var(--primary); opacity: 0; }
.dropdown-menu li[aria-selected="true"] .dropdown-check { opacity: 1; }

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    overflow-y: auto;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(18, 21, 33, 0.42);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fade-in 0.25s var(--ease) both;
}

.modal-dialog {
    position: relative;
    width: min(100%, 880px);
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.32s var(--ease) both;
}

.modal.is-closing .modal-backdrop { animation: fade-out 0.2s var(--ease) both; }
.modal.is-closing .modal-dialog { animation: modal-out 0.2s var(--ease) both; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 28px 32px 0;
}

.modal-title { font-size: 22px; }
.modal-body { padding: 28px 32px; }
.modal-text { color: var(--text-muted); }

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 32px 28px;
    border-top: 1px solid var(--border);
}

/* Small confirmation modal */
.modal-confirm .modal-dialog { width: min(100%, 440px); padding: 36px 32px 28px; text-align: center; }
.modal-confirm .modal-title { margin-top: 20px; }
.modal-confirm .modal-text { margin-top: 10px; }
.modal-confirm .modal-actions { padding: 28px 0 0; border: 0; justify-content: center; }
.modal-confirm .modal-actions .btn { flex: 1; }

.confirm-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 26px;
    color: var(--danger);
    background: var(--danger-soft);
    animation: pop-in 0.4s 0.1s var(--ease) both;
}

body.has-modal { overflow: hidden; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.6); } }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toasts {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(calc(100% - 48px), 420px);
}

.toast {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 12px 16px 18px;
    border-radius: var(--radius-md);
    background: var(--text);
    color: #fff;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.4s var(--ease) both;
}

.toast.is-leaving { animation: toast-out 0.3s var(--ease) both; }
.toast-icon { font-size: 18px; }
.toast-success .toast-icon { color: #4fd8a4; }
.toast-error .toast-icon { color: #ff8a94; }
.toast-warning .toast-icon { color: #ffc35c; }
.toast-info .toast-icon { color: #8fa3ff; }
.toast-text { flex: 1; }
.toast-close { border: 0; background: transparent; color: rgba(255, 255, 255, 0.6); width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer; }
.toast-close:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }

@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* --------------------------------------------------------------------------
   Skeleton loading
   -------------------------------------------------------------------------- */

.skeleton {
    display: block;
    border-radius: 8px;
    background: linear-gradient(90deg, #eef0f5 0%, #f7f8fb 50%, #eef0f5 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-title { height: 24px; width: 55%; }
.skeleton-text { height: 14px; width: 80%; }
.skeleton-short { width: 45%; }
.skeleton-value { height: 36px; width: 60%; }

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* --------------------------------------------------------------------------
   Empty states
   -------------------------------------------------------------------------- */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 560px;
    margin: 0 auto;
}

.empty-visual {
    position: relative;
    width: 200px;
    height: 200px;
    margin-bottom: 32px;
    display: grid;
    place-items: center;
}

.empty-ring {
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 2px dashed color-mix(in srgb, var(--primary) 22%, transparent);
    animation: spin 40s linear infinite;
}

.empty-glow {
    position: absolute;
    inset: 40px;
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--violet) 22%, transparent) 0%, transparent 70%);
    animation: glow 4s ease-in-out infinite;
}

.empty-icon {
    position: relative;
    width: 104px;
    height: 104px;
    display: grid;
    place-items: center;
    border-radius: 32px;
    font-size: 44px;
    color: #fff;
    background: var(--gradient-brand);
    box-shadow: 0 20px 40px -16px color-mix(in srgb, var(--primary) 70%, transparent);
    animation: float 5s ease-in-out infinite;
}

.empty-satellite {
    position: absolute;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    font-size: 17px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    animation: bob 4.5s ease-in-out infinite;
}

.empty-satellite-1 { top: 6px; right: 8px; color: var(--primary); }
.empty-satellite-2 { bottom: 18px; left: 0; color: var(--violet); animation-delay: -1.5s; }
.empty-satellite-3 { bottom: 4px; right: 22px; color: var(--success); animation-delay: -3s; }

.empty-title { font-size: clamp(22px, 2.2vw, 28px); }
.empty-text { margin-top: 12px; color: var(--text-muted); font-size: 17px; }
.empty-actions { margin-top: 28px; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-8px) rotate(-4deg); } }
@keyframes glow { 0%, 100% { opacity: 0.6; transform: scale(0.95); } 50% { opacity: 1; transform: scale(1.1); } }

/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: clamp(16px, 1.5vw, 24px);
}

.stat { padding: clamp(22px, 2vw, 28px); display: flex; flex-direction: column; gap: 18px; }
.stat-head { display: flex; align-items: center; gap: 14px; }

.stat-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    font-size: 18px;
}

.stat-primary .stat-icon { color: var(--primary); background: var(--primary-soft); }
.stat-success .stat-icon { color: var(--success); background: var(--success-soft); }
.stat-violet .stat-icon { color: var(--violet); background: var(--violet-soft); }
.stat-warning .stat-icon { color: var(--warning); background: var(--warning-soft); }

.stat-label {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.stat-value {
    min-height: 44px;
    display: flex;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 38px;
    font-weight: 600;
    line-height: 1;
}

.stat-value.is-empty { color: var(--text-faint); }
.stat-hint { min-height: 22px; font-size: 14px; color: var(--text-muted); }
.stat-loaded { animation: fade-in 0.4s var(--ease) both; }

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: clamp(16px, 1.5vw, 24px);
}

.module-tile {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 24px;
}

.module-tile:hover { background: var(--surface-muted); }

.module-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 16px;
    font-size: 23px;
    color: var(--primary);
    background: var(--primary-soft);
    transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.module-tile:hover .module-icon { background: var(--primary); color: #fff; }
.module-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.module-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text);
}

.module-description { font-size: 14px; color: var(--text-muted); }
.module-label .module-status { padding: 3px 9px; font-family: var(--font-body); font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.module-arrow { color: var(--text-faint); transition: color 0.2s var(--ease); }
.module-tile:hover .module-arrow { color: var(--primary); }

/* --------------------------------------------------------------------------
   Settings & UI reference
   -------------------------------------------------------------------------- */

.settings-grid, .ui-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr));
    gap: clamp(16px, 1.5vw, 24px);
    align-items: start;
}

.ui-wide { grid-column: 1 / -1; }
.ui-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.ui-stack { display: flex; flex-direction: column; gap: 14px; }

/* --------------------------------------------------------------------------
   Auth (login, setup)
   -------------------------------------------------------------------------- */

.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}

.auth-showcase {
    position: relative;
    overflow: hidden;
    padding: clamp(40px, 5vw, 80px);
    color: #fff;
    background: linear-gradient(150deg, #2a37c9 0%, var(--primary) 45%, var(--violet) 100%);
}

.auth-showcase-inner {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 48px;
}

.auth-shapes { position: absolute; inset: 0; }

.auth-shape {
    position: absolute;
    border-radius: 40%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    animation: drift 18s ease-in-out infinite;
}

.auth-shape-1 { width: 44vmax; height: 44vmax; right: -14vmax; top: -12vmax; }
.auth-shape-2 { width: 28vmax; height: 28vmax; left: -10vmax; bottom: -8vmax; animation-delay: -6s; animation-duration: 22s; }
.auth-shape-3 { width: 14vmax; height: 14vmax; right: 18%; bottom: 16%; border-radius: 32%; animation-delay: -11s; animation-duration: 16s; }

@keyframes drift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(-2vmax, 2vmax) rotate(12deg); }
}

.auth-claim h2 { font-size: clamp(40px, 4.4vw, 72px); font-weight: 700; letter-spacing: 0.04em; line-height: 1.05; }
.auth-claim p { margin-top: 24px; max-width: 46ch; font-size: 18px; color: rgba(255, 255, 255, 0.82); }

.auth-features { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }

.auth-features li {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 999px;
    font-family: var(--font-heading);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(6px);
}

.auth-main {
    display: grid;
    place-items: center;
    padding: clamp(32px, 5vw, 80px) var(--gutter);
    background: var(--surface);
}

.auth-panel {
    width: min(100%, 440px);
    animation: content-in 0.5s var(--ease) both;
}

.auth-brand-mobile { display: none; margin-bottom: 40px; }
.auth-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 36px; }
.auth-title { font-size: clamp(30px, 3vw, 38px); }
.auth-text { color: var(--text-muted); font-size: 17px; }
.auth-form { display: flex; flex-direction: column; gap: 22px; }
.auth-form .btn { margin-top: 8px; }

/* Error page without app shell */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-page .card-empty { width: min(100%, 720px); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.32s var(--ease);
        box-shadow: none;
    }

    .sidebar-open-state .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    .sidebar .sidebar-close { display: inline-grid; }

    .sidebar-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 35;
        background: rgba(18, 21, 33, 0.4);
        backdrop-filter: blur(4px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s var(--ease), visibility 0.3s;
    }

    .sidebar-open-state .sidebar-scrim { opacity: 1; visibility: visible; }

    .main { margin-left: 0; }

    .main .topbar {
        position: sticky;
        top: 0;
        z-index: 30;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px var(--gutter);
        background: color-mix(in srgb, var(--surface) 88%, transparent);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--border);
    }

    .topbar .brand-mark { width: 34px; height: 34px; font-size: 14px; border-radius: 10px; }
    .topbar .brand-name { font-size: 18px; }

    .auth { grid-template-columns: 1fr; }
    .auth-showcase { display: none; }
    .auth-brand-mobile { display: inline-flex; }
}

@media (max-width: 600px) {
    .page-actions, .page-actions .btn { width: 100%; }
    .modal { padding: 12px; align-items: end; }
    .modal-dialog { border-radius: var(--radius-xl) var(--radius-xl) var(--radius-lg) var(--radius-lg); }
    .modal-header { padding: 24px 20px 0; }
    .modal-body { padding: 24px 20px; }
    .modal-actions { padding: 16px 20px 20px; }
    .modal-actions .btn { flex: 1; }
    .modal-confirm .modal-dialog { padding: 32px 20px 20px; }
    .module-tile { padding: 20px; }
    .toasts { right: 12px; bottom: 12px; width: calc(100% - 24px); }
    .details dd { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
