/* BillBuddies Prototype — Design System */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --cyan: #0891b2;
  --cyan-light: #cffafe;
  --dark: #0f172a;
  --dark-2: #1e293b;
  --dark-3: #334155;
  --gray: #64748b;
  --gray-2: #94a3b8;
  --gray-light: #f1f5f9;
  --border: #e2e8f0;
  --white: #ffffff;
--sidebar-w: 240px;
  --header-h: 56px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font); background: var(--gray-light); color: var(--dark); }

/* ─── LAYOUT ─────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-logo {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.9rem; font-weight: 800;
  flex-shrink: 0;
}

.brand-name { font-size: 1rem; font-weight: 700; color: #fff; }
.brand-sub { font-size: 0.65rem; color: #64748b; margin-top: 1px; }

.sidebar-biz {
  padding: 12px 16px;
  margin: 12px 12px 0;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.08);
}

.biz-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.72rem; font-weight: 800; flex-shrink: 0;
}

.biz-name { font-size: 0.78rem; font-weight: 600; color: #e2e8f0; line-height: 1.3; }
.biz-gstin { font-size: 0.62rem; color: #64748b; }
.biz-switch { margin-left: auto; color: #64748b; font-size: 0.7rem; }

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section-label {
  padding: 8px 20px 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
  margin-top: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  border-radius: 0;
  position: relative;
}

.nav-link i { font-size: 1.05rem; width: 18px; text-align: center; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }
.nav-link.active {
  background: rgba(37,99,235,0.15);
  color: #60a5fa;
  font-weight: 600;
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  line-height: 1.4;
}

.nav-badge.green { background: var(--success); }
.nav-badge.amber { background: var(--warning); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.65rem; font-weight: 700; flex-shrink: 0;
}

.user-name { font-size: 0.75rem; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 0.62rem; color: #64748b; }
.user-logout { margin-left: auto; color: #64748b; font-size: 0.8rem; }
.user-logout:hover { color: var(--danger); }

/* ─── MAIN ───────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100vh;
 }

/* ─── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

/* topbar-title removed — titles live in .page-header only */
.topbar-breadcrumb { font-size: 0.75rem; color: var(--gray); margin-top: 1px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  color: var(--gray);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.95rem;
  position: relative;
  transition: all 0.15s;
}
.topbar-icon-btn:hover { background: var(--gray-light); color: var(--dark); }

/* ─── PROFILE DROPDOWN ───────────────────────────────────── */
.profile-dropdown {
  position: relative;
}

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 6px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.profile-trigger:hover {
  background: var(--gray-light);
  border-color: var(--border);
}

.profile-trigger .p-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.profile-trigger .p-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dark);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-trigger .p-chevron {
  font-size: 0.7rem;
  color: var(--gray);
  transition: transform 0.2s;
}

.profile-dropdown.open .p-chevron {
  transform: rotate(180deg);
}

.profile-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  min-width: 220px;
  z-index: 1000;
  overflow: hidden;
}

.profile-dropdown.open .profile-menu {
  display: block;
}

.profile-menu-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.profile-menu-header .pm-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--dark);
}

.profile-menu-header .pm-email {
  font-size: 0.72rem;
  color: var(--gray);
  margin-top: 1px;
}

.profile-menu-header .pm-biz {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.profile-menu a,
.profile-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--dark);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.profile-menu a:hover,
.profile-menu button:hover {
  background: var(--gray-light);
}

.profile-menu a i,
.profile-menu button i {
  color: var(--gray);
  font-size: 0.9rem;
  width: 16px;
  text-align: center;
}

.profile-menu .pm-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.profile-menu .pm-danger { color: var(--danger) !important; }
.profile-menu .pm-danger i { color: var(--danger) !important; }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid #fff;
}

/* ─── PAGE BODY ──────────────────────────────────────────── */
.page-body { padding: 24px; flex: 1; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 1.3rem; font-weight: 800; color: var(--dark); margin-bottom: 3px; }
.page-header p { font-size: 0.8rem; color: var(--gray); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── STAT CARDS ─────────────────────────────────────────── */
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-card .sc-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-card .sc-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--dark);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card .sc-sub {
  font-size: 0.72rem;
  color: var(--gray);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sc-trend { font-weight: 600; }
.sc-trend.up { color: var(--success); }
.sc-trend.down { color: var(--danger); }

.sc-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  float: right;
  margin-top: -4px;
}

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid #e2e8f0;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 7px;
}

