/* Hidden Rabbit panel UI foundation */

:root {
    --brand-navy: #050A3C;
    --brand-cyan: #08C5CB;
    --brand-white: #ffffff;
    --brand-java-dark: #02A8AD;
    --brand-java-light: #44EFF4;

    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: #ffffff;
    --bg-hover: #edf2f7;

    --text-primary: #0e163e;
    --text-secondary: #4f5b7a;
    --text-muted: #7f8aa5;

    --accent: var(--brand-navy);
    --accent-hover: #16226e;
    --accent-glow: rgba(8, 197, 203, 0.22);
    --accent-soft: rgba(8, 197, 203, 0.12);

    --success: #02A8AD;
    --success-bg: rgba(2, 168, 173, 0.16);
    --warning: #eab308;
    --warning-bg: rgba(234, 179, 8, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);

    --border: rgba(5, 10, 60, 0.12);
    --border-light: rgba(5, 10, 60, 0.2);

    --radius: 16px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    --shadow: 0 12px 28px rgba(5, 10, 60, 0.05);
    --shadow-lg: 0 18px 44px rgba(5, 10, 60, 0.08);

    --primary: var(--accent);
    --text: var(--text-primary);
    --bg: var(--bg-primary);
    --font-heading: 'Geologica', 'Segoe UI', sans-serif;
    --font-body: 'Lilex', 'Segoe UI', monospace;

    --transition: 0.15s ease;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 84px;
    --shell-sidebar-height: 100dvh;
    --shell-header-height: 94px;
}

:root[data-theme="dark"] {
    --bg-primary: #071030;
    --bg-secondary: #0b1338;
    --bg-tertiary: #101b4a;
    --bg-elevated: #111d4c;
    --bg-hover: #14215b;

    --text-primary: #f8fbff;
    --text-secondary: #bfd0eb;
    --text-muted: #7f95bd;

    --accent: var(--brand-cyan);
    --accent-hover: #39dce1;
    --accent-glow: rgba(8, 197, 203, 0.28);
    --accent-soft: rgba(8, 197, 203, 0.12);

    --border: rgba(191, 208, 235, 0.14);
    --border-light: rgba(191, 208, 235, 0.24);

    --shadow: none;
    --shadow-lg: 0 20px 54px rgba(0, 0, 0, 0.22);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

html.layout-stabilizing * {
    transition: none !important;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Layout */
.app {
    display: block;
    min-height: 100dvh;
    height: auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    isolation: isolate;
    transition: none;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px dashed var(--border);
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    min-height: 100dvh;
    height: 100dvh;
    z-index: 100;
    min-width: 0;
    overflow: clip;
    transition: width 0.22s ease, border-color 0.22s ease;
}

.sidebar-inner {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: inherit;
    overflow: clip;
    transition: padding 0.22s ease;
}

:root[data-theme="dark"] .sidebar {
    background: var(--bg-secondary);
}

:root.sidebar-collapsed {
    --sidebar-width: var(--sidebar-collapsed-width);
}

.sidebar-head {
    min-height: var(--shell-header-height);
    border-bottom: 1px dashed var(--border);
    display: flex;
    align-items: stretch;
}

.sidebar-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 16px 0;
}

.logo {
    width: 100%;
    min-height: var(--shell-header-height);
    padding: 18px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 0;
    transition: padding 0.22s ease, gap 0.22s ease;
}

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 12px var(--accent-glow));
    animation: pulse 3s infinite;
}

.logo-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--brand-navy);
}

:root[data-theme="dark"] .logo-text {
    color: var(--brand-white);
}

.logo-sub {
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.7;
    font-weight: 400;
}

.sidebar-toggle {
    width: 100%;
    min-height: 44px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.sidebar-toggle-label {
    white-space: nowrap;
}

.nav-menu {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
    min-height: 0;
    overflow: visible;
    scrollbar-width: none;
}

.nav-menu li {
    margin-bottom: 4px;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    position: relative;
}

.nav-menu a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    transition: height 0.3s ease;
}

.nav-menu a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-menu a:hover::before {
    height: 60%;
}

.nav-menu a.active {
    background: var(--brand-navy);
    color: white;
    box-shadow: none;
}

.nav-menu a.active::before {
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-label {
    white-space: nowrap;
}

.sidebar-footer {
    position: relative;
    z-index: 3;
    padding: 16px;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
    background: inherit;
    flex-shrink: 0;
}

.mobile-sidebar-controls {
    display: none;
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    font-weight: 500;
}

.sidebar-toggle i,
.logout-btn i {
    font-size: 16px;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

/* Content */
.content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: 100%;
    min-height: 100dvh;
    min-width: 0;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at top right, rgba(8, 197, 203, 0.02), transparent 22%),
        radial-gradient(circle at 16% 12%, rgba(5, 10, 60, 0.018) 0 0.9px, transparent 1.2px),
        radial-gradient(circle at 68% 28%, rgba(5, 10, 60, 0.012) 0 0.8px, transparent 1.15px),
        radial-gradient(circle at 42% 64%, rgba(5, 10, 60, 0.01) 0 0.7px, transparent 1px),
        linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0)),
        var(--bg-primary);
    background-size: auto, 34px 34px, 54px 54px, 78px 78px, auto;
    background-position: 0 0, 0 0, 7px 11px, 19px 15px, 0 0;
    transition: none;
}

