/* style.css */
/* Rental Car Management System (RCMS) - Muzammil Rent A Car */
/* Premium Dark Theme Stylesheet */

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

:root {
  /* Backgrounds */
  --bg-primary: #0d1117;
  /* Main dark background */
  --bg-secondary: #161b22;
  /* Sidebar, cards */
  --bg-tertiary: #1c2128;
  /* Table rows, inputs */
  --bg-hover: #21262d;
  /* Hover states */
  --bg-card: #161b22;
  /* KPI cards */
  --bg-modal: #161b22;
  /* Modals */

  /* Accent — Gold/Amber (car rental vibe) */
  --accent-primary: #f0a500;
  /* Primary buttons, active states */
  --accent-hover: #d4920a;
  /* Button hover */
  --accent-light: #f0a50022;
  /* Accent backgrounds (badges, highlights) */

  /* Status Colors */
  --success: #2ea043;
  --success-bg: #2ea04322;
  --danger: #f85149;
  --danger-bg: #f8514922;
  --warning: #e3b341;
  --warning-bg: #e3b34122;
  --info: #58a6ff;
  --info-bg: #58a6ff22;

  /* Text */
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --text-accent: #f0a500;

  /* Borders */
  --border-color: #30363d;
  --border-hover: #f0a50066;

  /* Sidebar */
  --sidebar-width: 260px;

  /* Misc */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: all 0.2s ease;
}

body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
}

h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.text-muted {
  color: var(--text-secondary) !important;
}

.text-accent {
  color: var(--text-accent);
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo img {
  max-width: 100%;
  height: auto;
}

/* Sidebar Navigation */
.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

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

.nav-link-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 0;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

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

.nav-link-item.active {
  background: var(--accent-light);
  color: var(--accent-primary);
  border-left-color: var(--accent-primary);
  font-weight: 600;
}

.nav-link-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-primary);
  transition: var(--transition);
}

/* Top Navbar */
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.content-wrapper {
  padding: 24px;
  flex: 1;
}

/* KPI Cards */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: var(--transition);
  cursor: pointer;
  height: 100%;
  min-height: auto;
}

.kpi-icon {
  flex-shrink: 0;
}

