/* ============================================================
   ScanIpProxy Dashboard — Dark Theme + Glassmorphism
   Mobile-first responsive design
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- CSS Variables (Design Tokens) --- */
:root {
    /* Background */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: rgba(22, 27, 34, 0.8);
    --bg-glass: rgba(30, 37, 48, 0.6);
    --bg-hover: rgba(48, 54, 61, 0.5);

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;

    /* Accent Colors */
    --color-new: #00c853;
    --color-new-bg: rgba(0, 200, 83, 0.15);
    --color-new-border: rgba(0, 200, 83, 0.35);
    --color-using: #ffd600;
    --color-using-bg: rgba(255, 214, 0, 0.15);
    --color-using-border: rgba(255, 214, 0, 0.35);
    --color-done: #ff1744;
    --color-done-bg: rgba(255, 23, 68, 0.15);
    --color-done-border: rgba(255, 23, 68, 0.35);
    --color-info: #2196f3;
    --color-info-bg: rgba(33, 150, 243, 0.15);
    --color-info-border: rgba(33, 150, 243, 0.35);
    --color-alive: #8c52ff;
    --color-alive-bg: rgba(140, 82, 255, 0.15);
    --color-alive-border: rgba(140, 82, 255, 0.35);
    --color-accent: #58a6ff;
    --color-danger: #f85149;
    --color-success: #3fb950;
    --color-warning: #d29922;

    /* Borders */
    --border-color: rgba(48, 54, 61, 0.6);
    --border-radius: 12px;
    --border-radius-sm: 8px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow-new: 0 0 20px rgba(0, 200, 83, 0.15);
    --shadow-glow-using: 0 0 20px rgba(255, 214, 0, 0.15);
    --shadow-glow-done: 0 0 20px rgba(255, 23, 68, 0.15);

    /* Glass */
    --glass-blur: blur(16px);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
}

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Background gradient mesh */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(0, 200, 83, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(88, 166, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 23, 68, 0.03) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* --- Header --- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-lg);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.header-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-accent), var(--color-new));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-title .logo {
    font-size: 1.5rem;
}

.header-status {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-danger);
    transition: background var(--transition-base);
}

.status-dot.connected {
    background: var(--color-success);
    box-shadow: 0 0 8px rgba(63, 185, 80, 0.5);
    animation: pulse-glow 2s infinite;
}

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

/* Auto-refresh indicator */
.refresh-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.refresh-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* --- Tab Navigation --- */
.tab-nav {
    position: sticky;
    top: 60px;
    z-index: 90;
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    padding: 0 var(--space-lg);
}

.tab-nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
}

.tab-buttons {
    display: flex;
    gap: var(--space-xs);
    overflow-x: auto;
    scrollbar-width: none;
    flex-grow: 1;
}

.tab-buttons::-webkit-scrollbar { display: none; }

.tab-nav .search-bar {
    margin-bottom: 0;
    width: 280px;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .tab-nav .search-bar {
        width: 140px;
    }
    .tab-nav .search-bar input {
        padding: var(--space-xs) var(--space-sm) var(--space-xs) 28px;
        font-size: 0.75rem;
    }
    .tab-nav .search-bar .search-icon {
        left: 8px;
        font-size: 0.75rem;
    }
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

.tab-btn.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.tab-btn .tab-icon { font-size: 1.1rem; }

.tab-btn .tab-badge {
    background: var(--color-accent);
    color: var(--bg-primary);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* --- Main Content --- */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-lg);
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

/* --- Glass Card --- */
.card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

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

.card-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1rem;
    font-weight: 600;
}

.card-title .icon { font-size: 1.25rem; }

.card-badge {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 20px;
    border: 1px solid transparent;
}

.card-badge.new { background: var(--color-new-bg); color: var(--color-new); border-color: var(--color-new-border); }
.card-badge.using { background: var(--color-using-bg); color: var(--color-using); border-color: var(--color-using-border); }
.card-badge.done { background: var(--color-done-bg); color: var(--color-done); border-color: var(--color-done-border); }
.card-badge.info { background: var(--color-info-bg); color: var(--color-info); border-color: var(--color-info-border); }
.card-badge.alive { background: var(--color-alive-bg); color: var(--color-alive); border-color: var(--color-alive-border); }

/* --- State Color Bars --- */
.card.state-new { border-left: 3px solid var(--color-new); }
.card.state-using { border-left: 3px solid var(--color-using); }
.card.state-done { border-left: 3px solid var(--color-done); }
.card.state-info { border-left: 3px solid var(--color-info); }
.card.state-alive { border-left: 3px solid var(--color-alive); }

