/* ==========================================================================
   TemplatePilot - design system
   Palette: white surfaces, dark navy chrome, electric blue + orange accents.
   ========================================================================== */

:root {
    /* Typography */
    --font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Mono", "Consolas", ui-monospace, monospace;

    /* Spacing scale (4px base) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Radii */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 999px;

    /* Neutrals */
    --canvas: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e6eaf2;
    --border-strong: #d3dae7;
    --text: #101828;
    --text-2: #4a5568;
    --text-3: #7d8aa0;
    --text-4: #9aa5b8;

    /* Navy chrome */
    --navy-950: #070f1d;
    --navy-900: #0a1526;
    --navy-850: #0d1c31;
    --navy-800: #11243c;
    --navy-700: #17304f;
    --navy-600: #1e3d64;
    --navy-line: rgba(255, 255, 255, 0.08);
    --navy-text: #c9d4e5;
    --navy-text-dim: #7f92ad;

    /* Brand accents */
    --brand: #2563eb;
    --brand-600: #1d4ed8;
    --brand-700: #1a43b8;
    --brand-soft: #eef4ff;
    --brand-soft-2: #dbe7ff;
    --accent: #f97316;
    --accent-600: #ea580c;
    --accent-soft: #fff3e9;

    /* Semantic */
    --success: #16a34a;
    --success-soft: #e9f9ef;
    --warning: #b45309;
    --warning-soft: #fff5e5;
    --danger: #dc2626;
    --danger-soft: #fdeceb;
    --info: #0284c7;
    --info-soft: #e6f4fd;

    /* Elevation */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 6px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 2px 4px rgba(16, 24, 40, 0.04), 0 8px 20px rgba(16, 24, 40, 0.07);
    --shadow-lg: 0 4px 8px rgba(16, 24, 40, 0.04), 0 18px 40px rgba(16, 24, 40, 0.11);
    --shadow-xl: 0 8px 16px rgba(16, 24, 40, 0.06), 0 32px 64px rgba(16, 24, 40, 0.16);
    --ring: 0 0 0 3px rgba(37, 99, 235, 0.18);

    /* Motion */
    --ease: cubic-bezier(0.32, 0.72, 0, 1);
    --dur-fast: 130ms;
    --dur: 200ms;
    --dur-slow: 320ms;

    /* Shell metrics */
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 64px;
}

/* ==========================================================================
   Base
   ========================================================================== */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--text);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.011em;
    line-height: 1.25;
    color: var(--text);
}

p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--brand); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--brand-600); }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-6) 0; opacity: 1; }

::selection { background: var(--brand-soft-2); color: var(--navy-900); }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* Scrollbars */
.scroll-y { overflow-y: auto; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #cdd6e4; border-radius: var(--radius-full); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #b3bfd2; background-clip: content-box; border: 3px solid transparent; }

/* Utility text */
.text-muted-2 { color: var(--text-2) !important; }
.text-muted-3 { color: var(--text-3) !important; }
.text-mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.text-tabular { font-variant-numeric: tabular-nums; }
.text-eyebrow {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-3);
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   App shell
   ========================================================================== */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
    color: var(--navy-text);
    transition: width var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.app-sidebar::after {
    content: "";
    position: absolute;
    inset: 0 0 0 auto;
    width: 1px;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--topbar-h);
    padding: 0 var(--space-5);
    flex: 0 0 auto;
    color: #fff;
    border-bottom: 1px solid var(--navy-line);
}

.sidebar-brand:hover { color: #fff; }

.brand-mark {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, var(--brand) 0%, #3b82f6 55%, var(--accent) 130%);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.brand-mark svg { width: 19px; height: 19px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 650; font-size: 0.9688rem; letter-spacing: -0.015em; line-height: 1.2; }
.brand-tag { font-size: 0.6875rem; color: var(--navy-text-dim); letter-spacing: 0.04em; }

.sidebar-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-4) var(--space-3) var(--space-2);
}

.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); background-clip: content-box; }

.nav-section { margin-bottom: var(--space-5); }

