/* ===== Tremor Planner-grade Design System ===== */
:root,
[data-theme="light"] {
    --bg-body: #ffffff;
    --bg-sidebar: #f9fafb;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: rgba(229, 231, 235, 0.5);
    --bg-active: #ffffff;
    --text-main: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-placeholder: #9ca3af;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-text: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.08);
    --success: #059669;
    --success-light: rgba(5, 150, 105, 0.06);
    --success-ring: rgba(5, 150, 105, 0.2);
    --danger: #dc2626;
    --danger-light: rgba(220, 38, 38, 0.06);
    --danger-ring: rgba(220, 38, 38, 0.2);
    --warning: #d97706;
    --warning-light: rgba(217, 119, 6, 0.06);
    --warning-ring: rgba(217, 119, 6, 0.2);
    --border: #e5e7eb;
    --border-input: #d1d5db;
    --border-hover: #d1d5db;
    --ring-focus: 0 0 0 2px rgba(59, 130, 246, 0.15), 0 0 0 1px rgba(59, 130, 246, 0.4);
    --radius: 6px;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.025);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.025), 0 8px 10px -6px rgba(0,0,0,0.02);
    --shadow-dropdown: 0 20px 40px -8px rgba(0,0,0,0.08);
    --modal-overlay: rgba(107, 114, 128, 0.4);
}

[data-theme="dark"] {
    --bg-body: #030712;
    --bg-sidebar: #050814;
    --bg-card: #111827;
    --bg-input: #030712;
    --bg-hover: rgba(17, 24, 39, 0.8);
    --bg-active: #1f2937;
    --text-main: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --text-placeholder: #6b7280;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-text: #60a5fa;
    --primary-light: rgba(59, 130, 246, 0.1);
    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.1);
    --success-ring: rgba(52, 211, 153, 0.3);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.1);
    --danger-ring: rgba(248, 113, 113, 0.3);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.1);
    --warning-ring: rgba(251, 191, 36, 0.3);
    --border: #1f2937;
    --border-input: #374151;
    --border-hover: #374151;
    --ring-focus: 0 0 0 2px rgba(59, 130, 246, 0.2), 0 0 0 1px rgba(59, 130, 246, 0.5);
    --radius: 6px;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.4);
    --shadow-dropdown: 0 20px 40px -8px rgba(0,0,0,0.5);
    --modal-overlay: rgba(0, 0, 0, 0.75);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    /* 动态补偿底部操作栏高度，未选中账号时为 0，由 JS 实时写入 --action-bar-h */
    padding-bottom: var(--action-bar-h, 0px);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.15s, color 0.15s, padding-bottom 0.2s ease;
}

/* ===== Login ===== */
.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.3s;
}
.login-overlay.hide { opacity: 0; pointer-events: none; }
.login-box {
    background: var(--bg-card);
    padding: 36px 32px;
    border-radius: 12px;
    width: 100%;
    max-width: 380px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}
