/* ============================================================
   ESS 管理 — Design System
   Inspired by Linear, Vercel Dashboard, Raycast
   Premium dark-mode admin dashboard
   ============================================================ */

/* ----------------------------------------------------------
   1. CSS Variables
   ---------------------------------------------------------- */
:root {
    /* Backgrounds */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a2e;
    --bg-hover: #22223a;

    /* Text */
    --text-primary: #e8e8ed;
    --text-secondary: #8888a0;
    --text-muted: #55556a;

    /* Accent / Brand */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-subtle: rgba(59, 130, 246, 0.12);

    /* Semantic colors */
    --success: #22c55e;
    --success-subtle: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --warning-subtle: rgba(245, 158, 11, 0.12);
    --error: #ef4444;
    --error-subtle: rgba(239, 68, 68, 0.12);

    /* Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-highlight: rgba(255, 255, 255, 0.12);

    /* Border radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 20px;

    /* Shadows */
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-modal: 0 16px 48px rgba(0, 0, 0, 0.6);

    /* Fonts */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;

    /* Transitions */
    --transition-fast: 100ms ease;
    --transition: 150ms ease;
    --transition-slow: 250ms ease;

    /* Input background */
    --input-bg: var(--bg-secondary);

    /* Spacing (for reference — used directly as values) */
    /* 4px  8px  12px  16px  20px  24px  32px  40px  48px */
}

/* ----------------------------------------------------------
   2. Global Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--accent-hover);
}

::selection {
    background: var(--accent);
    color: #fff;
}

/* Focus-visible for accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.14);
}

/* ----------------------------------------------------------
   3. Layout — Sidebar + Main
   ---------------------------------------------------------- */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 24px 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.sidebar-logo {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
    padding: 6px 12px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    position: relative;
    user-select: none;
}

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

.sidebar-item.active {
    background: var(--accent-subtle);
    color: var(--text-primary);
}

.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--accent);
}

.sidebar-item-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-item.active .sidebar-item-icon {
    opacity: 1;
}

.sidebar-divider {
    height: 1px;
    margin: 8px 12px;
    background: linear-gradient(90deg, transparent, var(--border-highlight), transparent);
}

.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--border);
}

.sidebar-footer .sidebar-item {
    color: var(--text-muted);
}

.sidebar-footer .sidebar-item:hover {
    color: var(--error);
    background: var(--error-subtle);
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sidebar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    line-height: 1;
}

.sidebar-logout:hover {
    color: var(--error);
    background: var(--error-subtle);
}

.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 32px 40px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 28px;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ----------------------------------------------------------
   4. Cards
   ---------------------------------------------------------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
    border-color: var(--border-highlight);
    box-shadow: var(--shadow-card-hover);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* ----------------------------------------------------------
   5. Buttons
   ---------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    user-select: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

/* Primary */
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    filter: brightness(1.1);
}

/* Danger */
.btn-danger {
    background: var(--error);
    color: #fff;
}
.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    filter: brightness(1.1);
}

/* Success */
.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover:not(:disabled) {
    background: #16a34a;
    filter: brightness(1.1);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Outline */
.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-highlight);
}
.btn-outline:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: rgba(255, 255, 255, 0.18);
}

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

/* Small */
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* Secondary */
.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-highlight);
}
.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
}

/* Loading button */
.btn-loading {
    pointer-events: none;
    opacity: 0.7;
}
.btn-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 6px;
}

/* ----------------------------------------------------------
   6. Inputs
   ---------------------------------------------------------- */
.input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

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

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.input-error {
    border-color: var(--error) !important;
    box-shadow: 0 0 0 3px var(--error-subtle) !important;
}

textarea.input {
    min-height: 80px;
    resize: vertical;
}

select.input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ----------------------------------------------------------
   7. Toggle Switch
   ---------------------------------------------------------- */
.toggle {
    position: relative;
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 11px;
    border: none;
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
}

.toggle::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 200ms ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle.on {
    background: var(--accent);
}

.toggle.on::after {
    transform: translateX(18px);
}

.toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ----------------------------------------------------------
   8. Badges
   ---------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-default {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.badge-accent {
    background: var(--accent-subtle);
    color: var(--accent);
}

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

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

.badge-error {
    background: var(--error-subtle);
    color: var(--error);
}

.badge-danger {
    background: var(--error-subtle);
    color: var(--error);
}

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

/* ----------------------------------------------------------
   9. Modal
   ---------------------------------------------------------- */
.modal-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-modal);
    padding: 24px;
    min-width: 400px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 200ms ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
    line-height: 1;
}
.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    margin-bottom: 8px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ----------------------------------------------------------
   10. Progress Bar
   ---------------------------------------------------------- */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 300ms ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    animation: progressShimmer 2s infinite;
}

@keyframes progressShimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.progress-fill.success {
    background: var(--success);
}

.progress-fill.error {
    background: var(--error);
}

/* ----------------------------------------------------------
   11. Spinner
   ---------------------------------------------------------- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-highlight);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 1.5px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

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

/* ----------------------------------------------------------
   12. Skeleton Loading
   ---------------------------------------------------------- */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-hover) 25%,
        rgba(255, 255, 255, 0.06) 50%,
        var(--bg-hover) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite ease-in-out;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-rect {
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ----------------------------------------------------------
   13. Toast Notifications
   ---------------------------------------------------------- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card-hover);
    font-size: 13px;
    color: var(--text-primary);
    pointer-events: all;
    animation: toastIn 250ms ease, toastOut 250ms ease 2.75s forwards;
    max-width: 360px;
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-error {
    border-left: 3px solid var(--error);
}

.toast-warning {
    border-left: 3px solid var(--warning);
}

.toast-info {
    border-left: 3px solid var(--accent);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(24px) translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}

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

/* ----------------------------------------------------------
   14. Log Viewer
   ---------------------------------------------------------- */
.log-viewer {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.7;
    overflow-y: auto;
    padding: 12px 16px;
    max-height: 500px;
    min-height: 200px;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-line {
    padding: 1px 0;
}

.log-cmd {
    color: var(--accent);
}

.log-success {
    color: var(--success);
}

.log-error {
    color: var(--error);
}

.log-warning {
    color: var(--warning);
}

.log-dim {
    color: var(--text-muted);
}

.log-timestamp {
    color: var(--text-muted);
    margin-right: 8px;
    font-size: 11px;
}

/* Legacy log panel styles (backward compat) */
.log-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.log-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.log-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.7;
    max-height: 500px;
    min-height: 200px;
    white-space: pre-wrap;
    word-break: break-all;
    background: var(--bg-primary);
}

.log-body .cmd { color: var(--accent); }
.log-body .success { color: var(--success); }
.log-body .error { color: var(--error); }

/* ----------------------------------------------------------
   15. Tables
   ---------------------------------------------------------- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

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

.table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table tbody tr {
    transition: background var(--transition-fast);
}

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

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

/* Legacy DNS table (backward compat) */
.dns-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.dns-table th,
.dns-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.dns-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.dns-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dns-status.ok { background: var(--success); }
.dns-status.fail { background: var(--error); }
.dns-status.unknown { background: var(--text-muted); }

/* ----------------------------------------------------------
   16. Page Transitions
   ---------------------------------------------------------- */
.page-enter {
    animation: pageEnter 200ms ease;
}

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

.page-leave {
    animation: pageLeave 150ms ease forwards;
}

@keyframes pageLeave {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-4px);
    }
}

/* ----------------------------------------------------------
   17. Tabs
   ---------------------------------------------------------- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
}

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

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

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 1px 1px 0 0;
}

/* ----------------------------------------------------------
   18. Form Groups
   ---------------------------------------------------------- */
.form-group {
    margin-bottom: 16px;
}

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

.form-group .input {
    width: 100%;
}

.form-group .form-error,
.setting-row .form-error,
.form-error {
    font-size: 12px;
    color: var(--error);
    margin-top: 4px;
}

.form-group .form-hint,
.setting-row .form-hint,
.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

.input-error,
input.input-error {
    border-color: var(--error) !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15) !important;
}