.card-title i { color: var(--primary); }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: #fafafa; border-radius: 0 0 var(--radius) var(--radius); }

/* ─── TABLE ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  border-bottom: 2px solid #cbd5e1;
  white-space: nowrap;
  background: #e8edf5;
}

.data-table th.num, .data-table td.num { text-align: right; }
.data-table th input[type=checkbox], .data-table td input[type=checkbox] { cursor: pointer; }

.data-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.data-table tbody tr:nth-child(even) td { background: #f8fafc; }
.data-table tbody tr:hover td { background: #eff6ff !important; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Cell helpers */
.data-table .td-name    { font-weight: 600; color: #1e293b; }
.data-table .td-muted   { color: #64748b; font-size: 0.8rem; }
.data-table .td-mono    { font-family: monospace; font-size: 0.8rem; color: #475569; }
.data-table .td-sub     { font-size: 0.75rem; color: #94a3b8; margin-top: 2px; }

/* ─── TABLE ACTION BUTTONS ───────────────────────────────── */
/* Always-visible rounded buttons in table rows */
.data-table .btn-ghost {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
  border-radius: 6px;
}
.data-table .btn-ghost:hover {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: #2563eb;
}
/* Delete / danger variant keeps red */
.data-table .btn-ghost[style*="ef4444"],
.data-table .btn-ghost[style*="dc2626"] {
  color: #ef4444 !important;
}
.data-table .btn-ghost[style*="ef4444"]:hover,
.data-table .btn-ghost[style*="dc2626"]:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #dc2626 !important;
}

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-gray { background: #f1f5f9; color: var(--gray); }
.badge-cyan { background: var(--cyan-light); color: var(--cyan); }
.badge-dark { background: var(--dark-2); color: #e2e8f0; }

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: var(--font);
}

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #b45309; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-outline { background: #fff; color: var(--dark); border-color: var(--border); }
.btn-outline:hover { background: var(--gray-light); }
.btn-ghost { background: transparent; color: var(--gray); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-light); color: var(--dark); }
.btn-sm { padding: 5px 11px; font-size: 0.75rem; }
.btn-icon { padding: 6px; width: 30px; height: 30px; justify-content: center; }

/* ─── FORM ELEMENTS ──────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--dark-3);
  margin-bottom: 5px;
}

.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--dark);
  background: var(--white);
  transition: border-color 0.15s;
  font-family: var(--font);
  outline: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: 0.72rem; color: var(--danger); margin-top: 4px; }
.form-hint { font-size: 0.7rem; color: var(--gray); margin-top: 4px; }

textarea.form-control { resize: vertical; min-height: 80px; }

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group-text {
  padding: 0 12px;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.8rem;
  color: var(--gray);
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input { width: 15px; height: 15px; cursor: pointer; }
.form-check-label { font-size: 0.82rem; color: var(--dark-3); cursor: pointer; }

/* ─── FILTER BAR ─────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.filter-bar .form-control,
.filter-bar .form-select { width: auto; min-width: 140px; font-size: 0.78rem; padding: 6px 10px; }

.filter-bar .search-box { min-width: 220px; position: relative; }
.filter-bar .search-box i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray); font-size: 0.85rem; }
.filter-bar .search-box input { padding-left: 30px; }

.filter-bar .ms-auto { margin-left: auto; }

/* ─── TABS ───────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
  margin-bottom: 20px;
}

.tab-link {
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.tab-link:hover { color: var(--dark); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── INVOICE BUILDER ────────────────────────────────────── */
.inv-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.inv-section-head {
  padding: 12px 20px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.inv-section-head i { color: var(--primary); }
.inv-section-body { padding: 20px; }

.line-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.line-items-table th {
  padding: 8px 10px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
  border-bottom: 2px solid var(--border);
  background: #fafafa;
  white-space: nowrap;
}

.line-items-table th.num { text-align: right; }

.line-items-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.line-items-table td .form-control { padding: 5px 8px; font-size: 0.78rem; }

.line-items-table .gst-cell {
  background: #f8fafc;
  text-align: right;
  font-size: 0.75rem;
  color: var(--gray);
  white-space: nowrap;
}

.line-items-table .amount-cell {
  text-align: right;
  font-weight: 700;
  color: var(--dark);
}

.line-items-table .del-btn { color: var(--danger); cursor: pointer; font-size: 0.9rem; }

.add-row-btn {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  background: none;
  cursor: pointer;
  transition: all 0.15s;
}

.add-row-btn:hover { border-color: var(--primary); background: var(--primary-light); }

.totals-box {
  margin-left: auto;
  width: 340px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}

.totals-row:last-child { border-bottom: none; }
.totals-row .tl { color: var(--gray); }
.totals-row .tv { font-weight: 600; color: var(--dark); }

.totals-row.highlight { background: #f0f7ff; padding: 7px 10px; border-radius: var(--radius-sm); border: none; margin-top: 4px; }
.totals-row.highlight .tl { color: var(--primary); font-weight: 700; }
.totals-row.highlight .tv { color: var(--primary); font-weight: 800; font-size: 0.9rem; }

.gst-split { font-size: 0.7rem; color: var(--gray); text-align: right; }
.gst-split span { display: inline-block; margin-left: 8px; }

/* ─── ALERTS & BANNERS ───────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert i { font-size: 1rem; margin-top: 1px; flex-shrink: 0; }
.alert-info { background: var(--primary-light); color: var(--primary); border-left: 3px solid var(--primary); }
.alert-success { background: #166534; color: #fff; border-left: 3px solid #14532d; }
.alert-warning { background: var(--warning-light); color: var(--warning); border-left: 3px solid var(--warning); }
.alert-danger { background: var(--danger-light); color: var(--danger); border-left: 3px solid var(--danger); }

/* ─── PARTY TRUST BADGE ──────────────────────────────────── */
.trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.65rem;
  font-weight: 700;
}

.trust-excellent { background: var(--success-light); color: var(--success); }
.trust-good { background: var(--primary-light); color: var(--primary); }
.trust-fair { background: var(--warning-light); color: var(--warning); }
.trust-poor { background: var(--danger-light); color: var(--danger); }

/* ─── MISC ───────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray);
}

.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; opacity: 0.4; }
.empty-state h4 { font-size: 0.9rem; font-weight: 700; color: var(--dark-3); margin-bottom: 6px; }
.empty-state p { font-size: 0.78rem; }

.section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  margin-bottom: 10px;
}

.text-muted { color: var(--gray); }
.text-small { font-size: 0.72rem; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }

/* Grid utils */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ─── FORM LAYOUT (2-column with sticky sidebar) ─────────── */
.form-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.sticky-sidebar { position: sticky; top: 80px; }

.form-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.form-grid   { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.type-toggle { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.type-toggle button {
  flex: 1;
  padding: 0.6rem 1rem;
  border: none;
  background: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--gray);
  transition: background 0.15s, color 0.15s;
}
.type-toggle button.active { background: var(--primary); color: #fff; }

/* ─── PRODUCT FORM ───────────────────────────────────────── */
.item-type-toggle { display: flex; gap: 12px; }
.item-type-btn {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.item-type-btn:hover { border-color: var(--primary); }
.item-type-btn.active { border-color: var(--primary); background: #eff6ff; }
.item-type-btn .type-icon { font-size: 1.5rem; margin-bottom: 6px; }
.item-type-btn .type-label { font-size: 0.875rem; font-weight: 600; display: block; }
.item-type-btn.active .type-label { color: var(--primary); }
.item-type-btn .type-desc { font-size: 0.75rem; color: var(--gray); margin-top: 2px; }

.gst-preview-card {
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
  color: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.gst-preview-row { display: flex; justify-content: space-between; padding: 0.4rem 0; font-size: 0.875rem; }
.gst-preview-row.total { border-top: 1px solid rgba(255,255,255,0.3); margin-top: 0.5rem; padding-top: 0.75rem; font-weight: 700; font-size: 1rem; }

/* ─── AUTH PAGES ─────────────────────────────────────────── */
.auth-body { background: var(--gray-light); }

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

/* ── Left brand panel ── */
.auth-brand {
  flex: 0 0 480px;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
  position: relative;
  overflow: hidden;
}
.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 75%, rgba(37,99,235,.18) 0%, transparent 50%),
    radial-gradient(circle at 85% 15%, rgba(37,99,235,.12) 0%, transparent 40%);
}
.auth-brand-inner { position: relative; z-index: 1; max-width: 340px; }

.auth-brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 40px;
}
.auth-brand-icon {
  width: 44px; height: 44px;
  background: #2563eb;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.25rem;
}
.auth-brand-logo span {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
}

.auth-brand-headline {
  font-size: 2.1rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -.03em;
}
.auth-brand-sub {
  font-size: 0.88rem;
  color: rgba(255,255,255,.75);
  line-height: 1.65;
  margin-bottom: 36px;
}

.auth-features {
  list-style: none;
  padding: 0; margin: 0 0 40px;
  display: flex; flex-direction: column; gap: 12px;
}
.auth-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  color: rgba(255,255,255,.9);
  font-weight: 500;
}
.auth-features li i {
  font-size: 0.95rem;
  color: #93c5fd;
  flex-shrink: 0;
}

.auth-trust {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.auth-trust-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  color: rgba(255,255,255,.65);
  font-weight: 500;
}
.auth-trust-item i { font-size: 0.8rem; color: #93c5fd; }

/* ── Right form panel ── */
.auth-form-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--gray-light);
}

.auth-card {
  background: #fff;
  border-radius: 18px;
  padding: 40px 44px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,.05), 0 20px 40px -8px rgba(37,99,235,.1);
  border: 1px solid #e2e8f0;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  justify-content: center;
}
.auth-logo-mobile { display: none; }

.auth-logo .logo-box {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem;
}

.auth-footer {
  margin-top: 24px;
  font-size: 0.72rem;
  color: #94a3b8;
  text-align: center;
}

.auth-card h2 { font-size: 1.3rem; font-weight: 800; color: var(--dark); margin-bottom: 4px; }
.auth-card p { font-size: 0.82rem; color: var(--gray); margin-bottom: 24px; }

/* ─── INVOICE VIEW / PRINT ───────────────────────────────── */
.inv-view-header {
  background: linear-gradient(135deg, var(--dark), var(--dark-2));
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.inv-view-biz-name { font-size: 1rem; font-weight: 700; }
.inv-view-gstin { font-size: 0.72rem; color: #94a3b8; }

.inv-document {
  background: #fff;
  max-width: 860px;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
}

.inv-doc-header {
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  border-bottom: 2px solid var(--dark);
}

.inv-doc-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.inv-doc-num { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.inv-doc-meta { font-size: 0.75rem; color: var(--gray); margin-top: 4px; }

.inv-doc-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.inv-party-box { padding: 16px 24px; }
.inv-party-box:first-child { border-right: 1px solid var(--border); }
.inv-party-label { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gray); margin-bottom: 6px; }
.inv-party-name { font-size: 0.9rem; font-weight: 700; color: var(--dark); }
.inv-party-detail { font-size: 0.75rem; color: var(--dark-3); margin-top: 2px; line-height: 1.5; }

.inv-doc-items { padding: 0; }
.inv-doc-items table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.inv-doc-items th { padding: 8px 16px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #fff; background: var(--dark-2); }
.inv-doc-items td { padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--dark-3); }
.inv-doc-items tr:last-child td { border-bottom: none; }
.inv-doc-items .num { text-align: right; }

.inv-doc-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 2px solid var(--border);
}

.inv-doc-totals { padding: 16px 24px; border-right: 1px solid var(--border); }
.inv-doc-bank { padding: 16px 24px; }
.inv-doc-words { padding: 12px 24px; border-top: 1px solid var(--border); font-size: 0.75rem; color: var(--dark-3); font-style: italic; }
.inv-doc-sign { padding: 12px 24px; border-top: 1px solid var(--border); text-align: right; }

/* ─── REPORT CARDS ───────────────────────────────────────── */
.report-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: block;
  box-shadow: var(--shadow);
}

.report-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.report-card .rc-icon { font-size: 1.6rem; margin-bottom: 10px; }
.report-card .rc-title { font-size: 0.88rem; font-weight: 700; color: var(--dark); margin-bottom: 4px; }
.report-card .rc-desc { font-size: 0.75rem; color: var(--gray); line-height: 1.4; }

/* ─── MINI CHART PLACEHOLDERS ────────────────────────────── */
.chart-placeholder {
  background: linear-gradient(180deg, rgba(37,99,235,0.06) 0%, rgba(37,99,235,0.02) 100%);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-2);
  font-size: 0.75rem;
  gap: 6px;
}

/* ─── SETTINGS TABS ─────────────────────────────────────── */
.settings-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.settings-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.settings-tab:hover { color: var(--dark); }

.settings-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}

.settings-tab i { font-size: 0.9rem; }

/* ─── SIDEBAR TRANSITION (always) ───────────────────────────── */
.sidebar { transition: transform 0.25s cubic-bezier(.4,0,.2,1); }

/* ─── SIDEBAR OVERLAY BACKDROP ──────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 98;
  opacity: 0;
  transition: opacity 0.25s;
}

body.sidebar-open .sidebar-overlay {
  display: block;
  opacity: 1;
}

body.sidebar-open .sidebar {
  transform: translateX(0) !important;
  box-shadow: 4px 0 32px rgba(0,0,0,0.25);
}

/* Prevent body scroll when sidebar open on mobile */
body.sidebar-open { overflow: hidden; }

/* ─── HAMBURGER BUTTON ───────────────────────────────────────── */
.topbar-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--white);
  align-items: center;
  justify-content: center;
  color: var(--dark);
  cursor: pointer;
  font-size: 1.05rem;
  flex-shrink: 0;
  transition: background 0.15s;
}

