/* SmartCare Admin — New components */

/* =============================================================
 * SIDEBAR
 * ========================================================== */
.app-sidebar {
    grid-area: sidebar;
    background: var(--surface-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    transition: width var(--dur-base) var(--ease-out);
    position: relative;
    z-index: 30;
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-5);
    height: var(--topbar-height);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
}
.app-sidebar__brand-mark {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 10px;
    background: var(--gradient-hero);
    display: grid;
    place-items: center;
    color: #ffffff;
    font-weight: 800;
    font-size: 0.95rem;
    box-shadow: 0 6px 14px -6px rgba(99,102,241,0.55);
}
.app-sidebar__brand-name {
    font-weight: 700;
    font-size: var(--fs-lg);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.app-sidebar__brand-sub {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
}

.app-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-3);
}
.app-sidebar__group {
    margin-bottom: var(--space-5);
}
.app-sidebar__group-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
}
.app-sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0.55rem var(--space-3);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-weight: 500;
    text-decoration: none;
    transition: background-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out);
    white-space: nowrap;
    position: relative;
}
.app-sidebar__link i { font-size: 18px; flex: 0 0 18px; }
.app-sidebar__link:hover {
    background: var(--surface-1);
    color: var(--text-primary);
}
.app-sidebar__link.active {
    background: var(--tint-brand);
    color: var(--brand-primary);
    font-weight: 600;
}
.app-sidebar__link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--gradient-hero);
    border-radius: var(--radius-pill);
}
.app-sidebar__link .badge {
    margin-left: auto;
    font-size: 0.68rem;
}

.app-sidebar__footer {
    border-top: 1px solid var(--border);
    padding: var(--space-3);
}
.user-chip {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out);
}
.user-chip:hover { background: var(--surface-1); }
.avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 50%;
    background: var(--gradient-tile-2);
    color: #ffffff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: var(--fs-sm);
}
.avatar.avatar-sm { width: 28px; height: 28px; flex-basis: 28px; font-size: var(--fs-xs); }
.avatar.avatar-lg { width: 44px; height: 44px; flex-basis: 44px; font-size: var(--fs-base); }
.user-chip__name { font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); line-height: 1.1; }
.user-chip__role { font-size: var(--fs-xs); color: var(--text-muted); }

/* Collapsed state */
.app-sidebar[data-collapsed="true"] {
    width: var(--sidebar-width-collapsed);
}
.app-sidebar[data-collapsed="true"] .app-sidebar__brand-name,
.app-sidebar[data-collapsed="true"] .app-sidebar__brand-sub,
.app-sidebar[data-collapsed="true"] .app-sidebar__group-label,
.app-sidebar[data-collapsed="true"] .app-sidebar__link span:not(.badge),
.app-sidebar[data-collapsed="true"] .user-chip > div:not(.avatar) {
    display: none;
}
.app-sidebar[data-collapsed="true"] .app-sidebar__link { justify-content: center; padding: 0.6rem; }
.app-sidebar[data-collapsed="true"] .app-sidebar__brand { justify-content: center; padding: 0; }
.app-sidebar[data-collapsed="true"] .user-chip { justify-content: center; }

/* =============================================================
 * TOPBAR
 * ========================================================== */
.app-topbar {
    grid-area: topbar;
    height: var(--topbar-height);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-5);
    gap: var(--space-4);
    position: sticky;
    top: 0;
    z-index: 20;
}
.app-topbar__title {
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.app-topbar__crumbs {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}
.app-topbar__crumbs a { color: var(--text-secondary); }
.app-topbar__crumbs i { font-size: 12px; opacity: 0.6; margin: 0 6px; }
.app-topbar__search {
    flex: 1;
    max-width: 480px;
    position: relative;
}
.app-topbar__search input {
    width: 100%;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.85rem 0.5rem 36px;
    color: var(--text-primary);
    font-size: var(--fs-sm);
    transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.app-topbar__search input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-glow);
}
.app-topbar__search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.app-topbar__kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-elevated);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.app-topbar__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}
.topbar-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out);
    position: relative;
    font-size: 18px;
}
.topbar-btn:hover { background: var(--surface-1); color: var(--text-primary); }
.topbar-btn .dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 8px;
    height: 8px;
    background: var(--brand-danger);
    border: 2px solid var(--surface-0);
    border-radius: 50%;
}

