:root {
  /* Paleta */
  --primary: #2b0f54;      /* Roxo Uva - principal 60% */
  --primary-600: #1e0a3c;
  --secondary: #d9ccff;    /* Lavanda Gelo - secundaria 30% */
  --secondary-soft: #efe9ff;
  --impact: #ffc300;       /* Amarelo Gema - impacto 10% */
  --impact-600: #e6af00;

  --bg: #f5f1ff;
  --surface: #ffffff;
  --surface-2: #f8f5ff;
  --border: #e6deff;
  --text: #241040;
  --muted: #6e5f88;

  --ok: #1f7a4d;
  --ok-bg: #e3f6ec;
  --bad: #b3261e;
  --bad-bg: #fde7e5;
  --warn: #8a5a00;
  --warn-bg: #fff2cc;

  --sidebar: #2b0f54;
  --sidebar-2: #1b0838;
  --sidebar-text: #d9ccff;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(43, 15, 84, .06), 0 14px 34px rgba(43, 15, 84, .10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1000px 520px at 0% 0%, rgba(217, 204, 255, .55), transparent 62%),
    radial-gradient(820px 460px at 100% 100%, rgba(255, 195, 0, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

::selection { background: var(--secondary); color: var(--primary); }

a { color: #3a1a6b; text-decoration: none; font-weight: 500; }
a:hover { color: var(--primary); text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; color: var(--primary); }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }
p { margin: 0 0 .85rem; }

.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

:focus-visible {
  outline: 2px solid var(--impact);
  outline-offset: 2px;
}

/* Layout */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background:
    radial-gradient(260px 160px at 20% 0%, rgba(217, 204, 255, .18), transparent 70%),
    linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  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: 0 6px 22px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--impact);
  color: var(--primary);
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .04em;
  box-shadow: 0 8px 18px rgba(255, 195, 0, .28);
}
.brand-text { display: flex; flex-direction: column; font-weight: 700; color: #fff; line-height: 1.15; }
.brand-text small { font-weight: 400; color: var(--sidebar-text); font-size: .72rem; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: 11px;
  color: var(--sidebar-text);
  font-weight: 500;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.nav-item:hover { background: rgba(217, 204, 255, .14); color: #fff; text-decoration: none; }
.nav-item.active {
  background: rgba(217, 204, 255, .18);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--impact);
}

.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(217, 204, 255, .18); padding-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--secondary); color: var(--primary); font-weight: 800;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { color: #fff; font-size: .9rem; }
.user-meta small { color: var(--sidebar-text); font-size: .72rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 24px 30px 12px;
}
.topbar h1 { position: relative; padding-bottom: 8px; }
.topbar h1::after {
  content: "";
  position: absolute; left: 0; bottom: 0;
  width: 46px; height: 3px; border-radius: 999px;
  background: var(--impact);
}
.topbar .subtitle { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.topbar-actions { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; }
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--impact);
  box-shadow: 0 0 0 4px rgba(255, 195, 0, .22);
}
.topbar-note { color: var(--primary); font-weight: 600; }
.content { padding: 14px 30px 40px; max-width: 1280px; width: 100%; }

/* Cards and grids */
.grid { display: grid; gap: 18px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 1rem; }

.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--secondary);
}
.stat:first-child::before { background: var(--impact); }
.stat-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.stat-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; color: var(--primary); }
.stat-value small { font-size: .9rem; color: var(--muted); font-weight: 600; }
.stat-value.ok { color: var(--primary); }
.stat-value.ok::before {
  content: "●";
  color: var(--impact);
  font-size: .68em;
  margin-right: 6px;
  vertical-align: .14em;
}
.stat-value.bad { color: var(--bad); }
.stat-note { color: var(--muted); font-size: .8rem; }

.info-strip { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 28px; }
.info-strip > div { display: flex; flex-direction: column; gap: 2px; }
.info-strip strong { font-size: .9rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--secondary-soft); color: #4a2a78; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #faf7ff; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--primary);
  font-size: .74rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge.ok { background: var(--secondary); color: var(--primary); }
