/* ============================================
   APPLE LIQUID GLASS DESIGN SYSTEM
   Translucent · Luminous · Fluid · Layered
   ============================================ */

:root {
    /* ---- Glass Surface Tokens ---- */
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-bg-thick: rgba(255, 255, 255, 0.62);
    --glass-bg-thin: rgba(255, 255, 255, 0.28);
    --glass-bg-hover: rgba(255, 255, 255, 0.58);
    --glass-bg-active: rgba(255, 255, 255, 0.72);
    --glass-blur: 40px;
    --glass-blur-heavy: 60px;
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-border-subtle: rgba(255, 255, 255, 0.25);
    --glass-shadow: 0 2px 20px rgba(0, 0, 0, 0.06), 0 0 0 0.5px rgba(255, 255, 255, 0.5) inset;
    --glass-shadow-elevated: 0 8px 40px rgba(0, 0, 0, 0.1), 0 0 0 0.5px rgba(255, 255, 255, 0.55) inset;
    --glass-highlight: linear-gradient(135deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0) 100%);

    /* ---- Color Palette ---- */
    --accent: #007AFF;
    --accent-hover: #0A84FF;
    --accent-soft: rgba(0, 122, 255, 0.12);
    --accent-text: #0055D4;
    --accent-gradient: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);

    --red: #FF3B30;
    --orange: #FF9500;
    --green: #34C759;
    --teal: #5AC8FA;
    --purple: #AF52DE;
    --pink: #FF2D55;

    /* ---- Semantic Color Mappings ---- */
    --color-primary: var(--accent);
    --color-success: var(--green);
    --color-warning: var(--orange);
    --color-danger: var(--red);

    /* ---- Text ---- */
    --text-primary: rgba(0, 0, 0, 0.85);
    --text-secondary: rgba(0, 0, 0, 0.55);
    --text-tertiary: rgba(0, 0, 0, 0.35);
    --text-on-accent: #ffffff;

    /* ---- Layout ---- */
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    --radius-pill: 100px;

    --transition-spring: 0.5s cubic-bezier(0.32, 0.72, 0, 1);
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* ============================================
   RESET & BASE
   ============================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;

    /* Clean white-cream background */
    background: linear-gradient(160deg, #ffffff 0%, #faf8f5 30%, #f5f0eb 60%, #f0ece6 100%);
    background-attachment: fixed;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

input,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
    color: var(--text-primary);
    outline: none;
}

/* Scrollbar - Ultra-thin Apple style */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ============================================
   LAYOUT
   ============================================ */
#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ============================================
   SIDEBAR — Frosted Navigation Rail
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--glass-bg-thick);
    backdrop-filter: blur(var(--glass-blur-heavy)) saturate(1.8);
    -webkit-backdrop-filter: blur(var(--glass-blur-heavy)) saturate(1.8);
    border-right: 0.5px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 100;
    transition: transform var(--transition-spring);
}

.sidebar-header {
    padding: 20px 18px 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 11px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.3);
}

.logo-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.logo-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.logo-text span {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 8px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.93rem;
    transition: all var(--transition-normal);
    position: relative;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: all var(--transition-normal);
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.04);
}

.nav-item:hover svg {
    opacity: 1;
}

.nav-item.active {
    color: var(--text-on-accent);
    background: var(--accent-gradient);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.25), 0 0 0 0.5px rgba(255, 255, 255, 0.2) inset;
}

.nav-item.active svg {
    opacity: 1;
    color: white;
}

/* Footer */
.sidebar-footer {
    padding: 14px 18px;
    border-top: 0.5px solid rgba(0, 0, 0, 0.06);
}

.server-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px rgba(52, 199, 89, 0.5);
    animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.6;
    }
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--glass-bg-thin);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.35);
    position: relative;
    z-index: 10;
}