.nav-section-label {
    padding: 0 var(--space-3) var(--space-2);
    font-size: 0.6563rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--navy-text-dim);
    white-space: nowrap;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 9px var(--space-3);
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--navy-text);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.nav-link i { font-size: 1.0625rem; flex: 0 0 20px; text-align: center; opacity: 0.85; }
.nav-link .nav-text { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }

.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.nav-link.is-active {
    background: rgba(37, 99, 235, 0.22);
    color: #fff;
}

.nav-link.is-active i { opacity: 1; color: #7ea9ff; }

.nav-link.is-active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

.nav-badge {
    flex: 0 0 auto;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: rgba(249, 115, 22, 0.18);
    color: #fdba74;
    font-size: 0.6875rem;
    font-weight: 600;
    text-align: center;
}

.sidebar-foot {
    flex: 0 0 auto;
    padding: var(--space-3);
    border-top: 1px solid var(--navy-line);
}

.sidebar-usage {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--navy-line);
}

.sidebar-usage-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    font-size: 0.75rem;
    color: var(--navy-text-dim);
}

.sidebar-usage-value { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }

.usage-bar {
    height: 5px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.usage-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand) 0%, #60a5fa 100%);
    transition: width var(--dur-slow) var(--ease);
}

.usage-bar.is-warn span { background: linear-gradient(90deg, var(--accent) 0%, #fbbf24 100%); }

.sidebar-collapse-btn {
    width: 100%;
    margin-top: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 8px var(--space-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--navy-text-dim);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.sidebar-collapse-btn:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar-collapse-btn i { font-size: 1rem; flex: 0 0 20px; transition: transform var(--dur) var(--ease); }

/* Collapsed state */
.is-sidebar-collapsed .app-sidebar { width: var(--sidebar-w-collapsed); }
.is-sidebar-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }
.is-sidebar-collapsed .brand-text,
.is-sidebar-collapsed .nav-section-label,
.is-sidebar-collapsed .nav-text,
.is-sidebar-collapsed .nav-badge,
.is-sidebar-collapsed .sidebar-usage,
.is-sidebar-collapsed .sidebar-collapse-btn span { display: none; }
.is-sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
.is-sidebar-collapsed .nav-link { justify-content: center; padding-inline: 0; }
.is-sidebar-collapsed .nav-section { margin-bottom: var(--space-3); }
.is-sidebar-collapsed .nav-section + .nav-section { border-top: 1px solid var(--navy-line); padding-top: var(--space-3); }
.is-sidebar-collapsed .sidebar-collapse-btn { justify-content: center; }
.is-sidebar-collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--dur) var(--ease);
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-h);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-6);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-2);
    align-items: center;
    justify-content: center;
}

.topbar-search {
    position: relative;
    flex: 1 1 380px;
    max-width: 440px;
}

.topbar-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-4);
    font-size: 0.9375rem;
    pointer-events: none;
}

.topbar-search input {
    width: 100%;
    height: 38px;
    padding: 0 68px 0 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.875rem;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.topbar-search input::placeholder { color: var(--text-4); }

.topbar-search input:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--brand);
    box-shadow: var(--ring);
}

.kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    gap: 3px;
    pointer-events: none;
}

.kbd span {
    min-width: 20px;
    padding: 1px 5px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface);
    color: var(--text-3);
    font-size: 0.6875rem;
    font-weight: 600;
    text-align: center;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.token-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 36px;
    padding: 0 var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    font-size: 0.8125rem;
    color: var(--text-2);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.token-pill:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); color: var(--text-2); }
.token-pill i { color: var(--accent); font-size: 0.9375rem; }
.token-pill strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.icon-btn {
    position: relative;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-2);
    font-size: 1.0625rem;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.is-bordered { border-color: var(--border); background: var(--surface); }

.icon-btn .dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--surface);
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
    flex: 0 0 auto;
}

.avatar-sm { width: 26px; height: 26px; font-size: 0.625rem; }
.avatar-lg { width: 44px; height: 44px; font-size: 0.875rem; }
.avatar-xl { width: 64px; height: 64px; font-size: 1.125rem; }

