/* ── RESET & BASE ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary:   #1a1a2e;
  --accent:    #2196F3;
  --accent2:   #0d47a1;
  --success:   #2e7d32;
  --danger:    #c62828;
  --warning:   #e65100;
  --bg:        #f0f2f5;
  --sidebar-w: 230px;
  --topbar-h:  60px;
  --card-bg:   #ffffff;
  --border:    #e0e0e0;
  --text:      #1a1a2e;
  --muted:     #757575;
  --radius:    8px;
  --shadow:    0 2px 8px rgba(0,0,0,0.08);
}
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
a { text-decoration: none; color: inherit; }

/* ── LOGIN PAGE ────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-wrap { width: 100%; max-width: 400px; padding: 24px; }
.login-brand { text-align: center; margin-bottom: 32px; }
.brand-icon { font-size: 56px; margin-bottom: 8px; }
.login-brand h1 { font-size: 32px; color: #fff; letter-spacing: 2px; margin-bottom: 6px; }
.login-brand p { color: rgba(255,255,255,0.6); font-size: 14px; }
.login-card { background: #fff; border-radius: 12px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.login-card h2 { font-size: 22px; margin-bottom: 24px; color: var(--primary); }
.login-hint { text-align: center; margin-top: 16px; font-size: 12px; color: var(--muted); }

/* ── SIDEBAR ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px;
  font-size: 18px; font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #fff;
}
.brand-icon-sm { font-size: 24px; }
.sidebar-nav { padding: 12px 0; overflow-y: auto; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  transition: all 0.15s;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-icon { font-size: 16px; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 8px 0; }

/* ── MAIN LAYOUT ──────────────────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  box-shadow: var(--shadow);
}
.page-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-badge {
  background: var(--primary); color: #fff;
  padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
}
.sidebar-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; }
.content { padding: 24px; flex: 1; }

/* ── CARDS ────────────────────────────────────────────────────────────────── */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }
.mb-16 { margin-bottom: 16px; }
.mt-24 { margin-top: 24px; }

/* ── STATS ────────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── TABLE ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: #f5f5f5; padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.data-table tr:hover td { background: #fafafa; }
.data-table td.empty { text-align: center; color: var(--muted); padding: 32px; font-style: italic; }

/* ── BADGES ───────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-paid    { background: #e8f5e9; color: #2e7d32; }
.badge-active  { background: #e3f2fd; color: #1565c0; }
.badge-draft   { background: #fff3e0; color: #e65100; }
.badge-pending { background: #fff8e1; color: #f57f17; }
.size-badge { display: inline-block; background: var(--primary); color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }

/* ── FORMS ────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.form-row { display: flex; gap: 16px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; color: var(--text);
  background: #fff; transition: border-color 0.15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(33,150,243,0.1); }
.readonly-input { background: #f5f5f5; color: var(--muted); }
textarea { resize: vertical; }

/* ── BUTTONS ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer; border: none;
  transition: all 0.15s; white-space: nowrap; font-family: inherit;
}
.btn-primary  { background: var(--accent);   color: #fff; }
.btn-primary:hover  { background: var(--accent2); }
.btn-outline  { background: #fff; color: var(--primary); border: 1px solid var(--border); }
.btn-outline:hover  { border-color: var(--accent); color: var(--accent); }
.btn-danger   { background: #ffebee; color: var(--danger); border: 1px solid #ffcdd2; }
.btn-danger:hover   { background: var(--danger); color: #fff; }
.btn-success  { background: #e8f5e9; color: var(--success); border: 1px solid #c8e6c9; }
.btn-success:hover  { background: var(--success); color: #fff; }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-row { display: flex; gap: 12px; justify-content: flex-end; }

/* ── FILTER BAR ───────────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-input { flex: 1; min-width: 200px; max-width: 300px; }
.filter-select { min-width: 140px; }

/* ── MODAL ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 1000;
  align-items: center; justify-content: center; padding: 20px;
}
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 12px; justify-content: flex-end; }

/* ── INVOICE ──────────────────────────────────────────────────────────────── */
.invoice-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; }
.totals-block { padding: 20px; }
.total-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
.total-grand { font-size: 18px; font-weight: 800; border-top: 2px solid var(--primary); border-bottom: none; padding-top: 12px; margin-top: 4px; }
.totals-summary { display: flex; gap: 24px; flex-wrap: wrap; background: #fff; border-radius: var(--radius); padding: 16px 20px; margin-top: 16px; box-shadow: var(--shadow); }
.sum-item { font-size: 14px; color: var(--muted); }

/* ── STATUS SELECT ────────────────────────────────────────────────────────── */
.status-select { padding: 4px 8px; font-size: 12px; border-radius: 4px; width: auto; }

/* ── CATEGORIES ───────────────────────────────────────────────────────────── */
.cat-layout { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 300px; }

/* ── ALERTS ───────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .invoice-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-input { max-width: 100%; }
}
