:root {
  --primary: #182230;
  --primary-dark: #0F1620;
  --accent: #F05A24;
  --accent-hover: #D94A18;
  --accent-light: #FFF0E8;
  --accent-soft: #FED7C3;
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --text: #182230;
  --text-soft: #667085;
  --gray: #667085;
  --gray-light: #98A2B3;
  --border: #EAECF0;
  --border-soft: #F0F1F4;
  --danger: #DC2626;
  --danger-light: #FEF0F0;
  --success: #16A34A;
  --success-light: #EAF8EF;
  --warning: #D97706;
  --warning-light: #FFF7E6;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'tnum';
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { font-weight: 800; letter-spacing: -0.02em; margin: 0; }

.icon { flex-shrink: 0; }

/* ---------- Layout ---------- */

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

.sidebar {
  width: 272px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  color: var(--text);
  padding: 28px 18px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, padding 0.2s ease;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 4px 8px 28px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  position: relative;
}

.sidebar-collapse-btn {
  position: absolute;
  right: -12px;
  top: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--gray);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, background 0.12s ease, color 0.12s ease;
}

.sidebar-collapse-btn:hover { background: var(--accent-light); color: var(--accent); }

/* ---------- Collapsed sidebar ---------- */

.sidebar.collapsed {
  width: 84px;
  padding: 28px 14px;
}

.sidebar.collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-user-info { display: none; }
.sidebar.collapsed .sidebar-collapse-btn { transform: rotate(180deg); }
.sidebar.collapsed nav a { justify-content: center; padding: 12px; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 10px; }

.sidebar.collapsed.hover-expand {
  position: fixed;
  left: 0;
  top: 0;
  width: 272px;
  padding: 28px 18px;
  z-index: 45;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.18);
}

.sidebar.collapsed.hover-expand .brand { justify-content: flex-start; padding-left: 8px; padding-right: 8px; }
.sidebar.collapsed.hover-expand .brand-text,
.sidebar.collapsed.hover-expand .nav-label,
.sidebar.collapsed.hover-expand .sidebar-user-info { display: block; }
.sidebar.collapsed.hover-expand nav a { justify-content: flex-start; padding: 11px 14px; }
.sidebar.collapsed.hover-expand .sidebar-user { justify-content: flex-start; padding: 12px; }
.sidebar.collapsed.hover-expand .sidebar-collapse-btn { transform: rotate(0deg); }

@media (max-width: 768px) {
  .sidebar.collapsed { width: 258px; padding: 24px 16px; }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .sidebar-user-info { display: block; }
  .sidebar.collapsed nav a { justify-content: flex-start; padding: 10px 14px; }
  .sidebar.collapsed .sidebar-user { justify-content: flex-start; padding: 12px; }
  .sidebar-collapse-btn { display: none; }
}

.sidebar .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  flex-shrink: 0;
}

.sidebar .brand-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.sidebar .brand-sub {
  font-size: 11.5px;
  color: var(--gray-light);
  font-weight: 600;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar nav::-webkit-scrollbar { width: 5px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.sidebar nav::-webkit-scrollbar-thumb:hover { background: var(--gray-light); }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar nav a .icon { color: var(--gray-light); transition: color 0.15s ease; }

.sidebar nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sidebar nav a:hover .icon { color: var(--text); }

.sidebar nav a.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
}

.sidebar nav a.active .icon { color: var(--accent); }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 12px 4px;
  font-size: 11px;
  color: var(--gray-light);
}

.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border-soft);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; }

.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  background: none;
  border: none;
  color: var(--gray);
  font-size: 11.5px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.sidebar-logout:hover { color: var(--accent); }

.main { flex: 1; padding: 32px 40px 60px; max-width: 1180px; min-width: 0; }

/* ---------- Mobile topbar ---------- */

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }

.menu-btn {
  background: none;
  border: none;
  color: #fff;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 13, 0.5);
  z-index: 40;
}

.sidebar-overlay.show { display: block; }

/* ---------- Page header ---------- */