/* =============================================================
 * APP SHELL
 * ========================================================== */
.app-shell {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
    background: var(--surface-0);
}
.app-main {
    grid-area: main;
    padding: var(--space-6) var(--space-8);
    overflow-x: hidden;
}
.app-main__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}
.app-main__title {
    margin: 0;
    font-size: var(--fs-3xl);
    letter-spacing: -0.025em;
}
.app-main__subtitle {
    color: var(--text-muted);
    font-size: var(--fs-base);
    margin: 4px 0 0;
}
.app-main__actions { display: flex; gap: var(--space-2); align-items: center; }

@media (max-width: 992px) {
    .app-main { padding: var(--space-4); }
    .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
    .app-sidebar { position: fixed; left: -100%; top: 0; bottom: 0; transition: left var(--dur-base) var(--ease-out); }
    .app-sidebar[data-mobile-open="true"] { left: 0; box-shadow: var(--shadow-xl); }
}

/* =============================================================
 * KPI TILE
 * ========================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-tile {
    position: relative;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    overflow: hidden;
    transition: transform var(--dur-base) var(--ease-out),
                box-shadow var(--dur-base) var(--ease-out);
}
.kpi-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.kpi-tile::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--gradient-card);
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-out);
    pointer-events: none;
}
.kpi-tile:hover::before { opacity: 1; }
.kpi-tile__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}
.kpi-tile__label {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 500;
    letter-spacing: 0;
}
.kpi-tile__icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #ffffff;
    font-size: 20px;
    flex: 0 0 40px;
}
.kpi-tile__icon--indigo { background: var(--gradient-tile-1); }
.kpi-tile__icon--violet { background: var(--gradient-tile-2); }
.kpi-tile__icon--emerald { background: var(--gradient-tile-3); }
.kpi-tile__icon--amber { background: var(--gradient-tile-4); }
.kpi-tile__value {
    font-size: var(--fs-4xl);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: var(--space-2);
}
.kpi-tile__trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
}
.kpi-tile__trend--up   { background: var(--tint-success); color: #047857; }
.kpi-tile__trend--down { background: var(--tint-danger);  color: #be123c; }
.kpi-tile__trend--flat { background: var(--surface-2);    color: var(--text-secondary); }
[data-theme="dark"] .kpi-tile__trend--up   { color: #6ee7b7; }
[data-theme="dark"] .kpi-tile__trend--down { color: #fda4af; }

.kpi-tile__delta {
    color: var(--text-muted);
    font-size: var(--fs-xs);
    margin-left: var(--space-2);
}

/* =============================================================
 * GLASS PANEL
 * ========================================================== */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
}

