@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

:root {
  --bg: #0a0d14;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, rgba(91,140,255,0.14), transparent 60%),
             radial-gradient(900px 500px at 100% 0%, rgba(120,80,255,0.10), transparent 55%);
  --card: #121722;
  --card-hover: #151b28;
  --border: #212838;
  --border-soft: #1a2130;
  --text: #e9ecf3;
  --muted: #838fa3;
  --muted-dim: #5b6579;
  --accent: #5b8cff;
  --accent-soft: rgba(91,140,255,0.14);
  --ok: #35d399;
  --ok-soft: rgba(53,211,153,0.14);
  --warn: #f0a93c;
  --warn-soft: rgba(240,169,60,0.14);
  --danger: #f2545b;
  --danger-soft: rgba(242,84,91,0.14);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 32px -12px rgba(0,0,0,0.5);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg) var(--bg-grad); background-attachment: fixed;
  color: var(--text); overflow-x: hidden; -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
code { background: #060810; padding: 2px 7px; border-radius: 5px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.9em; }
svg { display: block; }

.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- Topbar --- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  padding: 16px 24px; gap: 8px 16px; border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; background: rgba(10,13,20,0.85); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); animation: pulse 2.4s ease-in-out infinite; }
.topbar h1 { font-size: 1.05rem; word-break: break-word; }
.topbar-right { display: flex; gap: 8px 18px; align-items: center; font-size: 0.86rem; flex-wrap: wrap; color: var(--muted); }
.topbar-right a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; transition: color 0.15s; }
.topbar-right a:hover { color: var(--danger); }

main { max-width: 1040px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }

/* --- Cards --- */
.card {
  background: linear-gradient(180deg, var(--card), var(--card) 60%, #10141d);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow); animation: fadeIn 0.4s ease both;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-head .icon { color: var(--accent); width: 17px; height: 17px; }
.card h2 { font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.card.danger { border-color: #3a1f28; background: linear-gradient(180deg, #171018, #121722 70%); }
.card.danger .card-head .icon { color: var(--danger); }

/* --- Stat grid --- */
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 0.78rem; color: var(--muted); }

/* --- Disk / SMART --- */
.disk-list, .smart-list { margin-top: 16px; display: flex; flex-direction: column; gap: 9px; }
.disk-row { display: flex; align-items: center; gap: 12px; font-size: 0.88rem; }
.disk-row .mount { width: 150px; color: var(--muted); font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { flex: 1; height: 7px; background: #060810; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7aa3ff); border-radius: 4px; transition: width 0.6s ease; }
.bar.high > span { background: linear-gradient(90deg, var(--warn), #f6c268); }
.bar.crit > span { background: linear-gradient(90deg, var(--danger), #ff8288); }
.disk-row .pct { width: 40px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.82rem; }

/* --- Tables --- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px; }
.tbl { width: 100%; min-width: 460px; border-collapse: collapse; font-size: 0.9rem; }
.tbl th { text-align: left; color: var(--muted-dim); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 0 10px 10px; white-space: nowrap; }
.tbl td { padding: 11px 10px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
.tbl tr:first-child td { border-top: none; }
.tbl td.name { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.tbl td .btn { margin: 2px 4px 2px 0; }

/* --- Badges --- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 20px; font-size: 0.76rem; font-weight: 600; white-space: nowrap; }
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.ok .bdot { animation: pulse 2.4s ease-in-out infinite; }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.mid { background: var(--warn-soft); color: var(--warn); }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: #171d2b; color: var(--text); padding: 8px 13px; border-radius: 9px; cursor: pointer;
  font-size: 0.82rem; font-weight: 600; font-family: inherit; min-height: 38px;
  touch-action: manipulation; transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.btn:hover { border-color: var(--accent); background: #1a2131; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { background: #4a7bf0; }
.btn.warn { border-color: rgba(240,169,60,0.4); color: var(--warn); }
.btn.warn:hover { background: var(--warn-soft); }
.btn.danger { border-color: rgba(242,84,91,0.4); color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: white; }
.btn.danger.solid:hover { background: #e13a42; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 4px; }

/* --- Chart --- */
.chart-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 4px; }
.range-tabs { display: flex; gap: 4px; background: #060810; padding: 3px; border-radius: 8px; }
.range-tabs button {
  border: none; background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 6px;
  font-size: 0.78rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.range-tabs button.active { background: var(--accent); color: white; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 14px; }
@media (max-width: 640px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-box { min-width: 0; }
.chart-box .chart-title { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.chart-box .chart-title .now { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-svg { width: 100%; height: 100px; overflow: visible; }
.chart-empty { color: var(--muted-dim); font-size: 0.82rem; padding: 20px 0; text-align: center; }

/* --- Toasts --- */
#toast { position: fixed; bottom: 20px; right: 20px; left: 20px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 100; pointer-events: none; }
.toast-item {
  background: #171d2b; border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 11px 16px; border-radius: 9px; max-width: 340px; width: 100%; font-size: 0.86rem;
  box-shadow: var(--shadow); pointer-events: auto; animation: slideIn 0.25s ease both;
}
.toast-item.err { border-left-color: var(--danger); }

/* --- Login --- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 20px; box-sizing: border-box; background: var(--bg) var(--bg-grad); background-attachment: fixed; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 34px 30px; width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); animation: fadeIn 0.4s ease both; }
.login-card .brand { display: flex; justify-content: center; margin-bottom: 4px; }
.login-card .brand .icon { width: 30px; height: 30px; color: var(--accent); }
.login-card h1 { font-size: 1.15rem; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 0 0 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; color: var(--muted); font-weight: 500; }
.login-card input { background: #060810; border: 1px solid var(--border); color: var(--text); padding: 11px 12px; border-radius: 8px; font-size: 16px; font-family: inherit; }
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button { margin-top: 6px; background: var(--accent); border: none; color: white; padding: 12px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 15px; min-height: 46px; transition: background 0.15s; }
.login-card button:hover { background: #4a7bf0; }
.login-card .error { color: var(--danger); font-size: 0.85rem; text-align: center; }

/* --- Animations --- */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 600px) {
  main { padding: 14px; gap: 12px; }
  .topbar { padding: 12px 16px; }
  .card { padding: 16px; }
  .grid4 { grid-template-columns: repeat(2, 1fr); }
  .disk-row .mount { width: 92px; font-size: 0.76rem; }
  #toast { left: 12px; right: 12px; }
  .toast-item { max-width: none; }
}