.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar { border: 2px solid var(--surface); box-shadow: none; }
.avatar-stack .avatar + .avatar { margin-left: -9px; }
.avatar-stack .avatar-more { background: var(--surface-3); color: var(--text-2); }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px 6px 4px 4px;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    background: transparent;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease);
}

.user-chip:hover { background: var(--surface-3); }
.user-chip i { color: var(--text-3); font-size: 0.75rem; }

/* Dropdown polish */
.dropdown-menu {
    --bs-dropdown-border-color: var(--border);
    --bs-dropdown-border-radius: var(--radius-lg);
    --bs-dropdown-link-active-bg: var(--brand-soft);
    --bs-dropdown-link-active-color: var(--brand-600);
    --bs-dropdown-padding-y: 6px;
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    animation: dropIn var(--dur) var(--ease);
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.985); }
    to { opacity: 1; transform: none; }
}

.dropdown-item { border-radius: var(--radius-xs); padding: 7px 12px; display: flex; align-items: center; gap: 10px; }
.dropdown-item i { font-size: 0.9375rem; color: var(--text-3); width: 16px; }
.dropdown-item:active i, .dropdown-item.active i { color: inherit; }
.dropdown-menu { padding-inline: 6px; }
.dropdown-header { font-size: 0.6875rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }

.notif-menu { width: 380px; max-width: calc(100vw - 32px); padding: 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background-color var(--dur-fast) var(--ease); }
.notif-item:hover { background: var(--surface-2); }
.notif-item.is-unread { background: linear-gradient(90deg, rgba(37, 99, 235, 0.05), transparent 60%); }
.notif-icon { flex: 0 0 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center; font-size: 0.9375rem; }
.notif-title { font-size: 0.8438rem; font-weight: 600; margin: 0 0 2px; }
.notif-text { font-size: 0.8125rem; color: var(--text-2); margin: 0; }
.notif-time { font-size: 0.75rem; color: var(--text-4); margin-top: 3px; }
.notif-foot { padding: 10px 16px; text-align: center; }
a.notif-item { position: relative; color: inherit; text-decoration: none; }
a.notif-item:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.notif-unread-dot { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--brand); }
.notif-empty { display: grid; justify-items: center; gap: 4px; padding: 32px 24px; text-align: center; }
.notif-empty > i { margin-bottom: 6px; font-size: 1.5rem; color: var(--text-4); }
.notif-foot:empty { display: none; }

/* My profile */
.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-5); align-items: start; }
.profile-main { display: grid; gap: var(--space-5); min-width: 0; }
.profile-identity { display: flex; align-items: center; gap: 14px; margin-bottom: var(--space-5); padding-bottom: var(--space-5); border-bottom: 1px solid var(--border); }
.profile-identity .avatar { flex: 0 0 auto; transition: background-color var(--dur) var(--ease); }
.field-error { min-height: 0; margin-top: 4px; color: var(--danger); font-size: 0.75rem; }
.field-error:empty { display: none; }
.color-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.color-swatch { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--swatch); color: #fff; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.12); transition: transform var(--dur-fast) var(--ease); }
.color-swatch:hover { transform: scale(1.08); }
.color-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.color-swatch i { opacity: 0; font-size: 1rem; }
.color-swatch:has(input:checked) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch); }
.color-swatch:has(input:checked) i { opacity: 1; }
.color-swatch:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 5px; }
.password-field { position: relative; }
.password-field .form-control { padding-right: 44px; }
.password-toggle { position: absolute; top: 50%; right: 6px; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-3); transform: translateY(-50%); }
.password-toggle:hover { background: var(--surface-3); color: var(--text); }
.password-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; }
.profile-facts { display: grid; gap: 12px; margin: 0; }
.profile-facts > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.profile-facts dt { color: var(--text-3); font-size: 0.8125rem; font-weight: 500; }
.profile-facts dd { margin: 0; color: var(--text); font-size: 0.875rem; font-weight: 500; text-align: right; }
.profile-methods { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.profile-methods li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 0.875rem; }
.profile-method-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); }
@media (max-width: 991.98px) {
    .profile-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .color-swatch, .profile-identity .avatar { transition: none; }
    .color-swatch:hover { transform: none; }
}