/* Legacy form-group input styles */
.form-group input:not(.input) {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:not(.input):focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* ----------------------------------------------------------
   19. Wizard Steps
   ---------------------------------------------------------- */
.wizard-steps {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 20px 0;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.wizard-step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
    border: 2px solid transparent;
}

/* Pending state */
.wizard-step.pending .wizard-step-circle {
    background: var(--bg-hover);
    color: var(--text-muted);
    border-color: var(--border);
}

/* Active state */
.wizard-step.active .wizard-step-circle {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-subtle);
}

/* Done state */
.wizard-step.done .wizard-step-circle {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

/* Error state */
.wizard-step.error .wizard-step-circle {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

.wizard-step-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.wizard-step.active .wizard-step-label {
    color: var(--text-primary);
}

.wizard-step.done .wizard-step-label {
    color: var(--text-secondary);
}

.wizard-step-connector {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 8px;
    min-width: 24px;
}

.wizard-step.done + .wizard-step-connector,
.wizard-step-connector.done {
    background: var(--success);
}

/* ----------------------------------------------------------
   20. Step Items (Deploy wizard)
   ---------------------------------------------------------- */
.steps-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
    min-height: 500px;
}

.step-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    border: 1px solid transparent;
}

.step-item:hover {
    background: var(--bg-hover);
}

.step-item.active {
    background: var(--bg-card);
    border-color: var(--accent);
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-muted);
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.step-item[data-status="done"] .step-num {
    background: var(--success);
    color: #fff;
}

.step-item[data-status="running"] .step-num {
    background: var(--accent);
    color: #fff;
    animation: pulse 1.5s infinite;
}

.step-item[data-status="error"] .step-num {
    background: var(--error);
    color: #fff;
}

.step-info { flex: 1; }

.step-name {
    font-size: 14px;
    font-weight: 500;
}

.step-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.step-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

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

/* ----------------------------------------------------------
   21. Connection Status Indicator
   ---------------------------------------------------------- */
.conn-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error);
    transition: background var(--transition);
}

.conn-dot.connected {
    background: var(--success);
    box-shadow: 0 0 6px var(--success-subtle);
}

/* ----------------------------------------------------------
   22. Domain Section
   ---------------------------------------------------------- */
.domain-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

.domain-section h3 {
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
}

.domain-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.domain-input-row input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.domain-input-row input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* ----------------------------------------------------------
   23. Backup Grid
   ---------------------------------------------------------- */
.backup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.backup-controls {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
}

.backup-controls h3 {
    margin-bottom: 16px;
    font-weight: 600;
}

.backup-list {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
}

.backup-list h3 {
    margin-bottom: 16px;
    font-weight: 600;
}

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

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

.backup-info {
    font-size: 13px;
}

.backup-info .name {
    font-weight: 500;
}

.backup-info .size {
    color: var(--text-secondary);
    margin-left: 8px;
}

.backup-actions {
    display: flex;
    gap: 4px;
}

.backup-log {
    margin-top: 16px;
}

/* ----------------------------------------------------------
   24. Settings Row
   ---------------------------------------------------------- */
.setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.setting-row label {
    font-size: 13px;
    min-width: 100px;
    color: var(--text-secondary);
}

/* ----------------------------------------------------------
   25. Panel (tab content switching)
   ---------------------------------------------------------- */
.panel {
    display: none;
}

.panel.active {
    display: block;
    animation: pageEnter 200ms ease;
}

/* ----------------------------------------------------------
   26. Container
   ---------------------------------------------------------- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* ----------------------------------------------------------
   27. Login Page
   ---------------------------------------------------------- */
.login-wrapper,
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-modal);
}