:root.sidebar-collapsed .content {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

:root[data-theme="dark"] .content {
    background:
        radial-gradient(circle at top right, rgba(8, 197, 203, 0.04), transparent 22%),
        radial-gradient(circle at 18% 14%, rgba(221, 229, 237, 0.03) 0 0.9px, transparent 1.2px),
        radial-gradient(circle at 62% 36%, rgba(221, 229, 237, 0.02) 0 0.8px, transparent 1.15px),
        radial-gradient(circle at 40% 72%, rgba(221, 229, 237, 0.014) 0 0.7px, transparent 1px),
        linear-gradient(180deg, rgba(17, 29, 76, 0.14), rgba(17, 29, 76, 0)),
        var(--bg-primary);
    background-size: auto, 34px 34px, 54px 54px, 78px 78px, auto;
    background-position: 0 0, 0 0, 7px 11px, 19px 15px, 0 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: var(--shell-header-height);
    padding: 18px 32px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px dashed var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    min-width: 0;
    overflow: hidden;
}

:root[data-theme="dark"] .topbar {
    background: rgba(11, 19, 56, 0.94);
}

.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.topbar h1 {
    font-size: 20px;
    font-family: var(--font-heading);
    font-weight: 600;
}

.topbar-kicker {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topbar-utility {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-wrap: wrap;
}

.theme-switcher {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-secondary);
}

:root[data-theme="dark"] .theme-switcher {
    background: var(--bg-secondary);
}

.theme-btn {
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.theme-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
    transform: translateY(-1px);
}

.theme-btn.active {
    background: var(--brand-navy);
    color: #fff;
    box-shadow: none;
}

.theme-btn-label {
    display: none;
}

:root[data-theme="dark"] .theme-btn.active {
    background: var(--brand-cyan);
    color: var(--brand-navy);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 12px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.main-content {
    padding: 32px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    flex: 1 1 auto;
}

.main-content > * {
    max-width: 100%;
    width: 100%;
}

.experience-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 24px;
    padding: 24px 28px;
    border: 1px dashed var(--border);
    border-radius: 18px;
    background:
        radial-gradient(circle at 14% 18%, rgba(5, 10, 60, 0.03) 0 1px, transparent 1.3px),
        radial-gradient(circle at 76% 36%, rgba(5, 10, 60, 0.02) 0 0.9px, transparent 1.2px),
        radial-gradient(circle at 44% 72%, rgba(5, 10, 60, 0.018) 0 0.8px, transparent 1.1px),
        var(--bg-secondary);
    background-size: 38px 38px, 64px 64px, 88px 88px, auto;
    background-position: 0 0, 8px 16px, 18px 12px, 0 0;
    box-shadow: none;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

:root[data-theme="dark"] .experience-hero {
    background:
        radial-gradient(circle at 16% 18%, rgba(221, 229, 237, 0.045) 0 1px, transparent 1.3px),
        radial-gradient(circle at 70% 34%, rgba(221, 229, 237, 0.03) 0 0.9px, transparent 1.2px),
        radial-gradient(circle at 48% 74%, rgba(221, 229, 237, 0.024) 0 0.8px, transparent 1.1px),
        var(--bg-secondary);
    background-size: 38px 38px, 64px 64px, 88px 88px, auto;
    background-position: 0 0, 8px 16px, 18px 12px, 0 0;
}

.experience-hero::after {
    content: '';
    position: absolute;
    right: 24px;
    bottom: 20px;
    width: 180px;
    height: 180px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    opacity: 0.7;
}

.dashboard-hero::after {
    display: none;
}

.hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.hero-eyebrow,
.hero-mini-kicker,
.preview-kicker {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid var(--border);
}

.hero-copy h2 {
    font-family: var(--font-heading);
    font-size: clamp(28px, 3.6vw, 40px);
    line-height: 1.02;
    max-width: 14ch;
}

.hero-copy p,
.hero-mini-card p,
.preview-surface-copy p {
    color: var(--text-secondary);
    max-width: 62ch;
}

.hero-action-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.hero-action-row .btn,
.hero-action-row .hero-link-chip {
    flex: 0 0 auto;
}

.hero-link-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 999px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.hero-link-chip:hover,
.hero-link-chip:focus-visible {
    background: var(--bg-hover);
    border-color: var(--brand-cyan);
    color: var(--brand-navy);
    transform: translateY(-1px);
    outline: none;
}

:root[data-theme="dark"] .hero-link-chip {
    background: var(--bg-secondary);
}

:root[data-theme="dark"] .hero-link-chip:hover,
:root[data-theme="dark"] .hero-link-chip:focus-visible {
    background: rgba(8, 197, 203, 0.12);
    border-color: var(--brand-cyan);
    color: var(--brand-white);
}

.hero-metrics,
.settings-hero-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-content: stretch;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.hero-sparkline-card,
.hero-device-card {
    grid-column: 1 / -1;
}

.hero-meter-card,
.hero-mini-card,
.hero-sparkline-card {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 16px;
    border-radius: 14px;
    border: 1px dashed var(--border);
    background: var(--bg-secondary);
    min-width: 0;
    min-height: 112px;
}

:root[data-theme="dark"] .hero-meter-card,
:root[data-theme="dark"] .hero-mini-card,
:root[data-theme="dark"] .hero-sparkline-card {
    background: var(--bg-secondary);
}

.hero-meter-ring {
    --meter-track: rgba(8, 197, 203, 0.42);
    --meter-gap: 5px;
    --meter-border-width: 1px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    position: relative;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 18px;
    color: var(--brand-navy);
    isolation: isolate;
    overflow: visible;
    border: var(--meter-border-width) dashed var(--meter-track);
}

.hero-meter-ring::before {
    content: "";
    position: absolute;
    inset: var(--meter-gap);
    border-radius: 50%;
    border: var(--meter-border-width) dashed var(--meter-track);
    pointer-events: none;
    z-index: 1;
}

.hero-meter-ring > .hero-meter-value {
    position: relative;
    z-index: 3;
    line-height: 1;
}

.hero-meter-ring.mini {
    width: 68px;
    height: 68px;
    font-size: 15px;
    --meter-gap: 4px;
    --meter-border-width: 1px;
}

.hero-meter-ring.soft {
    --meter-track: rgba(8, 197, 203, 0.42);
    --meter-gap: 5px;
    --meter-border-width: 1px;
}

:root[data-theme="dark"] .hero-meter-ring,
:root[data-theme="dark"] .hero-meter-ring.soft {
    color: var(--brand-white);
}

:root[data-theme="dark"] .hero-meter-ring {
    --meter-track: rgba(68, 239, 244, 0.34);
}

:root[data-theme="dark"] .hero-meter-ring.soft {
    --meter-track: rgba(68, 239, 244, 0.34);
}

.hero-meter-copy,
.preview-surface-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hero-meter-copy strong,
.hero-sparkline-card strong,
.hero-mini-card strong,
.preview-surface-copy strong,
.section-heading-stack h2 {
    font-family: var(--font-heading);
}

.hero-meter-copy span,
.hero-sparkline-card span,
.hero-mini-card p {
    color: var(--text-secondary);
}

.hero-device-card {
    justify-content: space-between;
    align-items: center;
}

.hero-device-rings {
    display: flex;
    gap: 12px;
    align-items: center;
}

.hero-device-card .hero-meter-copy {
    flex: 1;
}

.hero-device-card .hero-meter-copy span + span {
    margin-top: 2px;
}

.hero-sparkline-card {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
}

.sparkline-copy {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
    min-width: 0;
}

.hero-sparkline-card .sparkline-copy,
.hero-sparkline-card .sparkline-visual,
.hero-sparkline-card .sparkline-foot {
    width: 100%;
    margin-inline: auto;
}

.sparkline-copy strong {
    font-size: clamp(30px, 4vw, 42px);
    line-height: 0.95;
}

.sparkline-periods {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border: 1px dashed var(--border);
    border-radius: 999px;
    background: var(--bg-secondary);
}

.sparkline-period-btn {
    padding: 6px 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}

.nav-menu,
.nav-menu a,
.sidebar-footer,
.sidebar-toggle,
.logout-btn,
.nav-icon {
    transition:
        padding 0.22s ease,
        gap 0.22s ease,
        width 0.22s ease,
        min-height 0.22s ease,
        background-color 0.18s ease,
        color 0.18s ease,
        border-color 0.18s ease;
}

.sparkline-period-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sparkline-period-btn.active {
    background: var(--brand-navy);
    color: var(--brand-white);
}

.sparkline-visual {
    --sparkline-height: clamp(280px, 34vw, 420px);
    position: relative;
    min-height: var(--sparkline-height);
    aspect-ratio: 2.7 / 1;
    border-radius: 22px;
    border: 1px dashed rgba(5,10,60,0.12);
    background:
        linear-gradient(to top, rgba(8,197,203,0.08), rgba(8,197,203,0.012)),
        repeating-linear-gradient(
            to right,
            rgba(5,10,60,0.028) 0 1px,
            transparent 1px 72px
        ),
        repeating-linear-gradient(
            to top,
            rgba(5,10,60,0.018) 0 1px,
            transparent 1px 62px
        );
    overflow: hidden;
}

:root[data-theme="dark"] .sparkline-visual {
    border-color: rgba(255,255,255,0.12);
    background:
        linear-gradient(to top, rgba(8,197,203,0.14), rgba(8,197,203,0.022)),
        repeating-linear-gradient(
            to right,
            rgba(255,255,255,0.034) 0 1px,
            transparent 1px 72px
        ),
        repeating-linear-gradient(
            to top,
            rgba(255,255,255,0.022) 0 1px,
            transparent 1px 62px
        );
}

.sparkline-visual canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.sparkline-foot {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-secondary);
    flex-wrap: wrap;
    font-size: 13px;
}

@media (max-width: 900px) {
    .hero-device-card {
        flex-direction: column;
        align-items: flex-start;
    }
}

.settings-shell {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 0.25rem;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.settings-tabs::-webkit-scrollbar {
    display: none;
}

.settings-tab {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
    flex: 0 0 auto;
}

:root[data-theme="dark"] .settings-tab {
    background: var(--bg-secondary);
}

.settings-tab:hover {
    color: var(--text-primary);
    border-color: rgba(8,197,203,0.28);
}

.settings-tab.active {
    color: #fff;
    border-color: transparent;
    background: var(--brand-navy);
    box-shadow: none;
}

:root[data-theme="dark"] .settings-tab.active {
    background: var(--brand-cyan);
    color: var(--brand-navy);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.settings-feature-card .card-header,
.settings-happ-card .card-header {
    align-items: flex-start;
}

.section-heading-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.feature-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 11px;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid var(--border);
}

.preview-surface {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(240px, 0.9fr);
    gap: 18px;
    margin-bottom: 22px;
    padding: 18px;
    border-radius: 14px;
    border: 1px dashed var(--border);
    background: var(--bg-tertiary);
}

.preview-surface-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
    padding: 18px;
    border-radius: 14px;
    border: 1px dashed var(--border);
    background: var(--bg-secondary);
    box-shadow: none;
}

:root[data-theme="dark"] .preview-surface-card {
    background: rgba(13,23,65,0.88);
}

.preview-topline {
    font-size: 12px;
    color: var(--text-muted);
}

.preview-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    color: #fff;
    background: var(--brand-navy);
}

