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

:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c7d2fe;
  --sidebar-active: #4f46e5;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 220px; background: var(--sidebar-bg); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 20px 16px; font-size: 16px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-icon { font-size: 20px; }
.nav-list { list-style: none; padding: 12px 0; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: var(--sidebar-text); cursor: pointer; border-radius: 6px; margin: 2px 8px; transition: background .15s; font-size: 13px; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-icon { font-size: 15px; }

/* Content */
.content { flex: 1; padding: 24px; overflow-y: auto; min-width: 0; }
.page { display: none; }
.page.active { display: block; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header .subtitle { color: var(--text-muted); font-size: 13px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.kpi-card.warning { border-left-color: var(--warning); }
.kpi-card.danger { border-left-color: var(--danger); }
.kpi-card.success { border-left-color: var(--success); }
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text); }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-header { padding: 14px 20px; font-weight: 600; border-bottom: 1px solid var(--border); font-size: 14px; }
.card-body { padding: 16px 20px; }
.mt-4 { margin-top: 16px; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } .sidebar { width: 180px; } }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 12px; background: var(--bg); color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(79,70,229,.03); }
.text-center { text-align: center; color: var(--text-muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-active, .badge-paid, .badge-completed { background: #d1fae5; color: #065f46; }
.badge-draft { background: #e0e7ff; color: #3730a3; }
.badge-sent { background: #dbeafe; color: #1e40af; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-void { background: #f3f4f6; color: #6b7280; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.badge-suspended { background: #fef3c7; color: #92400e; }
.badge-refunded { background: #fef3c7; color: #92400e; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: background .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-link { background: none; border: none; color: var(--primary); font-size: 12px; cursor: pointer; padding: 2px 6px; }
.btn-link:hover { text-decoration: underline; }

/* Filters */
.table-filters { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.input-search { padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; width: 260px; outline: none; }
.input-search:focus { border-color: var(--primary); }
.select-filter { padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: var(--surface); cursor: pointer; outline: none; }

/* Pagination */
.pagination { display: flex; gap: 6px; margin-top: 16px; align-items: center; flex-wrap: wrap; }
.pagination button { padding: 5px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; cursor: pointer; background: var(--surface); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:hover:not(.active) { background: var(--bg); }
.pagination span { font-size: 12px; color: var(--text-muted); }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); width: 500px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-close { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; outline: none; }
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Health status */
.health-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.health-dot.healthy { background: var(--success); }
.health-dot.degraded { background: var(--warning); }
.health-dot.unhealthy { background: var(--danger); }
.health-checks { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.health-check { display: flex; align-items: center; padding: 6px 14px; background: var(--bg); border-radius: 20px; font-size: 12px; }

/* Plan bars */
.plan-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.plan-bar-name { width: 140px; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-bar-track { flex: 1; background: var(--bg); height: 10px; border-radius: 5px; overflow: hidden; }
.plan-bar-fill { height: 100%; background: var(--primary); border-radius: 5px; }
.plan-bar-count { font-size: 12px; color: var(--text-muted); width: 30px; text-align: right; }

/* Canvas */
canvas { max-width: 100%; }

/* Loading */
.loading { color: var(--text-muted); font-size: 13px; }

/* Amount colors */
.amount-danger { color: var(--danger); font-weight: 600; }
.amount-success { color: var(--success); }
