* { box-sizing: border-box; }

:root {
  --bg: #f7f9fc;
  --panel: #ffffff;
  --panel-soft: #f3f6fa;
  --line: #dfe6ef;
  --line-strong: #cdd8e6;
  --text: #20283a;
  --muted: #69758a;
  --soft: #98a4b7;
  --blue: #1265ff;
  --blue-soft: #eaf2ff;
  --green: #119f55;
  --green-soft: #e9f8ef;
  --orange: #f08a24;
  --orange-soft: #fff3e7;
  --red: #ef4b3e;
  --red-soft: #ffeceb;
  --shadow: 0 18px 44px rgba(38, 54, 85, .08);
  --radius: 14px;
}

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button, input, select, textarea {
  font: inherit;
}

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  color: var(--blue);
  background: #fff;
}

.brand-mark svg { width: 21px; height: 21px; }

.login-card h1 {
  margin: 26px 0 8px;
  font-size: 28px;
}

.login-card p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.55;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  min-height: 42px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(18, 101, 255, .12);
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.btn:hover { border-color: var(--line-strong); background: #f9fbfe; }

.btn:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn.primary:hover { background: #0d55da; }

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: var(--red);
  border-color: rgba(239, 75, 62, .22);
}

.btn.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.side-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 10px;
}

.menu-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
}

.menu-btn:hover { background: var(--panel-soft); }

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  border: 0;
  background: transparent;
  color: #424b5e;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 9px;
  text-align: left;
  font-weight: 600;
}

.nav button:hover,
.nav button.active {
  background: #edf2f8;
  color: var(--text);
}

.nav svg {
  width: 19px;
  height: 19px;
  color: #657188;
  flex: 0 0 auto;
}

.nav button.active svg { color: var(--blue); }

.side-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.status-list {
  display: grid;
  gap: 10px;
}

.side-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.side-stat .count {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: #f1f4f8;
  color: var(--text);
  font-weight: 800;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: var(--soft);
  box-shadow: 0 0 0 5px rgba(152, 164, 183, .13);
}

.dot.blue { background: var(--blue); box-shadow: 0 0 0 5px rgba(18, 101, 255, .12); }
.dot.green { background: var(--green); box-shadow: 0 0 0 5px rgba(17, 159, 85, .13); }
.dot.orange { background: var(--orange); box-shadow: 0 0 0 5px rgba(240, 138, 36, .13); }
.dot.red { background: var(--red); box-shadow: 0 0 0 5px rgba(239, 75, 62, .13); }

.tech-link {
  margin-top: auto;
  color: var(--soft);
  font-size: 12px;
  padding: 12px;
}

.main {
  min-width: 0;
  padding: 20px clamp(18px, 4vw, 54px) 44px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.balance {
  margin: 0 auto;
  color: #59657a;
}

.balance strong {
  color: #12284b;
  font-size: 18px;
  margin-left: 6px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #12a760;
  color: var(--blue);
  background: #f8fffb;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
}

.mobile-open { display: none; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 22px;
}

.page-title {
  margin: 0 0 7px;
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: -.03em;
}

.page-sub {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  max-width: 720px;
}

.location-pill {
  min-width: 240px;
}

.tabs {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 0 0 14px;
  color: var(--soft);
  font-weight: 700;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--text);
  border-color: var(--blue);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel.soft {
  background: #f9fbfe;
}

.panel-head {
  padding: 20px 20px 0;
}

.panel-head.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -.02em;
}

.summary-panel {
  padding: 20px;
  margin-bottom: 22px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.summary-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  min-height: 136px;
  display: grid;
  align-content: space-between;
}

.summary-card.active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(18, 101, 255, .04);
}

.summary-label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-label strong { color: var(--blue); }

.summary-value {
  font-size: 28px;
  font-weight: 800;
  margin: 12px 0 8px;
}

.summary-note {
  color: var(--soft);
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.quality-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 22px;
}

.mini-metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  min-width: 0;
}

.mini-metric span,
.mini-metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.mini-metric strong {
  display: block;
  font-size: 20px;
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
}

.search {
  position: relative;
  width: min(320px, 100%);
}

.search input {
  padding-left: 38px;
}

.search svg {
  width: 17px;
  height: 17px;
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--soft);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th, td {
  padding: 15px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: #637086;
  background: #f7f9fc;
  font-size: 12px;
  font-weight: 800;
}

tr:last-child td { border-bottom: 0; }

.proxy-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
}

.mono {
  font-family: "Cascadia Code", "SF Mono", Consolas, monospace;
  font-size: 12px;
}