.menu-toggle {
    display: none;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.menu-toggle svg {
    width: 22px;
    height: 22px;
    color: var(--text-secondary);
}

.topbar-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-time {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* ============================================
   PAGE CONTENT
   ============================================ */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px 40px;
    position: relative;
    z-index: 1;
}

/* ============================================
   GLASS CARD — Core Surface Element
   ============================================ */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

/* Specular highlight on top edge */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--glass-highlight);
    pointer-events: none;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.card:hover {
    background: var(--glass-bg-hover);
    box-shadow: var(--glass-shadow-elevated);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.card-header .badge {
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

/* ============================================
   STAT CARDS — Dashboard Metrics
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 22px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-spring);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--glass-highlight);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: var(--glass-shadow-elevated);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.stat-icon svg {
    width: 22px;
    height: 22px;
}

.stat-icon.purple {
    background: rgba(175, 82, 222, 0.15);
    color: var(--purple);
}

.stat-icon.green {
    background: rgba(52, 199, 89, 0.15);
    color: var(--green);
}

.stat-icon.blue {
    background: rgba(0, 122, 255, 0.12);
    color: var(--accent);
}

.stat-icon.orange {
    background: rgba(255, 149, 0, 0.15);
    color: var(--orange);
}

.stat-icon.pink {
    background: rgba(255, 45, 85, 0.12);
    color: var(--pink);
}

.stat-icon.cyan {
    background: rgba(90, 200, 250, 0.15);
    color: var(--teal);
}

.stat-info {
    position: relative;
    z-index: 1;
}

.stat-info h4 {
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-info .stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

/* ============================================
   TABLE
   ============================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    position: relative;
    z-index: 1;
}

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

th {
    text-align: left;
    padding: 12px 14px;
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
    white-space: nowrap;
}

td {
    padding: 13px 14px;
    font-size: 0.9rem;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.04);
    color: var(--text-secondary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-primary);
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
}

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

.status-badge.online {
    background: rgba(52, 199, 89, 0.12);
    color: #1a8038;
}

.status-badge.offline {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-tertiary);
}

.status-badge.active {
    background: rgba(0, 122, 255, 0.1);
    color: var(--accent-text);
}

.status-badge.disabled {
    background: rgba(255, 59, 48, 0.1);
    color: var(--red);
}

/* ============================================
   BUTTONS — Liquid Pill Style
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.88rem;
    transition: all var(--transition-normal);
    border: none;
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

.btn svg {
    width: 15px;
    height: 15px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(0, 122, 255, 0.35);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 0.5px solid var(--glass-border-subtle);
    color: var(--text-secondary);
    box-shadow: var(--glass-shadow);
}

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

.btn-danger {
    background: rgba(255, 59, 48, 0.1);
    color: var(--red);
}

.btn-danger:hover {
    background: rgba(255, 59, 48, 0.18);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.btn:disabled, .btn[disabled] {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}


/* ============================================
   FORMS — Frosted Inputs
   ============================================ */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all var(--transition-normal);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04) inset;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12), 0 1px 4px rgba(0, 0, 0, 0.04) inset;
    background: rgba(255, 255, 255, 0.7);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

textarea.form-input {
    min-height: 110px;
    resize: vertical;
    line-height: 1.6;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-hint {
    font-size: 0.73rem;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Toggle */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle {
    display: inline-block;
    position: relative;
    width: 46px;
    height: 28px;
    cursor: pointer;
    vertical-align: middle;
}

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

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 14px;
    transition: all var(--transition-spring);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    transition: all var(--transition-spring);
}

.toggle input:checked+.toggle-slider {
    background: var(--accent);
}

.toggle input:checked+.toggle-slider::before {
    transform: translateX(18px);
}

/* Range */
.range-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-wrap input[type="range"] {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.1);
    appearance: none;
    -webkit-appearance: none;
}

.range-wrap input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--accent);
    box-shadow: 0 1px 6px rgba(0, 122, 255, 0.3);
    cursor: pointer;
}

.range-value {
    font-size: 0.85rem;
    color: var(--accent);
    min-width: 30px;
    text-align: center;
    font-weight: 700;
}