/* --- Data Table --- */
.data-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    border-radius: var(--border-radius-sm);
    --row-height: 38px;
    --header-height: 34px;
    transition: height 0.2s ease-in-out;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    table-layout: fixed;
}

.data-table th {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: sticky;
    top: 0;
    z-index: 2;
    height: var(--header-height);
    box-sizing: border-box;
}

.data-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid rgba(48, 54, 61, 0.3);
    vertical-align: middle;
    word-break: break-word;
    overflow-wrap: break-word;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
    height: var(--row-height);
    box-sizing: border-box;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}
#table-new th:nth-child(1), #table-using th:nth-child(1), #table-done th:nth-child(1) { width: 18%; }
#table-new th:nth-child(2), #table-using th:nth-child(2), #table-done th:nth-child(2) { width: 22%; }
#table-new th:nth-child(3), #table-using th:nth-child(3), #table-done th:nth-child(3) { width: 18%; }
#table-new th:nth-child(4), #table-using th:nth-child(4), #table-done th:nth-child(4) { width: 27%; }
#table-new th:nth-child(5), #table-using th:nth-child(5), #table-done th:nth-child(5) { width: 15%; }

.ip-cell {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 500;
    color: var(--color-accent);
}

.timestamp-cell {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-glass);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, var(--color-accent), #3b82f6);
    border-color: transparent;
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
    border-color: transparent;
}

.btn-success {
    background: linear-gradient(135deg, var(--color-new), #059669);
    border-color: transparent;
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--color-warning), #b45309);
    border-color: transparent;
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--color-danger), #dc2626);
    border-color: transparent;
    color: white;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

/* --- Form Controls --- */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-select, .form-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color var(--transition-fast);
    appearance: none;
}

.form-select:focus, .form-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

/* --- Control Panel Grid --- */
.control-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

#panel-verify .control-grid .card {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin-bottom: 0;
}

#panel-verify .control-grid .card .card-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Segmented Delay Radio Selector */
.delay-radio-group {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.delay-radio-label {
    flex: 1;
    text-align: center;
    cursor: pointer;
}

.delay-radio-label input {
    display: none;
}

.delay-radio-label span {
    display: block;
    padding: var(--space-sm) var(--space-sm);
    border-radius: calc(var(--border-radius-sm) - 2px);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.delay-radio-label input:checked + span {
    background: var(--color-accent);
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* --- Activity Log --- */
.activity-log {
    max-height: 300px;
    overflow-y: auto;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    line-height: 1.8;
}

.activity-log .log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(48, 54, 61, 0.2);
    animation: slideIn 0.2s ease;
}

.activity-log .log-time {
    color: var(--text-muted);
    margin-right: var(--space-sm);
}

.activity-log .log-success { color: var(--color-success); }
.activity-log .log-error { color: var(--color-danger); }
.activity-log .log-info { color: var(--color-info); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Verify Pipeline --- */
.pipeline-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    padding: var(--space-xl);
    flex-wrap: wrap;
}

.pipeline-stage {
    text-align: center;
    min-width: 120px;
}

.pipeline-stage .stage-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto var(--space-sm);
    transition: transform var(--transition-base);
}

.pipeline-stage:hover .stage-icon {
    transform: scale(1.1);
}

.pipeline-stage.new .stage-icon {
    background: var(--color-new-bg);
    border: 2px solid var(--color-new);
    box-shadow: var(--shadow-glow-new);
}

.pipeline-stage.using .stage-icon {
    background: var(--color-using-bg);
    border: 2px solid var(--color-using);
    box-shadow: var(--shadow-glow-using);
}

.pipeline-stage.done .stage-icon {
    background: var(--color-done-bg);
    border: 2px solid var(--color-done);
    box-shadow: var(--shadow-glow-done);
}

.pipeline-stage .stage-label {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.pipeline-stage .stage-count {
    font-size: 1.5rem;
    font-weight: 700;
}

.pipeline-arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
}

/* --- Confirm Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-xl);
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal h3 {
    font-size: 1.1rem;
    margin-bottom: var(--space-md);
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    font-size: 0.875rem;
}

.modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    padding: var(--space-md);
    border-radius: var(--border-radius-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    text-align: center;
    transition: transform var(--transition-fast);
}

.stat-card:hover { transform: translateY(-2px); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: var(--space-xs);
}

.stat-card.new .stat-value { color: var(--color-new); }
.stat-card.using .stat-value { color: var(--color-using); }
.stat-card.done .stat-value { color: var(--color-done); }
.stat-card.info .stat-value { color: var(--color-info); }
.stat-card.alive .stat-value { color: var(--color-alive); }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

/* --- Search Bar --- */
.search-bar {
    position: relative;
    margin-bottom: var(--space-md);
}

.search-bar input {
    width: 100%;
    padding: var(--space-sm) var(--space-md) var(--space-sm) 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.search-bar .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* --- Toast Notification --- */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-sm);
}