.kpi-subvalue {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

.kpi-value {
  font-size: 1.4rem !important;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-label {
  font-size: 12px;
}

@media (max-width: 576px) {
  .kpi-card {
    padding: 12px 14px;
    gap: 10px;
  }
  .kpi-value {
    font-size: 1.2rem !important;
  }
  .kpi-label {
    font-size: 11px;
  }
}

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

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.kpi-icon.gold {
  background: var(--accent-light);
  color: var(--accent-primary);
}

.kpi-icon.green {
  background: var(--success-bg);
  color: var(--success);
}

.kpi-icon.red {
  background: var(--danger-bg);
  color: var(--danger);
}

.kpi-icon.blue {
  background: var(--info-bg);
  color: var(--info);
}

.kpi-icon.yellow {
  background: var(--warning-bg);
  color: var(--warning);
}

.kpi-details {
  flex: 1;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

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

.kpi-toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.kpi-label-compact {
  margin-top: 0;
  line-height: 1.35;
}

.kpi-range-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.kpi-range-toggle button {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  transition: var(--transition);
}

.kpi-range-toggle button:hover {
  color: var(--text-primary);
}

.kpi-range-toggle button.active {
  background: var(--accent-primary);
  color: #0d1117;
}

.kpi-subvalue {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

/* Tables */
.table-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 24px;
  width: 100%;
  max-width: 100%;
}

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

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

.rcms-table thead th {
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.rcms-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

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

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

/* Buttons */
.btn-rcms {
  background: var(--accent-primary);
  color: #0d1117;
  border: none;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.btn-rcms:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  color: #0d1117;
}

.btn-rcms-outline {
  background: transparent;
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.btn-rcms-outline:hover {
  background: var(--accent-light);
  color: var(--accent-primary);
}

.btn-danger-rcms {
  background: var(--danger);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger-rcms:hover {
  background: #d13d36;
}

.btn-success-rcms {
  background: var(--success);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-success-rcms:hover {
  background: #258535;
}

.btn-video-rcms {
  background: #6f42c1;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-video-rcms:hover {
  background: #5a32a3;
  transform: translateY(-1px);
}

.filter-pill {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.filter-pill.active,
.filter-pill:hover {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Forms & Inputs */
.form-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.form-control-rcms {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
  transition: var(--transition);
  outline: none;
}

.form-control-rcms:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--bg-hover);
}

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

.form-control-rcms[readonly] {
  background: var(--bg-primary);
  color: var(--accent-primary);
  font-weight: 600;
  cursor: default;
}

select.form-control-rcms {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.day-quick-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.day-quick-btn:hover,
.day-quick-btn.active {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 600;
}

/* Badges & Status Pills */
.badge-rcms {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-active {
  background: var(--info-bg);
  color: var(--info);
}

.badge-returned {
  background: var(--success-bg);
  color: var(--success);
}

.badge-overdue {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-available {
  background: var(--success-bg);
  color: var(--success);
}

.badge-rented {
  background: var(--warning-bg);
  color: var(--warning);
}

/* Modals */
.modal-rcms .modal-content {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
}

.modal-rcms .modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
}

.modal-rcms .modal-title {
  font-weight: 600;
  font-size: 15px;
}

.modal-rcms .modal-body {
  padding: 20px;
}

.modal-rcms .modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 14px 20px;
}

.modal-rcms .btn-close {
  filter: invert(1) opacity(0.6);
}

.modal-rcms .modal-dialog {
  width: calc(100% - 1.5rem);
  max-width: min(1140px, calc(100% - 1.5rem));
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-rcms {
  min-width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  color: var(--text-primary);
}

.toast-rcms.success {
  border-left: 4px solid var(--success);
}

.toast-rcms.error {
  border-left: 4px solid var(--danger);
}

.toast-rcms.warning {
  border-left: 4px solid var(--warning);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Video Upload Section */
.video-upload-section {
  background: var(--bg-tertiary);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  transition: var(--transition);
}

.video-upload-section:hover {
  border-color: var(--accent-primary);
}

.upload-btn-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.qr-container {
  margin-top: 16px;
  padding: 16px;
  background: white;
  border-radius: var(--radius-md);
  display: inline-block;
}

.qr-container img {
  width: 160px;
  height: 160px;
}

.qr-status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

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

.video-preview {
  margin-top: 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  display: none;
}

.video-preview video {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
}

/* Autocomplete/Live Search Dropdown */
.autocomplete-suggestions {
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  position: absolute;
  z-index: 999;
  width: 100%;
  box-shadow: var(--shadow);
}

.autocomplete-suggestion {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.autocomplete-suggestion:hover {
  background: var(--bg-hover);
}

.autocomplete-suggestion:last-child {
  border-bottom: none;
}

/* Settings Page Tabs */
.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.settings-tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

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

.settings-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 600;
}

.settings-pane {
  display: none;
}

.settings-pane.active {
  display: block;
}

/* Loading States */
.ajax-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(13, 17, 23, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}

.spinner-gold {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* Invoice — Print Styles */
.invoice-page {
  background: white;
  color: #333;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
}

.invoice-header {
  text-align: center;
  border-bottom: 2px solid #333;
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.invoice-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: #1a1a1a;
  margin: 0;
}

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

.invoice-meta-column {
  display: flex;
  flex-direction: column;
}

.invoice-meta-row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dotted #ccc;
}

.invoice-meta-label {
  font-weight: 600;
  color: #555;
  min-width: 140px;
}

.invoice-meta-value {
  color: #111;
  flex: 1;
}

.invoice-totals {
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 16px;
  margin: 20px 0;
}

.invoice-total-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
}

.invoice-total-row:last-child {
  border-bottom: none;
}

.invoice-total-row.final {
  font-size: 16px;
  font-weight: 700;
  color: #c47f00;
  border-top: 2px solid #333;
  border-bottom: none;
  margin-top: 8px;
  padding-top: 8px;
}

.invoice-terms {
  margin-top: 24px;
  font-size: 11px;
  color: #666;
  border-top: 1px solid #ddd;
  padding-top: 16px;
}

.invoice-terms ol {
  padding-left: 20px;
  margin: 8px 0;
}

.invoice-terms li {
  margin-bottom: 6px;
  line-height: 1.4;
}

.invoice-signatures {
  margin-top: 48px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  text-align: center;
}

.signature-line {
  border-top: 1px solid #333;
  padding-top: 8px;
  font-size: 11px;
  color: #666;
  margin-top: 48px;
}

/* Print — hide everything except invoice */
@media print {

  .sidebar,
  .topbar,
  .no-print,
  .btn,
  .btn-rcms,
  .btn-rcms-outline {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .invoice-page {
    padding: 10px;
    max-width: 100%;
  }

  body {
    background: white !important;
    color: #333 !important;
  }
}

/* Tablet Responsive */
@media (max-width: 992px) {
  .sidebar {
    width: 0;
    overflow: hidden;
  }

  .sidebar.open {
    width: min(82vw, var(--sidebar-width));
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
  }

  .main-content {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: block;
  }

  .kpi-card {
    padding: 14px;
  }

  .kpi-value {
    font-size: 1.4rem;
  }

  .table-card-header {
    flex-wrap: wrap;
    gap: 12px;
  }

  .table-card-header>* {
    min-width: 0;
  }

  .settings-tabs,
  .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
  }

  .settings-tab,
  .nav-tabs .nav-link {
    white-space: nowrap;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    top: 16px;
  }

  .toast-rcms {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .content-wrapper {
    padding: 18px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .topbar-title {
    gap: 10px;
  }

  .kpi-card {
    padding: 16px;
    gap: 14px;
  }

  .kpi-icon {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .kpi-toggle-row {
    flex-direction: column;
    align-items: stretch;
  }

  .kpi-range-toggle {
    align-self: flex-start;
  }

  .table-card-header {
    padding: 14px 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .table-card-header .btn,
  .table-card-header .btn-rcms,
  .table-card-header .btn-rcms-outline {
    width: 100%;
    justify-content: center;
  }

  .table-responsive {
    max-height: none;
  }

  .stat-card {
    padding: 16px;
  }

  .filter-pill {
    text-align: center;
  }

  .modal-rcms .modal-dialog {
    width: calc(100% - 1rem);
    max-width: calc(100% - 1rem);
    margin: 0.5rem auto;
  }

  .modal-rcms .modal-body,
  .modal-rcms .modal-header,
  .modal-rcms .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .modal-rcms .modal-footer {
    gap: 10px;
    flex-wrap: wrap;
  }

  .modal-rcms .modal-footer .btn,
  .modal-rcms .modal-footer .btn-rcms,
  .modal-rcms .modal-footer .btn-rcms-outline {
    flex: 1 1 180px;
    justify-content: center;
  }

  .upload-btn-group {
    justify-content: stretch;
  }

  .upload-btn-group>* {
    flex: 1 1 100%;
    justify-content: center;
  }

  .rcms-table tbody td .btn,
  .rcms-table tbody td a.btn,
  .rcms-table tbody td button.btn-rcms-outline,
  .rcms-table tbody td button.btn-danger-rcms,
  .rcms-table tbody td button.btn-success-rcms {
    width: auto !important;
    min-width: 78px;
    height: auto !important;
    padding: 6px 10px !important;
  }
}

/* Mobile Responsive Stacked Table */
@media (max-width: 767px) {
  .rcms-table,
  .rcms-table thead,
  .rcms-table tbody,
  .rcms-table th,
  .rcms-table td,
  .rcms-table tr {
    display: block;
  }

  .rcms-table thead {
    display: none;
  }

  .rcms-table tr {
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
  }

  .rcms-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  .rcms-table td:last-child {
    border-bottom: none;
  }

  .rcms-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 10px;
  }
}

/* Mobile Responsive */
@media (max-width: 576px) {
  .content-wrapper {
    padding: 16px;
  }

  .topbar {
    padding: 10px 14px;
  }

  .topbar-title h1 {
    font-size: 1.1rem;
  }

  .form-section {
    padding: 14px;
  }

  .btn-rcms,
  .btn-rcms-outline,
  .btn-danger-rcms,
  .btn-success-rcms,
  .btn-video-rcms {
    width: 100%;
    justify-content: center;
  }

  .upload-btn-group {
    flex-direction: column;
  }

  .kpi-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .kpi-details {
    width: 100%;
  }

  .kpi-value {
    font-size: 1.35rem;
  }

  .kpi-range-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .kpi-range-toggle button {
    flex: 1 1 50%;
    text-align: center;
  }

  .settings-tabs {
    gap: 0;
  }

  .settings-tab {
    padding: 10px 14px;
  }

  .nav-tabs .nav-link {
    padding: 10px 14px;
  }

  .rcms-table thead {
    display: none;
  }

  .rcms-table thead th {
    position: static;
  }

  .rcms-table tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    background: var(--bg-secondary);
  }

  .rcms-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
    flex-wrap: wrap;
  }

  .rcms-table tbody td:last-child {
    border-bottom: none;
  }

  .rcms-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    text-align: left;
    margin-right: 15px;
    flex: 0 0 42%;
  }

  .rcms-table tbody td>* {
    max-width: 100%;
  }

  .rcms-table tbody td.text-end {
    justify-content: flex-start !important;
  }

  .rcms-table tbody td.text-end::before {
    flex-basis: 100%;
    margin-right: 0;
    margin-bottom: 4px;
  }

  .rcms-table tbody td .btn,
  .rcms-table tbody td a.btn,
  .rcms-table tbody td button.btn-rcms-outline,
  .rcms-table tbody td button.btn-danger-rcms,
  .rcms-table tbody td button.btn-success-rcms {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
    margin: 0 !important;
  }

  .modal-rcms .modal-dialog {
    width: calc(100% - 0.75rem);
    max-width: calc(100% - 0.75rem);
  }

  .modal-rcms .modal-content {
    border-radius: 12px;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    top: 12px;
  }
}

/* --- Phase 4 Layout, Scrolling Tables & Pagination Updates --- */

/* Constrain main layout elements to prevent flexbox overflow */
.main-content {
  min-width: 0;
}

.content-wrapper {
  min-width: 0;
  overflow-x: hidden;
}

/* Scrollable table container with sticky headers */
.table-responsive {
  max-height: 480px;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
  width: 100%;
  max-width: 100%;
  /* Smooth scrollbars for premium look */
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--bg-secondary);
}

.table-responsive::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.table-responsive::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Sticky table headers on vertical scroll */
.rcms-table thead th {
  position: sticky;
  top: 0;
  z-index: 12;
  background: var(--bg-secondary) !important;
  /* Overwrite hover state transparency */
  box-shadow: inset 0 -1px 0 var(--border-color);
}

/* Uniform action buttons inside tables */
.rcms-table tbody td .btn,
.rcms-table tbody td a.btn,
.rcms-table tbody td button.btn-rcms-outline,
.rcms-table tbody td button.btn-danger-rcms,
.rcms-table tbody td button.btn-success-rcms {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 85px !important;
  height: 28px !important;
  padding: 0 !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  box-sizing: border-box !important;
  gap: 4px !important;
  margin: 2px !important;
  /* Add space around stacked buttons */
  white-space: nowrap !important;
  text-decoration: none !important;
}

/* Override padding/icons alignment inside action buttons */
.rcms-table tbody td .btn i,
.rcms-table tbody td a.btn i {
  font-size: 11px !important;
  margin: 0 !important;
}

/* Custom premium styling for pagination controls matching the gold accent theme */
.pagination-rcms .page-item .page-link {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 13px;
  transition: var(--transition);
}

.pagination-rcms .page-item.active .page-link {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #0d1117;
  font-weight: 600;
}

.pagination-rcms .page-item .page-link:hover {
  background: var(--bg-hover);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.pagination-rcms .page-item.disabled .page-link {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ─── V2 ADDITIONS ─── */

/* Stat Cards (Finances / Reports pages) */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  transition: var(--transition);
}

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

.stat-icon {
  font-size: 22px;
  color: var(--accent-primary);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

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

/* Cursor helper */
.cursor-pointer {
  cursor: pointer;
}

/* Bootstrap Nav Tabs — dark override */
.nav-tabs {
  border-bottom-color: var(--border-color) !important;
}

.nav-tabs .nav-link {
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
  transition: var(--transition);
}

.nav-tabs .nav-link:hover {
  color: var(--text-primary);
  border-bottom-color: var(--border-color);
}

.nav-tabs .nav-link.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: transparent;
  font-weight: 600;
}

/* Document preview thumbnails (customer modal) */
.doc-preview-thumb {
  display: inline-block;
}

.doc-preview-thumb img {
  width: 60px;
  height: 45px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

/* Challan pending badge indicator in nav */
.nav-link-item.has-badge {
  border-left-color: var(--danger);
}

/* Period-type / Payment-type radio buttons styled as pills */
.period-type-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
  user-select: none;
}

.period-type-btn:has(input:checked),
.period-type-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #0d1117;
}

.period-type-btn input[type="radio"] {
  display: none;
}