/* ============================================
   MODAL — Floating Glass Panel
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--glass-bg-thick);
    backdrop-filter: blur(var(--glass-blur-heavy)) saturate(1.8);
    -webkit-backdrop-filter: blur(var(--glass-blur-heavy)) saturate(1.8);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 580px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(255, 255, 255, 0.5) inset;
    transform: scale(0.92) translateY(12px);
    transition: all var(--transition-spring);
    position: relative;
    overflow: hidden;
}

.modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--glass-highlight);
    pointer-events: none;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 1;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 650;
}

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-tertiary);
    background: rgba(0, 0, 0, 0.05);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    padding: 22px;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

.modal-footer {
    padding: 14px 22px;
    border-top: 0.5px solid rgba(0, 0, 0, 0.06);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    position: relative;
    z-index: 1;
}

/* ============================================
   TOAST — Floating Notification Pill
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-pill);
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 260px;
    max-width: 380px;
    backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    animation: toastIn 0.5s cubic-bezier(0.32, 0.72, 0, 1);
    border: 0.5px solid;
}

.toast.success {
    background: rgba(52, 199, 89, 0.18);
    color: #1a8038;
    border-color: rgba(52, 199, 89, 0.2);
}

.toast.error {
    background: rgba(255, 59, 48, 0.18);
    color: #c62828;
    border-color: rgba(255, 59, 48, 0.2);
}

.toast.info {
    background: rgba(0, 122, 255, 0.15);
    color: var(--accent-text);
    border-color: rgba(0, 122, 255, 0.2);
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        transform: translateX(80px) scale(0.8);
        opacity: 0;
    }

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(80px);
        opacity: 0;
    }
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-tertiary);
    position: relative;
    z-index: 1;
}

.empty-state svg {
    width: 56px;
    height: 56px;
    margin-bottom: 14px;
    opacity: 0.25;
}

.empty-state h4 {
    font-size: 1.05rem;
    font-weight: 650;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.88rem;
}

/* ============================================
   TABS — Segmented Control (Apple style)
   ============================================ */
.tabs {
    display: flex;
    gap: 0;
    padding: 3px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: var(--radius-md);
    margin-bottom: 22px;
    overflow-x: auto;
}

.tab-btn {
    padding: 8px 18px;
    border-radius: calc(var(--radius-md) - 2px);
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-secondary);
    transition: all var(--transition-spring);
    white-space: nowrap;
    flex: 1;
    text-align: center;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: white;
    color: var(--text-primary);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

/* ============================================
   PROVIDER CARDS
   ============================================ */
.provider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.provider-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 20px;
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-spring);
    position: relative;
    overflow: hidden;
}

.provider-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--glass-highlight);
    pointer-events: none;
}

.provider-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--glass-shadow-elevated);
}

.provider-card.selected {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(0, 122, 255, 0.15), 0 0 0 0.5px rgba(255, 255, 255, 0.5) inset;
}

.provider-card.selected::after {
    content: '● 当前使用';
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--accent-gradient);
    color: white;
    font-weight: 700;
    z-index: 2;
}

.provider-name {
    font-size: 1rem;
    font-weight: 650;
    position: relative;
    z-index: 1;
}

.provider-type {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.provider-detail {
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.provider-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 0.5px solid rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1;
}

/* ============================================
   AGENT CARDS
   ============================================ */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.agent-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 22px;
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-spring);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.agent-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--glass-highlight);
    pointer-events: none;
}

.agent-card:hover {
    transform: translateY(-3px) scale(1.005);
    box-shadow: var(--glass-shadow-elevated);
}

.agent-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.agent-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}

.agent-name {
    font-size: 1rem;
    font-weight: 650;
}

.agent-meta {
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

.agent-prompt {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.agent-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.agent-tag {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
}

/* ============================================
   LOADING
   ============================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(0, 0, 0, 0.08);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ============================================
   SECTION HEADERS
   ============================================ */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.section-subtitle {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    margin-top: 3px;
    font-weight: 500;
}

/* ============================================
   CONFIG SECTIONS
   ============================================ */
.config-section {
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 18px;
    margin-bottom: 18px;
    position: relative;
    z-index: 1;
}

.config-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.config-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 0;
}

.config-label {
    font-size: 0.9rem;
    font-weight: 550;
}

.config-desc {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Chips */
.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 0.5px solid var(--glass-border-subtle);
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-fast);
}

.chip .chip-remove {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chip .chip-remove:hover {
    background: var(--red);
    color: white;
}

/* ============================================
   CONFIRM DIALOG
   ============================================ */
.confirm-content {
    text-align: center;
    padding: 20px 0;
    position: relative;
    z-index: 1;
}

.confirm-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.confirm-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

/* ============================================
   FADE-IN ANIMATION
   ============================================ */
.fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 60px rgba(0, 0, 0, 0.15);
    }

    .menu-toggle {
        display: flex;
    }

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

    .agent-grid,
    .provider-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   LOGIN OVERLAY — Pure White Minimalist
   ============================================ */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #ffffff 0%, #faf8f5 30%, #f5f0eb 60%, #f0ece6 100%);
    background-attachment: fixed;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.login-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.login-card {
    width: 380px;
    max-width: 90vw;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 44px 36px 36px;
    box-shadow: var(--glass-shadow-elevated);
    position: relative;
    overflow: hidden;
    animation: loginCardIn 0.5s cubic-bezier(0.32, 0.72, 0, 1) both;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--glass-highlight);
    pointer-events: none;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

