:root {
  --sf-blue: #0176d3;
  --sf-blue-dark: #014486;
  --sf-navy: #032d60;
  --green: #2e844a;
  --green-bg: #ebf7e6;
  --amber: #dd7a01;
  --amber-bg: #fef1e4;
  --red: #ba0517;
  --red-bg: #fdeded;
  --rf: #0b5cab;
  --rf-bg: #eaf1fb;
  --fo: #0e7a5f;
  --fo-bg: #e4f4ee;
  --bg: #f3f2f2;
  --card: #ffffff;
  --line: #dddbda;
  --txt: #181818;
  --muted: #706e6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  padding: 0 22px;
  background: var(--sf-blue);
  color: #fff;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-logo {
  flex: none;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.cutoff {
  font-size: 12px;
  opacity: 0.92;
}

.seg {
  display: inline-flex;
  flex: none;
  overflow: hidden;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.16);
}

.period-tools {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
}

.auth-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.auth-widget button,
.login-card button {
  border: 0;
  border-radius: 4px;
  background: #fff;
  color: var(--sf-blue);
  padding: 6px 12px;
  font-weight: 700;
}

.period-input {
  width: 150px;
  border: 0;
  border-radius: 14px;
  padding: 5px 10px;
  color: var(--sf-navy);
  background: #fff;
}

.seg button {
  min-width: 76px;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 6px 16px;
  font-size: 12.5px;
  font-weight: 500;
}

.seg button.on {
  background: #fff;
  color: var(--sf-blue);
  font-weight: 700;
}

.wrap {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 16px 18px 30px;
}

body.login-mode {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 18%, rgba(1, 118, 211, 0.10), transparent 28%),
    linear-gradient(180deg, #f7fbff 0%, #f3f2f2 58%, #eef1f5 100%);
}

body.login-mode .topbar,
body.login-mode .tabs,
body.login-mode footer {
  display: none;
}

body.login-mode .wrap {
  display: grid;
  min-height: 100vh;
  width: 100%;
  padding: 24px;
  place-items: center;
}

body.login-mode #stage {
  width: min(430px, 100%);
}

.login-panel {
  display: grid;
  place-items: center;
}

.login-card {
  width: 100%;
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  padding: 30px;
  box-shadow: 0 18px 44px rgba(3, 45, 96, 0.13);
}

.login-logo {
  width: 118px;
  height: auto;
  object-fit: contain;
}

.login-card h2 {
  margin: 4px 0 0;
  color: var(--sf-navy);
  font-size: 24px;
  line-height: 1.15;
}

.login-copy {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--txt);
  background: #fff;
}

.login-card input:focus {
  border-color: var(--sf-blue);
  outline: 3px solid rgba(1, 118, 211, 0.16);
}

.login-card button {
  background: var(--sf-blue);
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
}

.login-card button:hover {
  background: var(--sf-blue-dark);
}

#loginMessage {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 12px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 4px 4px 0 0;
  background: var(--card);
}

.tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 13px 20px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.tabs button.on {
  border-bottom-color: var(--sf-blue);
  color: var(--sf-blue);
  font-weight: 700;
}

