:root {
  --ink: #1b2430;
  --ink2: #4a5566;
  --muted: #7a8494;
  --line: #e3e7ee;
  --bg: #f5f7fa;
  --card: #ffffff;
  --brand: #00756f;
  --brand2: #00807a;
  --teal: #00b4aa;
  --brandSoft: #e3f6f4;
  --brandLine: #b5e6e2;
  --accent: #00b4aa;
  --ok: #2e7d4f;
  --okBg: #e6f4ec;
  --warn: #a26a00;
  --warnBg: #fdf3dc;
  --risk: #c2561a;
  --riskBg: #fde9df;
  --lost: #a3222b;
  --lostBg: #fbe3e5;
  --bar: #009b92;
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.45 "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
.hidden {
  display: none !important;
}
/* login */
#login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(150deg, #00756f 0%, #00b4aa 100%);
}
#login .box {
  background: #fff;
  border-radius: 14px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
#login h1 {
  margin: 0 0 4px;
  font-size: 20px;
  color: var(--brand);
}
#login p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}
#login input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
}
#login button {
  width: 100%;
  padding: 11px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
#login .err {
  color: var(--lost);
  font-size: 13px;
  min-height: 18px;
}
/* header */
header {
  background: linear-gradient(90deg, #00756f 0%, #00807a 35%, #00b4aa 100%);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.2px;
}
header .sub {
  font-size: 12px;
  opacity: 0.95;
}
header .tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.hbtn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.hbtn:hover {
  background: rgba(255, 255, 255, 0.22);
}
.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 10px;
  border-radius: 8px;
}
.switch input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
nav {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 2px;
  padding: 0 12px;
  overflow-x: auto;
  position: sticky;
  top: var(--header-h, 58px);
  z-index: 19;
}
nav button {
  background: none;
  border: 0;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--ink2);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  font-weight: 550;
}
nav button.on {
  color: var(--brand);
  border-bottom-color: var(--teal);
}
main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 16px 60px;
}
.banner {
  background: var(--brandSoft);
  border: 1px solid var(--brandLine);
  color: var(--brand);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}
.banner button {
  background: none;
  border: 0;
  color: var(--brand2);
  text-decoration: underline;
  cursor: pointer;
  font-size: 12.5px;
  padding: 0;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.f {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.f label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}
.f select,
.f input {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  min-width: 140px;
  max-width: 100%;
}
.f.grow {
  flex: 1;
  min-width: 180px;
}
.f.grow input {
  width: 100%;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.kpi .l {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.kpi .v {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.kpi .s {
  font-size: 12px;
  color: var(--ink2);
  margin-top: 2px;
}
.grid2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 900px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  min-width: 0;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--ink);
}
.card .hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12.5px;
}
.status-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.st {
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  text-align: left;
}
.st:hover {
  border-color: currentColor;
}
.st .n {
  font-size: 24px;
  font-weight: 700;
}
.st .t {
  font-size: 13px;
  font-weight: 600;
}
.st .d {
  font-size: 11.5px;
  opacity: 0.85;
}
.s-activo {
  background: var(--okBg);
  color: var(--ok);
}
.s-reponer {
  background: var(--warnBg);
  color: var(--warn);
}
.s-riesgo {
  background: var(--riskBg);
  color: var(--risk);
}
.s-perdido {
  background: var(--lostBg);
  color: var(--lost);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
th {
  background: #eef8f7;
  text-align: left;
  padding: 9px 10px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--ink2);
  cursor: pointer;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
th.num,
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}
tbody tr:hover {
  background: #f8fafc;
}
tbody tr.click {
  cursor: pointer;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.chart {
  width: 100%;
  height: 260px;
  position: relative;
}
.chart svg {
  width: 100%;
  height: 100%;
  display: block;
}
.tip {
  position: absolute;
  pointer-events: none;
  background: #1b2430;
  color: #fff;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
  transform: translate(-50%, -110%);
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 5;
}
.hbars .row {
  display: grid;
  grid-template-columns: minmax(110px, 190px) 1fr 90px;
  gap: 10px;
  align-items: center;
  margin: 7px 0;
  font-size: 13px;
}
.hbars .track {
  background: #eef1f6;
  border-radius: 4px;
  height: 12px;
  overflow: hidden;
}
.hbars .fill {
  background: var(--bar);
  height: 100%;
  border-radius: 0 4px 4px 0;
}
.hbars .val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink2);
}
.btn {
  background: var(--brand);
  color: #fff;
  border: 0;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.btn.ghost {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brandLine);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-bottom: 10px;
}
/* drawer */
#drawer {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 35, 0.45);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}
#drawer .panel {
  background: #fff;
  width: 100%;
  max-width: 560px;
  height: 100%;
  overflow-y: auto;
  padding: 22px 22px 40px;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.2);
}
#drawer h3 {
  margin: 0 0 2px;
  font-size: 18px;
}
#drawer .x {
  float: right;
  background: none;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
}
.facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.facts div {
  background: #f6f8fb;
  border-radius: 8px;
  padding: 8px 10px;
}
.facts b {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.seg-form {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin: 14px 0;
}
.seg-form .rowf {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.seg-form select,
.seg-form input,
.seg-form textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  background: #fff;
}
.seg-form textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
}
.hist {
  font-size: 12.5px;
  border-left: 3px solid var(--line);
  padding-left: 10px;
  margin: 6px 0;
}
.legend-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}
.seg-tag {
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #eef1f6;
  color: var(--ink2);
  white-space: nowrap;
}
.seg-tag.c {
  background: var(--brandSoft);
  color: var(--brand);
}
.seg-tag.r {
  background: var(--okBg);
  color: var(--ok);
}
.seg-tag.n {
  background: var(--lostBg);
  color: var(--lost);
}
footer {
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
  padding: 20px;
}
@media (max-width: 640px) {
  header {
    padding: 12px 16px;
  }
  main {
    padding: 14px 16px 60px;
  }
  .kpi .v {
    font-size: 20px;
  }
  .status-tiles {
    grid-template-columns: 1fr 1fr;
  }
  .hbars .row {
    grid-template-columns: 100px 1fr 70px;
  }
}
body.medico .only-admin {
  display: none !important;
}
body.admin .only-medico {
  display: none !important;
}
.msgbox {
  width: 100%;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  font-size: 13px;
  background: #fbfcfe;
}
.keyline {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: #fff;
  border: 1px dashed var(--teal);
  border-radius: 8px;
  padding: 4px 10px;
  font-family: Consolas, Menlo, monospace;
  font-size: 13px;
  color: var(--brand);
}
.progress {
  font-size: 12.5px;
  color: var(--brand);
  margin-left: 6px;
}
.brandrow {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo {
  height: 34px;
  width: auto;
  display: block;
}
.logo-login {
  height: 46px;
  width: auto;
  display: block;
  margin: 0 auto 16px;
  filter: none;
}
.login-badge {
  background: linear-gradient(150deg, #00756f, #00b4aa);
  border-radius: 10px;
  padding: 14px;
  margin: -6px 0 18px;
  display: flex;
  justify-content: center;
}
.login-badge img {
  height: 44px;
  width: auto;
}
header .divider {
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, 0.35);
}
#login .box {
  border-top: 5px solid var(--teal);
}
.kpi {
  border-top: 3px solid var(--teal);
}
@media (max-width: 640px) {
  .logo {
    height: 26px;
  }
  header .divider {
    display: none;
  }
}

.flag {
  height: 0.8em;
  width: auto;
  vertical-align: -0.05em;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
