* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f1420;
  --card: #1a2233;
  --card-2: #212b40;
  --text: #e8ecf4;
  --muted: #8b96ab;
  --accent: #4f9cff;
  --green: #3ddc84;
  --yellow: #ffc447;
  --red: #ff5c5c;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }

/* Login */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 90vh;
}
.login-box {
  background: var(--card); padding: 32px; border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 12px; width: min(320px, 90vw);
}
.login-box input {
  padding: 12px; border-radius: 8px; border: 1px solid #33415c;
  background: var(--bg); color: var(--text); font-size: 16px;
}
.login-box button {
  padding: 12px; border-radius: 8px; border: none;
  background: var(--accent); color: #fff; font-size: 16px; cursor: pointer;
}
.error { color: var(--red); font-size: 14px; }

/* Header */
header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
h1 { font-size: 20px; }
h2 { font-size: 15px; margin-bottom: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.subtitle, .muted { color: var(--muted); font-size: 13px; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); display: inline-block; }
.dot.ok { background: var(--green); }

/* Cards */
.cards {
  display: grid; gap: 12px; margin-bottom: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.cards .card { margin-bottom: 0; }
.big { font-size: 28px; font-weight: 700; }

.gauge {
  height: 10px; background: var(--bg); border-radius: 5px;
  overflow: hidden; margin-bottom: 10px;
}
.bar {
  height: 100%; width: 0%; background: var(--green);
  border-radius: 5px; transition: width 0.5s, background 0.5s;
}
.bar.warn { background: var(--yellow); }
.bar.crit { background: var(--red); }

.cores {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 6px; margin-top: 12px;
}
.core {
  background: var(--bg); border-radius: 6px; height: 40px;
  position: relative; overflow: hidden;
}
.core .fill {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--accent); transition: height 0.5s;
}
.core span {
  position: absolute; top: 2px; left: 0; right: 0;
  text-align: center; font-size: 10px; color: var(--muted); z-index: 1;
}

/* Disco / rede */
.disk-row, .net-row {
  margin-bottom: 10px; font-size: 13px;
}
.disk-row .gauge { margin: 4px 0 0; }
.row-head { display: flex; justify-content: space-between; }

/* Usuários / processos */
.user-group { margin-bottom: 8px; border-radius: 8px; overflow: hidden; background: var(--card-2); }
.user-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; cursor: pointer; user-select: none;
}
.user-head:hover { background: #283350; }
.user-head .uname { font-weight: 600; }
.user-head .ustats { color: var(--muted); font-size: 13px; }
.proc-table { width: 100%; border-collapse: collapse; font-size: 13px; display: none; }
.user-group.open .proc-table { display: table; }
.proc-table th, .proc-table td {
  text-align: left; padding: 6px 12px; border-top: 1px solid #2a3550;
}
.proc-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.proc-table td.num, .proc-table th.num { text-align: right; }
.proc-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.session-row { font-size: 13px; padding: 6px 0; border-bottom: 1px solid #2a3550; }
.session-row:last-child { border-bottom: none; }

@media (max-width: 600px) {
  body { padding: 10px; }
  .proc-table th:nth-child(4), .proc-table td:nth-child(4) { display: none; }
}