/* ==========================================================================
   Content area, page header, breadcrumb
   ========================================================================== */

.app-content {
    flex: 1 1 auto;
    padding: var(--space-6) var(--space-6) var(--space-12);
    animation: pageIn var(--dur-slow) var(--ease);
}

.app-content.is-flush { padding: 0; }

@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.tp-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--space-3);
    font-size: 0.8125rem;
    color: var(--text-3);
}

.tp-breadcrumb a { color: var(--text-3); }
.tp-breadcrumb a:hover { color: var(--brand); }
.tp-breadcrumb .sep { color: var(--text-4); font-size: 0.75rem; }
.tp-breadcrumb .current { color: var(--text-2); font-weight: 500; }

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 650;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.page-subtitle { margin: 6px 0 0; color: var(--text-2); font-size: 0.875rem; max-width: 76ch; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    --bs-btn-font-size: 0.875rem;
    --bs-btn-font-weight: 500;
    --bs-btn-border-radius: var(--radius-md);
    --bs-btn-padding-y: 0.5rem;
    --bs-btn-padding-x: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    line-height: 1.35;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform 90ms var(--ease);
}

.btn:active { transform: scale(0.985); }
.btn i { font-size: 1rem; line-height: 1; }
.btn-sm { --bs-btn-font-size: 0.8125rem; --bs-btn-padding-y: 0.3125rem; --bs-btn-padding-x: 0.625rem; --bs-btn-border-radius: var(--radius-sm); }
.btn-lg { --bs-btn-font-size: 0.9375rem; --bs-btn-padding-y: 0.6875rem; --bs-btn-padding-x: 1.25rem; }

.btn-brand {
    background: var(--brand);
    border: 1px solid var(--brand);
    color: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 16px rgba(37, 99, 235, 0.22);
}

.btn-brand:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-brand:focus-visible { box-shadow: var(--ring); }

.btn-accent {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 16px rgba(249, 115, 22, 0.24);
}

.btn-accent:hover { background: var(--accent-600); border-color: var(--accent-600); color: #fff; }

.btn-outline-neutral {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    box-shadow: var(--shadow-xs);
}

.btn-outline-neutral:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }

.btn-ghost-neutral { background: transparent; border: 1px solid transparent; color: var(--text-2); }
.btn-ghost-neutral:hover { background: var(--surface-3); color: var(--text); }

.btn-soft-danger { background: var(--danger-soft); border: 1px solid transparent; color: var(--danger); }
.btn-soft-danger:hover { background: #fbdad8; color: #b91c1c; }

.btn-soft-brand { background: var(--brand-soft); border: 1px solid transparent; color: var(--brand-600); }
.btn-soft-brand:hover { background: var(--brand-soft-2); color: var(--brand-700); }

.btn:disabled, .btn.disabled { opacity: 0.55; box-shadow: none; cursor: not-allowed; transform: none; }

.btn .spinner-border { width: 0.875rem; height: 0.875rem; border-width: 2px; }

.btn.is-loading { pointer-events: none; position: relative; color: transparent !important; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 620ms linear infinite;
    color: #fff;
}
.btn-outline-neutral.is-loading::after, .btn-ghost-neutral.is-loading::after { color: var(--text-2); }

@keyframes spin { to { transform: rotate(360deg); } }

.btn-group-segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.btn-group-segmented button,
.btn-group-segmented a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-3);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.btn-group-segmented button:hover,
.btn-group-segmented a:hover { color: var(--text); }

.btn-group-segmented button.is-active,
.btn-group-segmented a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* ==========================================================================
   Cards
   ========================================================================== */

.tp-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.tp-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}

