:root {
  --bg-color: #0a0b1e;
  --surface-color: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.1);
  --border-color: rgba(255, 255, 255, 0.12);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-primary: #3b82f6;
  --accent-secondary: #2dd4bf;
  --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #2dd4bf 100%);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

:root.light-mode {
  --bg-color: #f3f4f6;
  --surface-color: #ffffff;
  --surface-hover: #e5e7eb;
  --border-color: #d1d5db;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
}

/* Adjust the input background for light mode */
:root.light-mode input,
:root.light-mode select,
:root.light-mode textarea,
:root.light-mode .money-input-wrap .money-display {
  background: #ffffff;
  color: var(--text-primary);
}

:root.light-mode .sidebar {
  background: rgba(243, 244, 246, 0.95);
}

:root.light-mode body {
  background: var(--bg-color);
}

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

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(59, 130, 246, 0.12), transparent 32rem),
    radial-gradient(circle at 80% 90%, rgba(45, 212, 191, 0.1), transparent 30rem),
    var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-family);
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  width: 280px;
  height: 100vh;
  padding: 1.5rem;
  background: rgba(10, 11, 30, 0.82);
  border-right: 1px solid var(--border-color);
}

.sidebar-header,
.user-info,
.nav-item,
.system-status,
.stat-card,
.form-actions,
.toolbar,
.recent-item,
.progress-header {
  display: flex;
  align-items: center;
}

.sidebar-header {
  gap: 0.85rem;
  margin-bottom: 2.25rem;
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.sidebar-brand {
  font-size: 1.25rem;
  font-weight: 800;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.nav-item {
  gap: 0.85rem;
  padding: 0.8rem 0.9rem;
  border-radius: 8px;
  color: var(--text-secondary);
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

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

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

.user-info {
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.14);
  color: var(--accent-secondary);
}

.user-name {
  font-size: 0.88rem;
  font-weight: 700;
}

.user-role,
.cell-secondary,
.form-subtitle,
.text-muted {
  color: var(--text-secondary);
}

.user-role,
.cell-secondary {
  font-size: 0.78rem;
}

.logout-btn {
  color: #fecaca;
}

.main-content {
  flex: 1;
  width: calc(100% - 280px);
  padding: 2rem 3rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.page-title h1 {
  margin-bottom: 0.4rem;
  font-size: 2rem;
}

.page-title p {
  color: var(--text-secondary);
}

.system-status {
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--surface-color);
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card,
.table-container {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--surface-color);
}

.card {
  padding: 1.35rem;
}

.stat-card {
  gap: 1rem;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
}

.stat-icon.blue { background: rgba(59, 130, 246, 0.16); color: var(--accent-primary); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.16); color: var(--warning); }
.stat-icon.green { background: rgba(16, 185, 129, 0.16); color: var(--success); }
.stat-icon.purple { background: rgba(168, 85, 247, 0.16); color: #c084fc; }
.stat-icon.red { background: rgba(239, 68, 68, 0.16); color: var(--danger); }

.stat-label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 800;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

.card-title,
.form-title {
  margin-bottom: 1rem;
}

.form-subtitle {
  margin-top: -0.55rem;
  margin-bottom: 1.25rem;
}

.progress-item + .progress-item {
  margin-top: 1rem;
}

.progress-header {
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-fill {
  height: 100%;
}

.recent-list {
  display: grid;
  gap: 0.75rem;
}

.recent-item {
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.recent-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.recent-contractor,
.cell-primary {
  display: block;
  font-weight: 700;
}

.recent-office {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.recent-right {
  display: grid;
  justify-items: end;
  gap: 0.4rem;
}

.recent-amount {
  font-weight: 700;
}

.toolbar {
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.search-bar {
  position: relative;
  flex: 1;
}

.search-bar svg {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  color: var(--text-secondary);
  transform: translateY(-50%);
}

.search-bar input {
  padding-left: 2.65rem;
}

.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text-secondary);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-approved { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.status-rejected { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.form-card {
  max-width: 760px;
}

.form-group {
  margin-bottom: 1rem;
}

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

label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--text-secondary);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  font: inherit;
}

select option {
  background-color: #0f172a;
  color: #f8fafc;
}

:root.light-mode select option {
  background-color: #ffffff;
  color: #111827;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  border-color: var(--accent-primary);
}

/* ─── Date input dark-mode fix ─── */
input[type="date"] {
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
  position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7) brightness(1.5);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 1;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  filter: invert(0.9) brightness(2);
  background: rgba(59, 130, 246, 0.2);
}

/* ─── Money input with thousand separator ─── */
.money-input-wrap {
  position: relative;
}

.money-input-wrap .money-display {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  font: inherit;
}

.money-input-wrap .money-display:focus {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  border-color: var(--accent-primary);
}

.money-input-wrap .money-display::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.required {
  color: var(--danger);
}

.form-actions {
  justify-content: flex-end;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-success {
  background: rgba(16, 185, 129, 0.16);
  color: #a7f3d0;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
}

.btn-sm {
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.btn-full {
  width: 100%;
}

.alert {
  margin-bottom: 1rem;
  padding: 0.8rem 0.95rem;
  border-radius: 8px;
  font-weight: 700;
}

.alert-success {
  background: rgba(16, 185, 129, 0.14);
  color: #a7f3d0;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
}

.empty-row {
  padding: 1.5rem;
  color: var(--text-secondary);
  text-align: center;
}

.auth-body {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-container {
  width: 100%;
  max-width: 430px;
}

.auth-card {
  padding: 2rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--surface-color);
}

.auth-logo {
  margin-bottom: 1.5rem;
  text-align: center;
}

.auth-logo img {
  width: 76px;
  height: 76px;
  object-fit: contain;
  margin-bottom: 0.8rem;
}

.auth-logo h1 {
  font-size: 1.45rem;
}

.auth-logo p {
  margin-top: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.debug-note {
  margin-top: 1rem;
  color: rgba(148, 163, 184, 0.75);
  font-size: 0.72rem;
  text-align: center;
}

.report-card {
  padding: 0;
  overflow: hidden;
}

.report-card > .form-title,
.report-card > .form-subtitle {
  padding-inline: 1.25rem;
}

.report-card > .form-title {
  padding-top: 1.25rem;
}

.report-table {
  border-inline: 0;
  border-bottom: 0;
  border-radius: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.25s ease forwards;
}

@media (max-width: 900px) {
  .app-container {
    display: block;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
  }

  .main-content {
    width: 100%;
    padding: 1rem;
  }

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

  .page-header,
  .toolbar {
    flex-direction: column;
  }
}

/* Theme Toggle Icon Logic */
.moon-icon { display: none; }
:root.light-mode .moon-icon { display: block; }
:root.light-mode .sun-icon { display: none; }

/* Enhanced Light Mode Styles */
:root.light-mode .card,
:root.light-mode .auth-card,
:root.light-mode .table-container {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.05);
}