.linkish {
  color: var(--blue);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.copy-btn {
  border: 0;
  background: transparent;
  color: var(--soft);
  padding: 4px;
  border-radius: 6px;
}

.copy-btn:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.orange { background: var(--orange-soft); color: #b75f00; }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: #eef2f7; color: #647085; }

.small-muted {
  display: block;
  color: var(--soft);
  font-size: 12px;
  margin-top: 4px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(320px, .55fr);
}

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

.quick-actions {
  display: grid;
  gap: 10px;
}

.action-card {
  padding: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .full { grid-column: 1 / -1; }

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
}

.attention-strip {
  margin-bottom: 18px;
}

.issue-list {
  display: grid;
  gap: 0;
}

.issue-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.issue-row:last-child { border-bottom: 0; }

.issue-row strong {
  display: block;
  margin-bottom: 4px;
}

.issue-row span:not(.dot) {
  color: var(--muted);
  line-height: 1.45;
}

.issue-row.red {
  background: linear-gradient(90deg, rgba(239, 75, 62, .07), transparent 42%);
}

.issue-row.orange {
  background: linear-gradient(90deg, rgba(240, 138, 36, .08), transparent 42%);
}

.issue-row.info {
  background: linear-gradient(90deg, rgba(18, 101, 255, .06), transparent 42%);
}

.result-box {
  margin-top: 16px;
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.credential-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
}

.credential-row span:first-child {
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.lease-detail-row td {
  padding: 0;
  background: #fbfcfe;
}

.lease-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: stretch;
  padding: 14px 16px 16px;
}

.detail-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  min-width: 0;
}

.detail-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
}

.detail-card strong {
  overflow-wrap: anywhere;
}

.copy-detail {
  display: grid;
  gap: 8px;
}

.farm-card {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.farm-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.farm-title {
  margin: 0 0 4px;
  font-size: 17px;
}

.metric-list {
  display: grid;
  gap: 9px;
}

.modem-card-list {
  display: grid;
  gap: 10px;
}

.modem-mini {
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.modem-mini.muted {
  opacity: .78;
}

.modem-mini span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.modem-mini-side {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.health-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.health-card {
  min-height: 118px;
}

.health-card .summary-value {
  font-size: 22px;
}

.service-list {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.modem-service-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 18px;
  padding: 0 18px 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modem-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 18px 16px;
  border-bottom: 1px solid var(--line);
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.sim-card {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.sim-card.overdue {
  border-color: rgba(239, 75, 62, .35);
}

.sim-card.due_soon {
  border-color: rgba(240, 138, 36, .38);
}

.note-box {
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 10px;
  padding: 12px;
}

.note-box.sensitive {
  background: #fffdf8;
}

.note-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.note-box p {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sim-actions {
  justify-content: flex-start;
}

.sim-form {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.metric {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong { color: var(--text); }

.signal {
  display: inline-flex;
  align-items: end;
  gap: 3px;
  height: 18px;
}

.signal i {
  display: block;
  width: 4px;
  border-radius: 4px 4px 0 0;
  background: #d7dee8;
}

.signal i:nth-child(1) { height: 6px; }
.signal i:nth-child(2) { height: 9px; }
.signal i:nth-child(3) { height: 12px; }
.signal i:nth-child(4) { height: 15px; }
.signal i.on { background: var(--green); }

.health-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.health-row:last-child { border-bottom: 0; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #12284b;
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: min(420px, calc(100vw - 40px));
}

.toast.error { background: #b42318; }
.toast.success { background: #087443; }

.error-text {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
}

.loading {
  padding: 30px;
  color: var(--muted);
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(18, 101, 255, .18);
  border-top-color: var(--blue);
  display: inline-block;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .summary-grid,
  .health-metrics,
  .lease-details,
  .quality-strip,
  .sim-grid,
  .grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(290px, calc(100vw - 56px));
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 30;
  }

  .sidebar.open { transform: translateX(0); }

  .mobile-open {
    display: inline-grid;
    place-items: center;
  }

  .topbar {
    justify-content: space-between;
    margin-bottom: 22px;
  }

  .balance {
    margin: 0;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .location-pill {
    min-width: 0;
  }

  .summary-grid,
  .health-metrics,
  .quality-strip,
  .sim-grid,
  .grid.three,
  .form-grid,
  .lease-details,
  .modem-service-detail {
    grid-template-columns: 1fr;
  }

  .credential-row {
    grid-template-columns: 1fr;
  }

  .issue-row,
  .modem-mini {
    grid-template-columns: 1fr;
  }

  .modem-mini-side,
  .row-actions {
    justify-items: start;
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 16px 12px 30px;
  }

  .top-actions .btn:not(.mobile-open) {
    display: none;
  }

  .summary-panel,
  .action-card,
  .farm-card {
    padding: 14px;
  }

  .tabs {
    overflow-x: auto;
    gap: 18px;
  }
}