.tp-card-title { font-size: 0.9375rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tp-card-title i { color: var(--text-3); font-size: 1rem; }
.tp-card-sub { margin: 2px 0 0; font-size: 0.8125rem; color: var(--text-3); }
.tp-card-body { padding: var(--space-5); }
.tp-card-body.is-flush { padding: 0; }
.tp-card-foot { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: var(--space-4);
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }

.stat-card::after {
    content: "";
    position: absolute;
    inset: auto -30px -60px auto;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.07), transparent 70%);
    pointer-events: none;
}

.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    font-size: 1.125rem;
}

.stat-label { font-size: 0.8125rem; color: var(--text-3); font-weight: 500; }
.stat-value { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.025em; line-height: 1.15; margin-top: 10px; font-variant-numeric: tabular-nums; }
.stat-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 0.75rem; color: var(--text-3); }

.stat-delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.stat-delta.is-up { color: var(--success); }
.stat-delta.is-down { color: var(--danger); }
.stat-delta.is-flat { color: var(--text-3); }

/* Tinted helpers */
.tint-brand { background: var(--brand-soft); color: var(--brand-600); }
.tint-accent { background: var(--accent-soft); color: var(--accent-600); }
.tint-success { background: var(--success-soft); color: var(--success); }
.tint-warning { background: var(--warning-soft); color: var(--warning); }
.tint-danger { background: var(--danger-soft); color: var(--danger); }
.tint-info { background: var(--info-soft); color: var(--info); }
.tint-neutral { background: var(--surface-3); color: var(--text-2); }

/* ==========================================================================
   Badges, chips, pills
   ========================================================================== */

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-soft i { font-size: 0.75rem; }
.badge-soft .dot-mark { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 0.75rem;
    font-weight: 500;
}

.chip-removable button {
    border: 0;
    background: transparent;
    color: var(--text-4);
    padding: 0;
    line-height: 1;
    font-size: 0.875rem;
    cursor: pointer;
}

.chip-removable button:hover { color: var(--danger); }

/* ==========================================================================
   Forms
   ========================================================================== */

.form-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-hint { font-size: 0.75rem; color: var(--text-3); margin-top: 6px; display: block; }

.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.form-control::placeholder { color: var(--text-4); }

.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: var(--ring);
}

.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.16); }
.invalid-feedback { font-size: 0.75rem; display: flex; align-items: center; gap: 5px; }
.field-validation-error { display: flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--danger); margin-top: 6px; }

.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-4); font-size: 0.9375rem; pointer-events: none; }
.input-icon .form-control { padding-left: 36px; }
.input-icon .toggle-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--text-4); width: 30px; height: 30px; border-radius: var(--radius-xs); cursor: pointer; }
.input-icon .toggle-eye:hover { color: var(--text-2); background: var(--surface-3); }

.form-check-input { border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { border-color: var(--brand); box-shadow: var(--ring); }
.form-check-label { font-size: 0.8438rem; color: var(--text-2); }

.form-switch .form-check-input { width: 2.25em; height: 1.25em; }

/* Setting row */
.setting-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-6);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row:first-child { padding-top: 0; }
.setting-info { min-width: 0; flex: 1 1 auto; }
.setting-name { font-size: 0.875rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.setting-desc { margin: 3px 0 0; font-size: 0.8125rem; color: var(--text-3); max-width: 62ch; }
.setting-control { flex: 0 0 auto; min-width: 200px; max-width: 320px; }

/* ==========================================================================
   Tables
   ========================================================================== */

.tp-table-wrap { overflow-x: auto; }

.tp-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8438rem;
}

.tp-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 10px var(--space-4);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--text-3);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    text-align: left;
}

.tp-table thead th.is-sortable { cursor: pointer; user-select: none; }
.tp-table thead th.is-sortable:hover { color: var(--text-2); }
.tp-table thead th i { font-size: 0.6875rem; opacity: 0.6; margin-left: 3px; }

.tp-table tbody td {
    padding: 12px var(--space-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-2);
}