.preview-banner-text {
    max-width: 26ch;
    font-size: 13px;
}

.preview-banner-button,
.preview-sub-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.14);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.preview-subscription-card strong {
    font-size: 20px;
    font-family: var(--font-heading);
}

.preview-sub-row {
    display: flex;
    gap: 8px;
}

.preview-sub-chip.cyan {
    background: rgba(8,197,203,0.12);
    color: var(--brand-cyan);
}

.preview-sub-url {
    color: var(--text-muted);
    font-size: 12px;
}

.settings-divider {
    margin: 1.25rem 0;
    border: 0;
    border-top: 1px dashed var(--border-light);
}

.settings-nested-panel {
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
}

:root[data-theme="dark"] .settings-nested-panel {
    background: var(--bg-secondary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.stats-grid > * {
    min-width: 0;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
}

:root[data-theme="dark"] .stat-card {
    background: var(--bg-secondary);
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: auto 20px 16px 20px;
    height: 24px;
    border-bottom: 1px dashed rgba(8,197,203,0.4);
    opacity: 0.9;
}

.stat-card:hover {
    border-color: rgba(8, 197, 203, 0.34);
    transform: translateY(-2px);
    box-shadow: none;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px dashed rgba(8,197,203,0.34);
    border-radius: 50%;
    color: var(--brand-navy);
    background: rgba(8,197,203,0.08);
}

:root[data-theme="dark"] .stat-icon {
    color: var(--brand-cyan);
    background: rgba(8,197,203,0.12);
}

.stat-trend {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 20px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--brand-navy);
    line-height: 1.2;
}

:root[data-theme="dark"] .stat-value {
    color: var(--brand-white);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: none;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: none;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    min-height: 76px;
    padding: 20px 24px;
    border-bottom: 1px dashed var(--border);
    background: transparent;
    flex-wrap: wrap;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-heading);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    line-height: 1.25;
}

