/* ============================================
   InvoiceFlow - Main Stylesheet
   Professional Dark Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg-base:       #0d0f14;
  --bg-surface:    #13161e;
  --bg-card:       #1a1e28;
  --bg-hover:      #1f2433;
  --bg-input:      #161921;
  --border:        rgba(255,255,255,0.07);
  --border-focus:  rgba(99,179,237,0.5);

  --text-primary:  #eef0f6;
  --text-secondary:#8892a4;
  --text-muted:    #525d72;

  --accent:        #4f7cff;
  --accent-light:  #6b91ff;
  --accent-glow:   rgba(79,124,255,0.2);

  --green:         #34d399;
  --green-bg:      rgba(52,211,153,0.1);
  --yellow:        #fbbf24;
  --yellow-bg:     rgba(251,191,36,0.1);
  --red:           #f87171;
  --red-bg:        rgba(248,113,113,0.1);
  --blue:          #60a5fa;
  --blue-bg:       rgba(96,165,250,0.1);
  --purple:        #a78bfa;
  --purple-bg:     rgba(167,139,250,0.1);
  --orange:        #fb923c;
  --orange-bg:     rgba(251,146,60,0.1);

  --sidebar-w:     240px;
  --header-h:      60px;
  --radius:        10px;
  --radius-lg:     14px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);

  --font:          'DM Sans', sans-serif;
  --font-mono:     'DM Mono', monospace;

  --transition:    all 0.18s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============================================
   LAYOUT
   ============================================ */
.app-wrapper { display: flex; min-height: 100vh; }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.sidebar-logo h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: var(--transition);
  text-decoration: none;
  border-left: 3px solid transparent;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-light);
  border-left-color: var(--accent);
}

.nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.company-tag {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition);
}

.company-tag:hover { background: var(--bg-hover); }

.company-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.company-info { flex: 1; min-width: 0; }
.company-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-plan { font-size: 11px; color: var(--text-muted); }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* ============================================
   PAGE CONTENT
   ============================================ */
.page-content {
  padding: 24px;
  flex: 1;
}

.page { display: none; }
.page.active { display: block; }

/* ============================================
   CARDS & PANELS
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================
   KPI CARDS
   ============================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.kpi-card:hover {
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.kpi-card.green::before { background: var(--green); }
.kpi-card.blue::before  { background: var(--blue); }
.kpi-card.yellow::before{ background: var(--yellow); }
.kpi-card.red::before   { background: var(--red); }
.kpi-card.purple::before{ background: var(--purple); }

.kpi-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}

.kpi-icon.green  { background: var(--green-bg);  color: var(--green); }
.kpi-icon.blue   { background: var(--blue-bg);   color: var(--blue); }
.kpi-icon.yellow { background: var(--yellow-bg); color: var(--yellow); }
.kpi-icon.red    { background: var(--red-bg);    color: var(--red); }
.kpi-icon.purple { background: var(--purple-bg); color: var(--purple); }

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.kpi-change {
  font-size: 11px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-light); }

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); }

.btn-success { background: var(--green-bg); color: var(--green); border-color: rgba(52,211,153,0.2); }
.btn-success:hover { background: rgba(52,211,153,0.2); }

.btn-danger  { background: var(--red-bg);   color: var(--red);   border-color: rgba(248,113,113,0.2); }
.btn-danger:hover  { background: rgba(248,113,113,0.2); }

.btn-warning { background: var(--yellow-bg); color: var(--yellow); border-color: rgba(251,191,36,0.2); }
.btn-warning:hover { background: rgba(251,191,36,0.2); }

.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }
.btn-icon.btn-sm { width: 28px; height: 28px; padding: 4px; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input, select, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,179,237,0.08);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238892a4' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 4px; }

/* ============================================
   TABLES
   ============================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

thead th {
  background: var(--bg-surface);
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

inv.tr:hover { background: red }

tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.td-mono { font-family: var(--font-mono); font-size: 13px; }

/* ============================================
   BADGES / STATUS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: capitalize;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge.draft      { background: rgba(130,148,180,0.12); color: #8294b4; }
.badge.draft .badge-dot { background: #8294b4; }
.badge.sent       { background: var(--blue-bg);    color: var(--blue); }
.badge.sent .badge-dot { background: var(--blue); }
.badge.viewed     { background: var(--purple-bg);  color: var(--purple); }
.badge.viewed .badge-dot { background: var(--purple); }
.badge.paid       { background: var(--green-bg);   color: var(--green); }
.badge.paid .badge-dot { background: var(--green); }
.badge.partial    { background: var(--yellow-bg);  color: var(--yellow); }
.badge.partial .badge-dot { background: var(--yellow); }
.badge.overdue    { background: var(--red-bg);     color: var(--red); }
.badge.overdue .badge-dot { background: var(--red); }
.badge.cancelled  { background: rgba(100,100,100,0.1); color: #888; }
.badge.cancelled .badge-dot { background: #888; }
.badge.accepted   { background: var(--green-bg);   color: var(--green); }
.badge.accepted .badge-dot { background: var(--green); }
.badge.declined   { background: var(--red-bg);     color: var(--red); }
.badge.declined .badge-dot { background: var(--red); }
.badge.active     { background: var(--green-bg);   color: var(--green); }
.badge.inactive   { background: var(--red-bg);     color: var(--red); }

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in 0.2s ease;
}

.modal-sm { max-width: 420px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1100px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 2px;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ============================================
   INVOICE BUILDER
   ============================================ */