.tp-table tbody tr { transition: background-color var(--dur-fast) var(--ease); }
.tp-table tbody tr:hover { background: var(--surface-2); }
.tp-table tbody tr:last-child td { border-bottom: 0; }
.tp-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tp-table .cell-strong { color: var(--text); font-weight: 600; }
.tp-table .row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.tp-table .col-actions { width: 1%; text-align: right; white-space: nowrap; }
.tp-table .row-menu { display: flex; justify-content: flex-end; }
.site-url-actions { display: inline-flex; align-items: center; gap: var(--space-1); }
.site-url-actions .icon-btn { width: 34px; height: 34px; font-size: .9375rem; }

.cell-media { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-media .thumb { flex: 0 0 34px; height: 34px; border-radius: var(--radius-sm); }
.cell-media .cell-text { min-width: 0; }
.cell-media .cell-title { font-weight: 600; color: var(--text); }
.cell-media .cell-meta { font-size: 0.75rem; color: var(--text-4); }

/* Pagination */
.tp-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-3);
}

.pager { display: inline-flex; gap: 3px; }

.pager button,
.pager a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-2);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.pager button:hover:not(:disabled),
.pager a:hover:not(.disabled) { background: var(--surface-3); color: var(--text); }
.pager button.is-active,
.pager a.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled,
.pager a.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ==========================================================================
   Filter bar
   ========================================================================== */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    margin-bottom: var(--space-4);
}

.filter-search { position: relative; flex: 1 1 260px; min-width: 200px; }
.filter-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-4); font-size: 0.875rem; }
.filter-search input { width: 100%; height: 36px; padding: 0 32px 0 33px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); font-size: 0.8438rem; }
.filter-search input:focus { outline: none; background: var(--surface); border-color: var(--brand); box-shadow: var(--ring); }

/* Manage access user search */
.access-search-wrap { position: relative; margin-bottom: var(--space-2); }
.access-search-wrap > .bi-search { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-4); pointer-events: none; }
.access-search-wrap .form-control { height: 40px; padding-left: 36px; padding-right: 40px; }
.access-search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-3); }
.access-search-clear:hover { background: var(--surface-3); color: var(--text); }
.access-search-clear:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.access-search-meta { margin-bottom: var(--space-2); color: var(--text-4); font-size: .75rem; }
.access-table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.access-table-wrap .tp-table thead { position: sticky; top: 0; z-index: 2; background: var(--surface-2); box-shadow: 0 1px 0 var(--border); }
.access-search-empty { display: flex; min-height: 180px; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1); color: var(--text-3); text-align: center; }
.access-search-empty > i { margin-bottom: var(--space-1); color: var(--text-4); font-size: 1.5rem; }
.access-search-empty strong { color: var(--text-2); }
.access-search-empty span { font-size: .8125rem; }
.filter-search .clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--text-4); width: 24px; height: 24px; border-radius: 50%; cursor: pointer; display: none; }
.filter-search .clear:hover { background: var(--surface-3); color: var(--text-2); }
.filter-search.has-value .clear { display: grid; place-items: center; }

.filter-select { height: 36px; padding: 0 30px 0 11px; border: 1px solid var(--border); border-radius: var(--radius-md); background-color: var(--surface); font-size: 0.8438rem; color: var(--text-2); min-width: 130px; }
.filter-divider { width: 1px; height: 22px; background: var(--border); margin-inline: 2px; }

/* ==========================================================================
   Empty / loading / error states
   ========================================================================== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-12) var(--space-6);
}

.empty-art {
    width: 88px;
    height: 88px;
    border-radius: 24px;
    display: grid;
    place-items: center;
    font-size: 2rem;
    background: linear-gradient(150deg, var(--brand-soft), var(--surface-3));
    color: var(--brand);
    margin-bottom: var(--space-4);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.1);
}

.empty-state h3 { font-size: 1.0625rem; margin-bottom: 6px; }
.empty-state p { color: var(--text-3); font-size: 0.875rem; max-width: 46ch; margin-bottom: var(--space-5); }
.empty-state.is-compact { padding: var(--space-8) var(--space-4); }
.empty-state.is-compact .empty-art { width: 64px; height: 64px; border-radius: 18px; font-size: 1.5rem; }

.state-panel {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 0.875rem;
}

.state-panel.is-error { background: var(--danger-soft); border-color: rgba(220, 38, 38, 0.22); color: #991b1b; }
.state-panel.is-success { background: var(--success-soft); border-color: rgba(22, 163, 74, 0.22); color: #14532d; }
.state-panel.is-warning { background: var(--warning-soft); border-color: rgba(180, 83, 9, 0.2); color: #7c2d12; }
.state-panel.is-info { background: var(--info-soft); border-color: rgba(2, 132, 199, 0.2); color: #075985; }
.state-panel i { font-size: 1.125rem; flex: 0 0 auto; margin-top: 1px; }
.state-panel strong { display: block; margin-bottom: 2px; }

/* Skeletons */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--surface-3);
    border-radius: var(--radius-xs);
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer { to { transform: translateX(100%); } }