.toast {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--border-radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    font-size: 0.8125rem;
    animation: toastIn 0.3s ease;
    max-width: 360px;
}

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

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

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================================
   Responsive Breakpoints
   ============================================================ */
@media (min-width: 768px) {
    html { font-size: 15px; }

    .control-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tab-btn .tab-text { display: inline; }
}

@media (min-width: 1024px) {
    html { font-size: 16px; }

    .control-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile-specific */
@media (max-width: 767px) {
    .header-inner { padding: var(--space-sm); }

    .header-title h1 { font-size: 1rem; }

    .tab-btn {
        padding: var(--space-sm) var(--space-md);
    }

    .tab-btn .tab-text { display: none; }

    .main-content { padding: var(--space-md); }

    .card { padding: var(--space-md); }

    .pipeline-visual {
        flex-direction: column;
        gap: var(--space-md);
    }

    .pipeline-arrow { transform: rotate(90deg); }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }



    .modal { padding: var(--space-lg); }

    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
    }

    .toast { max-width: 100%; }

    /* Table becomes card on mobile */
    .data-table thead { display: none; }

    .data-table tbody tr {
        display: block;
        margin-bottom: var(--space-sm);
        padding: var(--space-sm);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-sm);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        padding: 4px var(--space-sm);
        border: none;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.7rem;
        text-transform: uppercase;
    }
}

/* ============================================================
   Error Row and Warning Badge Styling
   ============================================================ */
.data-table tbody tr.row-error {
    background: rgba(248, 81, 73, 0.06) !important;
    border-left: 3px solid var(--color-danger);
}

.data-table tbody tr.row-error:hover {
    background: rgba(248, 81, 73, 0.12) !important;
}

.error-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(248, 81, 73, 0.12);
    color: var(--color-danger);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(248, 81, 73, 0.25);
    box-shadow: 0 0 10px rgba(248, 81, 73, 0.05);
}

.error-badge .warning-icon {
    font-size: 0.85rem;
    animation: flash-pulse 2s infinite;
}

@keyframes flash-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.9); }
}

/* ============================================================
   Light Theme variables & overrides
   ============================================================ */
body.light-theme {
    /* Background */
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.85);
    --bg-hover: rgba(0, 0, 0, 0.04);

    /* Text */
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;

    /* Accent Overrides for Light Theme */
    --color-accent: #0969da;
    --color-new: #1a7f37;
    --color-using: #b45309;
    --color-done: #d11a2a;
    --color-info: #1a73e8;
    --color-alive: #6f42c1;
    --color-danger: #cf222e;
    --color-success: #1a7f37;
    --color-warning: #9a6700;

    /* Accent Background & Border Overrides for Light Theme */
    --color-new-bg: rgba(26, 127, 55, 0.1);
    --color-new-border: rgba(26, 127, 55, 0.25);
    --color-using-bg: rgba(180, 83, 9, 0.1);
    --color-using-border: rgba(180, 83, 9, 0.25);
    --color-done-bg: rgba(209, 26, 42, 0.1);
    --color-done-border: rgba(209, 26, 42, 0.25);
    --color-info-bg: rgba(26, 115, 232, 0.1);
    --color-info-border: rgba(26, 115, 232, 0.25);
    --color-alive-bg: rgba(111, 66, 193, 0.1);
    --color-alive-border: rgba(111, 66, 193, 0.25);

    /* Borders */
    --border-color: rgba(229, 231, 235, 0.9);
}

body.light-theme::before {
    background:
        radial-gradient(ellipse at 20% 20%, rgba(0, 200, 83, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(239, 68, 68, 0.01) 0%, transparent 60%);
}

body.light-theme .card {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    border-color: #cbd5e1;
}

body.light-theme .card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
}

body.light-theme .data-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

body.light-theme .activity-log {
    background: #f9fafb;
    border: 1px solid #cbd5e1;
}

body.light-theme .form-select,
body.light-theme .form-input,
body.light-theme .search-bar input,
body.light-theme .modal {
    border-color: #cbd5e1;
}