.card-header h2 i {
    font-size: 18px;
    opacity: 0.9;
}

.card-body {
    padding: 24px;
}

.card-body.no-padding {
    padding: 0;
}

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

.table th,
.table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px dashed var(--border);
}

.table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.table th.sortable {
    user-select: none;
    transition: all 0.2s ease;
}

.table th.sortable:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
    transform: none;
}

.table code {
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--brand-navy);
    border-color: var(--brand-navy);
    color: #ffffff;
    text-shadow: none;
    box-shadow: none;
}

.btn-primary:hover {
    background: #09115a;
    border-color: #09115a;
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

:root[data-theme="dark"] .btn-primary {
    background: var(--brand-cyan);
    border-color: var(--brand-cyan);
    color: var(--brand-navy);
}

:root[data-theme="dark"] .btn-primary:hover {
    background: #1cd7dc;
    border-color: #1cd7dc;
}

.btn-success { 
    background: var(--success); 
    border-color: var(--success); 
    color: white; 
}
.btn-success:hover { 
    background: #018B90; 
    border-color: #018B90;
    box-shadow: 0 6px 20px rgba(2, 168, 173, 0.28);
    transform: translateY(-2px);
}

.btn-warning { 
    background: var(--warning); 
    border-color: var(--warning); 
    color: black; 
}
.btn-warning:hover { 
    background: #ca8a04; 
    border-color: #ca8a04;
    box-shadow: 0 6px 20px rgba(234, 179, 8, 0.3);
    transform: translateY(-2px);
}

.btn-danger { 
    background: var(--danger); 
    border-color: var(--danger); 
    color: white; 
}
.btn-danger:hover { 
    background: #dc2626; 
    border-color: #dc2626;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border-color: var(--border);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    box-shadow: none;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(8,197,203,0.12);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.btn-icon:hover::after {
    opacity: 1;
}

.btn-icon:active {
    transform: translateY(0);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: 24px;
    transition: all var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    top: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--success);
    border-color: var(--success);
    box-shadow: none;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch:hover .toggle-slider {
    border-color: var(--border-light);
}

.toggle-switch:hover input:checked + .toggle-slider {
    box-shadow: 0 4px 12px rgba(2, 168, 173, 0.34);
}

/* Page Header with Sticky Filters */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    min-height: 88px;
    margin-bottom: 24px;
    min-width: 0;
    flex-wrap: wrap;
}

.sticky-header {
    position: sticky;
    top: 73px;
    z-index: 40;
    background: var(--bg-primary);
    padding: 16px 0;
    margin: -16px 0 24px 0;
    border-bottom: 1px dashed var(--border);
}

.page-header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.page-header-left,
.page-header-right,
.page-header-center,
.header-actions {
    min-width: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.filters-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 280px;
    padding: 10px 14px 10px 40px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-box input:hover {
    border-color: var(--border-light);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    background: var(--bg-tertiary);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-hint {
    position: absolute;
    right: 10px;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: inherit;
}

.filter-select {
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    max-width: 100%;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

.results-count {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

/* Users Table */
.users-table-card {
    overflow: visible;
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    min-width: 0;
}

.users-table-card .table {
    width: max-content;
    min-width: 100%;
}

#nodesTable {
    width: 100%;
    min-width: 720px;
    table-layout: auto;
}

.nodes-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#nodesTable th,
#nodesTable td {
    padding: 14px 12px;
    vertical-align: middle;
}

#nodesTable td .node-name-cell {
    min-width: 220px;
}

#nodesTable td code {
    white-space: nowrap;
}

.user-row {
    transition: all var(--transition);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-id {
    font-weight: 600;
    color: var(--text-primary);
}

.user-name {
    font-size: 12px;
    color: var(--text-muted);
}

.plan-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-standart {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px dashed var(--border);
}

.plan-premium {
    background: #f59e0b;
    color: white;
}

.traffic-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.traffic-bar {
    width: 60px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.traffic-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.traffic-limit {
    color: var(--text-muted);
    font-size: 12px;
}

.traffic-unlimited {
    color: var(--accent);
    font-weight: 600;
}

.live-user-summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: 220px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
}

.live-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}

.live-node-list {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
    gap: 24px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    align-items: start;
}

.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
    width: 100%;
    overflow: hidden;
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    width: 100%;
    overflow: hidden;
}

.logs-card {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    min-width: 0;
}

.logs-card .card-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    min-width: 0;
}

.logs-container {
    width: 100%;
    min-width: 0;
}

/* Nodes Table */
.node-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.node-name-row {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.node-name-row strong {
    display: inline;
}

.node-ip {
    font-size: 12px;
    color: var(--text-muted);
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-online .status-dot { 
    background: var(--success); 
    box-shadow: 0 0 12px var(--success), 0 0 20px rgba(2, 168, 173, 0.28);
}
.status-online { color: var(--success); font-weight: 500; }

.status-offline .status-dot { 
    background: var(--text-muted); 
}
.status-offline { color: var(--text-muted); }

.status-error .status-dot { 
    background: var(--danger); 
    box-shadow: 0 0 12px var(--danger);
}
.status-error { color: var(--danger); font-weight: 500; }

.status-syncing .status-dot { 
    background: var(--warning); 
    animation: pulse 1s infinite; 
    box-shadow: 0 0 12px var(--warning);
}
.status-syncing { color: var(--warning); font-weight: 500; }

.node-actions {
    display: flex;
    gap: 8px;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    width: 100%;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.quick-action::before {
    content: none;
}

.quick-action:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateX(2px);
}

.quick-action:active {
    transform: translateX(2px) scale(0.98);
}

.qa-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* System Info */
.system-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sys-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
}

.sys-item:last-child {
    border-bottom: none;
}

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

.sys-value {
    font-weight: 500;
    font-size: 13px;
}

/* Logs */
.logs-container {
    display: block;
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 360px;
    max-height: 620px;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: var(--bg-primary);
}

.log-line {
    padding: 8px 16px;
    border-bottom: 1px dashed var(--border);
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: anywhere;
}

.log-line:hover {
    background: var(--bg-tertiary);
}

.log-error { color: var(--danger); }
.log-warn { color: var(--warning); }
.log-success { color: var(--success); }

.logs-empty, .logs-loading, .logs-error {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

/* Logs search */
.logs-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logs-search-input {
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    padding: 7px 12px;
    width: 180px;
    outline: none;
    transition: all 0.2s ease;
}

.logs-search-input:hover {
    border-color: var(--border-light);
}

.logs-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-tertiary);
    width: 220px;
}