/* =============================================================
 * STATUS PILL
 * ========================================================== */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-pill--success { background: var(--tint-success); color: #047857; }
.status-pill--warning { background: var(--tint-warning); color: #b45309; }
.status-pill--danger  { background: var(--tint-danger);  color: #be123c; }
.status-pill--info    { background: var(--tint-info);    color: #075985; }
.status-pill--neutral { background: var(--surface-2);    color: var(--text-secondary); }
.status-pill--brand   { background: var(--tint-brand);   color: var(--brand-700); }
[data-theme="dark"] .status-pill--success { color: #6ee7b7; }
[data-theme="dark"] .status-pill--warning { color: #fcd34d; }
[data-theme="dark"] .status-pill--danger  { color: #fda4af; }
[data-theme="dark"] .status-pill--info    { color: #7dd3fc; }
[data-theme="dark"] .status-pill--brand   { color: var(--brand-300); }

/* =============================================================
 * SECTION CARD
 * ========================================================== */
.section-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.section-card__head {
    padding: var(--space-4) var(--space-5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    gap: var(--space-3);
}
.section-card__title {
    font-size: var(--fs-base);
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}
.section-card__subtitle { font-size: var(--fs-xs); color: var(--text-muted); margin: 2px 0 0; }
.section-card__body { padding: var(--space-5); }

/* =============================================================
 * ACTIVITY FEED
 * ========================================================== */
.activity {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.activity__item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    transition: background-color var(--dur-fast) var(--ease-out);
}
.activity__item:hover { background: var(--surface-1); }
.activity__icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex: 0 0 32px;
    font-size: 14px;
}
.activity__icon--brand   { background: var(--tint-brand);   color: var(--brand-primary); }
.activity__icon--success { background: var(--tint-success); color: #047857; }
.activity__icon--warning { background: var(--tint-warning); color: #b45309; }
.activity__icon--danger  { background: var(--tint-danger);  color: #be123c; }
.activity__icon--info    { background: var(--tint-info);    color: #075985; }
[data-theme="dark"] .activity__icon--success { color: #6ee7b7; }
[data-theme="dark"] .activity__icon--warning { color: #fcd34d; }
[data-theme="dark"] .activity__icon--danger  { color: #fda4af; }
[data-theme="dark"] .activity__icon--info    { color: #7dd3fc; }
.activity__body { flex: 1; min-width: 0; }
.activity__text { font-size: var(--fs-sm); color: var(--text-primary); margin: 0; line-height: 1.4; }
.activity__text strong { font-weight: 600; }
.activity__meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

/* =============================================================
 * INTEGRATION CONNECTOR CARD
 * ========================================================== */
.connector-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
    cursor: pointer;
}
.connector-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--brand-300);
}
.connector-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}
.connector-card__vendor {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}
.connector-card__logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-weight: 800;
    color: var(--brand-primary);
    flex: 0 0 44px;
}
.connector-card__name { font-weight: 700; font-size: var(--fs-base); color: var(--text-primary); line-height: 1.2; }
.connector-card__customer { font-size: var(--fs-xs); color: var(--text-muted); }
.connector-card__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}
.connector-card__actions { display: flex; gap: var(--space-2); }

/* =============================================================
 * SEGMENTED FILTERS / TAB CHIPS
 * ========================================================== */
.segmented {
    display: inline-flex;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    gap: 2px;
}
.segmented__item {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}
.segmented__item:hover { color: var(--text-primary); }
.segmented__item.active {
    background: var(--surface-0);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* =============================================================
 * QUICK ACTION TILE
 * ========================================================== */
.quick-action {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px dashed var(--border-strong);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    text-align: left;
    font-size: var(--fs-sm);
    font-weight: 500;
    width: 100%;
}
.quick-action:hover {
    background: var(--tint-brand);
    border-color: var(--brand-primary);
    border-style: solid;
    color: var(--brand-primary);
}
.quick-action__plus {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--tint-brand);
    color: var(--brand-primary);
    display: grid;
    place-items: center;
    flex: 0 0 28px;
}

/* =============================================================
 * AUTH LAYOUT (Login)
 * ========================================================== */
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(360px, 1fr) 1fr;
    background: var(--surface-0);
}
@media (max-width: 900px) { .auth-shell { grid-template-columns: 1fr; } }

.auth-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-8);
}
.auth-form-wrap { width: 100%; max-width: 400px; }
.auth-form-wrap .brand-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-12);
}
.auth-form-wrap h1 {
    font-size: var(--fs-3xl);
    margin-bottom: var(--space-2);
    letter-spacing: -0.025em;
}
.auth-form-wrap .sub {
    color: var(--text-muted);
    margin-bottom: var(--space-8);
    font-size: var(--fs-base);
}

.auth-hero-side {
    background: var(--gradient-hero);
    color: #ffffff;
    position: relative;
    overflow: hidden;
    padding: var(--space-12);
    display: flex;
    align-items: center;
}
.auth-hero-side::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(at 20% 30%, rgba(255,255,255,0.18) 0px, transparent 50%),
        radial-gradient(at 80% 20%, rgba(255,255,255,0.10) 0px, transparent 50%),
        radial-gradient(at 80% 80%, rgba(255,255,255,0.12) 0px, transparent 50%);
    pointer-events: none;
}
.auth-hero-content { position: relative; z-index: 1; max-width: 480px; }
.auth-hero-content h2 {
    color: #ffffff;
    font-size: var(--fs-4xl);
    margin-bottom: var(--space-4);
    letter-spacing: -0.025em;
    line-height: 1.15;
}
.auth-hero-content p { color: rgba(255,255,255,0.85); font-size: var(--fs-lg); margin-bottom: var(--space-8); }
.auth-features { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-feature {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    color: rgba(255,255,255,0.92);
}
.auth-feature__icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(255,255,255,0.18);
    display: grid;
    place-items: center;
    flex: 0 0 32px;
    font-size: 16px;
    color: #ffffff;
    backdrop-filter: blur(8px);
}
.auth-feature__title { font-weight: 600; font-size: var(--fs-base); }
.auth-feature__sub  { font-size: var(--fs-sm); color: rgba(255,255,255,0.75); }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 40px; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: grid;
    place-items: center;
}
.password-toggle:hover { background: var(--surface-2); color: var(--text-primary); }

/* =============================================================
 * DASHBOARD WELCOME BANNER
 * ========================================================== */
.welcome-banner {
    position: relative;
    border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-8);
    color: #ffffff;
    background: var(--gradient-hero);
    overflow: hidden;
    margin-bottom: var(--space-6);
}
.welcome-banner::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(at 100% 0%, rgba(255,255,255,0.20) 0px, transparent 40%),
        radial-gradient(at 0% 100%, rgba(255,255,255,0.10) 0px, transparent 50%);
    pointer-events: none;
}
.welcome-banner h2 { color: #ffffff; margin: 0 0 6px; font-size: var(--fs-2xl); }
.welcome-banner p  { color: rgba(255,255,255,0.85); margin: 0; }

/* =============================================================
 * CONTENT TWO-COLUMN
 * ========================================================== */
.row-2col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-5);
    margin-bottom: var(--space-5);
}
@media (max-width: 1100px) { .row-2col { grid-template-columns: 1fr; } }