.login-box h1 {
    font-size: 20px;
    margin-bottom: 4px;
    color: var(--text-main);
    text-align: center;
    font-weight: 700;
    -webkit-text-fill-color: initial;
    background: none;
}
.login-box p { color: var(--text-muted); margin-bottom: 28px; font-size: 14px; text-align: center; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: border-color 0.1s, box-shadow 0.1s;
    box-shadow: var(--shadow-sm);
}
.form-input:focus { border-color: var(--primary); box-shadow: var(--ring-focus); }
.form-input::placeholder { color: var(--text-placeholder); }
.btn {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.1s ease-in-out;
    box-shadow: var(--shadow-sm);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; border-color: transparent; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-card); color: var(--text-main); border-color: var(--border-input); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== Header ===== */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.15s, border-color 0.15s;
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sidebar-toggle-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.1s;
}
.sidebar-toggle-btn:hover { background: var(--bg-hover); color: var(--text-main); }
.sidebar-toggle-btn:active { transform: scale(0.92); }
.logo {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-text-fill-color: initial;
    background: none;
}
.logo i { font-size: 18px; color: var(--primary); -webkit-text-fill-color: initial; }
.header-right { display: flex; align-items: center; gap: 8px; }
.theme-toggle-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.1s;
}
.theme-toggle-btn:hover { background: var(--bg-hover); color: var(--text-main); }
.proxy-badge {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.1s;
}
.proxy-badge.active {
    background: var(--success-light);
    color: var(--success);
    box-shadow: inset 0 0 0 1px var(--success-ring);
}
.proxy-badge.direct {
    background: var(--warning-light);
    color: var(--warning);
    box-shadow: inset 0 0 0 1px var(--warning-ring);
}
.user-badge { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ===== Sidebar ===== */
.app-shell {
    display: flex;
    min-height: calc(100vh - 56px);
}
.group-sidebar {
    width: 16rem;
    flex: 0 0 16rem;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    transition: width 0.2s ease, flex-basis 0.2s ease, transform 0.2s ease;
    z-index: 90;
}
.group-sidebar.collapsed {
    width: 0;
    flex-basis: 0;
    overflow: hidden;
    border-right: none;
}
.group-sidebar-header {
    padding: 16px 12px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.group-sidebar-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.group-sidebar-close {
    width: 26px;
    height: 26px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.1s;
}
.group-sidebar-close:hover { background: var(--bg-hover); color: var(--text-main); }
.main-content {
    flex: 1;
    min-width: 0;
}
.nav-bar {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-x: visible;
    background: transparent;
    -webkit-overflow-scrolling: touch;
}
.nav-bar::-webkit-scrollbar { display: none; }
.nav-pill {
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.1s;
    color: var(--text-secondary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-weight: 500;
    position: relative;
}
.nav-pill:hover { background: var(--bg-hover); color: var(--text-main); }
.nav-pill:active { transform: scale(0.98); }
.nav-pill.active {
    background: var(--bg-active);
    color: var(--primary-text);
    font-weight: 600;
    box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border);
}
[data-theme="light"] .nav-pill.active {
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04), inset 0 0 0 1px var(--border);
}
.nav-pill.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}
.nav-pill .count { opacity: 0.5; font-size: 12px; margin-left: auto; font-weight: 400; }
.nav-icon {
    width: 100%;
    height: 34px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px dashed var(--border);
    cursor: pointer;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: all 0.1s;
    margin-top: 4px;
}
.nav-icon:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.nav-icon:active { transform: scale(0.95); }
.nav-icon.danger { color: var(--danger); border-color: var(--danger-ring); }

/* ===== Toolbar ===== */
.toolbar {
    padding: 16px 24px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.search-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: border-color 0.1s, box-shadow 0.1s;
    box-shadow: var(--shadow-sm);
}
.search-input::placeholder { color: var(--text-placeholder); }
.search-input:focus { border-color: var(--primary); box-shadow: var(--ring-focus); }
.toolbar-btn {
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border-input);
    color: var(--text-main);
    transition: all 0.1s;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}
.toolbar-btn:hover { background: var(--bg-hover); }
.toolbar-btn:active { transform: scale(0.97); }
.toolbar-btn.primary {
    background: var(--primary);
    border-color: transparent;
    color: white;
}
.toolbar-btn.primary:hover { background: var(--primary-hover); }

/* ===== Account Cards ===== */
.list {
    padding: 0 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(470px, 1fr));
    gap: 8px;
}
.card {
    background: var(--bg-card);
    border-radius: 7px;
    padding: 7px 10px;
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    transition: all 0.1s;
    border: 1px solid var(--border);
}
.card:hover { background: var(--bg-hover); }
.card:active { transform: scale(0.998); }
.card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.15);
}
.checkbox {
    width: 15px;
    height: 15px;
    border: 1.5px solid var(--border-input);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.1s;
}
.card.selected .checkbox { background: var(--primary); border-color: var(--primary); }
.card.mfa-processing { position: relative; }
.card.mfa-processing::before { content:''; position:absolute; left:6px; top:50%; transform:translateY(-50%); width:7px; height:7px; border-radius:50%; background:var(--danger); animation:mfaPulse 1.2s infinite; z-index:5; }
@keyframes mfaPulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
.checkbox i { color: white; font-size: 10px; opacity: 0; transition: opacity 0.1s; }
.card.selected .checkbox i { opacity: 1; }
.card-line {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    overflow: hidden;
}
.card-line .email {
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 60px;
}
.card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.tag {
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 11px;
    box-shadow: inset 0 0 0 1px currentColor;
    opacity: 0.85;
    flex-shrink: 0;
    white-space: nowrap;
}
.tag-cpu { background: var(--success-light); color: var(--success); box-shadow: inset 0 0 0 1px var(--success-ring); }
.tag-cpu.low { background: var(--warning-light); color: var(--warning); box-shadow: inset 0 0 0 1px var(--warning-ring); }
.tag-cpu.zero { background: var(--danger-light); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-ring); }
.tag-credit { background: var(--primary-light); color: var(--primary-text); box-shadow: inset 0 0 0 1px rgba(59,130,246,0.2); }
.tag-free {
    background: var(--success-light);
    color: var(--success);
    cursor: pointer;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--success-ring);
    transition: all 0.1s;
}
.tag-free:hover { opacity: 1; transform: scale(1.03); }
.tag-free:active { transform: scale(0.96); }
.tag-time { background: rgba(14, 165, 233, 0.06); color: #0284c7; box-shadow: inset 0 0 0 1px rgba(14,165,233,0.2); }
[data-theme="dark"] .tag-time { background: rgba(56, 189, 248, 0.1); color: #38bdf8; box-shadow: inset 0 0 0 1px rgba(56,189,248,0.25); }
.tag-note { background: var(--warning-light); color: var(--warning); box-shadow: inset 0 0 0 1px var(--warning-ring); }
.card.locating { animation: locatePulse 1.6s ease-out 2; border-color: var(--primary); }
@keyframes locatePulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.35); }
    100% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
}
.card-action {
    width: 26px;
    height: 26px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: transparent;
    flex-shrink: 0;
    font-size: 15px;
    transition: all 0.1s;
}
.card-action:hover { background: var(--bg-hover); color: var(--text-main); }
.country-flag { margin-right: 0; flex-shrink: 0; }

