/* ─── Cirex Systems Billing Portal ─── */
/* Tokens */
:root {
    --bg: #0B0E11;
    --surface: #12161C;
    --surface-hover: #181D25;
    --border: #1E2530;
    --border-light: #2A3240;
    --text: #E8ECF1;
    --text-muted: #7A8599;
    --text-dim: #4A5568;
    --accent: #00D4AA;
    --accent-dim: rgba(0,212,170,0.12);
    --accent-hover: rgba(0,212,170,0.2);
    --red: #FF5C5C;
    --red-dim: rgba(255,92,92,0.12);
    --yellow: #FFB84D;
    --yellow-dim: rgba(255,184,77,0.12);
    --blue: #4DA6FF;
    --blue-dim: rgba(77,166,255,0.12);
    --font: 'Outfit', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --radius: 10px;
}

/* ─── Reset ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { opacity: 0.85; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ─── Layout ─── */
.app-layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ─── */
.sidebar {
    width: 230px; flex-shrink: 0; background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 22px 18px 18px; border-bottom: 1px solid var(--border);
}
.brand-icon {
    width: 34px; height: 34px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #00A888);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--mono); font-weight: 700; font-size: 15px; color: var(--bg);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 10.5px; color: var(--text-muted); font-weight: 500; }

.sidebar-nav { padding: 12px 10px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
    color: var(--text-muted); transition: all 0.15s; margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-icon { width: 18px; height: 18px; }

.sidebar-footer {
    padding: 14px 16px; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar {
    width: 28px; height: 28px; border-radius: 6px; background: var(--border-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: var(--text-muted);
}
.user-name { font-size: 12px; font-weight: 600; }
.user-role { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.logout-btn { color: var(--text-dim); padding: 4px; transition: color 0.2s; }
.logout-btn:hover { color: var(--red); }

/* ─── Main ─── */
.main-content { flex: 1; padding: 28px 32px; max-width: 1060px; overflow-x: auto; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }

/* ─── Flash Messages ─── */
.flash {
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px;
    font-size: 13px; font-weight: 500;
}
.flash-success { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(0,212,170,0.2); }
.flash-error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255,92,92,0.2); }
.flash-warning { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(255,184,77,0.2); }

/* ─── Cards ─── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 20px 22px;
}
.card-title {
    font-size: 11.5px; color: var(--text-muted); font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px;
}

/* ─── Stat Cards ─── */
.stats-grid { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.stat-card { flex: 1; min-width: 180px; }
.stat-value {
    font-size: 28px; font-weight: 700; font-family: var(--mono);
    line-height: 1;
}
.stat-sub { font-size: 12px; font-weight: 500; margin-top: 6px; }
.stat-sub.up { color: var(--accent); }
.stat-sub.down { color: var(--red); }
.stat-sub.neutral { color: var(--text-muted); }

/* ─── Tables ─── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th {
    padding: 12px 16px; text-align: left; font-size: 11px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td { padding: 14px 16px; }
.data-table .cell-primary { font-weight: 600; }
.data-table .cell-secondary { font-size: 11.5px; color: var(--text-muted); }
.data-table .cell-mono { font-family: var(--mono); font-weight: 600; }
.data-table .cell-muted { color: var(--text-muted); font-size: 12px; }
.data-table .cell-id { font-family: var(--mono); font-size: 12px; color: var(--accent); }

/* ─── Badges ─── */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 600;
    letter-spacing: 0.03em; text-transform: uppercase;
}
.badge-green { background: var(--accent-dim); color: var(--accent); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }
.badge-gray { background: rgba(122,133,153,0.12); color: var(--text-muted); }

/* ─── Buttons ─── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px; border-radius: 8px; border: none; cursor: pointer;
    font-family: var(--font); font-weight: 600; font-size: 13px;
    transition: all 0.2s; text-decoration: none;
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-light); color: var(--text); }
.btn-danger { background: var(--red-dim); color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon {
    background: none; border: none; color: var(--text-dim); cursor: pointer;
    padding: 4px; transition: color 0.2s;
}
.btn-icon:hover { color: var(--text); }
.btn-icon.danger:hover { color: var(--red); }

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 12px; font-weight: 600; color: var(--text-muted);
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em;
}
.form-input, .form-select, .form-textarea {
    width: 100%; background: var(--bg); border: 1px solid var(--border);
    color: var(--text); font-family: var(--font); font-size: 13px;
    padding: 10px 12px; border-radius: 8px; outline: none; transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-select { cursor: pointer; appearance: none; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ─── Invoice Detail ─── */
.invoice-header { 
    display: flex; justify-content: space-between; padding: 18px;
    background: var(--bg); border-radius: var(--radius); margin-bottom: 20px;
}
.invoice-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.invoice-meta { display: flex; gap: 24px; margin-bottom: 16px; }
.invoice-meta > div > span { font-size: 11px; color: var(--text-muted); display: block; }
.invoice-meta > div > div { font-weight: 600; font-size: 13px; margin-top: 2px; }
.line-items { border-top: 1px solid var(--border); padding-top: 14px; }
.line-item {
    display: flex; justify-content: space-between; padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.line-item-desc { color: var(--text-muted); }
.line-item-amount { font-family: var(--mono); font-weight: 600; }
.invoice-total {
    display: flex; justify-content: space-between; padding: 12px 0;
    font-weight: 700; font-size: 16px;
}
.invoice-total-value { font-family: var(--mono); color: var(--accent); }

/* ─── MRR Chart ─── */
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bar-value { font-size: 10px; font-family: var(--mono); color: var(--accent); font-weight: 600; }
.chart-bar {
    width: 100%; max-width: 48px; border-radius: 6px 6px 2px 2px;
    background: linear-gradient(180deg, var(--accent) 0%, rgba(0,212,170,0.3) 100%);
    transition: height 0.5s ease;
}
.chart-bar-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* ─── Login Page ─── */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.login-card {
    width: 400px; max-width: 92vw; background: var(--surface);
    border: 1px solid var(--border); border-radius: 16px; padding: 36px;
}
.login-brand {
    display: flex; align-items: center; gap: 12px; margin-bottom: 32px;
}
.login-brand .brand-icon { width: 40px; height: 40px; font-size: 18px; }
.login-brand .brand-name { font-size: 20px; }
.login-error {
    background: var(--red-dim); color: var(--red); padding: 10px 14px;
    border-radius: 8px; font-size: 13px; margin-bottom: 16px;
}

/* ─── Empty State ─── */
.empty-state {
    text-align: center; padding: 48px 20px; color: var(--text-dim);
}
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { padding: 16px; }
    .stats-grid { flex-direction: column; }
    .form-row { flex-direction: column; }
    .invoice-header { flex-direction: column; gap: 12px; }
}