.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: 28px; color: var(--text); letter-spacing: -0.02em; }
.page-header .page-subtitle { color: var(--text-soft); font-size: 14px; margin-top: 6px; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card-title { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.card-subtitle { color: var(--text-soft); font-size: 13px; margin-bottom: 16px; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.card-flush { padding: 0; overflow-x: auto; }
.card-flush table { min-width: 560px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.05s ease;
}

.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; box-shadow: 0 4px 12px rgba(240, 90, 36, 0.25); }
.btn:active { transform: translateY(1px); }

.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); font-weight: 600; }
.btn-secondary:hover { background: var(--bg); color: var(--text); box-shadow: none; border-color: var(--gray-light); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #B53A30; }

.btn-ghost-danger { background: transparent; color: var(--danger); border: 1px solid transparent; }
.btn-ghost-danger:hover { background: var(--danger-light); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.danger:hover { background: var(--danger-light); color: var(--danger); border-color: #F1C7C2; }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 15px 20px; vertical-align: middle; }
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray);
  background: var(--bg);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell form { display: inline; }
.row-actions { display: inline-flex; gap: 6px; }

/* ---------- Avatars ---------- */

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12.5px;
  color: #fff;
  flex-shrink: 0;
}

.name-cell { display: flex; align-items: center; gap: 12px; }

/* ---------- Stats ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--accent-soft);
}

.stat-card-clickable {
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.stat-card-clickable:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-card-clickable.active-filter {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.dash-grid-left .stats-grid { margin-bottom: 0; height: 100%; }

.stats-grid-2col {
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.dash-chart-card { margin-bottom: 0; display: flex; flex-direction: column; }

.row-with-icon { display: flex; align-items: center; gap: 10px; }

.row-icon-badge {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr; }
}

.stat-card-hero {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border: none;
  box-shadow: 0 8px 24px rgba(240, 90, 36, 0.28);
}

.stat-card-hero .stat-label { color: rgba(255, 255, 255, 0.85); }
.stat-card-hero .stat-value { color: #fff; }
.stat-card-hero .stat-hint { color: rgba(255, 255, 255, 0.75); }
.stat-card-hero .stat-icon { background: rgba(255, 255, 255, 0.2) !important; color: #fff !important; }
.stat-card-hero .stat-breakdown { border-top-color: rgba(255, 255, 255, 0.25); }
.stat-card-hero .stat-breakdown-label { color: rgba(255, 255, 255, 0.75); }
.stat-card-hero .stat-breakdown-value { color: #fff; }

.stat-card-hero-negative {
  background: linear-gradient(135deg, var(--danger) 0%, #B53A30 100%) !important;
  box-shadow: 0 8px 24px rgba(208, 69, 58, 0.28) !important;
}

.datatable tbody tr.row-audit-mismatch,
.datatable tbody tr.row-audit-mismatch td {
  background-color: #fdecec !important;
  color: #b42318 !important;
}

.stat-breakdown {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border, #ECE7E1);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.stat-breakdown-row.clickable {
  cursor: pointer;
  margin: 0 -8px;
  padding: 3px 8px;
  border-radius: 6px;
  transition: background 0.12s ease;
}

.stat-breakdown-row.clickable:hover {
  background: var(--bg);
}

.stat-breakdown-row.clickable.active-filter {
  background: var(--accent-light);
}

.stat-breakdown-row.clickable.active-filter .stat-breakdown-label,
.stat-breakdown-row.clickable.active-filter .stat-breakdown-value {
  color: var(--accent-hover);
}

.stat-breakdown-label {
  color: var(--gray);
  font-weight: 600;
}

.stat-breakdown-value {
  color: var(--dark, #2A2420);
  font-weight: 700;
}

.stat-card .stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.stat-label { color: var(--gray); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); margin-top: 5px; letter-spacing: -0.02em; }
.stat-hint { color: var(--gray-light); font-size: 12px; margin-top: 4px; }

/* ---------- Forms ---------- */

.form-group { margin-bottom: 18px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 6px; color: var(--text-soft); }
label .hint { font-weight: 400; color: var(--gray-light); }

input[type=text], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=password], input[type=search], input[type=url], textarea, select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  min-height: 40px;
}

textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
select { cursor: pointer; }

.form-section-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.form-section-sub { color: var(--gray); font-size: 12px; margin-bottom: 18px; }

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

