:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #14161f;
  --muted: #6b6d80;
  --border: #e6e7ee;
  --accent: #6d5ef8;
  --accent-2: #4f3ff0;
  --accent-soft: #efecff;
  --ok: #17a673;
  --ok-soft: #e4f8f0;
  --off: #9ca0b3;
  --off-soft: #eef0f5;
  --erro: #e0446c;
  --erro-soft: #fdeaf0;
  --sidebar-bg: #14151f;
  --sidebar-text: #c9cadb;
  --sidebar-text-active: #ffffff;
  --shadow: 0 1px 2px rgba(20, 22, 31, 0.04), 0 8px 24px -12px rgba(20, 22, 31, 0.12);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0e14;
    --surface: #16171f;
    --surface-2: #1b1c26;
    --text: #f1f1f6;
    --muted: #9496a8;
    --border: #262835;
    --accent: #8b7bff;
    --accent-2: #7261f5;
    --accent-soft: #241f42;
    --ok: #35c896;
    --ok-soft: #10291f;
    --off: #6f7286;
    --off-soft: #1d1f2b;
    --erro: #f16a8c;
    --erro-soft: #2c1420;
    --sidebar-bg: #0a0a10;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 28px -14px rgba(0,0,0,0.55);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- layout ---------- */
.shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 26px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.brand-text {
  font-weight: 600;
  color: white;
  font-size: 15px;
}
.brand-text em { color: var(--accent); font-style: normal; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: var(--sidebar-text-active); }
.sidebar nav a.active { background: var(--accent); color: white; }
.sidebar nav a.active svg { opacity: 1; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.who { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.who-nome { font-size: 13px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who a { font-size: 12px; color: var(--muted); text-decoration: none; }
.who a:hover { color: var(--sidebar-text-active); }

main { flex: 1; padding: 40px 44px; max-width: 1000px; }

.page-header { margin-bottom: 28px; }
.page-header h1 { margin: 0 0 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.page-sub { margin: 0; color: var(--muted); font-size: 14.5px; }
.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-size: 13.5px; margin-bottom: 14px; }
.back-link:hover { color: var(--accent); }

/* ---------- cards ---------- */
.cards { display: flex; gap: 16px; flex-wrap: wrap; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px; min-width: 220px; flex: 1;
  text-decoration: none; color: var(--text);
  transition: transform 0.15s, border-color 0.15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card.muted { opacity: 0.75; }
.card-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
}
.card-icon svg { width: 19px; height: 19px; }
.card-value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.card-label { font-weight: 600; font-size: 14.5px; }
.card-hint { color: var(--muted); font-size: 13px; }

/* ---------- table ---------- */
.tabela-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.tabela { width: 100%; border-collapse: collapse; }
.tabela th {
  text-align: left; padding: 13px 18px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.tabela td { text-align: left; padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 14px; }
.tabela tr:last-child td { border-bottom: none; }
.tabela tr:hover td { background: var(--surface-2); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--off-soft); color: var(--muted); }
.badge.erro { background: var(--erro-soft); color: var(--erro); margin-left: 6px; }

.muted { color: var(--muted); }
.erro { color: var(--erro); }
.aviso {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; color: var(--muted); line-height: 1.6; font-size: 14.5px;
}

/* ---------- lists ---------- */
.lista-clientes, .lista-arquivos { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.lista-clientes li, .lista-arquivos li {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.lista-clientes a, .lista-arquivos a { color: var(--text); text-decoration: none; font-weight: 600; font-size: 14.5px; }
.lista-clientes a:hover, .lista-arquivos a:hover { color: var(--accent); }

/* ---------- login ---------- */
body.guest { background: radial-gradient(circle at 20% 20%, var(--accent-soft), var(--bg) 55%); }
.guest-main { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-box {
  width: 100%; max-width: 340px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); padding: 36px 32px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.brand-mark.big { width: 46px; height: 46px; font-size: 16px; border-radius: 12px; margin-bottom: 14px; }
.login-box h1 { font-size: 20px; margin: 0 0 6px; }
.login-box .subtitle { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; line-height: 1.5; }
.login-box form { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.login-box label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; text-align: left; }
.login-box input {
  padding: 11px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 14px; font-family: inherit;
}
.login-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-box button {
  padding: 11px; border-radius: 9px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; font-weight: 600; cursor: pointer; font-size: 14px; font-family: inherit;
  margin-top: 4px;
}
.login-box button:hover { filter: brightness(1.06); }
.login-box .erro { color: var(--erro); font-size: 13px; margin: 0 0 4px; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative; flex-direction: row;
    align-items: center; padding: 12px 16px; gap: 10px; overflow-x: auto;
  }
  .brand { padding: 0; }
  .brand-text { display: none; }
  .sidebar nav { flex-direction: row; flex: none; }
  .sidebar nav a span { display: none; }
  .sidebar-user { margin-top: 0; border-top: none; padding: 0; margin-left: auto; }
  .who-nome { display: none; }
  main { padding: 24px 18px; }
  .cards { flex-direction: column; }
}
