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

:root {
  /* Vibrant Coral Palette */
  --color-vibrant-coral-50: #fceae8;
  --color-vibrant-coral-100: #fad6d1;
  --color-vibrant-coral-200: #f5ada3;
  --color-vibrant-coral-300: #f08475;
  --color-vibrant-coral-400: #eb5a47;
  --color-vibrant-coral-500: #e63119;
  --color-vibrant-coral-600: #b82714;
  --color-vibrant-coral-700: #8a1e0f;
  --color-vibrant-coral-800: #5c140a;
  --color-vibrant-coral-900: #2e0a05;
  --color-vibrant-coral-950: #200704;

  --brand-dark: #8a1e0f;
  --brand-light: #fceae8;
  --primary: #e63119;
  --primary-hover: #b82714;
  --secondary: #6b7280;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1f2937;
  --text-muted: #6b7280;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --sidebar-bg: #1e293b;
  --sidebar-active: #0f172a;
}

body.theme-dark {
  --bg: #1c2028;
  --surface: #252b35;
  --border: #343b47;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --sidebar-bg: #161a20;
  --sidebar-active: #2a303c;
  --primary: #eb5a47;
  --primary-hover: #e63119;
}

body.theme-light {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1f2937;
  --text-muted: #6b7280;
  --sidebar-bg: #1e293b;
  --sidebar-active: #334155;
  --primary: #e63119;
  --primary-hover: #b82714;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: width 0.25s ease, background 0.25s ease;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.sidebar-brand p {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
}

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

.nav-section {
  padding: 14px 20px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-size: 14px;
  color: #cbd5e1;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-left: 3px solid transparent;
  margin: 0;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

.nav-item:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left-color: var(--primary);
}

.nav-item .icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .icon,
.nav-item:hover .icon {
  opacity: 1;
}

.main {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

body.sidebar-collapsed .sidebar {
  width: 80px;
}

body.sidebar-collapsed .main {
  margin-left: 80px;
}

body.sidebar-collapsed .sidebar-brand {
  padding: 16px 12px;
}

body.sidebar-collapsed .sidebar-brand h1 {
  font-size: 0;
  position: relative;
}

body.sidebar-collapsed .sidebar-brand h1::before {
  content: 'AQ';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: #fff;
}

body.sidebar-collapsed .sidebar-brand p,
body.sidebar-collapsed .nav-section {
  display: none;
}

body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 12px 0;
  border-left: 3px solid transparent;
}

body.sidebar-collapsed .nav-item.active {
  border-left: 3px solid var(--primary);
}

body.sidebar-collapsed .nav-item .nav-label {
  display: none;
}

body.sidebar-collapsed .nav-item .icon {
  margin-right: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar .btn {
  min-width: 44px;
}

.topbar h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.topbar-user {
  font-size: 13px;
  color: var(--text-muted);
}

.content {
  padding: 28px;
  flex: 1;
}

/* ---- Pages ---- */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

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

.stat-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  margin-top: 8px;
  color: var(--text);
}

.stat-card.blue .stat-value {
  color: var(--primary);
}

.stat-card.green .stat-value {
  color: #059669;
}

.stat-card.orange .stat-value {
  color: #d97706;
}

.stat-card.red .stat-value {
  color: #dc2626;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow);
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 20px;
}

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
}

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

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

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--bg);
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-pending {
  background: #fef3c7;
  color: #78350f;
}

.badge-assigned {
  background: #dbeafe;
  color: #1e40af;
}

.badge-in_progress {
  background: #e9d5ff;
  color: #5b21b6;
}

.badge-executed {
  background: #d1fae5;
  color: #065f46;
}