.topbar-menu-btn:hover { background: var(--gray-light); }

/* ─── MOBILE BOTTOM NAVIGATION ───────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  z-index: 90;
  /* Safe area for notched phones */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-nav-inner {
  display: flex;
  height: 56px;
  align-items: stretch;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--gray);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: .01em;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item i { font-size: 1.25rem; line-height: 1; }
.mobile-nav-item.active { color: var(--primary); }
.mobile-nav-item:active { color: var(--primary); }

.mobile-nav-fab {
  flex: 0 0 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.mobile-nav-fab a {
  width: 50px;
  height: 50px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(37,99,235,.45);
  transition: background 0.15s, transform 0.1s;
  margin-top: -20px;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-fab a:active { transform: scale(0.92); background: var(--primary-dark); }

/* ─── PREVENT HORIZONTAL OVERFLOW (viewport zoom fix) ────────── */
/*
  When any child element is wider than the viewport, the browser widens
  the virtual canvas — making the whole page appear zoomed-in on mobile.
  Clipping overflow on the layout wrapper prevents this without breaking
  position:fixed elements (sidebar overlay, bottom nav, drawers).
*/
html { overflow-x: hidden; }
.main-content { overflow-x: hidden; max-width: 100%; }
/* table-wrap already has overflow-x:auto — just ensure it can't bust out */
.table-wrap { max-width: 100%; }
/* Any wide card/section content stays clipped */
.card, .inv-section { max-width: 100%; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  /* Auth brand panel: shrink on medium screens */
  .auth-brand { flex: 0 0 360px; padding: 48px 32px; }
  .auth-brand-headline { font-size: 1.7rem; }
  .auth-card { padding: 36px 32px; }
}

@media (max-width: 768px) {
  /* Sidebar: hide off-screen, toggle via JS */
  .sidebar { transform: translateX(-100%); z-index: 100; }
  .main-content { margin-left: 0; }

  /* Show hamburger */
  .topbar-menu-btn { display: flex; }

  /* Topbar */
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar-breadcrumb { display: none; }
  /* Hide date and quick-action buttons entirely on mobile */
  .topbar-date { display: none !important; }
  .qa-btn { display: none !important; }

  /* Hide notification bell on mobile to save space, but keep trade inbox */
  .topbar-icon-btn { display: none; }
  .topbar-icon-btn.trade-inbox-btn { display: flex; }

  /* FY badge: show icon only, hide label text */
  .fy-trigger-label { display: none; }

  /* Profile name: hide on mobile */
  .profile-trigger .p-name { display: none; }
  .profile-trigger .p-chevron { display: none; }

  /* Page body — extra bottom padding for mobile nav bar */
  .page-body { padding: 12px; padding-bottom: 72px; }

  /* Grids */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* Inline grid forms: collapse columns */
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr !important; }
  .form-layout { grid-template-columns: 1fr; }
  .sticky-sidebar { position: static; }

  /* Invoice builder */
  .totals-box { width: 100%; }

  /* Invoice line items: sticky first column + min widths */
  .line-items-table { table-layout: auto; }
  .line-items-table th,
  .line-items-table td { white-space: nowrap; }
  .line-items-table th:first-child,
  .line-items-table td:first-child { position: sticky; left: 0; z-index: 2; min-width: 160px; }
  .line-items-table th:first-child { background: #fafafa; z-index: 3; }
  .line-items-table td:first-child { background: #fff; }
  .line-items-table tbody tr:nth-child(even) td:first-child { background: #f8fafc; }
  .line-items-table tbody tr:hover td:first-child { background: #eff6ff !important; }

  /* Invoice document view */
  .inv-doc-header { grid-template-columns: 1fr; }
  .inv-doc-parties { grid-template-columns: 1fr; }
  .inv-doc-parties .inv-party-box:first-child { border-right: none; border-bottom: 1px solid var(--border); }
  .inv-doc-footer { grid-template-columns: 1fr; }
  .inv-doc-totals { border-right: none; border-bottom: 1px solid var(--border); }
  /* Invoice document items table: horizontal scroll */
  .inv-doc-items { overflow-x: auto; }

  /* Settings tabs: allow horizontal scroll */
  .settings-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .settings-tabs::-webkit-scrollbar { display: none; }
  .settings-tab { white-space: nowrap; }

  /* Tab nav: allow horizontal scroll */
  .tab-nav { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tab-nav::-webkit-scrollbar { display: none; }

  /* Card header filter bars: stack */
  .card-header { flex-direction: column; align-items: flex-start; }
  .card-header form[method="get"] { margin-left: 0 !important; width: 100%; }
  .card-header form[method="get"] .form-control { width: 100%; }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; }

  /* Filter drawer: full width on mobile */
  #filter-drawer { width: 100% !important; min-width: unset !important; max-width: unset !important; }

  /* Auth — collapse brand panel, show mobile logo */
  .auth-brand { display: none; }
  .auth-logo-mobile { display: flex; }
  .auth-form-panel { padding: 24px 16px; background: var(--gray-light); }
  .auth-card { padding: 28px 24px; }

  /* Report card grid */
  .report-card { padding: 14px; }

  /* Show mobile bottom nav */
  .mobile-nav { display: block; }

  /* Biz switcher: tighter on mobile */
  .biz-switcher-trigger { max-width: 180px; }
}

@media (max-width: 480px) {
  .page-body { padding: 10px; padding-bottom: 72px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .card-header { padding: 10px 12px; }
  .card-body { padding: 12px; }
  .auth-card { padding: 24px 20px; }
  .data-table th, .data-table td { padding: 8px 10px; }
  /* Biz switcher: even tighter on very small phones */
  .biz-switcher-trigger { max-width: 140px; }
  .biz-switcher-name { font-size: 0.73rem; }
  /* Page action buttons: compact */
  .page-actions .btn { font-size: 0.72rem; padding: 5px 9px; }
}



/* ─── CUSTOM SIDEBAR SCROLLBAR ───────────────────────────── */

/* For Chrome, Edge, Safari */
.sidebar::-webkit-scrollbar {
  width: 6px; /* thin */
}

.sidebar::-webkit-scrollbar-track {
  background: transparent; /* no background */
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15); /* light transparent */
  border-radius: 10px;
  transition: background 0.2s;
}

/* Hover effect */
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* For Firefox */
.sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}