/* ===== Empty State ===== */
.empty { grid-column: 1 / -1; text-align: center; padding: 80px 20px; color: var(--text-muted); }
.empty i { font-size: 40px; margin-bottom: 12px; display: block; opacity: 0.3; }
.empty p { font-size: 14px; }

/* ===== Selection FAB ===== */
.selection-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 23px;
    cursor: pointer;
    z-index: 110;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), background 0.15s;
}
.selection-fab.show { display: flex; animation: fabIn 0.18s cubic-bezier(0.16, 1, 0.3, 1); }
.selection-fab:hover { background: var(--primary-hover); }
.selection-fab:active { transform: scale(0.9); }
@keyframes fabIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.selection-fab-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    background: var(--danger);
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    line-height: 19px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--bg-card);
}

/* ===== Action Bar ===== */
.action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 12px 16px 16px;
    transform: translateY(100%);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
[data-theme="dark"] .action-bar { box-shadow: 0 -4px 20px rgba(0,0,0,0.3); }
.action-bar.show { transform: translateY(0); }
.action-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.action-bar-header span { font-weight: 600; font-size: 14px; }
.action-bar-header .count { color: var(--primary-text); }
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.action-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 13px 5px 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    border-radius: 9999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: all 0.12s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    white-space: nowrap;
}
.action-item:hover {
    border-color: var(--border-hover);
    color: var(--text-main);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.action-item:active {
    transform: translateY(0) scale(0.95);
    box-shadow: none;
}
.action-icon {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 13px;
}
.action-icon i { display: inline-flex; line-height: 1; }
.actions-more-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 11px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    margin-top: 6px;
    user-select: none;
    font-weight: 500;
    border-radius: 9999px;
    border: 1px dashed var(--border);
    background: transparent;
    transition: all 0.12s;
}
.actions-more-toggle:hover { border-color: var(--border-hover); color: var(--text-main); }
.actions-more-toggle:active { transform: scale(0.95); }
.actions-more-toggle i { font-size: 13px; transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
.actions-extra {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.2s cubic-bezier(0.16, 1, 0.3, 1), margin-top 0.2s;
    margin-top: 0;
}
.actions-extra.open {
    grid-template-rows: 1fr;
    margin-top: 8px;
}
.actions-extra > .actions {
    overflow: hidden;
}
.actions-extra.open > .actions {
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
@media (max-width: 599px) {
    .modal { align-items: flex-end; padding: 0; }
}
.modal.show { display: flex; }
.modal-box {
    background: var(--bg-card);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-dropdown);
}
@media (max-width: 599px) {
    .modal-box { border-radius: 12px 12px 0 0; max-width: 100%; }
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-close { cursor: pointer; color: var(--text-muted); font-size: 20px; padding: 4px; border-radius: var(--radius); transition: all 0.1s; }
.modal-close:hover { background: var(--bg-hover); color: var(--text-main); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* ===== Form Elements ===== */
textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius);
    color: var(--text-main);
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 12px;
    resize: none;
    outline: none;
    transition: border-color 0.1s, box-shadow 0.1s;
    box-shadow: var(--shadow-sm);
}
textarea:focus { border-color: var(--primary); box-shadow: var(--ring-focus); }
textarea::placeholder { color: var(--text-placeholder); }
.form-row { display: flex; gap: 10px; margin-bottom: 12px; }
.form-col { flex: 1; }
select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: border-color 0.1s, box-shadow 0.1s;
    box-shadow: var(--shadow-sm);
}
select:focus { border-color: var(--primary); box-shadow: var(--ring-focus); }
input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: border-color 0.1s, box-shadow 0.1s;
    box-shadow: var(--shadow-sm);
}
input[type="number"]:focus { border-color: var(--primary); box-shadow: var(--ring-focus); }

