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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

button, input, select {
    font-family: inherit;
    font-size: 100%;
    margin: 0;
    vertical-align: baseline;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background: #0b101b;
    color: white;
    padding: 20px;
    margin: 0;
}

.container {
    max-width: 1800px;
    margin: auto;
    padding: 20px;
}

/* --- COMPONENTS --- */
.btn {
    padding: 10px 16px;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    font-size: 11px;
    font-weight: bold;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.2);
}

.card {
    background: #161d2d;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #2d3748;
    margin-bottom: 20px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.m-card {
    background: #1a2333;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #38bdf8;
    text-align: center;
}

.m-label {
    font-size: 9px;
    color: #94a3b8;
    text-transform: uppercase;
    margin-bottom: 5px;
    display: block;
    letter-spacing: 0.5px;
    font-weight: bold;
}

.m-value {
    font-size: 18px;
    font-weight: bold;
    font-family: 'JetBrains Mono', monospace;
}

/* --- STATUS INDICATORS --- */
.status-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    background: #1e293b;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid #334155;
}

.dot {
    height: 8px;
    width: 8px;
    border-radius: 50%;
    display: inline-block;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.dot.bottleneck {
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
    animation: pulse-red 1s infinite;
}

.dot.error {
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

/* --- TABLE STYLES --- */
.table-wrapper {
    max-height: 650px;
    overflow-y: auto;
    border: 1px solid #2d3748;
    border-radius: 12px;
    background: #161d2d;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}

thead th {
    position: sticky;
    top: 0;
    background: #1e293b;
    z-index: 10;
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.4);
}

th {
    color: #718096;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #2d3748;
    font-size: 10px;
    text-transform: uppercase;
}

td {
    padding: 12px;
    border-bottom: 1px solid #2d3748;
    vertical-align: top;
}

/* --- STATUS BADGES (JS Injected) --- */
.badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 10px;
}

.INITIATED { background: #38bdf8; }
.PENDING { background: #fbbf24; color: #000; }
.SUCCESS { background: #10b981; }
.FAILED { background: #ef4444; }
.MISMATCH {
    background: #ff004c;
    color: white;
    box-shadow: 0 0 12px #ff004c;
    animation: pulse-red 1.5s infinite;
}

/* --- TERMINAL LOCKDOWN --- */
#tunnel-error-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #0a0814; /* Solid background for process termination */
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.error-content {
    background: #1e1b2e;
    padding: 40px;
    border-radius: 12px;
    border: 1px solid #ef4444;
    text-align: center;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.2);
    max-width: 400px;
}

.error-content h1 { color: #ef4444; margin-bottom: 10px; }

/* --- JSON & COPY UTILS --- */
.pre-container {
    background: #000;
    padding: 8px;
    border-radius: 4px;
    max-height: 80px;
    overflow: auto;
    border: 1px solid #2d3748;
    position: relative;
}

pre {
    font-size: 9px;
    color: #34d399;
    margin: 0;
    white-space: pre-wrap;
    font-family: 'Consolas', monospace;
}

.copy-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #41b5bf66;
    border: none;
    font-size: 8px;
    color: white;
    padding: 2px 4px;
    cursor: pointer;
    border-radius: 2px;
    opacity: 0.6;
    z-index: 1;
}

.audit-col {
    width: 50px;
    font-weight: bold;
    color: #38bdf8;
    font-family: 'JetBrains Mono', monospace;
    text-align: center;
}

/* --- INPUTS --- */
input, select {
    background: #0f172a;
    color: white;
    border: 1px solid #334155;
    padding: 6px;
    border-radius: 4px;
    font-size: 11px;
    outline: none;
}

.input-tps { width: 60px; }
.input-dur { width: 50px; }
.input-weight-dep { width: 45px; color: #10b981; }
.input-weight-wit { width: 45px; color: #7c3aed; }

/* --- LAYOUT UTILITIES --- */
.flex-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.flex-align { display: flex; align-items: center; gap: 15px; }
.flex-gap { display: flex; gap: 10px; justify-content: center; }
.flex-row { display: flex; gap: 20px; align-items: stretch; margin-bottom: 20px; }
.flex-column { display: flex; flex-direction: column; gap: 5px; }
.divider-v { border-left: 1px solid #334155; height: 50px; }

/* --- DASHBOARD COMPONENTS --- */
.title-main { color: #38bdf8; margin: 0; }
.title-sub { font-weight: 300; }

.chart-card {
    width: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chart-shell {
    position: relative;
    width: 170px;
    height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-shell canvas {
    width: 170px !important;
    height: 170px !important;
}

.chart-center-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    text-align: center;
}

.chart-center-text {
    color: #ffffff;
    font-weight: bold;
    font-size: 20px;
    line-height: 1.1;
}

.chart-center-subtext {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1;
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
}

.chart-label { margin-top: 14px; font-size: 10px; color: #b9bdc0; }

.controls-card { flex-grow: 1; margin: 0; }
.controls-inner {
    display: flex;
    gap: 40px;
    align-items: center;
    background: #1e293b;
    padding: 20px;
    border-radius: 10px;
    justify-content: space-between;
    width: 100%;
}

.control-group-main { display: flex; align-items: flex-end; gap: 15px; }
.control-group-config { min-width: 120px; }

.manual-triggers-container {
    min-width: 300px;
    text-align: center;
}

.manual-triggers-container .btn {
    justify-content: center;
    padding: 10px 20px;
    min-width: 140px;
}

/* --- BUTTON COLORS --- */
.btn-danger { background: #ef4444; }
.btn-success { background: #059669; }
.btn-primary { background: #1e3a8a; }

.btn-recovery-locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: #94a3b8 !important;
    filter: grayscale(0.5);
}

/* --- ANIMATIONS --- */
@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* --- SCROLLBAR --- */
.table-wrapper::-webkit-scrollbar { width: 8px; }
.table-wrapper::-webkit-scrollbar-track { background: #0b101b; }
.table-wrapper::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
.table-wrapper::-webkit-scrollbar-thumb:hover { background: #38bdf8; }

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    .flex-row, .controls-inner { flex-direction: column; gap: 20px; align-items: center; }
    .divider-v { width: 80%; height: 1px; margin: 10px 0; background: rgba(255, 255, 255, 0.1); }
    .control-group-main { flex-direction: column; width: 100%; align-items: center; gap: 15px; }
    .btn, .input-tps, .input-dur, select { width: 100% !important; max-width: 300px; height: 45px; }
    .m-label { text-align: center; width: 100%; }
}
