:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1c2730;
  --muted: #62707e;
  --accent: #0a6d9c;
  --line: #d7dde3;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% 10%, #e9f5fb 0%, var(--bg) 55%);
}
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}
h1 {
  margin: 0 0 12px;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}
.hidden {
  display: none !important;
}
.auth-grid {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(140px, 220px) 140px 1fr auto;
  gap: 10px;
  align-items: end;
}
.auth-meta {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
  align-self: center;
}
.mode-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.mode-actions button {
  width: auto;
  min-width: 150px;
  padding: 8px 12px;
  font-size: 0.9rem;
}
.grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}
label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
}
select, button, input[type="text"], input[type="password"] {
  width: 100%;
  border: 1px solid #b8c2cc;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}
button {
  cursor: pointer;
  background: linear-gradient(135deg, #0a6d9c, #0f8dc9);
  color: #fff;
  border: none;
  font-weight: 600;
}
button:disabled {
  background: #8ba0af;
  cursor: not-allowed;
}
.status {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.2em;
}
.options {
  margin-top: 10px;
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--muted);
}
.options label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 0.9rem;
}
.totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.totals-bottom {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fafcfe;
}
.kpi .k {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}
.kpi .v {
  font-weight: 700;
  margin-top: 2px;
  text-align: right;
}
.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  max-height: none;
  border: 1px solid var(--line);
  border-radius: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: #fff;
}
thead th {
  position: sticky;
  top: 0;
  background: #e8f2f8;
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 8px;
  white-space: nowrap;
}
thead th[data-col="acc"],
thead th[data-col="office"],
thead th[data-col="facility"],
thead th[data-col="provider"],
thead th[data-col="retained"] {
  text-align: right;
}
tbody td {
  border-bottom: none;
  padding: 6px 8px;
  white-space: nowrap;
}
tbody td[data-col="acc"],
tbody td[data-col="office"],
tbody td[data-col="facility"],
tbody td[data-col="provider"],
tbody td[data-col="retained"] {
  text-align: right;
}
tfoot td {
  padding: 6px 8px;
  white-space: nowrap;
  background: #f7f7f7;
  border-top: 1px solid #d7dde3;
  font-weight: 600;
}
tfoot td[data-col="acc"],
tfoot td[data-col="office"],
tfoot td[data-col="facility"],
tfoot td[data-col="provider"],
tfoot td[data-col="retained"] {
  text-align: right;
}
tfoot td.summary-label {
  text-align: right;
  color: #17222c;
  font-weight: 700;
}
tfoot td.summary-eq {
  border-top: 3px double #6f7882;
  border-bottom: 3px double #6f7882;
  background: #f1f3f5;
}
.debug-only {
  display: none;
}
.cpt-black { color: #111; font-weight: 600; }
.cpt-blue { color: #0a53be; font-weight: 700; }
.cpt-gray { color: #7a7a7a; font-weight: 700; }
.cpt-green { color: #1f8b37; font-weight: 700; }
.cpt-purple { color: #6f2da8; font-weight: 700; }
.cpt-red { color: #b32121; font-weight: 700; }
.cpt-warn-bg { background: #fffbe8; }
.age-black { color: #111; }
.age-red { color: #b32121; font-weight: 700; }
.patient-main {
  color: #111;
  line-height: 1.15;
}
.patient-ins {
  color: #c96c19;
  font-size: 0.82rem;
  line-height: 1.1;
}
tbody tr.patient-start td {
  border-top: 1px solid #0b4d8a;
}
tbody tr.day-start td {
  border-top: 3px double #95a8bb;
}
.legend {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.legend-title {
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 12px;
}
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #8a8a8a;
  display: inline-block;
  flex: 0 0 auto;
}
@media (max-width: 920px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }
  .auth-meta {
    text-align: left;
  }
  .grid { grid-template-columns: 1fr; }
  .totals { grid-template-columns: 1fr 1fr; }
}