.logs-search-input::placeholder {
    color: var(--text-muted);
}

.logs-search-count {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 3px 8px;
    min-width: 20px;
    text-align: center;
}

.logs-search-count:empty {
    display: none;
}

.logs-search-clear {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
    margin-left: -4px;
}

.logs-search-clear:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 14px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.page-btn.active {
    background: var(--brand-navy);
    border-color: var(--brand-navy);
    color: white;
    box-shadow: none;
    transform: none;
}

.page-btn:active {
    transform: scale(0.95);
}

.page-dots {
    color: var(--text-muted);
    padding: 0 8px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-elevated);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    font-weight: 500;
    box-shadow: none;
    transform: translateY(150px) scale(0.9);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    min-width: 280px;
}

.toast.show {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.toast.error {
    border-color: var(--danger);
    background: var(--danger-bg);
    color: var(--danger);
}

.toast.success {
    border-color: var(--success);
    background: var(--success-bg);
    color: var(--success);
}

/* In-app confirm modal */
.hr-confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.hr-confirm-modal.is-open {
    display: flex;
}

.hr-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 10, 60, 0.42);
    backdrop-filter: blur(2px);
}

.hr-confirm-card {
    position: relative;
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    border: 1px dashed var(--border);
    border-radius: 14px;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    overflow: auto;
    z-index: 1;
}

.hr-confirm-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px dashed var(--border);
}

.hr-confirm-head h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.hr-confirm-close {
    width: 34px;
    height: 34px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.hr-confirm-close:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    background: var(--bg-hover);
}

.hr-confirm-body {
    padding: 16px;
    color: var(--text-primary);
    white-space: pre-wrap;
    line-height: 1.5;
}

.hr-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 16px 16px;
}

body.has-ui-confirm-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .hr-confirm-actions {
        flex-wrap: wrap;
    }

    .hr-confirm-actions .btn {
        flex: 1 1 calc(50% - 5px);
    }
}

/* Forms */
.form-group {
    margin-bottom: 20px;
    min-width: 0;
}