/* =============================================================
 * BUTTON GROUP / TOOLBAR
 * ========================================================== */
.toolbar {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}
.toolbar .search {
    position: relative;
    flex: 1;
    min-width: 260px;
    max-width: 380px;
}
.toolbar .search input {
    width: 100%;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.85rem 0.55rem 36px;
    color: var(--text-primary);
    font-size: var(--fs-sm);
}
.toolbar .search input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-glow);
}
.toolbar .search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-chip {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-pill);
    font-size: var(--fs-sm);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}
.filter-chip:hover { background: var(--surface-2); color: var(--text-primary); }
.filter-chip.active { background: var(--tint-brand); border-color: var(--brand-primary); color: var(--brand-primary); }

/* =============================================================
 * DATA TABLE (modern)
 * ========================================================== */
.data-table-wrap {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table thead th {
    background: var(--surface-1);
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    padding: 12px 16px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    user-select: none;
}
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--text-primary); }
.data-table tbody td {
    padding: 14px 16px;
    font-size: var(--fs-sm);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr {
    transition: background-color var(--dur-fast) var(--ease-out);
}
.data-table tbody tr:hover { background: var(--surface-1); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .row-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-out);
}
.data-table tbody tr:hover .row-actions { opacity: 1; }
.data-table .col-checkbox { width: 40px; }
.data-table .col-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; color: var(--text-secondary); }
.data-table-wrap .table-footer-row,
.table-footer-row {
    background: var(--surface-1);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: var(--space-3);
    border-top: 1px solid var(--border);
}
.table-footer-row > * { min-width: 0; }
.table-footer-row .pagination { margin: 0; }

/* =============================================================
 * TABS (form tabs in ConfigureDynamic)
 * ========================================================== */
.tab-strip {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 4px;
    margin-bottom: var(--space-5);
    overflow-x: auto;
}
.tab-strip__item {
    background: transparent;
    border: none;
    padding: var(--space-3) var(--space-4);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: var(--fs-sm);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color var(--dur-fast) var(--ease-out);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.tab-strip__item i { font-size: 16px; }
.tab-strip__item:hover { color: var(--text-primary); }
.tab-strip__item.active {
    color: var(--brand-primary);
    font-weight: 600;
}
.tab-strip__item.active::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 2px;
    background: var(--gradient-hero);
    border-radius: var(--radius-pill);
}

/* =============================================================
 * FIELD GROUP / FIELDSET
 * ========================================================== */
