:root {
  --paper: #f1f2ec;
  --surface: #ffffff;
  --ink: #1b2621;
  --muted: #5f6b65;
  --line: #d8dcd2;
  --accent: #26485c;
  --accent-soft: #e6edf1;

  --fill-green: #3c9b62;
  --fill-amber: #d69a1e;
  --fill-red: #c9483a;
  --fill-none: #b9bfb9;

  --badge-green-bg: #e3f1e7;   --badge-green-fg: #1f5a35;
  --badge-amber-bg: #fbefd2;   --badge-amber-fg: #7a4e00;
  --badge-red-bg: #f8e0dc;     --badge-red-fg: #8c2a1d;
  --badge-none-bg: #e8eae6;    --badge-none-fg: #4f5852;
}

html { scroll-padding-top: 1rem; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.page {
  /*max-width: 1240px;*/
  margin: 0 auto;
  padding: 1.75rem 1rem 3rem;
}

/* ---------- Header ---------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.period-line {
  margin: 0.15rem 0 0;
  color: var(--muted);
}

.month-picker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.month-picker label {
  margin: 0 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.month-picker input[type="month"] {
  height: 2.4rem;
  padding: 0 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.icon-btn,
.text-btn {
  height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.icon-btn { width: 2.4rem; font-size: 1.15rem; line-height: 1; }
.text-btn { padding: 0 0.8rem; }
.icon-btn:hover,
.text-btn:hover { background: var(--accent-soft); }

:where(button, input, a):focus-visible,
.dt-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.error-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* ---------- Overview ---------- */
.overview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem 1.5rem 1rem;
  margin-bottom: 1.25rem;
}
.overview-grid {
  display: grid;
  grid-template-columns: 1.3fr repeat(5, 1fr);
  gap: 1rem 0;
  align-items: stretch;
}
.overview-main { padding-right: 1.5rem; }
.hero-pct {
  font-size: 2.7rem;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.hero-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.stat {
  padding: 0.1rem 1rem;
  border-left: 1px solid var(--line);
}
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}
.stat-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Progress track with the two status thresholds marked on it */
.track-wrap { padding: 0.5rem 0 1.5rem; margin-top: 0.75rem; }
.track {
  position: relative;
  height: 10px;
  background: #e6e9e1;
  border-radius: 999px;
}
.track-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: var(--fill-none);
  transition: width 0.45s ease;
}
.tick {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  background: var(--ink);
  transform: translateX(-1px);
}
.tick span {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}
.tick-end { transform: translateX(-2px); }
.tick-end span { left: auto; right: 0; transform: none; }

/* ---------- Table card ---------- */
.table-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.25rem 0.75rem;
  min-height: 12rem;
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 8px;
  color: var(--muted);
}

.dt-container { font-size: 0.93rem; }
.dt-container .dt-layout-row { margin-bottom: 0.5rem; }
.dt-container .dt-layout-table { overflow-x: auto; }
.dt-container .dt-layout-table .dt-layout-cell { width: 100%; min-width: 0; }

.dt-container .dt-search input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
}

.dt-buttons { display: flex; gap: 0.4rem; }
.dt-button {
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.dt-button:hover { background: var(--accent-soft); }

#locTable {
  --bs-table-bg: transparent;
  margin-bottom: 0;
  white-space: nowrap;
}
#locTable > thead > tr > th {
  border-bottom: 1px solid var(--ink);
  color: var(--muted);
  font-weight: 600;
  padding: 0.6rem 0.75rem;
}
#locTable > tbody > tr > td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
#locTable > tbody > tr:hover > td { background: #f7f8f4; }
#locTable > tfoot > tr > th {
  padding: 0.7rem 0.75rem;
  border-top: 1px solid var(--ink);
  border-bottom: 0;
  background: #f7f8f4;
  font-weight: 600;
}
#locTable th.num,
#locTable td.num { text-align: right; }
#locTable th.sno,
#locTable td.sno { text-align: center; color: var(--muted); }

.progress-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}
.bar {
  display: inline-block;
  width: 96px;
  height: 6px;
  overflow: hidden;
  background: #e6e9e1;
  border-radius: 999px;
}
.fill { display: block; height: 100%; border-radius: 999px; }
.fill-green, .track-fill.is-green { background: var(--fill-green); }
.fill-amber, .track-fill.is-amber { background: var(--fill-amber); }
.fill-red,   .track-fill.is-red   { background: var(--fill-red); }
.fill-none,  .track-fill.is-none  { background: var(--fill-none); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.12rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
}
.status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.status-green { background: var(--badge-green-bg); color: var(--badge-green-fg); }
.status-amber { background: var(--badge-amber-bg); color: var(--badge-amber-fg); }
.status-red   { background: var(--badge-red-bg);   color: var(--badge-red-fg); }
.status-none  { background: var(--badge-none-bg);  color: var(--badge-none-fg); }

.hero-status { margin-left: 0.6rem; vertical-align: middle; }

/* ---------- Small screens ---------- */
@media (max-width: 960px) {
  .overview-grid { grid-template-columns: repeat(3, 1fr); }
  .overview-main { grid-column: 1 / -1; padding-right: 0; }
  .stat:nth-child(3n + 2) { border-left: 0; padding-left: 0; }
  .hero-pct { font-size: 2.3rem; }
}
@media (max-width: 560px) {
  .overview-grid { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3n + 2) { border-left: 1px solid var(--line); padding-left: 1rem; }
  .stat:nth-child(2n + 1) { border-left: 0; padding-left: 0; }
  .page-head { align-items: stretch; }
  .month-picker { flex-wrap: wrap; }
  .bar { width: 56px; }
  .table-card { padding: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .track-fill { transition: none; }
}

.type-toggle {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.25rem;
  margin-bottom: 1.25rem;
}
.type-btn {
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.type-btn:hover { background: var(--accent-soft); color: var(--ink); }
.type-btn.is-active { background: var(--accent); color: #fff; }
