:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #17201c;
  --muted: #717b76;
  --line: #e7eae8;
  --green: #16a66a;
  --green-soft: #eaf8f1;
  --red: #db3d55;
  --red-soft: #fff0f2;
  --amber: #bd7c08;
  --amber-soft: #fff7e6;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input { font: inherit; }
button { color: inherit; }
.site-header { height: 64px; padding: 0 max(24px, calc((100% - 1040px) / 2)); display: flex; align-items: center; justify-content: space-between; background: white; border-bottom: 1px solid var(--line); }
.brand, .login-brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 14px; }
.brand-dot { width: 11px; height: 11px; display: inline-block; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.header-actions, .connection { display: flex; align-items: center; gap: 18px; }
.connection { gap: 7px; color: var(--muted); font-size: 12px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #b8bfbb; }
.live-dot.online { background: var(--green); }
.shell { width: min(1040px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 60px; }
.page-title { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-title h1 { margin: 0 0 8px; font-size: 29px; letter-spacing: -.035em; }
.page-title p { margin: 0; color: var(--muted); font: 12px "Cascadia Code", Consolas, monospace; }
.actions { display: flex; gap: 9px; }
.button { padding: 10px 16px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 650; transition: .15s; }
.button:hover { filter: brightness(.97); }
.button:disabled { opacity: .55; cursor: wait; }
.button.primary { color: white; background: var(--green); }
.button.secondary { background: white; border-color: var(--line); }
.button.danger { color: var(--red); background: white; border-color: #f2cdd3; }
.link-button { padding: 0; color: var(--muted); background: none; border: 0; cursor: pointer; font-size: 12px; }
.link-button:hover, .link-button.green { color: var(--green); }
.status-card, .panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.status-card { padding: 28px; }
.status-line { display: flex; align-items: center; gap: 14px; }
.status-line h2 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.02em; }
.pulse { width: 12px; height: 12px; flex: 0 0 auto; border-radius: 50%; background: #a9b1ad; box-shadow: 0 0 0 6px #f0f2f1; }
.pulse.up { background: var(--green); box-shadow: 0 0 0 6px var(--green-soft); }
.pulse.down { background: var(--red); box-shadow: 0 0 0 6px var(--red-soft); }
.pulse.degraded, .pulse.checking { background: var(--amber); box-shadow: 0 0 0 6px var(--amber-soft); }
.status-pill { color: var(--muted); font-size: 11px; }
.status-pill.up { color: var(--green); }
.status-pill.down { color: var(--red); }
.status-pill.degraded, .status-pill.checking { color: var(--amber); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 26px 0 18px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stats div { padding: 16px; border-right: 1px solid var(--line); }
.stats div:last-child { border: 0; }
.stats small { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.stats strong { font-size: 16px; }
.subline { display: flex; justify-content: space-between; gap: 20px; margin: 0; color: var(--muted); font-size: 11px; }
.subline b { font-weight: 500; color: var(--text); }
.error-line { margin: 9px 0 0; color: var(--muted); font-size: 11px; }
.tabs { display: flex; gap: 24px; margin: 30px 0 14px; border-bottom: 1px solid var(--line); }
.tab { padding: 0 1px 12px; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; font-size: 13px; }
.tab.active { color: var(--text); border-color: var(--green); font-weight: 650; }
.panel { padding: 25px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-title { display: flex; justify-content: space-between; align-items: start; margin-bottom: 20px; }
.panel-title h2 { margin: 0; font-size: 17px; }
.panel-title p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.panel-title > span { color: var(--muted); font-size: 11px; }
.history-list { max-height: 420px; overflow: auto; }
.history-row { display: grid; grid-template-columns: 8px 1fr auto; gap: 13px; align-items: center; padding: 15px 3px; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: 0; }
.history-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.history-row.ok .history-dot { background: var(--green); }
.history-main strong, .history-meta strong { display: block; font-size: 12px; }
.history-main small, .history-meta small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.history-meta { text-align: right; }
.empty-state { padding: 75px 20px; color: var(--muted); text-align: center; font-size: 12px; }
.target-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 22px; }
.target-card { padding: 17px; border: 1px solid var(--line); border-radius: 10px; }
.target-card-head, .target-card-foot, .targets-heading, .target-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.target-card-head strong { display: block; font-size: 13px; }
.target-card-head small { display: block; margin-top: 5px; color: var(--muted); font: 10px "Cascadia Code", Consolas, monospace; }
.target-status { padding: 4px 7px; border-radius: 20px; color: var(--muted); background: #f1f3f2; font-size: 9px; }
.target-status.up { color: var(--green); background: var(--green-soft); }
.target-status.down { color: var(--red); background: var(--red-soft); }
.target-status.degraded, .target-status.checking { color: var(--amber); background: var(--amber-soft); }
.target-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 15px 0; color: var(--muted); font-size: 10px; }
.target-metrics b { float: right; color: var(--text); font-weight: 600; }
.target-card-foot { padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.targets-heading { margin-bottom: 12px; }
.targets-heading > strong { font-size: 12px; }
.button.small { padding: 7px 10px; font-size: 11px; }
.targets-editor { display: grid; gap: 12px; }
.target-editor { padding: 17px; border: 1px solid var(--line); border-radius: 10px; background: #fdfefd; }
.target-editor-head { margin-bottom: 14px; }
.target-editor-head strong { font-size: 11px; }
.remove-target { padding: 0; color: var(--red); background: none; border: 0; cursor: pointer; font-size: 10px; }
.target-fields { display: grid; grid-template-columns: 1.1fr 2fr repeat(4, .8fr); gap: 10px; }
.target-fields .field label { white-space: nowrap; }
.failover-config { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.failover-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 14px; }
[hidden] { display: none !important; }
.cloudflare-auth-box { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: center; margin-top: 16px; padding: 18px; border: 1px solid #dbe8e1; border-radius: 10px; background: #f8fcfa; }
.cloudflare-auth-box > div > strong { display: block; font-size: 12px; }
.cloudflare-auth-box > div > small { display: block; max-width: 370px; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.cloudflare-auth-box .field { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.history-actions { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 11px; }
.clear-history { color: var(--red); }
.span-2 { grid-column: 1 / -1; }
.field { margin-bottom: 3px; }
.field label { display: block; margin: 0 0 7px; color: #4e5853; font-size: 11px; }
input { width: 100%; padding: 11px 12px; color: var(--text); background: white; border: 1px solid #dce1de; border-radius: 8px; outline: none; font-size: 12px; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.notification-box { margin-top: 19px; padding: 18px; border-radius: 10px; background: #fafbfa; border: 1px solid var(--line); }
.switch-line { display: flex; align-items: center; justify-content: space-between; }
.switch-line strong { display: block; font-size: 12px; }
.switch-line small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.switch { width: 38px; height: 22px; position: relative; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: #d7dcda; cursor: pointer; transition: .2s; }
.switch span::after { content: ''; position: absolute; width: 16px; height: 16px; top: 3px; left: 3px; border-radius: 50%; background: white; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); }
#telegramFields { margin-top: 16px; }
#telegramFields .link-button { margin-top: 10px; }
.save-button { margin-top: 20px; min-width: 120px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 15px; color: white; background: #26312c; border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,.16); font-size: 12px; opacity: 0; transform: translateY(20px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.login-page { display: grid; place-items: center; padding: 24px; background: white; }
.login-card { width: min(390px, 100%); padding: 35px; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 55px rgba(25,38,31,.08); }
.login-brand { margin-bottom: 38px; }
.login-card h1 { margin: 0 0 9px; font-size: 25px; letter-spacing: -.035em; }
.login-card > p { margin: 0 0 28px; color: var(--muted); font-size: 12px; }
.login-card .field { margin-bottom: 16px; }
.login-button { width: 100%; padding: 12px; }
.login-error { min-height: 18px; margin: -3px 0 8px; color: var(--red); font-size: 11px; }

@media (max-width: 650px) {
  .site-header { padding: 0 18px; }
  .shell { width: min(100% - 28px, 1040px); padding-top: 32px; }
  .page-title { align-items: start; flex-direction: column; }
  .actions { width: 100%; }
  .actions .button { flex: 1; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats div:nth-child(2) { border-right: 0; }
  .stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .subline { flex-direction: column; gap: 6px; }
  .form-grid { grid-template-columns: 1fr; }
  .target-cards { grid-template-columns: 1fr; }
  .target-fields { grid-template-columns: 1fr 1fr; }
  .target-address { grid-column: 1 / -1; }
  .failover-fields, .cloudflare-auth-box { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .connection span { display: none; }
  .panel, .status-card { padding: 20px; }
}