.field-group {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-6);
    margin-bottom: var(--space-4);
}
.field-group__title { font-size: var(--fs-base); font-weight: 600; margin: 0 0 4px; }
.field-group__hint  { color: var(--text-muted); font-size: var(--fs-sm); margin: 0 0 var(--space-4); }
.field-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}
@media (max-width: 700px) { .field-row { grid-template-columns: 1fr; } }
.field-row .col-full { grid-column: 1 / -1; }

/* =============================================================
 * STICKY ACTION BAR
 * ========================================================== */
.action-bar {
    position: sticky;
    top: var(--topbar-height);
    z-index: 10;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* =============================================================
 * CHIP / TAG
 * ========================================================== */
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: 500;
    border: 1px solid var(--border);
}
.tag-chip__x { color: var(--text-muted); cursor: pointer; font-size: 14px; }
.tag-chip__x:hover { color: var(--brand-danger); }

/* =============================================================
 * THEME PICKER (topbar dropdown)
 * ========================================================== */
.theme-picker {
    position: relative;
    display: inline-flex;
}
.theme-picker__trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--fs-sm);
    height: 40px;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.theme-picker__trigger:hover { background: var(--surface-1); color: var(--text-primary); }
.theme-picker__trigger-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--surface-elevated);
    box-shadow: 0 0 0 1px var(--border);
    flex: 0 0 18px;
}
.theme-picker__trigger-caret { font-size: 11px; opacity: 0.7; }
.theme-picker__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 300px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out),
                visibility 0s linear var(--dur-fast);
    z-index: 100;
}
.theme-picker.open .theme-picker__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out),
                visibility 0s;
}
.theme-picker__group { padding: var(--space-2); }
.theme-picker__group-label {
    font-size: 0.68rem;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: var(--space-2);
}
.theme-picker__divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-1) 0;
}
.theme-picker__appearance {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.theme-picker__appearance-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--border);
    background: var(--surface-1);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: all var(--dur-fast) var(--ease-out);
}
.theme-picker__appearance-btn:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
}
.theme-picker__appearance-btn.active {
    border-color: var(--brand-primary);
    background: var(--tint-brand);
    color: var(--brand-primary);
    font-weight: 600;
}
.theme-picker__accents {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.theme-picker__swatch {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 8px 10px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    width: 100%;
    color: var(--text-primary);
    transition: background-color var(--dur-fast) var(--ease-out);
}
.theme-picker__swatch:hover { background: var(--surface-1); }
.theme-picker__swatch.active {
    background: var(--tint-brand);
}
.theme-picker__swatch-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex: 0 0 24px;
    border: 2px solid var(--surface-elevated);
    box-shadow: 0 0 0 1px var(--border);
}
.theme-picker__swatch-text { flex: 1; min-width: 0; line-height: 1.2; }
.theme-picker__swatch-name { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); }
.theme-picker__swatch-sub  { display: block; font-size: var(--fs-xs); color: var(--text-muted); margin-top: 1px; }
.theme-picker__check {
    color: var(--brand-primary);
    opacity: 0;
    font-size: 16px;
}
.theme-picker__swatch.active .theme-picker__check { opacity: 1; }

/* Compact (only swatch + caret) — used on auth/login floating button */
.theme-picker.compact .theme-picker__trigger-label { display: none; }
.theme-picker.compact .theme-picker__trigger {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
}

/* =============================================================
 * CFG-DYN scope — overrides for the JS-built dynamic-form markup
 * in Customer/Partner/Location/CustomerUser/Note ConfigureDynamic views.
 * The JS in those views builds HTML strings with inline styles for password
 * fields, image thumbnails, and feedback colors. We can't change the JS
 * during the visual re-skin phase, so we scope CSS overrides under .cfg-dyn
 * to make the inline-styled elements theme-aware (dark mode contrast)
 * without touching JS.
 * ========================================================== */

/* The JS injects an outer Bootstrap card to hold all dynamic property controls.
   Re-skin its header so the bg-secondary / bg-primary card-headers it ships
   blend with the new token system instead of staying solid Bootstrap colors. */