.badge-closed {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge-cancelled {
  background: #f3f4f6;
  color: #374151;
}

.badge-draft {
  background: #f3f4f6;
  color: #374151;
}

.badge-submitted {
  background: #dbeafe;
  color: #1e40af;
}

.badge-validated {
  background: #d1fae5;
  color: #065f46;
}

.badge-paid {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.badge-awaiting {
  background: #fef3c7;
  color: #78350f;
}

.badge-valuation_pending {
  background: #fed7aa;
  color: #92400e;
}

.badge-confirmed {
  background: #d1fae5;
  color: #065f46;
}

.badge-rejected_bank {
  background: #fee2e2;
  color: #991b1b;
}

/* Status pill */
.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-pill.on {
  background: #d1fae5;
  color: #065f46;
}

.status-pill.off {
  background: #f3f4f6;
  color: #6b7280;
}

.nav-label {
  display: inline-block;
  flex: 1;
  text-align: left;
}

.hero-banner {
  display: none;
  border-radius: var(--radius);
  padding: 28px;
  color: #fff;
  box-shadow: var(--shadow-lg);
  margin-bottom: 28px;
  background: linear-gradient(135deg, #e63119 0%, #b82714 100%);
}

body.theme-light .hero-banner {
  display: block;
  background: linear-gradient(135deg, #e63119 0%, #8a1e0f 100%);
}

body.theme-dark .hero-banner {
  display: block;
  background: linear-gradient(135deg, #3d1008 0%, #252b35 100%);
  color: #fff;
}

body.theme-dark .hero-banner p {
  opacity: 0.85;
}

.hero-banner h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.hero-banner p {
  font-size: 14px;
  opacity: 0.95;
  margin-bottom: 16px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(230, 49, 25, 0.3);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--primary);
}

.btn-success {
  background: #059669;
  color: #fff;
  border-color: #059669;
}

.btn-success:hover:not(:disabled) {
  background: #047857;
  border-color: #047857;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

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

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  transition: border 0.15s, box-shadow 0.15s;
  color: var(--text);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230, 49, 25, 0.1);
}

.form-control:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-control.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row.cols3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal-backdrop > .modal {
  margin: auto;
  flex-shrink: 0;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-lg {
  max-width: 860px;
}

.modal-xl {
  max-width: min(94vw, 1320px);
  width: min(94vw, 1320px);
}

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

.modal-header h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg);
}

/* ---- Alerts ---- */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.6;
  border-left: 4px solid transparent;
}

.alert-info {
  background: var(--color-vibrant-coral-50);
  color: var(--color-vibrant-coral-700);
  border-left-color: var(--color-vibrant-coral-500);
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border-left-color: #059669;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border-left-color: #d97706;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border-left-color: #dc2626;
}

/* ---- Filters ---- */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.filters .form-control {
  width: auto;
  min-width: 160px;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 15px;
  margin-bottom: 20px;
}

/* ---- Spinner ---- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

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

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

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

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  min-width: 280px;
  max-width: 400px;
  border-left: 4px solid transparent;
}

.toast.success {
  border-left-color: #059669;
}

.toast.error {
  border-left-color: #dc2626;
}

.toast.info {
  border-left-color: var(--primary);
}

@keyframes slideIn {
  from {
    transform: translateX(100px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* ---- Contract Gate ---- */
.contract-gate-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.contract-gate-card {
  max-width: 520px;
  width: 100%;
  text-align: center;
}

.contract-gate-card .card-body {
  padding: 56px 40px;
}

.contract-gate-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: #eff6ff;
  border-radius: 50%;
  color: var(--primary);
  margin-bottom: 24px;
  font-size: 40px;
}

.contract-gate-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.contract-gate-body {
  color: var(--text-muted);
  margin-bottom: 12px;
  font-size: 15px;
}

.contract-gate-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 32px;
}