.badge.muted { background: var(--secondary-soft); color: var(--muted); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1; }
label { font-size: .84rem; font-weight: 650; color: #3b215f; }
input[type="text"], input[type="password"], input[type="email"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #d9ccff;
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(217, 204, 255, .55); }
input::placeholder { color: #a294bd; }
.hint { color: var(--muted); font-size: .78rem; }
.inline-form { flex-direction: row; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.password-wrap { position: relative; display: flex; gap: 8px; }
.password-wrap input { flex: 1; }
.password-toggle { flex: 0 0 auto; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 15px;
  border: 1px solid var(--secondary);
  border-radius: 11px;
  background: #fff;
  color: var(--primary);
  font: inherit;
  font-weight: 650;
  font-size: .88rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--secondary-soft); color: var(--primary); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.sidebar .btn-ghost { color: var(--sidebar-text); border-color: rgba(217, 204, 255, .32); }
.sidebar .btn-ghost:hover { background: rgba(217, 204, 255, .14); color: #fff; }
.btn-small { padding: 6px 10px; font-size: .78rem; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #8f1d17; border-color: #8f1d17; color: #fff; }
.btn-warning { background: var(--impact); border-color: var(--impact); color: var(--primary); }
.btn-warning:hover { background: var(--impact-600); border-color: var(--impact-600); color: var(--primary); }

/* Flash */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-size: .88rem;
}
.flash-success { background: #fff6d6; border-color: var(--impact); color: #5c4300; }
.flash-error { background: var(--bad-bg); border-color: #f4c4bf; color: #7f1d17; }
.flash-warning { background: var(--warn-bg); border-color: var(--impact); color: #6b4600; }
.flash-info { background: var(--secondary); border-color: #c7b6ff; color: var(--primary); }

/* Activity */
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.activity li { display: flex; gap: 10px; align-items: flex-start; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--secondary); margin-top: 7px; flex: 0 0 8px; }
.activity li:first-child .activity-dot { background: var(--impact); }
.activity strong { font-size: .86rem; color: var(--primary); }
.activity small { display: block; color: var(--muted); font-size: .76rem; margin-top: 2px; }

/* Details */
.details { display: grid; gap: 10px; margin: 0; }
.details > div { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.details dt { color: var(--muted); font-size: .82rem; }
.details dd { margin: 0; font-weight: 650; text-align: right; }
.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* User page */
.user-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.user-header h2 { margin: 4px 0 6px; font-size: 1.35rem; }
.user-header-stats { display: flex; gap: 28px; text-align: right; }
.user-header-stats strong { display: block; font-size: .95rem; }
.user-header-stats span { font-size: .76rem; }
.danger-zone { margin-top: 18px; border-color: #f4c4bf; }

/* 2FA */
.qr-box {
  display: grid;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  width: fit-content;
  margin: 12px 0;
}
.secret {
  display: block;
  padding: 10px 12px;
  background: var(--secondary-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--primary);
  word-break: break-all;
  margin-bottom: 14px;
}
.checklist { margin: 0; padding-left: 20px; color: #3b215f; }
.checklist li { margin-bottom: 7px; }
.checklist li::marker { color: var(--impact-600); }
.recovery-codes {
  background: var(--primary);
  color: var(--secondary);
  padding: 18px;
  border-radius: 14px;
  font-size: 1rem;
  letter-spacing: .08em;
  line-height: 1.9;
  overflow-x: auto;
}

/* Auth */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 520px at 12% 0%, rgba(217, 204, 255, .75), transparent 62%),
    radial-gradient(720px 460px at 100% 100%, rgba(255, 195, 0, .16), transparent 58%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 5px solid var(--impact);
  border-radius: 20px;
  box-shadow: 0 26px 64px rgba(43, 15, 84, .20);
  padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand h1 { font-size: 1.2rem; }
.auth-brand p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; }

.center-card { max-width: 620px; margin: 30px auto; text-align: center; }
.error-code { font-size: 3.5rem; font-weight: 800; color: var(--primary); margin: 0 0 8px; }

@media (max-width: 1040px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; flex: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { flex: 1 1 auto; text-align: center; }
  .sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .cards { grid-template-columns: 1fr; }
  .user-header { flex-direction: column; align-items: flex-start; }
  .user-header-stats { text-align: left; }
  .inline-form { flex-direction: column; align-items: stretch; }
}