.sk-line { height: 10px; margin-bottom: 9px; }
.sk-line.w-25 { width: 25%; } .sk-line.w-40 { width: 40%; } .sk-line.w-50 { width: 50%; }
.sk-line.w-60 { width: 60%; } .sk-line.w-75 { width: 75%; } .sk-line.w-90 { width: 90%; }
.sk-title { height: 16px; width: 45%; margin-bottom: 14px; }
.sk-box { height: 100px; border-radius: var(--radius-md); }
.sk-circle { width: 38px; height: 38px; border-radius: 50%; }
.sk-thumb { height: 132px; border-radius: var(--radius-md); }

/* Progress */
.progress-thin { height: 6px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.progress-thin > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width var(--dur-slow) var(--ease); }
.progress-thin.is-accent > span { background: var(--accent); }
.progress-thin.is-success > span { background: var(--success); }
.progress-thin.is-danger > span { background: var(--danger); }

/* ==========================================================================
   Toasts
   ========================================================================== */

.toast-stack {
    position: fixed;
    right: var(--space-5);
    bottom: var(--space-5);
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 360px;
    max-width: calc(100vw - 2rem);
    pointer-events: none;
}

.tp-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: toastIn var(--dur-slow) var(--ease);
}

.tp-toast.is-leaving { animation: toastOut 220ms var(--ease) forwards; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(14px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(24px) scale(0.97); }
}

.tp-toast .t-icon { flex: 0 0 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; font-size: 0.9375rem; }
.tp-toast .t-body { flex: 1 1 auto; min-width: 0; }
.tp-toast .t-title { font-size: 0.8438rem; font-weight: 600; margin: 0; }
.tp-toast .t-text { font-size: 0.8125rem; color: var(--text-3); margin: 2px 0 0; }
.tp-toast .t-close { border: 0; background: transparent; color: var(--text-4); padding: 0; width: 22px; height: 22px; border-radius: var(--radius-xs); cursor: pointer; flex: 0 0 auto; }
.tp-toast .t-close:hover { background: var(--surface-3); color: var(--text-2); }
.tp-toast .t-progress { position: absolute; }

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-content {
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-header { padding: var(--space-5) var(--space-5) var(--space-3); border-bottom: 0; align-items: flex-start; }
.modal-title { font-size: 1.0625rem; font-weight: 650; letter-spacing: -0.015em; }
.modal-sub { margin: 4px 0 0; font-size: 0.8438rem; color: var(--text-3); }
.modal-body { padding: var(--space-3) var(--space-5) var(--space-5); }
.modal-footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); background: var(--surface-2); gap: var(--space-2); }
.modal-backdrop.show { opacity: 0.5; backdrop-filter: blur(2px); }
.modal.fade .modal-dialog { transform: translateY(14px) scale(0.985); transition: transform var(--dur-slow) var(--ease); }
.modal.show .modal-dialog { transform: none; }

.modal-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-lg);
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    flex: 0 0 auto;
    margin-bottom: var(--space-3);
}

.confirm-list { margin: var(--space-3) 0 0; padding: var(--space-3) var(--space-4); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 0.8125rem; }
.confirm-list li { color: var(--text-2); }

/* ==========================================================================
   Tabs
   ========================================================================== */

.tp-tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tp-tabs button, .tp-tabs a {
    position: relative;
    padding: 10px 14px;
    border: 0;
    background: transparent;
    color: var(--text-3);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease);
}