.tabs button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.franja {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 10px;
  color: var(--sf-blue-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.franja:first-child {
  margin-top: 0;
}

.franja::after {
  flex: 1;
  height: 1px;
  background: var(--line);
  content: "";
}

.grid {
  display: grid;
  gap: 12px;
  margin-bottom: 6px;
}

.g2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.g3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.g4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.g6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.g7 {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.widget,
.stat {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
}

.widget {
  margin-bottom: 14px;
}

.w-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #f0efee;
}

.w-title {
  color: var(--txt);
  font-size: 13px;
  font-weight: 700;
}

.w-sub {
  color: var(--muted);
  font-size: 11.5px;
}

.w-body {
  padding: 16px;
}

.w-body.flush {
  overflow: hidden;
  padding: 0;
  border-radius: 0 0 4px 4px;
}

.stat {
  position: relative;
  min-height: 116px;
  padding: 14px 16px;
}

button.stat {
  display: block;
  width: 100%;
  color: inherit;
  text-align: left;
}

.movement-card {
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.movement-card:hover,
.movement-card.active {
  border-color: var(--sf-blue);
  box-shadow: inset 0 3px 0 var(--sf-blue);
}

.stat.hero {
  min-height: 174px;
  background: var(--sf-navy);
  border-color: var(--sf-navy);
}

.stat .lbl {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.stat .val {
  color: var(--txt);
  font-size: 25px;
  font-weight: 700;
  line-height: 1.1;
}

.stat .sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.stat.hero .lbl,
.stat.hero .sub {
  color: #aec8e8;
}

.stat.hero .val {
  color: #fff;
  font-size: 34px;
}

.pend {
  border: 1px dashed var(--amber);
  background: repeating-linear-gradient(45deg, #fff8f0, #fff8f0 9px, #fcebd6 9px, #fcebd6 18px);
}

.pend .val {
  color: #9c6a1d;
  font-size: 18px;
  font-weight: 600;
}

.badge-pend {
  flex: none;
  border-radius: 10px;
  background: var(--amber);
  color: #fff;
  padding: 2px 9px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.dot {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.d-v {
  background: var(--green);
}

.d-a {
  background: var(--amber);
}

.d-r {
  background: var(--red);
}

.pill {
  display: inline-block;
  border-radius: 10px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
}

.p-v {
  background: var(--green-bg);
  color: var(--green);
}

.p-a {
  background: var(--amber-bg);
  color: var(--amber);
}

.p-r {
  background: var(--red-bg);
  color: var(--red);
}

.p-rf {
  background: var(--rf-bg);
  color: var(--rf);
}

.p-fo {
  background: var(--fo-bg);
  color: var(--fo);
}

.p-sc {
  background: var(--amber-bg);
  color: var(--amber);
}

.delta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 12px;
  font-weight: 700;
}

.delta .vs {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.up-good,
.down-good {
  color: var(--green);
}

.up-bad,
.down-bad {
  color: var(--red);
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11.5px;
}

.meta-row input {
  width: 56px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--txt);
  padding: 4px 6px;
  font-size: 12.5px;
  text-align: right;
}

.meta-row input:focus {
  border-color: var(--sf-blue);
  outline: none;
  box-shadow: 0 0 0 1px var(--sf-blue);
}

.donut-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.donut {
  width: 120px;
  height: 120px;
  flex: none;
}

.chart-large {
  width: 100%;
  height: 320px;
}

.chart-mid {
  width: 100%;
  height: 185px;
}

.gauge {
  width: 138px;
  height: 92px;
  flex: none;
}

.legend {
  color: var(--muted);
  font-size: 12px;
}

.legend .row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}

.legend b {
  color: var(--txt);
  font-size: 14px;
}

.sw {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.progress-layout {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 18px;
  align-items: center;
}

.prog {
  overflow: hidden;
  height: 10px;
  border-radius: 6px;
  background: #f0efee;
}

.prog > div {
  height: 100%;
  background: var(--green);
}

.score {
  color: var(--green);
  font-size: 25px;
  font-weight: 700;
  text-align: center;
}

.score span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

details.det {
  margin-top: 12px;
}

.det summary {
  cursor: pointer;
  color: var(--sf-blue);
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
  list-style: none;
}

.det summary::-webkit-details-marker {
  display: none;
}

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

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

.table-scroll table {
  min-width: 1040px;
}

th {
  border-bottom: 1px solid var(--line);
  background: #fafaf9;
  color: var(--muted);
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

td {
  border-top: 1px solid #f0efee;
  padding: 9px 12px;
  font-size: 13px;
}

tr:hover td {
  background: #f8fbfe;
}

th.r,
td.r {
  text-align: right;
}

.note {
  margin-top: 9px;
  color: var(--muted);
  font-size: 11.5px;
  font-style: italic;
}

.muted-small {
  color: var(--muted);
  font-size: 11.5px;
}

.kpi-foot {
  border-top: 1px solid var(--line);
  background: #fafaf9;
  padding: 13px;
  text-align: center;
}

.kpi-foot .l {
  color: var(--muted);
  font-size: 12px;
}

.kpi-foot .v {
  color: var(--sf-navy);
  font-size: 27px;
  font-weight: 700;
}

.error,
.loading {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  padding: 18px;
}

.error {
  border-color: #f5b5b5;
  color: var(--red);
}

.pending-box {
  border: 1px dashed var(--amber);
  border-radius: 4px;
  background: repeating-linear-gradient(45deg, #fff8f0, #fff8f0 9px, #fcebd6 9px, #fcebd6 18px);
  color: #8a5a00;
  padding: 16px;
}

.pending-box b,
.pending-box span {
  display: block;
}

.network-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 4px;
  background: var(--card);
  padding: 12px 16px;
}

.network-status.is-ready {
  border-left-color: var(--green);
}

.network-status b,
.network-status span {
  display: block;
}

.network-status span {
  color: var(--muted);
  font-size: 11.5px;
}

.network-quality {
  flex: none;
  text-align: right;
}

.network-quality b {
  color: var(--sf-navy);
  font-size: 18px;
}

.network-table-wrap {
  overflow-x: auto;
}

.network-table {
  min-width: 940px;
}

.network-table .pill {
  white-space: nowrap;
}

.network-positive {
  color: var(--green);
  font-weight: 700;
}

.network-idle-row td {
  background: #fef6e9;
}

.network-total-row {
  font-weight: 700;
}

.network-total-row.rf-total td {
  background: var(--rf-bg);
}

.network-total-row.fo-total td {
  background: var(--fo-bg);
}

.network-mobile-list {
  display: none;
}

.network-mobile-row {
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.network-mobile-row.is-idle {
  background: #fef6e9;
}

.network-mobile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.network-mobile-row dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 0;
}

.network-mobile-row dl div {
  min-width: 0;
}

.network-mobile-row dt {
  color: var(--muted);
  font-size: 10.5px;
  text-transform: uppercase;
}

.network-mobile-row dd {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 600;
}

.network-unclassified-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.network-unclassified-value b {
  color: var(--amber);
  font-size: 24px;
}

.network-unclassified-value span {
  color: var(--muted);
  font-size: 12px;
}

.network-method-note {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.pending-box span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

footer {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--sf-blue-dark);
  padding-top: 14px;
  font-size: 12px;
  font-style: italic;
  text-align: center;
}

@media (max-width: 1020px) {
  .g6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .g7 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .g4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 14px;
  }

  .seg {
    width: 100%;
  }

  .period-tools {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .period-input {
    width: 100%;
  }

  .seg button {
    flex: 1;
  }

  .g2,
  .g3,
  .g4,
  .g6 {
    grid-template-columns: 1fr;
  }

  .g7 {
    grid-template-columns: 1fr;
  }

  .donut-card,
  .progress-layout {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .chart-large {
    height: 260px;
  }

  .network-status {
    align-items: flex-start;
    flex-direction: column;
  }

  .network-quality {
    text-align: left;
  }

  .network-table-wrap {
    display: none;
  }

  .network-mobile-list {
    display: block;
  }

  .network-widget .w-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