.login-card h2 {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

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

.login-card .btn-primary {
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
}

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

.login-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

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

.login-form {
    display: flex;
    flex-direction: column;
}

.login-error {
    font-size: 13px;
    color: var(--error);
    text-align: center;
    margin-bottom: 12px;
}

.captcha-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.captcha-row .input {
    flex: 1;
}

.captcha-img {
    height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
}

/* ----------------------------------------------------------
   28. Empty State
   ---------------------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    gap: 12px;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

/* ----------------------------------------------------------
   29. Wizard Additions
   ---------------------------------------------------------- */
.wizard-container {
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 24px 0;
}

.wizard-panel {
    animation: pageEnter 200ms ease;
}

.wizard-step {
    cursor: pointer;
}

/* DNS status badges */
.dns-status {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.dns-ok { color: var(--success); }
.dns-checking { color: var(--warning); }
.dns-pending { color: var(--text-muted); }

/* Sub-step icons */
.sub-icon-done { background: var(--success) !important; color: #fff !important; }
.sub-icon-running { background: var(--accent) !important; color: #fff !important; animation: pulse 1.5s infinite; }
.sub-icon-error { background: var(--error) !important; color: #fff !important; }
.sub-icon-pending { background: var(--bg-hover) !important; color: var(--text-muted) !important; }

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Config sections (collapsible) */
.config-sections {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.config-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.config-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    user-select: none;
    transition: background var(--transition-fast);
}

.config-section-header:hover {
    background: var(--bg-hover);
}

.config-toggle {
    font-size: 10px;
    color: var(--text-muted);
}

.config-section-body {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.config-section-body .setting-row {
    margin-bottom: 8px;
}

.config-section-body .setting-row:last-child {
    margin-bottom: 0;
}

.config-section-body .input-sm {
    height: 32px;
    font-size: 13px;
    padding: 4px 10px;
}

/* Simple table for DNS records */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th, .table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

.table code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ----------------------------------------------------------
   30z. Alert banners
   ---------------------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
}

.alert-error {
    background: var(--error-subtle);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
    background: var(--success-subtle);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ----------------------------------------------------------
   30a. form-input (dark theme native inputs)
   ---------------------------------------------------------- */
.form-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}
.form-input::placeholder {
    color: var(--text-muted);
}
.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* ----------------------------------------------------------
   30b. Link Muted
   ---------------------------------------------------------- */
.link-muted {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: color var(--transition-fast);
}
.link-muted:hover {
    color: var(--text-primary);
}

/* ----------------------------------------------------------
   30c. Toggle Switch (checkbox replacement)
   ---------------------------------------------------------- */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 11px;
    transition: background var(--transition);
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 200ms ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

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

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

.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ----------------------------------------------------------
   30d. Card consecutive spacing
   ---------------------------------------------------------- */
.card + .card {
    margin-top: 20px;
}

/* ----------------------------------------------------------
   30e. Action bar (button groups)
   ---------------------------------------------------------- */
.action-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* ----------------------------------------------------------
   30f. Config view input override
   ---------------------------------------------------------- */
.config-view input[type="text"] {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* ----------------------------------------------------------
   30g. Page header with actions
   ---------------------------------------------------------- */
.page-header-with-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

/* ----------------------------------------------------------
   30h. Log empty state
   ---------------------------------------------------------- */
.log-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ----------------------------------------------------------
   30i. Sidebar icon and label
   ---------------------------------------------------------- */
.sidebar-icon {
    margin-right: 10px;
    font-size: 16px;
}

.sidebar-label {
    font-size: 14px;
}

/* ----------------------------------------------------------
   30. Utility Classes
   ---------------------------------------------------------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.p-16 { padding: 16px; }
.p-20 { padding: 20px; }
.p-24 { padding: 24px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ----------------------------------------------------------
   30. Responsive
   ---------------------------------------------------------- */
@media (max-width: 1024px) {
    .main-content {
        padding: 24px 20px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
        z-index: 100;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

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

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

    .modal {
        min-width: 0;
        margin: 16px;
        width: calc(100% - 32px);
    }

    .domain-input-row {
        flex-direction: column;
    }

    .wizard-steps {
        overflow-x: auto;
        padding: 16px 0;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        max-width: 100%;
    }
}

/* Sidebar mobile overlay */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

@media (max-width: 768px) {
    .sidebar-backdrop.show {
        display: block;
    }
}

/* Mobile menu toggle */
.mobile-menu-btn {
    display: none;
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ----------------------------------------------------------
   Search Select Component
   ---------------------------------------------------------- */
.search-select {
    position: relative;
}

.search-select-input {
    width: 100%;
}

.search-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius);
    box-shadow: var(--shadow-modal);
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
}

.search-select-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.search-select-item:hover {
    background: var(--bg-hover);
}

.search-select-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.search-select-item-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.search-select-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.search-select-secondary {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-select-loading,
.search-select-empty,
.search-select-error {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.search-select-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--error);
}
