:root {
  --bg: #0f1117;
  --bg-2: #161923;
  --bg-3: #1e2230;
  --border: #2a2f3e;
  --text: #e5e7eb;
  --muted: #9099ab;
  --accent: #f97316;
  --accent-2: #ea580c;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
a { color: #fb923c; }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; }
.brand-badge {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800;
}

/* Buttons */
.btn {
  border: 1px solid var(--border); background: var(--bg-3); color: var(--text);
  padding: 9px 15px; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: .15s; line-height: 1; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: #3a4152; background: #262b3a; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-block { width: 100%; justify-content: center; margin-top: 6px; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; margin: 18px 0 4px; }
.login-card label { display: block; margin: 16px 0 6px; font-size: 13px; font-weight: 600; }

input[type=text], input[type=password] {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 11px 13px; border-radius: 9px; font-size: 14px; outline: none;
}
input:focus { border-color: var(--accent); }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--border); background: var(--bg-2);
  position: sticky; top: 0; z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.container { max-width: 1000px; margin: 0 auto; padding: 26px 22px 80px; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-card .v { font-size: 26px; font-weight: 800; margin-top: 4px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 14px; }
.section-head h2 { font-size: 16px; margin: 0; }

/* Sites list */
.site-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 12px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.site-main { flex: 1; min-width: 220px; }
.site-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.site-url { margin-top: 3px; }
.site-url a { text-decoration: none; }
.site-url a:hover { text-decoration: underline; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.badge-on { background: rgba(34,197,94,.15); color: #4ade80; }
.badge-off { background: rgba(239,68,68,.15); color: #f87171; }

.site-metrics { display: flex; gap: 22px; }
.metric { text-align: center; }
.metric .m-v { font-weight: 800; font-size: 18px; }
.metric .m-k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.site-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.icon-btn {
  border: 1px solid var(--border); background: var(--bg-3); color: var(--text);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 15px; display: grid; place-items: center;
}
.icon-btn:hover { background: #262b3a; }
.icon-btn.danger:hover { background: rgba(239,68,68,.15); border-color: var(--danger); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .btn { margin-top: 14px; }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(6,8,14,.7); display: grid; place-items: center; z-index: 100; padding: 20px; backdrop-filter: blur(2px); }
.modal-box { background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 480px; box-shadow: var(--shadow); max-height: 90vh; display: flex; flex-direction: column; }
.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 24px; cursor: pointer; line-height: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; }
.modal-body label:first-child { margin-top: 0; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Dropzone */
.dropzone { border: 2px dashed var(--border); border-radius: 11px; padding: 26px; text-align: center; cursor: pointer; transition: .15s; background: var(--bg); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(249,115,22,.08); }
.dz-icon { font-size: 30px; }
.dz-inner { pointer-events: none; }

/* Progress */
.progress { height: 8px; background: var(--bg); border-radius: 20px; overflow: hidden; margin-top: 16px; border: 1px solid var(--border); }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }

.error { color: #fca5a5; background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); padding: 9px 12px; border-radius: 8px; margin-top: 14px; font-size: 13px; }

/* Stats modal */
.stat-mini-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px,1fr)); gap: 12px; margin-bottom: 20px; }
.stat-mini { background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.stat-mini .v { font-size: 22px; font-weight: 800; }
.stat-mini .k { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.chart-wrap { background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 20px; overflow-x: auto; }
.chart-wrap h4, .list-block h4 { margin: 0 0 12px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.list-block { margin-bottom: 20px; }
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { grid-column: 1 / -1; height: 6px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-val { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--bg-3); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 9px; box-shadow: var(--shadow); font-size: 14px; max-width: 340px; animation: slidein .2s; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

@media (max-width: 620px) {
  .site-metrics { width: 100%; justify-content: flex-start; }
  .topbar-right #host-label { display: none; }
}
