:root {
  --bg: #070b14;
  --bg2: #0b1220;
  --card: #0e1728;
  --card2: #111c31;
  --line: #1c2a45;
  --text: #e6edf7;
  --muted: #8aa0be;
  --accent: #38e8c8;
  --accent2: #7c6cff;
  --ok: #2fe08a;
  --warn: #ffbf4d;
  --danger: #ff5d6c;
  --radius: 16px;
  --shadow: 0 18px 50px -22px rgba(0, 0, 0, .9);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(56, 232, 200, .09), transparent 60%),
    radial-gradient(900px 500px at 92% 0%, rgba(124, 108, 255, .11), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 18px; }
.muted { color: var(--muted); }
.sm { font-size: 12.5px; }
.accent { color: var(--accent); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, rgba(17, 28, 49, .92), rgba(10, 17, 31, .96));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px 30px 26px;
  box-shadow: var(--shadow);
  text-align: center;
}
.logo { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.logo span { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo.small { font-size: 20px; }
.login-sub { color: var(--muted); margin: 6px 0 26px; font-size: 13.5px; }
.login-card label { display: block; text-align: left; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.login-foot { margin-top: 22px; font-size: 11.5px; color: #5d718c; }

/* ---------- form elemanları ---------- */
input, select, button { font: inherit; }
input, select {
  width: 100%;
  background: #0a1424;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #52678a; }
input:focus, select:focus {
  border-color: rgba(56, 232, 200, .55);
  box-shadow: 0 0 0 3px rgba(56, 232, 200, .12);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #5d7594 50%), linear-gradient(135deg, #5d7594 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.hint { color: #587092; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; }
.form-actions.between { justify-content: space-between; }
.form-col { display: flex; flex-direction: column; gap: 13px; }

.btn {
  border: 1px solid var(--line);
  background: #16233a;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  transition: transform .06s, border-color .15s, background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #2a3d61; background: #1a2942; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, #12b9a2, #5b4bdd); border-color: transparent; color: #04100f; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffb3ba; border-color: rgba(255, 93, 108, .35); }
.btn.danger:hover { background: rgba(255, 93, 108, .12); }
.btn.danger.solid { background: #7a2030; border-color: transparent; color: #fff; }
.btn.sm { padding: 7px 11px; font-size: 12.5px; }
.btn.block { width: 100%; margin-top: 14px; padding: 12px; }
.icon-btn { background: transparent; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: #1a2740; color: var(--text); }

/* ---------- topbar / layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  background: rgba(7, 11, 20, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.pill {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); background: #0b1526;
  padding: 6px 12px; border-radius: 999px;
}
.container { max-width: 1280px; margin: 0 auto; padding: 26px 22px 70px; display: flex; flex-direction: column; gap: 22px; }

/* ---------- stat kartları ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 26px; font-weight: 750; margin: 6px 0 2px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: #6d84a6; font-variant-numeric: tabular-nums; }

/* ---------- kartlar ---------- */
.card {
  background: linear-gradient(180deg, rgba(17, 28, 49, .72), rgba(11, 20, 36, .9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.card-head.tight { margin: 16px 0 10px; align-items: center; }
.chart-wrap { position: relative; height: 190px; }
.chart-wrap.small { height: 160px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.legend { display: flex; gap: 18px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.in { background: var(--accent); }
.dot.out { background: var(--accent2); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0a1424; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 7px 11px; font-size: 12px; cursor: pointer; }
.seg button.on { background: #17253d; color: var(--text); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }

/* ---------- rota kartları ---------- */
.routes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.route {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s, transform .12s;
}
.route:hover { border-color: #2a3d61; }
.route-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.route-domain { font-weight: 700; font-size: 15.5px; word-break: break-all; }
.route-addr { font-size: 12.5px; color: var(--accent); cursor: pointer; margin-top: 2px; }
.route-addr:hover { text-decoration: underline; }
.badge { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.badge.running { color: #83f5c4; border-color: rgba(47, 224, 138, .35); background: rgba(47, 224, 138, .1); }
.badge.paused { color: #ffd98a; border-color: rgba(255, 191, 77, .35); background: rgba(255, 191, 77, .1); }
.badge.stopped { color: #ffa8b1; border-color: rgba(255, 93, 108, .35); background: rgba(255, 93, 108, .1); }
.route-target { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.code { background: #0a1424; border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #c9d7ec; }
.route-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { background: #0a1424; border: 1px solid #16233a; border-radius: 10px; padding: 8px 10px; }
.metric .k { font-size: 10.5px; color: #6d84a6; text-transform: uppercase; letter-spacing: .05em; }
.metric .v { font-size: 13.5px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.spark { height: 42px; }
.spark canvas { width: 100%; height: 100%; display: block; }
.route-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.route-err { font-size: 12px; color: #ffb3ba; background: rgba(255, 93, 108, .08); border: 1px solid rgba(255, 93, 108, .25); border-radius: 8px; padding: 7px 10px; }
.empty { text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(3, 6, 12, .72); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 18px; }
.modal-card {
  width: 100%; max-width: 480px; max-height: 90vh; overflow: auto;
  background: linear-gradient(180deg, #111c31, #0a1220);
  border: 1px solid var(--line); border-radius: 18px; padding: 20px;
  box-shadow: var(--shadow);
}
.modal-card.wide { max-width: 880px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.detail-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 6px; }

/* ---------- tablo ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 12px; background: #0a1424; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid #142138; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast {
  background: #12203a; border: 1px solid var(--line); color: var(--text);
  padding: 11px 15px; border-radius: 11px; font-size: 13.5px; box-shadow: var(--shadow);
  animation: in .18s ease-out;
  max-width: 340px;
}
.toast.ok { border-color: rgba(47, 224, 138, .45); }
.toast.err { border-color: rgba(255, 93, 108, .5); }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.err { color: #ffb3ba; font-size: 13px; margin-top: 12px; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .routes-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .container { padding: 16px 13px 60px; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 21px; }
  .topbar { padding: 12px 14px; }
  #pillHost { display: none; }
  .detail-stats { grid-template-columns: repeat(2, 1fr); }
}