/* ---------- Vendors ---------- */

.vendor-type-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.vendor-type-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.vendor-type-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.vendor-type-option input[type=radio] {
  width: auto;
  margin-top: 3px;
}

.vendor-type-option-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
}

.vendor-type-option-sub {
  font-size: 11.5px;
  color: var(--gray);
  margin-top: 2px;
}

.rate-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .rate-editor-grid { grid-template-columns: 1fr; }
}

.rate-editor-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 10px;
}

.slab-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 30px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.slab-row-header span {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.slab-row input {
  padding: 8px 10px;
  font-size: 12.5px;
}

/* ---------- Invoice line items ---------- */

.item-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  background: #FCFDFE;
  overflow: hidden;
}

.item-row .item-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--accent-light);
  border-bottom: 1px solid var(--border);
}

.item-row .item-row-head .item-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
}

.item-row .item-row-head .item-badge .num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.item-row-body { padding: 16px; }

.remove-item-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
}

.remove-item-btn:hover { background: var(--danger-light); }

.item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.item-grid-full { grid-column: 1 / -1; }

.item-totals-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.item-totals-row input[readonly] {
  background: var(--accent-light);
  font-weight: 700;
  color: var(--primary);
  border-color: var(--accent-soft);
}

.summary-total {
  text-align: right;
  font-size: 13px;
  color: var(--gray);
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.summary-total .amount { font-size: 22px; font-weight: 800; color: var(--primary); margin-left: 8px; }

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--gray);
}

.empty-state .icon { color: var(--gray-light); margin-bottom: 14px; }
.empty-state-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; color: var(--gray); margin-bottom: 18px; }

/* ---------- Badges / status ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-light);
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: #E8F1FD; color: #2563A8; }
.badge-neutral { background: var(--bg); color: var(--text-soft); }

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--success-light);
  color: #146643;
  border: 1px solid #BFEBD7;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-weight: 600;
  font-size: 13px;
}

.status .icon { color: var(--success); }

.errors {
  background: var(--danger-light);
  border: 1px solid #F1C7C2;
  color: var(--danger);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
}

.errors .icon { flex-shrink: 0; margin-top: 1px; }
.errors ul { margin: 0; padding-left: 18px; }
.errors li { font-size: 13px; }

/* ---------- Search ---------- */

.search-bar { margin-bottom: 18px; position: relative; max-width: 340px; }
.search-bar .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-light); }
.search-bar input { padding-left: 36px; }

.muted { color: var(--gray); }

/* ---------- Pagination ---------- */

.pagination { margin-top: 18px; display: flex; justify-content: center; }
.pagination nav { display: flex; align-items: center; gap: 4px; }
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  border: 1px solid transparent;
}
.pagination a:hover { background: var(--surface); border-color: var(--border); text-decoration: none; }
.pagination .current span { background: var(--primary); color: #fff; }
.pagination .disabled { color: var(--gray-light); }

/* ---------- Invoice preview / detail ---------- */

.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.detail-label { color: var(--gray); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; margin-bottom: 6px; }
.detail-value { font-size: 14px; font-weight: 600; color: var(--text); }
.detail-sub { color: var(--gray); font-size: 12.5px; margin-top: 2px; }

.invoice-preview-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--accent-light);
  font-size: 12.5px;
  color: var(--text-soft);
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
}
.invoice-preview-box .icon { color: var(--accent); flex-shrink: 0; margin-top: 1px; }

.terms-block { white-space: pre-line; font-size: 13px; color: var(--text-soft); line-height: 1.7; }