/* Architecture SVG overrides for Light Theme */
body.light-theme svg rect[stroke="var(--border-color)"] {
    stroke: #94a3b8;
    stroke-width: 1.5px;
}
body.light-theme svg rect[fill="var(--bg-secondary)"] {
    fill: #ffffff;
}
body.light-theme svg text[fill="var(--text-secondary)"] {
    fill: #475569;
}
body.light-theme svg path[stroke="var(--text-secondary)"] {
    stroke: #64748b;
    stroke-width: 1.5px;
}

/* Custom button theme toggler styling */
.theme-toggle-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.theme-toggle-btn:hover {
    background: var(--bg-hover);
    border-color: var(--color-accent);
    transform: scale(1.08);
}

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

.timer-cell {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 500;
    color: var(--text-secondary);
}

/* --- Quick Glance Summary Bar --- */
.quick-glance-bar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    align-items: center;
    gap: var(--space-md);
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px var(--space-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 110px;
    z-index: 80;
    transition: background var(--transition-base), border-color var(--transition-base);
}

body.light-theme .quick-glance-bar {
    background: var(--bg-glass);
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.glance-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-xs);
    font-size: 0.875rem;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--border-radius-sm);
    transition: background var(--transition-fast);
    min-width: 0;
    cursor: pointer;
}

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

.glance-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.glance-label {
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.glance-value {
    font-weight: 700;
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    flex-shrink: 0;
}

.glance-item.glance-health {
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(63, 185, 80, 0.1);
    color: var(--color-success);
    border: 1px solid rgba(63, 185, 80, 0.2);
}

.glance-item.glance-health.warning {
    background: rgba(210, 153, 34, 0.15);
    color: var(--color-warning);
    border-color: rgba(210, 153, 34, 0.3);
    animation: warning-pulse 2s infinite;
}

.glance-item.glance-health.critical {
    background: rgba(248, 81, 73, 0.15);
    color: var(--color-danger);
    border-color: rgba(248, 81, 73, 0.3);
    animation: critical-pulse 1s infinite;
}

.glance-item.glance-new .glance-value { color: var(--color-new); }
.glance-item.glance-using .glance-value { color: var(--color-using); }
.glance-item.glance-done .glance-value { color: var(--color-done); }

@keyframes warning-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(210, 153, 34, 0); }
    50% { box-shadow: 0 0 10px rgba(210, 153, 34, 0.3); }
}

@keyframes critical-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(248, 81, 73, 0); }
    50% { box-shadow: 0 0 12px rgba(248, 81, 73, 0.4); }
}

/* --- SVG Diagram Styling --- */
svg text {
    fill: var(--text-primary) !important;
}
svg text[fill="var(--text-secondary)"] {
    fill: var(--text-secondary) !important;
}
svg text[fill="var(--color-alive)"] { fill: var(--color-alive) !important; }
svg text[fill="var(--color-new)"] { fill: var(--color-new) !important; }
svg text[fill="var(--color-using)"] { fill: var(--color-using) !important; }
svg text[fill="var(--color-done)"] { fill: var(--color-done) !important; }

/* SVG Flow Dash Lines */
svg path {
    stroke-dasharray: 6, 4;
    animation: none;
    transition: stroke 0.3s, opacity 0.3s;
}

svg path:not(.flow-active) {
    stroke: var(--text-secondary) !important;
    opacity: 0.35;
    animation: none !important;
}

svg path.flow-active {
    animation: svg-dash-flow 12s linear infinite !important;
    opacity: 1 !important;
}

svg path#flow-host-redis.flow-active {
    stroke: var(--color-done) !important;
}

@keyframes svg-dash-flow {
    from { stroke-dashoffset: 200; }
    to { stroke-dashoffset: 0; }
}

