/* ── Reset & Base ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f0f2f5;
  color: #1a202c;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ───────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  background: linear-gradient(180deg, #1a202c 0%, #2d3748 100%);
  color: #e2e8f0;
  padding: 1.5rem 0;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  margin-bottom: 1rem;
}

.sidebar-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #fff;
}

.sidebar-brand small {
  font-size: .7rem;
  color: #718096;
  font-weight: 400;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 1.25rem;
  color: #a0aec0;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, .06);
  border-left-color: #667eea;
}

.sidebar-nav a .icon {
  font-size: 1rem;
  width: 1.2rem;
  text-align: center;
}

.sidebar-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-bottom button {
  background: none;
  border: none;
  color: #a0aec0;
  font-size: .8rem;
  cursor: pointer;
  font-family: inherit;
  transition: color .15s;
}

.sidebar-bottom button:hover {
  color: #fc8181;
}

.main-content {
  margin-left: 230px;
  flex: 1;
  padding: 2rem 2.5rem;
  min-height: 100vh;
}

/* ── Login Page ───────────────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a202c 0%, #2d3748 50%, #4a5568 100%);
  padding: 2rem;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: .25rem;
  color: #1a202c;
}

.login-card p {
  font-size: .8rem;
  color: #718096;
  margin-bottom: 1.5rem;
}

/* ── Typography ───────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a202c;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  transition: box-shadow .2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 1.2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  display: flex;
  flex-direction: column;
}

.stat-card .stat-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #718096;
  font-weight: 600;
  margin-bottom: .25rem;
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2d3748;
}

.stat-card.accent-blue {
  border-left: 3px solid #667eea;
}

.stat-card.accent-green {
  border-left: 3px solid #48bb78;
}

.stat-card.accent-orange {
  border-left: 3px solid #ed8936;
}

.stat-card.accent-purple {
  border-left: 3px solid #9f7aea;
}

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: .3rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: .85rem;
  font-family: inherit;
  color: #2d3748;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, .12);
}

textarea {
  resize: vertical;
  min-height: 60px;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
}

.btn-primary {
  background: #667eea;
  color: #fff;
}

.btn-primary:hover {
  background: #5a67d8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, .35);
}

.btn-secondary {
  background: #edf2f7;
  color: #4a5568;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-success {
  background: #48bb78;
  color: #fff;
}

.btn-success:hover {
  background: #38a169;
}

.btn-danger {
  background: #fc8181;
  color: #fff;
}

.btn-danger:hover {
  background: #f56565;
}

.btn-ghost {
  background: transparent;
  color: #667eea;
  padding: .35rem .6rem;
}

.btn-ghost:hover {
  background: rgba(102, 126, 234, .08);
}

.btn-sm {
  padding: .3rem .65rem;
  font-size: .75rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-group {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ── Tables ───────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

thead th {
  background: #f7fafc;
  color: #4a5568;
  font-weight: 600;
  text-align: left;
  padding: .65rem .75rem;
  border-bottom: 2px solid #e2e8f0;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

tbody td {
  padding: .6rem .75rem;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}

tbody tr {
  transition: background .1s;
}

tbody tr:hover {
  background: #f7fafc;
}

tbody tr:last-child td {
  border-bottom: none;
}

.actions {
  display: flex;
  gap: .3rem;
}

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  backdrop-filter: blur(2px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 8vh;
  z-index: 1000;
  animation: fadeIn .15s ease;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
  animation: slideIn .2s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #a0aec0;
  padding: .2rem;
  border-radius: 4px;
  transition: all .15s;
}

.modal-close:hover {
  background: #f7fafc;
  color: #2d3748;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Alerts & Badges ──────────────────────────────────────────────── */
.alert {
  padding: .7rem 1rem;
  border-radius: 6px;
  font-size: .82rem;
  margin-bottom: 1rem;
  font-weight: 500;
}

.alert-error {
  background: #fed7d7;
  color: #c53030;
}

.alert-success {
  background: #c6f6d5;
  color: #276749;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .5rem;
  border-radius: 9999px;
  font-size: .68rem;
  font-weight: 600;
}

.badge-blue {
  background: #ebf4ff;
  color: #3182ce;
}

.badge-green {
  background: #f0fff4;
  color: #38a169;
}

.badge-purple {
  background: #faf5ff;
  color: #805ad5;
}

.badge-gray {
  background: #edf2f7;
  color: #4a5568;
}

/* ── Filters ──────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-bar select,
.filter-bar input {
  width: auto;
  min-width: 140px;
}

/* ── File upload ──────────────────────────────────────────────────── */
.file-input-wrapper {
  position: relative;
}

.file-name {
  font-size: .75rem;
  color: #718096;
  margin-top: .25rem;
}

/* ── Receipt link ─────────────────────────────────────────────────── */
.receipt-link {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
  font-size: .78rem;
}

.receipt-link:hover {
  text-decoration: underline;
}

/* ── Month detail sections ────────────────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
}

.section-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #2d3748;
}

/* ── Coverage bar ─────────────────────────────────────────────────── */
.coverage-bar {
  height: 6px;
  background: #edf2f7;
  border-radius: 3px;
  overflow: hidden;
  margin-top: .25rem;
}

.coverage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #48bb78);
  border-radius: 3px;
  transition: width .4s ease;
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
  }

  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Empty states ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #a0aec0;
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
}

.empty-state p {
  font-size: .85rem;
}

/* ── Clickable rows ───────────────────────────────────────────────── */
.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: #edf2f7 !important;
}