:root{
  --bg:#0b0f14;
  --panel:#121822;
  --panel-2:#182130;
  --line:#243044;
  --text:#e7edf5;
  --text-muted:#8b98ab;
  --teal:#14a3a0;
  --teal-deep:#0b5e5d;
  --green:#33c17b;
  --amber:#e0a83d;
  --red:#e0524f;
  --gray:#6b7686;
  --radius:10px;
}

:root[data-theme="light"]{
  --bg:#f4f6f9;
  --panel:#ffffff;
  --panel-2:#eef1f6;
  --line:#dde3ec;
  --text:#182430;
  --text-muted:#5b6675;
  --teal:#0e8f8c;
  --teal-deep:#0b6b69;
  --green:#1f9d5c;
  --amber:#b9790a;
  --red:#d1403c;
  --gray:#8b95a3;
}
:root[data-theme="light"] .alert-error{ color:#b3221f; }
:root[data-theme="light"] .alert-success{ color:#146b3a; }

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  min-height:100vh;
}
a{ color:var(--teal); }
code{ background:var(--panel-2); padding:1px 6px; border-radius:4px; font-size:.9em; }

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 28px; background:var(--panel); border-bottom:1px solid var(--line);
}
.topbar .brand{ font-weight:700; color:var(--text); text-decoration:none; font-size:16px; }
.topbar .brand span{ color:var(--teal); font-weight:400; }
.topbar nav{ display:flex; align-items:center; gap:22px; }
.topbar nav a{ color:var(--text-muted); text-decoration:none; font-size:14px; }
.topbar nav a:hover, .topbar nav a.active{ color:var(--text); }

.link-button{
  background:none; border:none; color:var(--text-muted); font-size:14px; cursor:pointer; padding:0; font-family:inherit;
}
.link-button:hover{ color:var(--text); }
.inline-form{ display:inline; }

.theme-toggle-inline{ font-size:16px; line-height:1; }
.theme-toggle-fixed{
  position:fixed; top:16px; right:16px; z-index:50;
  background:var(--panel-2); border:1px solid var(--line); color:var(--text);
  border-radius:8px; width:36px; height:36px; cursor:pointer; font-size:16px;
  display:flex; align-items:center; justify-content:center;
}
.theme-toggle-fixed:hover{ border-color:var(--teal); }

main{ max-width:1040px; margin:0 auto; padding:32px 24px 60px; }

.page-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:22px; }
.page-head h1{ margin:0; font-size:22px; }

.btn{
  display:inline-block; padding:9px 16px; border-radius:8px; border:1px solid var(--line);
  background:var(--panel-2); color:var(--text); text-decoration:none; font-size:14px; cursor:pointer;
  font-family:inherit;
}
.btn:hover{ border-color:var(--teal); }
.btn-primary{ background:var(--teal-deep); border-color:var(--teal-deep); color:#fff; }
.btn-primary:hover{ background:var(--teal); border-color:var(--teal); }
.btn-danger{ color:var(--red); }
.btn-danger:hover{ border-color:var(--red); }
.btn-small{ padding:6px 11px; font-size:13px; }
.btn-block{ display:block; width:100%; text-align:center; }

.empty-state{
  text-align:center; padding:60px 20px; color:var(--text-muted);
  background:var(--panel); border:1px dashed var(--line); border-radius:var(--radius);
}
.empty-state p{ margin-bottom:18px; }

.checks-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(300px,1fr)); gap:16px; }
.check-card{
  background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:18px;
  border-left:4px solid var(--gray);
}
.check-card.status-up{ border-left-color:var(--green); }
.check-card.status-new{ border-left-color:var(--teal); }
.check-card.status-late{ border-left-color:var(--amber); }
.check-card.status-down{ border-left-color:var(--red); }
.check-card.status-paused{ border-left-color:var(--gray); }

