* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    padding: 20px;
    min-height: 100vh;
}

.container { max-width: 900px; margin: 0 auto; }

h1 {
    color: #38bdf8;
    margin-bottom: 30px;
    font-size: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    font-size: 14px;
    color: #94a3b8;
    font-weight: normal;
}

.user-info button {
    margin-left: 10px;
}

/* Login Form */
.login-container {
    max-width: 400px;
    margin: 100px auto;
}

.login-box {
    background: #1e293b;
    padding: 30px;
    border-radius: 12px;
}

.login-box h2 {
    color: #38bdf8;
    margin-bottom: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #94a3b8;
    font-size: 13px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 14px;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #38bdf8;
}

/* Status Bar */
.status-bar {
    background: #1e293b;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
}

.status-dot.running { background: #22c55e; }

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-success { background: #22c55e; color: white; }
.btn-danger { background: #ef4444; color: white; }
.btn-secondary { background: #64748b; color: white; }
.btn-primary { background: #3b82f6; color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Sections */
.section {
    background: #1e293b;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.section h2 {
    color: #38bdf8;
    margin-bottom: 15px;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tunnel List */
.tunnel-list { display: grid; gap: 12px; }

.tunnel-item {
    background: #0f172a;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #334155;
}

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

.tunnel-name-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tunnel-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
}

.tunnel-status-dot.active { background: #22c55e; }

.tunnel-name {
    color: #38bdf8;
    font-weight: 600;
    font-size: 15px;
}

.tunnel-type {
    background: #334155;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
}

.tunnel-details {
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 8px;
}

.tunnel-url {
    color: #22c55e;
    font-size: 12px;
    word-break: break-all;
}

.tunnel-url a {
    color: #22c55e;
    text-decoration: none;
}

.tunnel-url a:hover {
    text-decoration: underline;
}

.tunnel-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #334155;
}

.tunnel-last-connected {
    color: #64748b;
    font-size: 11px;
}

/* Create Tunnel Form */
.create-form {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: #0f172a;
    border-radius: 6px;
    border: 1px solid #334155;
}

.create-form.show { display: block; }

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

.form-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

/* Alerts */
.alert {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background: #22c55e22;
    color: #22c55e;
    border: 1px solid #22c55e44;
}

.alert-error {
    background: #ef444422;
    color: #ef4444;
    border: 1px solid #ef444444;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #64748b;
}

/* View Controls */
.view-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px solid #334155;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-controls label {
    color: #94a3b8;
    font-size: 13px;
}

.sort-controls select {
    padding: 6px 10px;
    border: 1px solid #334155;
    border-radius: 4px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
}

.sort-dir-btn {
    width: 32px;
    padding: 6px !important;
    background: #334155 !important;
}

.view-toggle {
    display: flex;
    gap: 5px;
}

.view-btn {
    background: #334155 !important;
    border: 1px solid #475569 !important;
}

.view-btn.active {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Table View */
.tunnel-table {
    width: 100%;
    border-collapse: collapse;
}

.tunnel-table th {
    text-align: left;
    padding: 12px 10px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    border-bottom: 1px solid #334155;
}

.tunnel-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #1e293b;
    font-size: 14px;
}

.tunnel-table tr:hover {
    background: #1e293b;
}

.tunnel-table .tunnel-name {
    color: #38bdf8;
    font-weight: 600;
}

.tunnel-table .tunnel-type {
    display: inline-block;
}

.tunnel-table .tunnel-remote a {
    color: #22c55e;
    text-decoration: none;
}

.tunnel-table .tunnel-remote a:hover {
    text-decoration: underline;
}

.tunnel-table .actions {
    white-space: nowrap;
}

.tunnel-table .tunnel-status-dot {
    margin: 0 auto;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid #334155;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #e2e8f0;
}

.tab-btn.active {
    color: #38bdf8;
    border-bottom-color: #38bdf8;
}

.tab-content {
    display: none;
}

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

/* Metrics Summary Cards */
.metrics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.metric-card {
    background: #0f172a;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #334155;
    text-align: center;
}

.metric-label {
    color: #94a3b8;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.metric-value {
    color: #38bdf8;
    font-size: 24px;
    font-weight: 600;
}

/* Metrics Controls */
.metrics-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px 0;
    border-bottom: 1px solid #334155;
}

.metrics-controls label {
    color: #94a3b8;
    font-size: 13px;
}

.metrics-controls select {
    padding: 6px 10px;
    border: 1px solid #334155;
    border-radius: 4px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.chart-container {
    background: #0f172a;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #334155;
}

.chart-container h3 {
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.chart-container canvas {
    max-height: 250px;
}

/* Slow Requests Table */
.slow-requests {
    background: #0f172a;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #334155;
}

.slow-requests h3 {
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 15px;
    text-transform: uppercase;
}

/* Status code colors */
.status-2xx { color: #22c55e; }
.status-3xx { color: #38bdf8; }
.status-4xx { color: #f59e0b; }
.status-5xx { color: #ef4444; }

/* Response time colors */
.time-fast { color: #22c55e; }
.time-medium { color: #f59e0b; }
.time-slow { color: #ef4444; }

/* SSH Connection String */
.ssh-connection {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: #a78bfa;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.ssh-connection:hover {
    background: #a78bfa22;
}

/* SSH Key Items */
.ssh-key-list {
    display: grid;
    gap: 12px;
}

.ssh-key-item {
    background: #0f172a;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #334155;
}

.ssh-key-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ssh-key-name {
    color: #38bdf8;
    font-weight: 600;
    font-size: 15px;
    margin-right: 10px;
}

.ssh-key-fingerprint {
    color: #a78bfa;
    font-family: monospace;
    font-size: 12px;
}

.ssh-key-value {
    color: #64748b;
    font-family: monospace;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 8px;
}

.ssh-key-meta {
    color: #475569;
    font-size: 11px;
}

/* Code Block */
.code-block {
    background: #0f172a;
    padding: 12px 15px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 13px;
    color: #e2e8f0;
    overflow-x: auto;
    white-space: pre-wrap;
    border: 1px solid #334155;
    line-height: 1.5;
}