@media (max-width: 960px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .item-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .topbar { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 258px;
    max-width: 80vw;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open { transform: translateX(0); }

  .main { padding: 18px 16px 40px; }

  .page-header { margin-bottom: 18px; }
  .page-header h1 { font-size: 19px; }

  .card { padding: 16px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 19px; }

  .detail-grid { grid-template-columns: 1fr 1fr; gap: 16px; }

  .form-row { flex-direction: column; gap: 0; }

  .item-totals-row { grid-template-columns: 1fr; gap: 10px; }

  .search-bar { max-width: 100%; }

  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; justify-content: center; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* ---------- DataTables theming (v2.x class names) ---------- */

.dt-container { padding: 4px 4px 16px; }

.dt-layout-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 0;
  padding: 16px 20px 0;
}

.dt-layout-table { padding: 0 !important; }
.dt-layout-row:has(.dt-paging),
.dt-layout-row:has(.dt-length) {
  padding: 14px 20px 16px;
}

.dt-search { display: flex; align-items: center; }
.dt-search label { display: none; }

.dt-search input.dt-input,
.dt-length select.dt-input {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  height: 34px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.dt-search input.dt-input {
  min-width: 220px;
}

.dt-search input.dt-input:focus,
.dt-length select.dt-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.dt-length label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--gray); font-weight: 600; }

.dt-info {
  font-size: 12.5px;
  color: var(--gray);
}

table.dataTable thead th {
  position: relative;
  cursor: pointer;
}

table.dataTable thead th.dt-orderable-asc:hover,
table.dataTable thead th.dt-orderable-desc:hover {
  background: var(--accent-soft);
}

table.dataTable thead th .dt-column-order {
  margin-left: 6px;
  opacity: 0.5;
}

table.dataTable thead th.dt-ordering-asc .dt-column-order,
table.dataTable thead th.dt-ordering-desc .dt-column-order {
  opacity: 1;
  color: var(--accent);
}

.dt-paging {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.dt-container .dt-paging .dt-paging-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft) !important;
  border: 1px solid var(--border) !important;
  background: #fff !important;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.dt-container .dt-paging .dt-paging-button:hover:not(.disabled):not(.current) {
  background: var(--accent-light) !important;
  color: var(--accent) !important;
  border-color: var(--accent-soft) !important;
}

.dt-container .dt-paging .dt-paging-button.current {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
  box-shadow: 0 4px 10px rgba(240, 90, 36, 0.28);
}

.dt-container .dt-paging .dt-paging-button.disabled {
  color: var(--gray-light) !important;
  cursor: default;
  opacity: 0.6;
}

.dt-empty {
  text-align: center;
  padding: 40px 20px !important;
  color: var(--gray);
}

.dt-processing {
  --dt-row-selected: 240, 90, 36;
  background: var(--surface) !important;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  color: var(--text-soft) !important;
  font-size: 12.5px;
  font-weight: 600;
  padding: 10px !important;
}

/* ---------- Auth / Login (split screen) ---------- */

.split-auth-body { margin: 0; background: var(--surface); }

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

.split-auth-panel {
  flex: 0 0 44%;
  max-width: 540px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 60%, #150F0C 100%);
  position: relative;
  overflow: hidden;
  padding: 48px 52px;
  display: flex;
  flex-direction: column;
  color: #fff;
}

.split-auth-glow {
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 90, 36, 0.32) 0%, rgba(240, 90, 36, 0) 70%);
  top: -150px;
  left: -140px;
  pointer-events: none;
}

.split-auth-glow-2 {
  top: auto;
  left: auto;
  bottom: -220px;
  right: -160px;
  background: radial-gradient(circle, rgba(240, 90, 36, 0.16) 0%, rgba(240, 90, 36, 0) 70%);
}

.split-auth-brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }

.split-auth-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.split-auth-brand-name { font-weight: 700; font-size: 16px; }
.split-auth-brand-sub { font-size: 12px; color: #C9BEB4; }

.split-auth-copy { margin-top: auto; padding-top: 60px; position: relative; z-index: 1; }
.split-auth-copy h1 { font-size: 30px; line-height: 1.28; margin: 0 0 14px; font-weight: 800; max-width: 420px; }
.split-auth-copy p { font-size: 14.5px; color: #D8CFC5; max-width: 380px; line-height: 1.6; margin: 0; }

.split-auth-features { margin-top: 38px; display: flex; flex-direction: column; gap: 20px; position: relative; z-index: 1; }
.split-auth-feature { display: flex; gap: 14px; align-items: flex-start; }

.split-auth-feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.split-auth-feature-title { font-size: 13.5px; font-weight: 700; color: #fff; }
.split-auth-feature-sub { font-size: 12px; color: #B0A196; margin-top: 2px; }

.split-auth-footer { margin-top: 50px; font-size: 11.5px; color: #8A7C71; position: relative; z-index: 1; }

.split-auth-form-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.split-auth-form-wrap { width: 100%; max-width: 380px; }
.split-auth-form-head h2 { font-size: 24px; margin: 0 0 6px; }
.split-auth-form-head p { color: var(--gray); font-size: 13.5px; margin: 0 0 28px; }

.split-auth-remember { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 13px; color: var(--text-soft); margin-bottom: 22px; }

.input-icon-group { position: relative; }
.input-icon-group .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-light); pointer-events: none; z-index: 1; }
.input-icon-group input { padding-left: 40px; }

.floating-group { position: relative; margin-bottom: 20px; }

.floating-group input {
  width: 100%;
  height: 52px;
  padding: 20px 14px 6px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}

.floating-group label {
  position: absolute;
  left: 40px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--gray);
  font-weight: 400;
  pointer-events: none;
  transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease, transform 0.15s ease;
  margin: 0;
  background: transparent;
}

.floating-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.floating-group input:focus + label,
.floating-group input:not(:placeholder-shown) + label {
  top: 13px;
  transform: translateY(0);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.split-auth-trust { margin-top: 24px; display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 11.5px; color: var(--gray-light); }

@media (max-width: 960px) {
  .split-auth-panel { display: none; }
  .split-auth-form-side { padding: 24px; }
}

/* ---------- Toasts ---------- */

.toastify {
  border-radius: var(--radius-sm) !important;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  padding: 12px 18px !important;
  box-shadow: var(--shadow-lg) !important;
}

/* ---------- Button loading state ---------- */

.btn.is-loading, .btn-sm.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: btn-spin 0.6s linear infinite;
}

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

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 28px;
}

.date-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.date-filter-row .date-range-input {
  width: auto;
  min-width: 210px;
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='1.8'%3E%3Cpath d='M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 16px;
  cursor: pointer;
}

/* ---------- DataTables toolbar icon buttons ---------- */

.dt-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dt-buttons .dt-button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 0 !important;
  border-radius: 9px !important;
  border: 1px solid var(--border) !important;
  background: #fff !important;
  color: var(--text-soft) !important;
  cursor: pointer;
  box-shadow: var(--shadow-sm) !important;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.dt-buttons .dt-button.buttons-collection {
  width: auto;
  padding: 0 10px 0 12px !important;
}

.dt-buttons .dt-button .dt-button-down-arrow {
  font-size: 0 !important;
  width: 7px !important;
  height: 7px !important;
  flex-shrink: 0;
  color: var(--gray-light) !important;
  position: relative;
  display: inline-block;
}

.dt-buttons .dt-button .dt-button-down-arrow::before {
  content: '';
  position: absolute;
  top: 1px;
  left: 0;
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
}

.dt-buttons .dt-button:hover {
  background: var(--accent-light) !important;
  color: var(--accent) !important;
  border-color: var(--accent-soft) !important;
}

.dt-button-collection {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 60;
  min-width: 190px;
  max-height: min(480px, 70vh) !important;
  overflow-y: auto !important;
}

.dt-button-collection .dt-button {
  display: flex !important;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: auto;
  padding: 9px 10px !important;
  margin-bottom: 2px;
  font-size: 13px !important;
  font-weight: 500;
  border-radius: 8px !important;
  border: none !important;
  background: transparent !important;
  color: var(--text-soft) !important;
  text-align: left;
  justify-content: flex-start !important;
  transition: background 0.12s ease, color 0.12s ease;
}

.dt-button-collection .dt-button:last-child { margin-bottom: 0; }

.dt-button-collection .dt-button:hover { background: var(--bg) !important; color: var(--text) !important; }

.dt-button-collection .dt-button.dt-button-active {
  color: var(--accent) !important;
  font-weight: 700;
  background: var(--accent-light) !important;
}

.dt-button-collection .dt-button.dt-button-active::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.dt-button-collection .dt-button:not(.dt-button-active)::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.dt-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.dt-icon-columns {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='4' width='5' height='16' rx='1'/%3E%3Crect x='9.5' y='4' width='5' height='16' rx='1'/%3E%3Crect x='16' y='4' width='5' height='16' rx='1'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='4' width='5' height='16' rx='1'/%3E%3Crect x='9.5' y='4' width='5' height='16' rx='1'/%3E%3Crect x='16' y='4' width='5' height='16' rx='1'/%3E%3C/svg%3E");
}

.dt-icon-copy {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='3' width='13' height='13' rx='2'/%3E%3Crect x='8' y='8' width='13' height='13' rx='2'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='3' width='13' height='13' rx='2'/%3E%3Crect x='8' y='8' width='13' height='13' rx='2'/%3E%3C/svg%3E");
}

.dt-icon-download {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3a1 1 0 0 1 1 1v8.586l2.293-2.293a1 1 0 1 1 1.414 1.414l-4 4a1 1 0 0 1-1.414 0l-4-4a1 1 0 1 1 1.414-1.414L11 12.586V4a1 1 0 0 1 1-1z'/%3E%3Cpath d='M5 18a1 1 0 0 1 1-1h12a1 1 0 1 1 0 2H6a1 1 0 0 1-1-1z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3a1 1 0 0 1 1 1v8.586l2.293-2.293a1 1 0 1 1 1.414 1.414l-4 4a1 1 0 0 1-1.414 0l-4-4a1 1 0 1 1 1.414-1.414L11 12.586V4a1 1 0 0 1 1-1z'/%3E%3Cpath d='M5 18a1 1 0 0 1 1-1h12a1 1 0 1 1 0 2H6a1 1 0 0 1-1-1z'/%3E%3C/svg%3E");
}

div.dt-scroll-body table.dataTable { border-bottom: none; }
div.dt-scroll-head table.dataTable thead th { border-bottom: none; }

/* ---------- daterangepicker brand overrides ---------- */

.daterangepicker { font-family: 'Plus Jakarta Sans', 'Inter', sans-serif; border-radius: var(--radius-sm); border-color: var(--border); box-shadow: var(--shadow-lg); }
.daterangepicker td.active, .daterangepicker td.active:hover { background: var(--accent) !important; }
.daterangepicker td.in-range { background: var(--accent-light); }
.daterangepicker .drp-buttons .btn.applyBtn { background: var(--accent); border-color: var(--accent); }
.daterangepicker .drp-buttons .btn.cancelBtn { color: var(--danger); }
.daterangepicker .ranges li.active { background: var(--accent); }

.cell-truncate {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
}

@media (max-width: 680px) {
  .daterangepicker {
    width: 92vw !important;
    max-width: 320px;
    left: 16px !important;
    right: 16px !important;
  }

  .daterangepicker .drp-calendar.left,
  .daterangepicker .drp-calendar.right {
    position: static !important;
    display: block !important;
    float: none !important;
    clear: both !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 8px !important;
  }

  .daterangepicker .calendar-table table,
  .daterangepicker .calendar-table {
    width: 100% !important;
    table-layout: fixed !important;
  }

  .daterangepicker .calendar-table td,
  .daterangepicker .calendar-table th {
    width: auto !important;
    min-width: 0 !important;
    padding: 4px 2px !important;
    font-size: 12px !important;
  }

  .daterangepicker .drp-calendar.left { border-right: none; border-bottom: 1px solid var(--border); }

  .daterangepicker .ranges { display: none; }

  .daterangepicker .drp-buttons {
    clear: both;
    display: block !important;
  }
}

.line-items-list {
  margin: 0;
  padding-left: 16px;
  list-style: disc;
  max-height: 90px;
  overflow-y: auto;
}

.line-items-list li {
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.6;
}

.line-items-list li::marker { color: var(--accent); }

/* ---------- Subscription ticker + modal ---------- */

.sub-ticker {
  background: var(--primary);
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  z-index: 60;
}

.sub-ticker-track {
  display: inline-flex;
  gap: 60px;
  padding: 8px 0;
  animation: sub-ticker-scroll 18s linear infinite;
}

.sub-ticker-track span {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding-left: 60px;
}

@keyframes sub-ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.sub-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 24, 0.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

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

.sub-modal {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.sub-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sub-modal-close {
  border: none;
  background: var(--bg);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-soft);
}

.sub-modal-account {
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 18px;
  white-space: pre-line;
}