.cfg-dyn .card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.cfg-dyn .card > .card-header {
    background: var(--surface-1) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border);
    padding: var(--space-4) var(--space-5);
    font-weight: 600;
}
.cfg-dyn .card > .card-header.bg-primary,
.cfg-dyn .card > .card-header.bg-secondary,
.cfg-dyn .card > .card-header.text-white { color: var(--text-primary) !important; }
.cfg-dyn .card > .card-body { padding: var(--space-5); }

/* Bootstrap is-valid / is-invalid — drop the SVG check/cross to keep the
   token border colors clean, and tighten the feedback line. */
.cfg-dyn .form-control.is-valid,
.cfg-dyn .form-select.is-valid {
    border-color: var(--brand-success) !important;
    background-image: none !important;
    padding-right: 0.85rem !important;
}
.cfg-dyn .form-control.is-invalid,
.cfg-dyn .form-select.is-invalid {
    border-color: var(--brand-danger) !important;
    background-image: none !important;
    padding-right: 0.85rem !important;
}
.cfg-dyn .invalid-feedback {
    font-size: var(--fs-xs);
    color: var(--brand-danger);
    font-weight: 500;
    margin-top: 4px;
}

/* Password fields — JS builds:
     .password-input-group  (relative wrapper)
     input.form-control     (with inline style="padding-right: 120px;")
     .password-actions       (absolute, top:50% transform translateY)
       button.btn-outline-secondary "Generate"
       button.btn-link "Toggle visibility"
   The inline positioning works fine; we just theme the buttons + feedback. */
.cfg-dyn .password-input-group { position: relative; }
.cfg-dyn .password-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.cfg-dyn .password-actions .btn {
    font-size: var(--fs-xs);
    padding: 4px 10px;
    height: 28px;
    line-height: 1;
    border-radius: var(--radius-sm);
}
.cfg-dyn .password-actions .btn-outline-secondary {
    border-color: var(--border-strong);
    color: var(--text-secondary);
    background: var(--surface-0);
}
.cfg-dyn .password-actions .btn-outline-secondary:hover {
    background: var(--tint-brand);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}
.cfg-dyn .password-actions .btn-link {
    color: var(--text-muted) !important;
    text-decoration: none;
    padding: 4px 8px;
}
.cfg-dyn .password-actions .btn-link:hover {
    color: var(--brand-primary) !important;
    background: var(--surface-2);
}

/* Password match/mismatch feedback text (JS toggles classes match/mismatch on
   <div class="password-feedback">). Make it token-aware so dark mode works. */
.cfg-dyn .password-feedback {
    font-size: var(--fs-xs);
    margin-top: 4px;
    font-weight: 500;
}
.cfg-dyn .password-feedback.match    { color: var(--brand-success); }
.cfg-dyn .password-feedback.mismatch { color: var(--brand-danger); }
.cfg-dyn .password-match    { border-color: var(--brand-success) !important; }
.cfg-dyn .password-mismatch { border-color: var(--brand-danger)  !important; }

/* JS-built image preview thumbnail (`<img class="img-thumbnail" style="max-height:150px">`) */
.cfg-dyn .img-thumbnail {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-elevated);
    padding: 4px;
    box-shadow: var(--shadow-sm);
}

/* Form labels inside cfg-dyn — JS adds .form-label.fw-bold; soften the weight
   and align spacing with the new field-group style. */
.cfg-dyn .form-label.fw-bold {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}
.cfg-dyn .form-label.fw-bold i.bi {
    color: var(--text-muted);
    margin-right: 4px;
}

/* Helper text under fields (.form-text.text-muted) */
.cfg-dyn .form-text.text-muted {
    color: var(--text-muted) !important;
    font-size: var(--fs-xs);
    margin-top: 4px;
}

/* The JS-rendered "Configuration Properties" card body uses col-md-6 per field —
   keep that, but tighten the row spacing for the new visual rhythm. */
.cfg-dyn .card .card-body > .row > [class*="col-"] {
    margin-bottom: var(--space-4);
}

/* =============================================================
 * MINI STATS LIST
 * ========================================================== */
.mini-stats { display: flex; flex-direction: column; gap: var(--space-3); }
.mini-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--surface-1);
}
.mini-stat__label { display: flex; align-items: center; gap: var(--space-2); color: var(--text-secondary); font-size: var(--fs-sm); }
.mini-stat__value { font-weight: 700; color: var(--text-primary); }