.form-group label:not(.checkbox-label) {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-group select {
    color-scheme: dark;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 38px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.form-group select option,
.form-group select optgroup {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

.form-group input:not([type="checkbox"]):not([type="radio"]):hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: var(--border-light);
}

.form-group small {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

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

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

.form-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px dashed var(--border);
}

.form-section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.section-hint {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.docs-hint-link {
    display: inline-block;
    margin-right: 6px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.docs-hint-link:hover,
.docs-hint-link:focus {
    text-decoration: underline;
}

.optional-fields-wrap {
    margin-top: 12px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    line-height: 1.35;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 0;
    vertical-align: middle;
}

.form-group label.checkbox-label {
    display: flex;
    margin-bottom: 0;
}

.checkbox-label > input[type="checkbox"],
.checkbox-label > input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    accent-color: var(--accent);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
}

.checkbox-label > input[type="checkbox"]:hover,
.checkbox-label > input[type="checkbox"]:focus,
.checkbox-label > input[type="radio"]:hover,
.checkbox-label > input[type="radio"]:focus {
    background: transparent;
    box-shadow: none;
    transform: none;
}

.checkbox-label > .checkbox-text,
.checkbox-label > span {
    line-height: 1.35;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 32px 20px;
    background:
        linear-gradient(rgba(5,10,60,0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(5,10,60,0.06) 1px, transparent 1px),
        var(--bg-primary);
    background-size: 84px 84px, 84px 84px, auto;
    position: relative;
    overflow: clip;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(5,10,60,0.03), rgba(8,197,203,0.02));
    pointer-events: none;
}

.login-page::after {
    display: none;
}

@keyframes float {
    to {
        transform: translate(50px, 50px) scale(1.1);
    }
}

.login-container {
    width: 100%;
    max-width: 430px;
    padding: 0;
    position: relative;
    z-index: 1;
}

.login-box {
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: 18px;
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: none;
    animation: slideUp 0.28s ease-out;
    max-width: 100%;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header .logo-icon {
    font-size: 34px;
    filter: none;
    display: inline-block;
    animation: none;
}

.login-header h1 {
    margin-top: 16px;
    font-size: 28px;
    font-weight: 700;
    color: var(--brand-navy);
}

:root[data-theme="dark"] .login-header h1 {
    color: var(--brand-white);
}

.login-header p {
    color: var(--text-secondary);
    margin-top: 8px;
}

.login-form .form-group {
    margin-bottom: 24px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.badge-success { 
    background: var(--success-bg); 
    color: var(--success); 
    border-color: var(--success);
}

.badge-warning { 
    background: var(--warning-bg); 
    color: var(--warning); 
    border-color: var(--warning);
}

.badge-danger { 
    background: var(--danger-bg); 
    color: var(--danger); 
    border-color: var(--danger);
}

.badge-secondary { 
    background: var(--bg-tertiary); 
    color: var(--text-secondary); 
    border-color: var(--border);
}

.badge-lg { 
    padding: 7px 16px; 
    font-size: 12px; 
}

.badge:hover {
    transform: scale(1.05);
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.detail-item {
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.detail-item label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.detail-item .value {
    font-size: 14px;
    font-weight: 500;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    margin: 28px 0 16px;
    color: var(--text-secondary);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* Nodes List */
.nodes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.node-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.node-name {
    font-weight: 600;
}

/* Actions List */
.actions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Input readonly */
.input-readonly {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

/* Grid */
.row {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.col { flex: 1; }
.col-4 { flex: 0 0 33.333%; }
.col-6 { flex: 0 0 calc(50% - 12px); }
.col-8 { flex: 0 0 calc(66.666% - 12px); }

/* Empty State */
.empty-state {
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.empty-cell {
    padding: 0 !important;
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.hint { font-size: 13px; color: var(--text-muted); }

/* Settings grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.settings-grid .form-group {
    margin-bottom: 0;
}
.settings-grid input[type="number"] {
    width: 100%;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-error { background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success); color: var(--success); }
.alert-warning { background: var(--warning-bg); border: 1px solid var(--warning); color: var(--warning); }

/* Groups */
.groups-select {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.checkbox-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 2px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    background: var(--bg-tertiary);
}

.checkbox-tag:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.checkbox-tag input {
    display: none;
}

.checkbox-tag:has(input:checked) {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 12px var(--accent-glow);
    transform: scale(1.02);
}

.checkbox-tag:has(input:checked) span {
    color: white;
    font-weight: 600;
}

.checkbox-tag:has(input:checked) .tag-dot {
    background: white !important;
    box-shadow: 0 0 8px rgba(255,255,255,0.5);
}

.tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.group-tag {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border: 1px solid;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 6px;
    transition: all 0.2s ease;
    cursor: default;
}

.group-tag:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.group-tag-sm {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border: 1px solid;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    margin-right: 4px;
    transition: all 0.2s ease;
    cursor: default;
}

.group-tag-sm:hover {
    transform: scale(1.08);
}

.group-more {
    font-size: 11px;
    color: var(--text-muted);
}

.groups-list {
    margin-top: 8px;
}

/* Actions Grid (Node Management) */
.actions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn .action-icon {
    font-size: 16px;
}

/* Mobile Header (hidden on desktop) */
.mobile-header {
    display: none;
}

.mobile-overlay {
    display: none;
}

body.mobile-menu-open {
    overflow: hidden;
}

/* Mobile Cards - скрыты по умолчанию (показываются только на мобилке) */
.mobile-nodes-list,
.mobile-users-list {
    display: none;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-btn span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Responsive */
@media (max-width: 1380px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-sidebar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

@media (max-width: 1200px) {
    .hero-metrics {
        grid-template-columns: 1fr;
    }

    .hero-sparkline-card,
    .hero-device-card {
        grid-column: auto;
    }

    .dashboard-sidebar {
        grid-template-columns: 1fr;
    }

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

    .hero-sparkline-card .sparkline-copy,
    .hero-sparkline-card .sparkline-visual,
    .hero-sparkline-card .sparkline-foot {
        width: 100%;
    }
}

@media (max-width: 768px) {
    /* Скрываем desktop таблицы */
    .table-wrapper {
        display: none !important;
    }
    
    /* Показываем мобильные карточки */
    .mobile-nodes-list,
    .mobile-users-list {
        display: flex !important;
    }
    
    /* Mobile Header */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        z-index: 200;
    }
    
    .mobile-logo {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .mobile-logo .logo-icon {
        font-size: 24px;
    }
    
    .mobile-logo .logo-text {
        font-size: 16px;
        font-weight: 700;
        letter-spacing: 0.5px;
        color: var(--brand-navy);
    }

    :root[data-theme="dark"] .mobile-logo .logo-text {
        color: var(--brand-white);
    }
    
    .mobile-status {
        display: flex;
        align-items: center;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    /* Overlay */
    .mobile-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.24s ease, visibility 0.24s ease;
        z-index: 320;
        pointer-events: none;
    }
    
    .mobile-overlay.active {
        left: min(88vw, 320px);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    
    /* Sidebar Mobile */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(88vw, 320px);
        height: 100dvh;
        z-index: 360;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
        overflow: hidden;
    }

    .sidebar-inner {
        min-height: 100dvh;
        overflow-y: auto;
    }

    :root.sidebar-collapsed {
        --sidebar-width: 260px;
    }
    
    .sidebar.active {
        transform: translateX(0);
        pointer-events: auto;
    }

    body.mobile-menu-open .content,
    body.mobile-menu-open .mobile-header {
        pointer-events: none;
        user-select: none;
    }

    body.mobile-menu-open .sidebar,
    body.mobile-menu-open .mobile-overlay {
        pointer-events: auto;
        user-select: auto;
    }
    
    /* Content */
    .content {
        grid-column: 1 / -1;
        margin-left: 0;
        width: 100%;
        padding-top: 60px;
        max-width: 100%;
    }
    
    .topbar {
        position: relative;
        padding: 16px;
        align-items: flex-start;
        gap: 12px;
    }

    .topbar-utility {
        display: none;
    }

    .topbar-right {
        display: none;
    }
    
    .topbar h1 {
        font-size: 18px;
    }
    
    .topbar-right .status-text {
        display: none;
    }
    
    .main-content {
        padding: 16px;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .settings-shell {
        gap: 14px;
    }

    .settings-tabs {
        flex-wrap: nowrap;
        gap: 8px;
        margin-inline: -4px;
        padding-inline: 4px 12px;
    }

    .settings-tab {
        padding: 10px 14px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    /* Forms */
    .form-row,
    .form-row-3,
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .row {
        flex-direction: column;
        gap: 16px;
    }
    
    .col-4, .col-6, .col-8 {
        flex: 1;
    }

    .preview-surface {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 16px;
    }

    .preview-surface-card {
        min-height: 0;
    }

    .preview-subscription-card strong,
    .preview-sub-url {
        word-break: break-word;
    }
    
    /* Page Header */
    .page-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .page-header-left,
    .page-header-center,
    .page-header-right {
        width: 100%;
    }
    
    .filters-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-box,
    .filter-select {
        width: 100%;
    }
    
    .search-box input {
        width: 100%;
    }
    
    .logs-search-wrap {
        flex: 1;
        min-width: 0;
    }
    
    .logs-search-input {
        width: 100% !important;
    }
    
    /* Tables - скрываем на мобилках */
    .table-wrapper {
        display: none;
    }
    
    /* Mobile Cards - показываем только на мобилке */
    .mobile-nodes-list,
    .mobile-users-list {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }
    
    .mobile-node-card,
    .mobile-user-card {
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 16px;
        transition: all 0.2s ease;
    }
    
    .mobile-node-card:active,
    .mobile-user-card:active {
        transform: scale(0.98);
        background: var(--bg-hover);
    }
    
    .mobile-node-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 12px;
        gap: 12px;
    }
    
    .mobile-node-title {
        flex: 1;
    }
    
    .mobile-node-title strong {
        font-size: 15px;
        display: block;
        margin-bottom: 4px;
    }
    
    .mobile-node-title code {
        font-size: 12px;
        color: var(--text-muted);
    }
    
    .mobile-node-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 12px;
    }
    
    .mobile-stat-item {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .mobile-stat-label {
        font-size: 11px;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .mobile-stat-value {
        font-size: 14px;
        font-weight: 500;
    }
    
    .mobile-node-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        padding-top: 12px;
        border-top: 1px solid var(--border);
    }

    .mobile-node-actions .btn,
    .mobile-node-actions .btn-icon {
        width: 100%;
        min-width: 0;
        height: 42px;
        padding: 0;
        justify-content: center;
    }

    .mobile-node-actions .btn {
        font-size: 0;
    }

    .mobile-node-actions .btn i,
    .mobile-node-actions .btn-icon i {
        margin: 0;
        font-size: 18px;
    }
    
    
    /* Logs Container Mobile */
    .logs-container {
        min-height: 200px;
        max-height: 200px;
        font-size: 11px;
    }
    
    .log-line {
        padding: 6px 12px;
        word-break: break-word;
        white-space: pre-wrap;
        font-size: 10px;
    }
    
    /* Buttons */
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .btn-sm {
        padding: 10px 16px;
    }
    
    .action-buttons {
        justify-content: center;
    }
    
    /* Cards */
    .card {
        border-radius: 10px;
    }
    
    .card-header {
        padding: 16px;
        flex-wrap: wrap;
    }
    
    .card-body {
        padding: 16px;
    }
    
    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .dashboard-main,
    .dashboard-sidebar {
        width: 100%;
        margin-top: 0;
    }

    .experience-hero {
        padding: 18px;
        gap: 16px;
        border-radius: 14px;
    }

    .hero-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .hero-meter-card,
    .hero-mini-card,
    .hero-sparkline-card {
        padding: 14px;
        min-height: auto;
    }

    .hero-meter-card,
    .hero-device-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .hero-meter-card .hero-meter-copy,
    .hero-meter-card .hero-meter-copy strong,
    .hero-meter-card .hero-meter-copy span {
        width: 100%;
        text-align: center;
        align-items: center;
    }

    .hero-meter-card .hero-meter-ring {
        width: 84px;
        height: 84px;
        font-size: 19px;
        --meter-gap: 5px;
        --meter-border-width: 1px;
    }

    .hero-meter-card .hero-meter-ring > .hero-meter-value {
        line-height: 1;
    }

    .hero-sparkline-card,
    .hero-device-card {
        grid-column: 1 / -1;
    }

    .hero-device-rings {
        width: 100%;
        gap: 10px;
        justify-content: space-between;
        padding-inline: 20px;
    }

    .hero-device-rings .hero-meter-ring.mini {
        width: 72px;
        height: 72px;
        font-size: 16px;
        --meter-gap: 4px;
        --meter-border-width: 1px;
    }

    .hero-device-card .hero-meter-copy {
        width: 100%;
        text-align: center;
        align-items: center;
    }

    .sparkline-visual {
        --sparkline-height: 220px;
        aspect-ratio: auto;
    }

    .sparkline-copy {
        flex-direction: column;
        align-items: stretch;
    }

    .sparkline-periods {
        width: fit-content;
    }

    .chart-card .card-header {
        align-items: flex-start;
        gap: 10px;
    }

    .chart-card .card-header h2 {
        font-size: 15px;
    }

    .chart-legend,
    .traffic-totals,
    .heatmap-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .users-heatmap {
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .users-heatmap-row {
        min-width: 560px;
    }

    .sparkline-copy strong {
        font-size: 22px;
    }

    .hero-action-row > * {
        width: 100%;
    }

    .mobile-sidebar-controls {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        margin-bottom: 4px;
    }

    .mobile-sidebar-controls .lang-switcher,
    .mobile-sidebar-controls .theme-switcher {
        width: 100%;
        min-width: 0;
    }

    .sidebar-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .sidebar-footer-toggle {
        display: none;
    }

    .sidebar-footer .logout-btn {
        order: 2;
    }
    
    /* Nodes table scrollable */
    .nodes-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #nodesTable {
        min-width: 620px;
    }
    
    /* Quick Actions */
    .quick-action {
        padding: 16px;
        font-size: 15px;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
    }
    
    .page-btn {
        min-width: 36px;
        height: 36px;
        padding: 0 10px;
        font-size: 13px;
    }
    
    /* Forms */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Login Page */
    .login-container {
        padding: 0;
    }
    
    .login-box {
        padding: 32px 24px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .stat-card {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .table th,
    .table td {
        padding: 10px 8px;
        font-size: 12px;
    }
    
    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .action-buttons {
        gap: 6px;
    }
}

/* Language Switcher */
.lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-secondary);
}

.lang-switcher-top {
    margin-bottom: 0;
    min-width: 112px;
}

.lang-switcher-topbar {
    min-width: 104px;
}

.lang-btn {
    flex: 1;
    min-width: 44px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 999px;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.lang-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
    transform: translateY(-1px);
}

.lang-btn.active {
    color: #ffffff;
    background: var(--brand-navy);
}

:root[data-theme="dark"] .lang-btn.active {
    color: var(--brand-navy);
    background: var(--brand-cyan);
}

:root.sidebar-collapsed .logo {
    justify-content: center;
    padding: 18px 12px 20px;
}

:root.sidebar-collapsed .logo-content,
:root.sidebar-collapsed .nav-label,
:root.sidebar-collapsed .logout-label,
:root.sidebar-collapsed .sidebar-toggle-label {
    display: none;
}

:root.sidebar-collapsed .nav-menu {
    padding-left: 10px;
    padding-right: 10px;
}

:root.sidebar-collapsed .nav-menu a {
    justify-content: center;
    padding: 12px 10px;
    gap: 0;
}

:root.sidebar-collapsed .nav-menu a::before {
    left: auto;
    right: 0;
    border-radius: 2px 0 0 2px;
}

:root.sidebar-collapsed .nav-icon {
    width: 100%;
    font-size: 20px;
}

:root.sidebar-collapsed .sidebar-footer {
    padding: 12px 10px 16px;
}

:root.sidebar-collapsed .sidebar-toggle,
:root.sidebar-collapsed .logout-btn {
    padding: 12px 0;
}

.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.card,
.card-header,
.card-body,
.charts-grid,
.chart-card,
.chart-body,
.stats-grid,
.experience-hero,
.hero-metrics,
.hero-copy,
.view-tabs,
.dashboard-grid,
.dashboard-main,
.dashboard-sidebar,
.topbar-left,
.topbar-right,
.topbar-utility {
    min-width: 0;
}

.form-group .datetime-input {
    color-scheme: dark;
    padding-right: 44px;
}

.form-group .datetime-input::-webkit-calendar-picker-indicator {
    opacity: 1;
    cursor: pointer;
    border-radius: var(--radius-xs);
    padding: 4px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-light);
    filter: invert(94%) sepia(7%) saturate(154%) hue-rotate(192deg) brightness(91%) contrast(96%);
    transition: all var(--transition);
}

.form-group .datetime-input::-webkit-calendar-picker-indicator:hover {
    background-color: var(--bg-hover);
    border-color: var(--accent);
}

.form-group .datetime-input::-webkit-calendar-picker-indicator:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* ── Tabler Icons ── */
.ti {
    font-size: 1em;
    line-height: 1;
    vertical-align: -0.125em;
}

/* Spinner animation for loader icons */
@keyframes ti-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.ti-loader-2 {
    display: inline-block;
    animation: ti-spin 1s linear infinite;
}

/* ─── Page enter animations ───────────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Main content area fades in on navigation */
.main-content {
    animation: none;
}

/* Stats cards stagger */
.stat-card {
    animation: fadeUp 0.3s ease-out both;
}
.stat-card:nth-child(1) { animation-delay: 0.03s; }
.stat-card:nth-child(2) { animation-delay: 0.07s; }
.stat-card:nth-child(3) { animation-delay: 0.11s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }

/* Cards */
.card {
    animation: fadeUp 0.25s ease-out both;
}

/* Dashboard grid children stagger */
.dashboard-main > .card:nth-child(1) { animation-delay: 0.05s; }
.dashboard-main > .card:nth-child(2) { animation-delay: 0.1s; }
.dashboard-sidebar > .card:nth-child(1) { animation-delay: 0.08s; }
.dashboard-sidebar > .card:nth-child(2) { animation-delay: 0.13s; }

/* Table rows */
.table tbody tr {
    animation: fadeIn 0.2s ease-out both;
}
.table tbody tr:nth-child(1)  { animation-delay: 0.04s; }
.table tbody tr:nth-child(2)  { animation-delay: 0.07s; }
.table tbody tr:nth-child(3)  { animation-delay: 0.10s; }
.table tbody tr:nth-child(4)  { animation-delay: 0.13s; }
.table tbody tr:nth-child(5)  { animation-delay: 0.16s; }
.table tbody tr:nth-child(n+6) { animation-delay: 0.18s; }

/* Топбар */
.topbar {
    animation: fadeIn 0.15s ease-out;
}

/* Page header */
.page-header {
    animation: fadeUp 0.2s ease-out both;
}

/* Quick action items */
.quick-action {
    animation: fadeUp 0.25s ease-out both;
}
.quick-actions .quick-action:nth-child(1) { animation-delay: 0.05s; }
.quick-actions .quick-action:nth-child(2) { animation-delay: 0.08s; }
.quick-actions .quick-action:nth-child(3) { animation-delay: 0.11s; }
.quick-actions .quick-action:nth-child(4) { animation-delay: 0.14s; }
.quick-actions .quick-action:nth-child(5) { animation-delay: 0.17s; }

/* Уважаем prefer-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .main-content, .stat-card, .card, .table tbody tr,
    .nav-menu li, .topbar, .page-header, .quick-action {
        animation: none;
    }
}

/* ==================== CASCADE ROLE PICKER ==================== */

.cascade-role-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.role-card {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 14px;
    border: 1.5px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.02));
    user-select: none;
}

.role-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
}

.role-card.active {
    border-color: var(--accent, #6366f1);
    background: rgba(99, 102, 241, 0.08);
}

.role-card-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.role-card-icon.role-standalone { background: rgba(71, 85, 105, 0.3); color: #94a3b8; }
.role-card-icon.role-portal     { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
.role-card-icon.role-bridge     { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.role-card-icon.role-relay      { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }

.role-card.active .role-card-icon.role-standalone { background: rgba(71, 85, 105, 0.5); }
.role-card.active .role-card-icon.role-portal     { background: rgba(99, 102, 241, 0.3); }
.role-card.active .role-card-icon.role-bridge     { background: rgba(245, 158, 11, 0.3); }
.role-card.active .role-card-icon.role-relay      { background: rgba(139, 92, 246, 0.3); }

.role-card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.role-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
    white-space: nowrap;
}

.role-card-name small {
    font-weight: 400;
    color: var(--text-muted, #64748b);
    font-size: 10px;
}

.role-card-desc {
    font-size: 10px;
    color: var(--text-muted, #64748b);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ==================== CASCADE LINKS TABLE ==================== */

.cascade-links-table td { vertical-align: middle; }

.cascade-node-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.badge-this {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    background: rgba(99, 102, 241, 0.18);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
    text-transform: uppercase;
}

.cascade-link-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}