.invoice-builder {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.invoice-header-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.items-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

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

.items-table th {
  background: var(--bg-surface);
  padding: 10px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.items-table td {
  padding: 8px 4px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.items-table td:first-child { padding-left: 12px; }
.items-table td:last-child  { padding-right: 12px; }
.items-table tr:last-child td { border-bottom: none; }

.items-table input {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 8px;
  border-radius: 6px;
  transition: var(--transition);
}

.items-table input:focus {
  background: var(--bg-input);
  border-color: var(--border-focus);
}

.col-name    { width: 30%; }
.col-desc    { width: 20%; }
.col-qty     { width: 8%; }
.col-price   { width: 12%; }
.col-disc    { width: 8%; }
.col-tax     { width: 8%; }
.col-total   { width: 10%; }
.col-action  { width: 4%; }

.invoice-totals {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 13.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.total-row:last-child { border-bottom: none; }

.total-row.grand-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ============================================
   SEARCH & FILTERS
   ============================================ */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 340px;
}

.search-bar input {
  padding-left: 36px;
  background: var(--bg-card);
}

.search-bar .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.filters-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-select {
  width: auto;
  min-width: 130px;
  background: var(--bg-card);
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.page-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
}

.page-btn:hover, .page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============================================
   CHARTS
   ============================================ */
.chart-container { position: relative; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.empty-desc  { font-size: 13px; color: var(--text-muted); max-width: 320px; margin: 0 auto 20px; }

/* ============================================
   ALERTS & TOASTS
   ============================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: slide-in 0.25s ease;
  pointer-events: all;
  border-left: 3px solid var(--accent);
}

.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--yellow); }

.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-msg  { font-size: 13px; flex: 1; }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   PRINT / INVOICE PREVIEW
   ============================================ */
.invoice-preview {
  background: #fff;
  color: #1a1a2e;
  padding: 40px;
  border-radius: var(--radius-lg);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
}

/* ============================================
   DASHBOARD GRID
   ============================================ */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.dash-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  gap: 0;
}

.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -1px;
  transition: var(--transition);
}

.tab-btn.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

.tab-btn:hover { color: var(--text-primary); }

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

/* ============================================
   UTILITIES
   ============================================ */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue   { color: var(--blue); }
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-bold   { font-weight: 700; }
.text-mono   { font-family: var(--font-mono); }
.text-sm     { font-size: 12px; }
.text-xs     { font-size: 11px; }
.text-lg     { font-size: 16px; }

.d-flex      { display: flex; }
.align-center{ align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.mt-8        { margin-top: 8px; }
.mt-12       { margin-top: 12px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-8        { margin-bottom: 8px; }
.mb-12       { margin-bottom: 12px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.w-full      { width: 100%; }
.ml-auto     { margin-left: auto; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .invoice-builder { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .dash-grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .invoice-header-row { grid-template-columns: 1fr; }
}

/* ============================================
   UPGRADE PATCH v2 — Responsive + Users + Reports + PWA
   ============================================ */

/* ── License Expiry Banner ── */
.license-expiry-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: linear-gradient(90deg, rgba(79,124,255,0.12), rgba(107,91,239,0.08));
    border-bottom: 1px solid rgba(79,124,255,0.2);
    font-size: 12px;
    color: #a0b0cc;
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}
.license-expiry-bar.show { display: flex; }
.license-expiry-bar .expiry-badge {
    background: rgba(79,124,255,0.2);
    color: #7ba4ff;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 11px;
    white-space: nowrap;
}
.license-expiry-bar.expiry-warn .expiry-badge { background: rgba(251,191,36,0.2); color: #fbbf24; }
.license-expiry-bar.expiry-critical .expiry-badge { background: rgba(248,113,113,0.2); color: #f87171; }
.license-expiry-bar.expiry-expired .expiry-badge { background: rgba(248,113,113,0.3); color: #f87171; }

/* ── Users Page ── */
.user-role-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
}
.user-role-badge.admin { background: rgba(79,124,255,0.15); color: #7ba4ff; }
.user-role-badge.user  { background: rgba(52,211,153,0.12); color: #34d399; }
.user-avatar-sm {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, #4f7cff, #6b5bef);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}

/* ── Full Report Page ── */
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 768px) { .report-grid { grid-template-columns: 1fr; } }
.report-kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .report-kpi-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .report-kpi-row { grid-template-columns: 1fr; } }
.report-kpi-mini {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    padding: 16px; text-align: center;
}
.report-kpi-mini .val { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.report-kpi-mini .lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Enhanced Mobile Sidebar ── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        z-index: 200; transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar-overlay {
        display: none; position: fixed; inset: 0;
        background: rgba(0,0,0,0.5); z-index: 199;
    }
    .sidebar-overlay.show { display: block; }
    .topbar { position: sticky; top: 0; z-index: 100; }
    .filters-row { flex-wrap: wrap; gap: 8px; }
    .filters-row .search-bar { min-width: 100%; order: -1; }
    table { font-size: 13px; }
    th, td { padding: 10px 12px !important; }
    .modal { margin: 8px; max-height: calc(100vh - 16px); overflow-y: auto; border-radius: 14px !important; }
    .topbar-actions .btn { padding: 9px 14px; font-size: 13px; }
}

/* ── Table horizontal scroll on mobile ── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 600px) {
    .table-wrapper table { min-width: 520px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .page-content { padding: 12px; }
    .card { border-radius: 12px; }
}

/* ── Full Report page tabs ── */
.full-report-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.full-report-tab {
    padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; cursor: pointer;
    border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-secondary);
    transition: all 0.15s; -webkit-tap-highlight-color: transparent;
}
.full-report-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.full-report-tab:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* ── Print styles ── */
@media print {
    .sidebar, .topbar, .filters-row, .btn, .license-expiry-bar { display: none !important; }
    .main-content { margin: 0 !important; }
    .page { display: block !important; }
    .page:not(.active) { display: none !important; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
