:root {
  --bg: #f4f7fb;
  --bg-2: #eef4fa;
  --panel: #ffffff;
  --panel-2: #f8fbff;
  --text: #172235;
  --muted: #6f7f93;
  --muted-2: #99a7ba;
  --line: #dbe5f1;
  --line-soft: rgba(113, 132, 154, .18);
  --ok: #2faf72;
  --ok-soft: rgba(47, 175, 114, .12);
  --ok-strong: #177b4f;
  --warn: #d2972c;
  --bad: #e05d85;
  --bad-soft: rgba(224, 93, 133, .12);
  --blue: #448aff;
  --shadow: rgba(37, 57, 82, .12);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 4%, rgba(101, 150, 255, .14), transparent 26%),
    radial-gradient(circle at 94% 9%, rgba(70, 209, 160, .14), transparent 30%),
    linear-gradient(180deg, #f9fbfe 0%, var(--bg) 46%, #edf3f9 100%);
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: #1f72e8; }
code { color: #2563a8; background: #edf4ff; border-radius: 7px; padding: 2px 7px; }

.phone-shell {
  position: relative;
  width: min(100%, 720px);
  margin: 0 auto;
  min-height: 100vh;
  padding: 28px 34px 44px;
}

.clean-search {
  padding-top: 28px;
  margin-bottom: 18px;
}

.search-box {
  min-height: 78px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 13px 10px 26px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(119, 139, 165, .23);
  box-shadow: 0 18px 44px rgba(59, 87, 118, .13), inset 0 1px 0 rgba(255,255,255,.8);
  backdrop-filter: blur(18px);
}
.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #1b293f;
  font-size: 24px;
  letter-spacing: .2px;
  min-width: 0;
}
.search-box input::placeholder { color: #98a7b9; }
.search-logo {
  flex: 0 0 auto;
  min-width: 66px;
  height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: #ffffff;
  font-weight: 900;
  letter-spacing: .05em;
  background: linear-gradient(135deg, #ff7bb0 0%, #8c7cff 48%, #38d9b2 100%);
  box-shadow: 0 10px 22px rgba(101, 116, 255, .22);
}
.magnifier {
  width: 29px;
  height: 29px;
  border: 3px solid #8e9db2;
  border-radius: 50%;
  position: relative;
  opacity: .9;
  flex: 0 0 auto;
}
.magnifier::after {
  content: "";
  width: 13px;
  height: 3px;
  border-radius: 999px;
  background: #8e9db2;
  position: absolute;
  right: -10px;
  bottom: -5px;
  transform: rotate(45deg);
}

.front-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 18px;
}
.front-stats span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  color: #607084;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--line-soft);
  box-shadow: 0 8px 24px rgba(48, 73, 104, .07);
  font-size: 14px;
}

.cards { display: grid; gap: 22px; }
.monitor-card {
  position: relative;
  min-height: 190px;
  border-radius: 30px;
  padding: 22px 24px 20px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,251,255,.96));
  border: 1px solid rgba(123, 143, 169, .18);
  box-shadow: 0 24px 55px rgba(39, 61, 89, .12);
  transition: transform .15s ease, opacity .15s ease;
}
.monitor-card.loading { opacity: .72; }
.monitor-card.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 0%, rgba(68, 138, 255, .08) 45%, transparent 80%);
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-80%); } to { transform: translateX(80%); } }
.card-head {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.status-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 6px rgba(153, 167, 186, .13);
}
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 6px var(--ok-soft), 0 0 20px rgba(47,175,114,.28); }
.status-dot.bad { background: var(--bad); box-shadow: 0 0 0 6px var(--bad-soft), 0 0 20px rgba(224,93,133,.22); }
.status-dot.waiting { background: #a7b3c4; }
.card-title-wrap {
  min-width: 0;
  display: grid;
  gap: 5px;
}
.card-title {
  margin: 0;
  font-size: 25px;
  line-height: 1.16;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1b2638;
}
.card-channel {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #7d8da2;
  font-size: 14px;
  line-height: 1.25;
  font-weight: 700;
}
.rate-pill {
  min-width: 74px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: var(--ok-strong);
  background: #eaf8f0;
  border: 1px solid rgba(47,175,114,.18);
  font-size: 15px;
  font-weight: 800;
  padding: 0 12px;
}
.monitor-card.bad .rate-pill { color: #bd3e69; background: #fff0f5; border-color: rgba(224,93,133,.2); }
.monitor-card.waiting .rate-pill { color: #718096; background: #f0f4f8; border-color: #dfe7ef; }
.chart-wrap {
  margin: 23px 0 13px;
  height: 73px;
  padding: 8px 0 0;
  border-radius: 20px;
  background: linear-gradient(180deg, #f4f8fc, #edf3f8);
  box-shadow: inset 0 1px 4px rgba(69, 90, 113, .06);
}
.bars {
  height: 52px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  overflow: hidden;
  padding: 0 10px;
}
.bar {
  display: block;
  width: 7px;
  height: var(--h);
  min-height: 8px;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, #71ddb0, #2faf72);
  opacity: .96;
}
.bar.empty { background: rgba(149, 164, 183, .23); opacity: .65; }
.bar.warn { background: linear-gradient(180deg, #f7d98b, #d2972c); }
.bar.bad { background: linear-gradient(180deg, #ffaac8, #e05d85); }
.time-axis {
  display: flex;
  justify-content: space-between;
  color: #91a0b2;
  font-size: 12px;
  margin-top: 3px;
  padding: 0 10px;
}
.card-foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  color: #748397;
  font-size: 15px;
}
.metrics { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.metrics b { color: #2b3950; }
.bolt { color: #448aff; font-size: 20px; line-height: 0; }
.dot-sep { color: #a8b4c3; }
.run-state { color: #36506f; white-space: nowrap; font-weight: 700; }
.monitor-card.ok .run-state { color: #168052; }
.monitor-card.bad .run-state { color: #c2416d; }
.err-line {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  color: #b83360;
  background: #fff0f5;
  border: 1px solid rgba(224, 93, 133, .14);
  font-size: 13px;
  line-height: 1.5;
}

.notice, .empty-state {
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(255,255,255,.82);
  color: #627287;
  border: 1px solid var(--line-soft);
  box-shadow: 0 18px 44px rgba(38, 61, 87, .09);
  line-height: 1.75;
}
.notice.error { color: #ba3c67; background: #fff3f7; border-color: rgba(224, 93, 133, .18); }
.notice.ok { color: #147a4d; background: #effbf4; border-color: rgba(47, 175, 114, .18); }

/* Admin */
.admin-page {
  background:
    radial-gradient(circle at 10% 0%, rgba(68,138,255,.12), transparent 24%),
    radial-gradient(circle at 90% 12%, rgba(56,217,178,.13), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, #eef4fa 100%);
}
.admin-shell {
  width: min(1180px, calc(100% - 34px));
  margin: 0 auto;
  padding: 34px 0 70px;
}
.admin-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.admin-header h1 { margin: 6px 0 8px; font-size: clamp(34px, 7vw, 66px); line-height: .95; }
.admin-header p { margin: 0; color: var(--muted); max-width: 740px; line-height: 1.7; }
.eyebrow { color: #397ee8; font-weight: 800; letter-spacing: .16em; font-size: 13px; }
.admin-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.logout-form { margin: 0; }
.admin-link {
  flex: 0 0 auto;
  text-decoration: none;
  color: #1d5fc5;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 18px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 10px 28px rgba(49, 76, 105, .08);
}
.admin-panel {
  margin: 18px 0;
  padding: 24px;
  border: 1px solid rgba(121, 143, 169, .20);
  border-radius: 28px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 24px 70px rgba(50, 73, 101, .10);
  backdrop-filter: blur(18px);
}
.admin-panel h2 { margin: 0 0 18px; font-size: 23px; }
.admin-panel p { color: var(--muted); margin: 4px 0 0; line-height: 1.6; }
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.panel-title-row h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: 1.5fr 1fr auto; }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mt16 { margin-top: 16px; }
label { display: grid; gap: 9px; color: #55657a; font-size: 14px; font-weight: 650; }
input[type="text"], input[type="url"], input[type="password"], input[type="number"], input[type="search"] {
  width: 100%;
  border: 1px solid #d6e1ee;
  outline: 0;
  color: #172235;
  background: #ffffff;
  border-radius: 15px;
  padding: 13px 14px;
}
input:focus { border-color: rgba(68, 138, 255, .58); box-shadow: 0 0 0 4px rgba(68, 138, 255, .12); }
.switch-wrap {
  min-height: 70px;
  border: 1px solid #dbe5f1;
  background: #f8fbff;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  gap: 10px;
}
.switch-wrap input, .checkline input { width: 18px; height: 18px; accent-color: #2faf72; }
button {
  border: 0;
  border-radius: 15px;
  padding: 12px 17px;
  color: #172235;
  cursor: pointer;
  font-weight: 800;
}
button:disabled { opacity: .65; cursor: not-allowed; }
.primary { background: linear-gradient(135deg, #5c9dff, #4bd8a5); color: #06131d; box-shadow: 0 12px 28px rgba(68,138,255,.18); }
.secondary { background: #ffffff; border: 1px solid #d6e1ee; color: #2b3b52; }
.danger { background: #fff1f5; border: 1px solid rgba(224, 93, 133, .28); color: #bf3b68; }
.align-end { align-self: end; }
.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.checkline {
  display: inline-flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f8fbff;
  border: 1px solid #dfe7f0;
}
.hint, .sub-hint { color: var(--muted); font-size: 13px; }
.inline-error { color: #be3c69 !important; }
.inline-ok { color: #147b4e !important; }
.api-list { display: grid; gap: 18px; }
.api-admin-card {
  padding: 18px;
  border-radius: 24px;
  background: #f8fbff;
  border: 1px solid #dbe5f1;
}
.api-admin-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.api-admin-title {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.api-admin-title h3 { margin: 0; font-size: 22px; }
.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  color: #167b50;
  background: #eaf8f0;
  font-size: 12px;
  border: 1px solid rgba(47,175,114,.18);
}
.badge.off { color: #718096; background: #eef3f8; border-color: #dce5ee; }
.api-meta { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.7; word-break: break-all; }
.api-actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }
.model-tools {
  margin: 18px 0 12px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
}
.model-search { height: 44px; }
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 9px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}
.model-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  border-radius: 15px;
  background: #ffffff;
  border: 1px solid #e0e8f2;
  color: #2d3a50;
  font-size: 13px;
  min-width: 0;
}
.model-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-item input { width: 17px; height: 17px; accent-color: #2faf72; flex: 0 0 auto; }

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}
.login-card {
  width: min(100%, 430px);
  border-radius: 30px;
  padding: 30px;
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(121,143,169,.20);
  box-shadow: 0 30px 80px rgba(43, 70, 103, .15);
}
.login-logo {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  letter-spacing: .05em;
  background: linear-gradient(135deg, #ff7bb0 0%, #8c7cff 48%, #38d9b2 100%);
  box-shadow: 0 16px 34px rgba(101,116,255,.22);
  margin-bottom: 20px;
}
.login-card h1 { margin: 0 0 10px; font-size: 30px; }
.login-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.65; }
.login-form { display: grid; gap: 15px; }
.login-form button { margin-top: 4px; min-height: 48px; }
.login-error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  color: #be3c69;
  background: #fff1f5;
  border: 1px solid rgba(224,93,133,.20);
}
.login-back { display: inline-block; margin-top: 16px; text-decoration: none; color: #607084; }

@media (max-width: 900px) {
  .grid.four, .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .api-admin-top { flex-direction: column; }
  .api-actions { justify-content: flex-start; }
  .model-tools { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .phone-shell { padding: 18px 18px 34px; }
  .clean-search { padding-top: 12px; margin-bottom: 16px; }
  .search-box { min-height: 66px; padding: 8px 10px 8px 20px; gap: 12px; }
  .search-box input { font-size: 19px; }
  .search-logo { min-width: 56px; height: 40px; padding: 0 12px; font-size: 14px; }
  .magnifier { width: 23px; height: 23px; border-width: 3px; }
  .monitor-card { border-radius: 26px; padding: 19px; }
  .card-title { font-size: 20px; }
  .bar { width: 5px; }
  .card-foot { font-size: 13px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .admin-shell { width: min(100% - 22px, 1180px); padding-top: 20px; }
  .admin-header { flex-direction: column; align-items: flex-start; }
  .admin-header-actions { justify-content: flex-start; }
  .admin-panel { padding: 18px; border-radius: 22px; }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .model-tools { grid-template-columns: 1fr; }
  .model-grid { grid-template-columns: 1fr; }
  .login-shell { padding: 18px; }
  .login-card { padding: 24px; border-radius: 26px; }
}