.tp-tabs button::after, .tp-tabs a::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: -1px;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--brand);
    transform: scaleX(0);
    transition: transform var(--dur) var(--ease);
}

.tp-tabs button:hover, .tp-tabs a:hover { color: var(--text); }
.tp-tabs button.is-active, .tp-tabs a.is-active { color: var(--brand); }
.tp-tabs button.is-active::after, .tp-tabs a.is-active::after { transform: scaleX(1); }

/* ==========================================================================
   Timeline / activity
   ========================================================================== */

.timeline { position: relative; padding-left: 30px; }

.timeline::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: linear-gradient(180deg, var(--border), transparent);
}

.timeline-item { position: relative; padding-bottom: var(--space-5); }
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
    position: absolute;
    left: -30px;
    top: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.8125rem;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.timeline-title { font-size: 0.875rem; font-weight: 600; margin: 3px 0 2px; }
.timeline-meta { font-size: 0.75rem; color: var(--text-4); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.timeline-text { font-size: 0.8125rem; color: var(--text-2); margin: 4px 0 0; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1199.98px) {
    .app-content { padding: var(--space-5) var(--space-4) var(--space-10); }
    .app-topbar { padding-inline: var(--space-4); }
}

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-xl); }
    .is-sidebar-open .app-sidebar { transform: none; }
    .app-main, .is-sidebar-collapsed .app-main { margin-left: 0; }
    .topbar-toggle { display: inline-flex; }
    .topbar-search { flex-basis: 200px; }
    .topbar-search .kbd { display: none; }
    .topbar-search input { padding-right: 12px; }

    .sidebar-scrim {
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(10, 21, 38, 0.45);
        backdrop-filter: blur(2px);
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--dur) var(--ease), visibility var(--dur);
    }

    .is-sidebar-open .sidebar-scrim { opacity: 1; visibility: visible; }
}

@media (max-width: 767.98px) {
    .app-content { padding: var(--space-4) var(--space-3) var(--space-10); }
    .page-title { font-size: 1.25rem; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-actions { justify-content: flex-start; }
    .topbar-search { display: none; }
    .token-pill span { display: none; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); }
    .stat-value { font-size: 1.5rem; }
    .toast-stack { right: var(--space-3); left: var(--space-3); bottom: var(--space-3); width: auto; }
    .setting-row { flex-direction: column; gap: var(--space-3); }
    .setting-control { max-width: none; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------------------------------------------------- Rich information tooltips */

.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.info-tooltip-trigger { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-4); vertical-align: middle; cursor: help; transition: color 140ms ease, background-color 140ms ease; flex-shrink: 0; }
.info-tooltip-trigger:hover, .info-tooltip-trigger[aria-expanded="true"] { color: var(--brand); background: var(--brand-soft, rgba(37, 99, 235, 0.08)); }
.info-tooltip-trigger:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.rich-info-tooltip { position: fixed; z-index: 1090; width: min(320px, calc(100vw - 16px)); padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; color: var(--text-1, #0f172a); background: var(--surface); box-shadow: var(--shadow-lg); animation: info-tooltip-enter 140ms ease-out; }
.rich-info-tooltip::after { content: ""; position: absolute; left: var(--info-arrow-x); bottom: -5px; width: 9px; height: 9px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); transform: translateX(-50%) rotate(45deg); }
.rich-info-tooltip.below::after { top: -5px; bottom: auto; transform: translateX(-50%) rotate(225deg); }
.info-tooltip-title { font-size: 13px; font-weight: 600; line-height: 1.4; margin-bottom: 6px; }
.info-tooltip-body { color: var(--text-3); font-size: 12px; line-height: 1.7; margin: 0; overflow-wrap: anywhere; }
@keyframes info-tooltip-enter { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@media (pointer: coarse) { .info-tooltip-trigger { width: 40px; height: 40px; } }
@media (prefers-reduced-motion: reduce) { .rich-info-tooltip { animation: none; } .info-tooltip-trigger { transition: none; } }