/* ===== Progress ===== */
.progress-box { margin-top: 14px; }
.progress-bar { height: 4px; background: var(--bg-hover); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s; border-radius: 2px; }
.progress-text { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ===== Logs ===== */
.logs {
    background: var(--bg-input);
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-top: 12px;
    max-height: 180px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.8;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
}
.logs .success { color: var(--success); }
.logs .error { color: var(--danger); }
.logs .warn { color: var(--warning); }

/* ===== Region Selector ===== */
.region-container {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 280px;
    overflow-y: auto;
    background: var(--bg-input);
    -webkit-overflow-scrolling: touch;
}
.region-group { border-bottom: 1px solid var(--border); }
.region-group:last-child { border-bottom: none; }
.region-group-header {
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    transition: background 0.1s;
}
.region-group-header:hover { background: var(--bg-hover); }
.region-group-body {
    display: none;
    padding: 8px 10px;
    gap: 6px;
    flex-wrap: wrap;
}
.region-group-body.open { display: flex; }
.region-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    background: var(--bg-card);
    border-radius: var(--radius);
    font-size: 12px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color 0.1s;
}
.region-item:hover { border-color: var(--border-hover); }
.region-item:active { opacity: 0.8; }
.region-item input { accent-color: var(--primary); width: 14px; height: 14px; }

/* ===== Alerts ===== */
.alert {
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    margin-bottom: 12px;
    line-height: 1.5;
}
.alert-danger { background: var(--danger-light); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-ring); }
.alert-info { background: var(--primary-light); color: var(--primary-text); box-shadow: inset 0 0 0 1px rgba(59,130,246,0.2); }

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 9px 18px;
    border-radius: var(--radius);
    color: white;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 9999;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.info { background: #3b82f6; }
.toast.warn { background: #d97706; }

/* ===== Detail Region List ===== */
.detail-region-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    margin-top: 12px;
}
.detail-region-item {
    background: var(--bg-input);
    padding: 9px 12px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    border: 1px solid var(--border);
}
.detail-region-item .region-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
.detail-region-item .quota-val {
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12px;
}
.detail-region-item .quota-val.high { background: var(--success-light); color: var(--success); box-shadow: inset 0 0 0 1px var(--success-ring); }
.detail-region-item .quota-val.mid { background: var(--warning-light); color: var(--warning); box-shadow: inset 0 0 0 1px var(--warning-ring); }
.detail-region-item .quota-val.low { color: var(--text-muted); }

/* ===== Loading ===== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.ri-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}
.global-loading {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}
.global-loading.hide { opacity: 0; pointer-events: none; }
.global-loading-icon { font-size: 40px; color: var(--primary); margin-bottom: 16px; }
.global-loading-text { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.global-loading-bar { width: 200px; height: 3px; background: var(--bg-hover); border-radius: 2px; overflow: hidden; }
.global-loading-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s; border-radius: 2px; }
.loading-container { text-align: center; padding: 40px 20px; }
.loading-spinner { font-size: 28px; color: var(--primary); margin-bottom: 12px; }
.loading-text { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.loading-progress { margin-top: 16px; padding: 0 20px; }
.loading-progress-bar { height: 3px; background: var(--bg-hover); border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
.loading-progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s; }
.loading-progress-text { font-size: 12px; color: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 720px) {
    .app-shell { display: block; }
    .group-sidebar {
        position: fixed;
        left: 0;
        top: 56px;
        bottom: 0;
        height: auto;
        width: min(80vw, 280px);
        flex-basis: auto;
        transform: translateX(0);
        box-shadow: var(--shadow-dropdown);
        z-index: 180;
    }
    .group-sidebar.collapsed {
        width: min(80vw, 280px);
        transform: translateX(-105%);
        border-right: 1px solid var(--border);
    }
    body.sidebar-open::after {
        content: '';
        position: fixed;
        left: 0;
        right: 0;
        top: 56px;
        bottom: 0;
        background: var(--modal-overlay);
        z-index: 170;
    }
    .toolbar { padding: 12px 16px; }
    .list { padding: 0 16px; display: block; }
    .nav-pill { font-size: 13px; }
    .card { padding: 6px 9px; gap: 7px; margin-bottom: 4px; }
    .card-line { gap: 5px; font-size: 12px; }
    .card-line .email { min-width: 40px; }
}