/* Light Theme Contrast Fixes */
body.light-theme .glance-value {
    color: var(--text-primary);
}
body.light-theme .timer-cell {
    color: #374151;
}
body.light-theme svg text {
    fill: #111827 !important;
}
body.light-theme svg text[fill="var(--text-secondary)"] {
    fill: #4b5563 !important;
}
body.light-theme svg text[fill="var(--color-alive)"] { fill: #6f42c1 !important; }
body.light-theme svg text[fill="var(--color-new)"] { fill: #1a7f37 !important; }
body.light-theme svg text[fill="var(--color-using)"] { fill: #b45309 !important; }
body.light-theme svg text[fill="var(--color-done)"] { fill: #d11a2a !important; }

body.light-theme svg rect[id^="arch-rect-"] {
    fill: #ffffff;
    stroke: #94a3b8;
}
body.light-theme svg rect[id="arch-rect-mqtt"] {
    fill: #f5f3ff;
    stroke: #6f42c1;
}
body.light-theme svg rect[id="arch-rect-redis"] {
    fill: #fef2f2;
    stroke: #d11a2a;
}
body.light-theme svg rect[id="arch-rect-script"] {
    fill: #f0fdf4;
    stroke: #1a7f37;
}
body.light-theme svg rect[id="arch-rect-dashboard"] {
    fill: #f0fdfa;
    stroke: #0d9488;
}

/* --- Auto Move Buttons --- */
.card.state-new .btn,
.card.state-using .btn,
.card.state-done .btn {
    display: flex;
    width: 100%;
    justify-content: center;
}
.card.state-new .btn + .btn,
.card.state-using .btn + .btn,
.card.state-done .btn + .btn {
    margin-top: var(--space-sm);
}

.btn-auto {
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}
.btn-auto:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: var(--bg-hover);
}
.btn-auto.active {
    color: white !important;
    font-weight: bold;
    box-shadow: 0 0 12px var(--btn-glow);
    background: var(--btn-active-bg);
    border-color: transparent;
}
.state-new .btn-auto.active { --btn-glow: rgba(63, 185, 80, 0.4); --btn-active-bg: linear-gradient(135deg, var(--color-new), #059669); }
.state-using .btn-auto.active { --btn-glow: rgba(210, 153, 34, 0.4); --btn-active-bg: linear-gradient(135deg, var(--color-warning), #b45309); }
.state-done .btn-auto.active { --btn-glow: rgba(248, 81, 73, 0.4); --btn-active-bg: linear-gradient(135deg, var(--color-done), #dc2626); }

.btn-auto.active .auto-arrows::after {
    content: ' >';
    animation: movingArrows 1.2s infinite steps(5);
    display: inline-block;
    letter-spacing: 2px;
}
@keyframes movingArrows {
    0% { content: ' >'; }
    20% { content: ' >>'; }
    40% { content: ' >>>'; }
    60% { content: ' >>>>'; }
    80% { content: ' >>>>>'; }
    100% { content: ' >'; }
}

/* ============================================================
   Mobile Specific Overrides for Quick Glance Bar
   Guarantees proper specificity and overriding of desktop grid
   ============================================================ */
@media (max-width: 767px) {
    .quick-glance-bar {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 6px !important;
        padding: 8px 10px !important;
        margin-bottom: var(--space-md) !important;
        position: sticky !important;
        top: 102px !important; /* Positioned nicely below the sticky tab-nav */
        z-index: 80 !important;
        background: var(--bg-glass) !important;
        border-radius: var(--border-radius-sm) !important;
        border: 1px solid var(--border-color) !important;
        box-shadow: var(--shadow-md) !important;
    }

    .glance-item {
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
        font-size: 0.75rem !important;
        padding: 4px 8px !important;
        border-radius: 20px !important;
        background: rgba(30, 37, 48, 0.3) !important;
        border: 1px solid var(--border-color) !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        min-width: unset !important;
    }

    body.light-theme .glance-item {
        background: rgba(255, 255, 255, 0.4) !important;
    }

    .glance-item:hover {
        background: var(--bg-hover) !important;
    }

    .glance-icon {
        font-size: 0.875rem !important;
    }

    .glance-label {
        font-size: 0.65rem !important;
        color: var(--text-secondary) !important;
    }

    .glance-value {
        font-size: 0.75rem !important;
        font-weight: 700 !important;
    }

    /* Keep the specialized color treatments for health indicator */
    .glance-item.glance-health {
        border-radius: 20px !important;
        background: rgba(63, 185, 80, 0.1) !important;
        border: 1px solid rgba(63, 185, 80, 0.2) !important;
    }
    .glance-item.glance-health.warning {
        background: rgba(210, 153, 34, 0.15) !important;
        border-color: rgba(210, 153, 34, 0.3) !important;
    }
    .glance-item.glance-health.critical {
        background: rgba(248, 81, 73, 0.15) !important;
        border-color: rgba(248, 81, 73, 0.3) !important;
    }
}

/* Shake Animation for incorrect password inputs */
.shake-animation {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Scroll target glow highlight */
@keyframes card-glow {
    0%, 100% {
        box-shadow: var(--shadow-sm);
        border-color: var(--border-color);
    }
    50% {
        box-shadow: 0 0 15px rgba(58, 162, 239, 0.5);
        border-color: var(--color-accent);
    }
}

.card.highlight-glow {
    animation: card-glow 2.0s ease-in-out;
}






