/* Traffic Deco - Modern Clean Theme */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-hover: #252838;
    --border: #2a2d3a;
    --text-primary: #e4e6eb;
    --text-secondary: #8b8fa3;
    --text-muted: #5c6070;
    --accent: #6366f1;
    --accent-hover: #5254cc;
    --accent-soft: rgba(99, 102, 241, 0.12);
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* Pages */
.page { display: none; min-height: 100vh; }
.page.active { display: block; }

/* Login */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

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

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

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.login-header .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Forms */
.input-group {
    margin-bottom: 16px;
}

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

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition);
    outline: none;
}

input:focus, select:focus {
    border-color: var(--accent);
}

/* Buttons */
.password-wrap {
    position: relative;
}

.password-wrap input {
    padding-right: 40px;
}

.toggle-pass {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.5;
    transition: opacity var(--transition);
    padding: 4px;
    line-height: 1;
}

.toggle-pass:hover { opacity: 1; }
.toggle-pass.active { opacity: 1; }

.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; }

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 16px;
    font-weight: 600;
    margin-right: 32px;
}

.nav-links {
    display: flex;
    gap: 4px;
}

.nav-link {
    padding: 6px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); }

.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Content */
.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

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

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

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    font-weight: 600;
}

.stat-active { color: var(--success); }

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

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Inbounds Grid */
.inbounds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
}

.inbound-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all var(--transition);
}

.inbound-card:hover { border-color: var(--accent); background: var(--bg-hover); }
.inbound-card.selected { border-color: var(--accent); background: var(--accent-soft); }

.inbound-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.inbound-name {
    font-weight: 600;
    font-size: 14px;
}

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

.inbound-status.active { background: var(--success); }

.inbound-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.inbound-meta span { display: flex; align-items: center; gap: 4px; }

.traffic-bar {
    margin-top: 10px;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
}

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

.inbound-limit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.limit-pct {
    font-weight: 600;
    color: var(--accent);
}

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

.chart-header .section-title { margin-bottom: 0; }

.chart-controls { display: flex; gap: 4px; }
.range-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart-container {
    position: relative;
    height: 280px;
}

/* Destination form */
.dest-form { margin-top: 8px; }
.dest-inputs { display: flex; gap: 12px; align-items: flex-end; }
.dest-inputs .input-group { flex: 1; margin-bottom: 0; }
.dest-inputs .btn { margin-bottom: 0; height: 40px; }

/* Admin */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.tab-btn {
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition);
}

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

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

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

.tab-header h2 { font-size: 18px; font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

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

th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover td { background: var(--bg-hover); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
}

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

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

#modal-body { padding: 20px; }
#modal-body .input-group:last-of-type { margin-bottom: 20px; }

/* Status & Error */
.error-text { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; }
.status-text { font-size: 13px; margin-top: 8px; }
.status-text.success { color: var(--success); }
.status-text.error { color: var(--danger); }

/* Utility */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
    .content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .inbounds-grid { grid-template-columns: 1fr; }
    .dest-inputs { flex-direction: column; }
    .navbar { padding: 0 12px; }
    .nav-brand { margin-right: 16px; }
}