.contract-gate-status {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Payslip ---- */
.payslip {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.payslip-header {
  background: linear-gradient(135deg, #e63119 0%, #8a1e0f 100%);
  color: #fff;
  padding: 24px;
}

.payslip-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.payslip-header p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  margin: 2px 0;
}

.payslip-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.payslip-info-col {
  padding: 16px 24px;
}

.payslip-info-col:first-child {
  border-right: 1px solid var(--border);
}

.payslip-info-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.payslip-info-row .lbl {
  color: var(--text-muted);
  font-size: 13px;
}

.payslip-info-row .val {
  font-weight: 600;
  color: var(--text);
}

.payslip-section {
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.payslip-section-header {
  background: var(--bg);
  padding: 10px 24px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.payslip-section table {
  width: 100%;
  border-collapse: collapse;
}

.payslip-section td {
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.payslip-section td:last-child {
  text-align: right;
  font-weight: 600;
}

.payslip-section tr:last-child td {
  border-bottom: none;
}

.payslip-subtotal {
  background: var(--bg);
}

.payslip-subtotal td {
  font-weight: 700 !important;
  color: var(--text);
}

.payslip-total {
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border-top: 2px solid var(--border);
}

.payslip-total .label {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.payslip-total .amount {
  font-size: 24px;
  font-weight: 800;
  color: #059669;
}

.payslip-empty {
  padding: 16px 24px;
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
}

/* ---- Document Checklist ---- */
.doc-checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.doc-checklist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: all 0.15s;
}

.doc-checklist-row:hover {
  border-color: var(--primary);
}

.doc-checklist-row.uploaded {
  border-color: #a7f3d0;
  background: #f0fdf4;
}

.doc-checklist-row.missing {
  border-color: #fecaca;
  background: #fef2f2;
}

.doc-check-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.doc-check-icon.ok {
  background: #059669;
  color: #fff;
}

.doc-check-icon.warn {
  background: #d97706;
  color: #fff;
}

.doc-check-icon.miss {
  background: var(--border);
  color: var(--text-muted);
}

.doc-check-label {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
}

.doc-check-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.doc-check-actions {
  display: flex;
  gap: 8px;
}

.badge-expiring {
  background: #fef3c7;
  color: #78350f;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-expired {
  background: #fee2e2;
  color: #991b1b;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-valid {
  background: #d1fae5;
  color: #065f46;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.alert-cdc {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 20px;
  color: #78350f;
}

.alert-cdc ul {
  margin: 4px 0 0 16px;
  font-size: 13px;
}

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

.fica-actions .fica-label {
  font-size: 14px;
  color: var(--text-muted);
}

/* ---- Rate Card Pills (agent table inline select) ---- */
select.rc-pill {
  -webkit-appearance: none;
  appearance: none;
  padding: 3px 10px;
  border-radius: 20px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  outline: none;
  min-width: 80px;
  letter-spacing: 0.02em;
}
select.rc-pill:focus { box-shadow: 0 0 0 2px rgba(59,130,246,0.4); }
select.rc-pill.rc-none        { background: #e2e8f0; color: #475569; }
select.rc-pill.rc-tracer      { background: #dbeafe; color: #1e40af; }
select.rc-pill.rc-ext-tracer  { background: #e0f2fe; color: #0c4a6e; }
select.rc-pill.rc-edc         { background: #d1fae5; color: #065f46; }
select.rc-pill.rc-ext-edc     { background: #ccfbf1; color: #134e4a; }
select.rc-pill.rc-anpr        { background: #ede9fe; color: #4c1d95; }
select.rc-pill.rc-ftv         { background: #fce7f3; color: #831843; }
select.rc-pill.rc-teamlead    { background: #ffedd5; color: #7c2d12; }
select.rc-pill.rc-coord       { background: #fef9c3; color: #713f12; }
select.rc-pill.rc-crm         { background: #ccfbf1; color: #134e4a; }

body.theme-dark select.rc-pill.rc-none       { background: #334155; color: #cbd5e1; }
body.theme-dark select.rc-pill.rc-tracer     { background: #1e3a5f; color: #93c5fd; }
body.theme-dark select.rc-pill.rc-ext-tracer { background: #164e63; color: #7dd3fc; }
body.theme-dark select.rc-pill.rc-edc        { background: #064e3b; color: #6ee7b7; }
body.theme-dark select.rc-pill.rc-ext-edc    { background: #134e4a; color: #5eead4; }
body.theme-dark select.rc-pill.rc-anpr       { background: #3b0764; color: #c4b5fd; }
body.theme-dark select.rc-pill.rc-ftv        { background: #500724; color: #fbcfe8; }
body.theme-dark select.rc-pill.rc-teamlead   { background: #431407; color: #fdba74; }
body.theme-dark select.rc-pill.rc-coord      { background: #422006; color: #fde68a; }
body.theme-dark select.rc-pill.rc-crm        { background: #134e4a; color: #5eead4; }

/* ---- Rate Card Modal Pill Picker ---- */
.rc-pill-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 6px 0 4px;
}

.rc-pill-btn {
  padding: 4px 13px;
  border-radius: 20px;
  border: 2px solid transparent;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  opacity: 0.52;
  transition: opacity 0.15s, border-color 0.15s, box-shadow 0.15s;
  line-height: 1.6;
  letter-spacing: 0.03em;
}
.rc-pill-btn:hover  { opacity: 0.85; }
.rc-pill-btn.selected {
  opacity: 1;
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}
.rc-pill-btn.rc-none       { background: #e2e8f0; color: #475569; }
.rc-pill-btn.rc-tracer     { background: #dbeafe; color: #1e40af; }
.rc-pill-btn.rc-ext-tracer { background: #e0f2fe; color: #0c4a6e; }
.rc-pill-btn.rc-edc        { background: #d1fae5; color: #065f46; }
.rc-pill-btn.rc-ext-edc    { background: #ccfbf1; color: #134e4a; }
.rc-pill-btn.rc-anpr       { background: #ede9fe; color: #4c1d95; }
.rc-pill-btn.rc-ftv        { background: #fce7f3; color: #831843; }
.rc-pill-btn.rc-teamlead   { background: #ffedd5; color: #7c2d12; }
.rc-pill-btn.rc-coord      { background: #fef9c3; color: #713f12; }
.rc-pill-btn.rc-crm        { background: #ccfbf1; color: #134e4a; }

/* ---- Bank Multi-select Chips ---- */
.bank-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 48px;
  cursor: default;
  transition: border-color 0.15s;
}
.bank-chip-wrap:focus-within { border-color: var(--primary); }

.bank-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
  font-family: 'Poppins', sans-serif;
}
.bank-chip:hover { border-color: var(--primary); color: var(--primary); }
.bank-chip.selected {
  background: var(--color-vibrant-coral-50);
  color: var(--color-vibrant-coral-700);
  border-color: var(--color-vibrant-coral-500);
}
body.theme-dark .bank-chip.selected {
  background: #3d0f07;
  color: var(--color-vibrant-coral-300);
  border-color: var(--color-vibrant-coral-400);
}

.bank-chip-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 2px;
  font-style: italic;
}

/* ──────────────────────────────────────────────────────────
   RESPONSIVE — Mobile-first overlay sidebar + fluid grid
   ────────────────────────────────────────────────────────── */

/* ── Sidebar backdrop overlay (mobile) ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* ── Hamburger: hidden on desktop, visible on mobile ── */
.sidebar-toggle {
  display: none !important;
}

/* ── Tablet: slightly narrower sidebar ── */
@media (max-width: 1200px) {
  .sidebar { width: 240px; }
  .main    { margin-left: 240px; }
  body.sidebar-collapsed .sidebar { width: 80px; }
  body.sidebar-collapsed .main    { margin-left: 80px; }
}

/* ── Small tablet / large phone landscape (≤ 900px) ── */
@media (max-width: 900px) {
  .sidebar { width: 220px; }
  .main    { margin-left: 220px; }
  body.sidebar-collapsed .main { margin-left: 80px; }

  .content { padding: 20px; }

  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }

  .form-row.cols3 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Mobile (≤ 768px) — full overlay drawer ── */
@media (max-width: 768px) {
  /* Hamburger becomes visible */
  .sidebar-toggle {
    display: inline-flex !important;
    padding: 8px 10px;
  }

  /* Sidebar slides off-screen by default */
  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    /* Keep z-index above backdrop */
    z-index: 110;
    box-shadow: none;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.25s ease;
  }

  /* When open: slide in + show backdrop */
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  /* Main always full width on mobile */
  .main {
    margin-left: 0 !important;
  }

  /* Collapsed class irrelevant on mobile — ignore it */
  body.sidebar-collapsed .sidebar {
    width: 260px;
    transform: translateX(-100%);
  }

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

  /* Topbar */
  .topbar {
    padding: 12px 16px;
    gap: 8px;
  }

  .topbar h2 {
    font-size: 16px;
  }

  .topbar-left,
  .topbar-right {
    gap: 8px;
  }

  .topbar-user {
    display: none; /* reclaimed by profile in nav on mobile */
  }

  /* Content */
  .content {
    padding: 16px;
  }

  /* Stats grid — single column */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }

  .stat-card .stat-value {
    font-size: 26px;
  }

  /* Form grids — single column */
  .form-row,
  .form-row.cols3 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Card header may need to stack */
  .card-header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 16px;
  }

  .card-body {
    padding: 14px 16px;
  }

  /* Filters: allow horizontal scroll on very small screens */
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    overscroll-behavior-x: contain;
  }

  .filters .form-control {
    min-width: 120px;
    flex-shrink: 0;
  }

  /* Modals: full-width on mobile */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end; /* sheet slides up from bottom */
  }

  .modal,
  .modal-lg,
  .modal-xl {
    max-width: 100%;
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius) var(--radius) 0 0;
    margin: 0;
  }

  /* Toast: full width at bottom */
  #toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    min-width: unset;
    max-width: 100%;
  }

  /* Table: allow horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  /* Payslip */
  .payslip-info {
    grid-template-columns: 1fr;
  }

  .payslip-info-col:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  /* Hero banner smaller */
  .hero-banner {
    padding: 20px 16px;
    margin-bottom: 20px;
  }

  .hero-banner h2 {
    font-size: 18px;
  }

  /* Buttons in topbar: icon-only on very small screens */
  .theme-toggle .btn-label {
    display: none;
  }
}

/* ── Very small phones (≤ 390px) ── */
@media (max-width: 390px) {
  .topbar {
    padding: 10px 12px;
  }

  .content {
    padding: 12px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card .stat-value {
    font-size: 22px;
  }

  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
}

/* ---- Mono Dark Slate Theme ---- */
body.theme-mono {
  --bg: #0d0f13;
  --surface: #141720;
  --border: #1e2433;
  --text: #e8ecf4;
  --text-muted: #8892a4;
  --sidebar-bg: #0a0c10;
  --sidebar-active: #1a2030;
  --primary: #e63119;
  --primary-hover: #b82714;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
}

body.theme-mono .hero-banner {
  background: linear-gradient(135deg, #1a2030 0%, #0a0c10 100%) !important;
  border: 1px solid #1e2433;
}

body.theme-mono .stat-card {
  background: #141720;
  border-color: #1e2433;
}

body.theme-mono .stat-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow);
}

body.theme-mono .card {
  background: #141720;
  border-color: #1e2433;
}

body.theme-mono .topbar {
  background: #0a0c10;
  border-bottom-color: #1e2433;
}

body.theme-mono .payslip-header {
  background: linear-gradient(135deg, #1a2030 0%, #0a0c10 100%) !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

body.theme-mono thead th {
  background: #0d0f13;
}

body.theme-mono .modal {
  background: #141720;
  border: 1px solid #1e2433;
}

body.theme-mono .form-control {
  background: #0d0f13;
  border-color: #1e2433;
  color: #e8ecf4;
}

body.theme-mono .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230, 49, 25, 0.15);
}

body.theme-mono .btn-secondary {
  background: #1a2030;
  border-color: #1e2433;
  color: #e8ecf4;
}

body.theme-mono .btn-secondary:hover:not(:disabled) {
  background: #1e2433;
  border-color: var(--primary);
}

body.theme-mono .alert-info {
  background: #141c2c;
  color: #a5b4fc;
  border-left-color: #6366f1;
}

body.theme-mono .badge-assigned {
  background: #1a2030;
  color: #93c5fd;
}

body.theme-mono .payslip-section {
  border-bottom-color: #1e2433;
}

/* Province map in mono */
body.theme-mono #province-map-svg rect {
  stroke: #0a0c10;
}

/* ---- Print: Landscape Nett Commission Statement ---- */
@media print {
  @page { size: A4 landscape; margin: 12mm 15mm; }

  body > *:not(#print-area) {
    display: none !important;
  }

  #print-area {
    display: block !important;
  }

  .payslip {
    border: none;
    box-shadow: none;
    font-size: 12px;
    max-width: 100%;
  }

  .payslip-header {
    background: #1e293b !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 16px 24px;
  }

  .payslip-info {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .payslip-section td {
    padding: 7px 16px;
    font-size: 12px;
  }

  .payslip-total .label  { font-size: 14px; }
  .payslip-total .amount { font-size: 20px; }

  .modal-backdrop, .modal-header, .filters,
  .btn, .card { display: none !important; }

  #payslip-content { display: block !important; }
}

/* Leaflet province tooltip override */
.prov-tooltip {
  font-family: 'Poppins', sans-serif;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.prov-tooltip::before { display: none; }