.check-card-head{ display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.check-card-head h2{ margin:0; font-size:16px; }

.status-pill{
  font-size:11px; text-transform:uppercase; letter-spacing:.04em; font-weight:700;
  padding:3px 8px; border-radius:20px; color:#0b0f14; background:var(--gray); flex:none;
}
.status-pill.status-up{ background:var(--green); }
.status-pill.status-new{ background:var(--teal); }
.status-pill.status-late{ background:var(--amber); }
.status-pill.status-down{ background:var(--red); color:#fff; }
.status-pill.status-paused{ background:var(--gray); }

.check-meta{ display:flex; flex-direction:column; gap:2px; font-size:13px; color:var(--text-muted); margin-bottom:12px; }

.ping-url-row{ display:flex; gap:6px; margin-bottom:8px; }
.ping-url-input{
  flex:1; min-width:0; background:var(--panel-2); border:1px solid var(--line); border-radius:6px;
  color:var(--text-muted); font-size:12px; padding:7px 9px; font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
}
.curl-row{ display:flex; gap:6px; margin-bottom:12px; align-items:stretch; }
.curl-snippet{
  flex:1; min-width:0; background:var(--panel-2); border:1px solid var(--line); border-radius:6px; padding:8px 10px;
  font-size:12px; color:var(--text-muted); overflow-x:auto; margin:0;
}

.check-actions{ display:flex; gap:8px; flex-wrap:wrap; }

.card{ background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:22px; margin-bottom:18px; }

.history-card h2{ margin:0 0 14px; font-size:15px; }
.history-empty{ margin:0; }
.history-list{ list-style:none; margin:0; padding:0; max-height:220px; overflow-y:auto; }
.history-row{
  display:flex; align-items:center; gap:12px; padding:8px 0;
  border-top:1px solid var(--line); font-size:13px;
}
.history-row:first-child{ border-top:none; }
.history-name{ color:var(--text); flex:1; }
.history-time{ color:var(--text-muted); flex:none; }
.form-card h2{ margin:0 0 10px; font-size:15px; }
.form-card label{ display:block; margin-bottom:14px; font-size:13px; color:var(--text-muted); }
.form-card input[type=text], .form-card input[type=password], .form-card input[type=url], .form-card input[type=number]{
  display:block; width:100%; margin-top:6px; padding:9px 11px; background:var(--panel-2);
  border:1px solid var(--line); border-radius:7px; color:var(--text); font-size:14px; font-family:inherit;
}
.form-card select{
  margin-top:6px; padding:9px 11px; background:var(--panel-2); border:1px solid var(--line);
  border-radius:7px; color:var(--text); font-size:14px; font-family:inherit;
}
.form-card input:focus, .form-card select:focus{ outline:none; border-color:var(--teal); }
.form-row{ display:flex; gap:20px; flex-wrap:wrap; }
.form-row label{ flex:1; min-width:200px; }
.value-unit{ display:flex; gap:8px; }
.value-unit input{ flex:1; }
.hint{ font-size:12.5px; color:var(--text-muted); margin:0 0 16px; }
.hint-inline{ font-weight:400; opacity:.7; }
.check-meta a{ color:var(--teal); text-decoration:none; }
.check-meta a:hover{ text-decoration:underline; }
.form-actions{ display:flex; gap:10px; }

.alert{ padding:10px 14px; border-radius:8px; font-size:14px; margin-bottom:16px; }
.alert-error{ background:rgba(224,82,79,.12); border:1px solid rgba(224,82,79,.4); color:#ff8785; }
.alert-success{ background:rgba(51,193,123,.12); border:1px solid rgba(51,193,123,.4); color:#5fe0a4; }

.auth-wrap{ display:flex; align-items:center; justify-content:center; min-height:80vh; }
.auth-card{
  background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:32px;
  width:100%; max-width:340px;
}
.auth-card h1{ font-size:18px; text-align:center; margin:0 0 20px; line-height:1.4; }
.auth-card h1 span{ color:var(--teal); }
.auth-card label{ display:block; margin-bottom:14px; font-size:13px; color:var(--text-muted); }
.auth-card input{
  display:block; width:100%; margin-top:6px; padding:10px 11px; background:var(--panel-2);
  border:1px solid var(--line); border-radius:7px; color:var(--text); font-size:14px; font-family:inherit;
}
.auth-card input:focus{ outline:none; border-color:var(--teal); }
.auth-card button{ margin-top:6px; }

.devices-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(300px,1fr)); gap:16px; }
.device-card{
  background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:18px;
  border-left:4px solid var(--gray);
}
.device-card.status-online{ border-left-color:var(--green); }
.device-card.status-offline{ border-left-color:var(--red); }
.device-card.status-new{ border-left-color:var(--teal); }

.status-pill.status-online{ background:var(--green); }
.status-pill.status-offline{ background:var(--red); color:#fff; }

.device-card-head{ display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.device-card-head h2{ margin:0; font-size:16px; }
.device-meta{ display:flex; flex-direction:column; gap:2px; font-size:13px; color:var(--text-muted); margin-bottom:12px; }
.device-actions{ display:flex; gap:8px; flex-wrap:wrap; }

.tunnel-list{ list-style:none; margin:0 0 16px; padding:0; }
.tunnel-row{
  display:flex; align-items:center; gap:12px; padding:10px 0;
  border-top:1px solid var(--line); font-size:13px; flex-wrap:wrap;
}
.tunnel-row:first-child{ border-top:none; }
.tunnel-protocol{
  font-size:11px; text-transform:uppercase; letter-spacing:.04em; font-weight:700;
  padding:3px 8px; border-radius:20px; color:#0b0f14; background:var(--teal); flex:none;
}
.tunnel-hostport{ flex:1; min-width:220px; color:var(--text); }
.tunnel-hostport strong{ font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
.tunnel-command-row{ display:flex; align-items:center; gap:8px; flex-basis:100%; }
.tunnel-connect{
  flex:1; min-width:200px; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; color:var(--text-muted);
  background:var(--panel-2); border:1px solid var(--line); border-radius:6px; padding:6px 9px; font-size:12px;
  margin:0; overflow-x:auto;
}
.install-cmd{
  background:var(--panel-2); border:1px solid var(--line); border-radius:6px; padding:12px 14px;
  font-size:12.5px; color:var(--text); overflow-x:auto; white-space:pre-wrap; word-break:break-all; margin:0 0 10px;
}

@media (max-width:640px){
  .topbar{ flex-direction:column; gap:10px; align-items:flex-start; }
  .form-row{ flex-direction:column; gap:0; }
}