@keyframes loginCardIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.login-logo-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.3);
}

.login-logo-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.login-logo h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.login-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-field .form-input {
    width: 100%;
    padding: 11px 14px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.93rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04) inset;
    transition: all var(--transition-normal);
}

.login-field .form-input::placeholder {
    color: var(--text-tertiary);
}

.login-field .form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12), 0 1px 4px rgba(0, 0, 0, 0.04) inset;
    background: rgba(255, 255, 255, 0.7);
}

.login-error {
    font-size: 0.8rem;
    color: var(--red);
    text-align: center;
    min-height: 1.2em;
    font-weight: 500;
}

.login-btn {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    background: var(--accent-gradient);
    color: white;
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.25);
    margin-top: 4px;
    letter-spacing: 0.06em;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(0, 122, 255, 0.35);
}

.login-btn:active {
    transform: scale(0.98);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Logout button in topbar */
.topbar-logout {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem !important;
    padding: 5px 12px !important;
    color: var(--text-tertiary) !important;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.topbar-logout:hover {
    opacity: 1;
    color: var(--red) !important;
}

.topbar-logout svg {
    width: 14px;
    height: 14px;
}

/* Battery display styles */
.battery-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 500;
}

.battery-cell {
    position: relative;
    display: inline-block;
    width: 22px;
    height: 11px;
    border: 1.5px solid var(--text-secondary);
    border-radius: 2px;
    padding: 1px;
    box-sizing: border-box;
}

.battery-cell::after {
    content: '';
    position: absolute;
    top: 2px;
    right: -3px;
    width: 1.5px;
    height: 4px;
    background: var(--text-secondary);
    border-top-right-radius: 1px;
    border-bottom-right-radius: 1px;
}

.battery-fill {
    display: block;
    height: 100%;
    border-radius: 0.5px;
    background: #007aff; /* Fallback accent */
    transition: width 0.3s ease, background-color 0.3s ease;
}

/* Low battery red */
.battery-status.low .battery-cell {
    border-color: #ff3b30;
}
.battery-status.low .battery-cell::after {
    background: #ff3b30;
}
.battery-status.low .battery-fill {
    background: #ff3b30;
}

/* Normal battery dark/light */
.battery-status.normal .battery-cell {
    border-color: var(--text-secondary);
}
.battery-status.normal .battery-cell::after {
    background: var(--text-secondary);
}
.battery-status.normal .battery-fill {
    background: #34c759;
}

/* Charging status green */
.battery-status.charging .battery-cell {
    border-color: #34c759;
}
.battery-status.charging .battery-cell::after {
    background: #34c759;
}
.battery-status.charging .battery-fill {
    background: #34c759;
}

/* High battery green */
.battery-status.high .battery-cell {
    border-color: #34c759;
}
.battery-status.high .battery-cell::after {
    background: #34c759;
}
.battery-status.high .battery-fill {
    background: #34c759;
}

/* Personality Monitor Mini Progress Bar Styles */
.progress-container-mini {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.72rem;
    width: 100%;
}

.progress-label-mini {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1;
}

.progress-bar-mini {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-bar-mini span {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width 0.8s cubic-bezier(0.32, 0.72, 0, 1);
}

/* Bonding Stage Badges mapping styles */
.status-badge.stage-1 {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

.status-badge.stage-2 {
    background: rgba(255, 149, 0, 0.12);
    color: #b25e00;
    box-shadow: 0 0 10px rgba(255, 149, 0, 0.1);
}

.status-badge.stage-3 {
    background: rgba(175, 82, 222, 0.12);
    color: #7a20a3;
    box-shadow: 0 0 10px rgba(175, 82, 222, 0.1);
}

.status-badge.stage-4 {
    background: rgba(255, 45, 85, 0.12);
    color: #c9002b;
    box-shadow: 0 0 10px rgba(255, 45, 85, 0.15);
}

/* Personality Logs delta colors */
.delta-positive {
    color: #1a8038;
}

.delta-negative {
    color: var(--red);
}