/* KingMetrics — design system compartilhado (login, cadastro, app, admin) */
:root {
  --ink: #0d1424;
  --ink-2: #141d33;
  --violet: #7c3af5;
  --violet-2: #9b6bff;
  --blue: #2f6bff;
  --blue-2: #4d84ff;
  --grad: linear-gradient(120deg, #7c3af5, #2f6bff);
  --paper: #f6f7fc;
  --card: #ffffff;
  --muted: #64708c;
  --line: #e5e8f2;
  --ok: #1f9d63;
  --danger: #d5453b;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { color: var(--ink); background: var(--paper); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--violet); text-decoration: none; }
a:hover { text-decoration: underline; }

.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.crown { width: 30px; height: 28px; }
.wm-gr { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; padding: 11px 18px; border-radius: 999px; font-size: 14px; border: 0; cursor: pointer; transition: transform .12s, box-shadow .12s, background .12s; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 20px rgba(80,60,240,.32); width: 100%; }
.btn-primary:hover { transform: translateY(-1px); text-decoration: none; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { background: #faf9fe; text-decoration: none; }
.btn-sm { padding: 7px 13px; font-size: 13px; width: auto; }

/* Auth (login/cadastro) */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-aside { display: none; } }
.auth-aside { background: radial-gradient(900px 500px at 30% 10%, rgba(109,59,245,.5), transparent 60%), var(--ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside h2 { font-size: 34px; letter-spacing: -.02em; margin-top: 40px; max-width: 380px; line-height: 1.1; }
.auth-aside p { color: #cfc9e6; margin-top: 16px; max-width: 360px; }
.auth-aside .brand { color: #fff; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 26px; letter-spacing: -.02em; }
.auth-card .sub { color: var(--muted); margin: 8px 0 28px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #443c66; }
.field input, .field select { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; background: #fff; outline: none; transition: border-color .12s, box-shadow .12s; }
.field input:focus, .field select:focus { border-color: var(--violet-2); box-shadow: 0 0 0 3px rgba(109,59,245,.12); }
.muted { color: var(--muted); font-size: 13px; }
.center-row { text-align: center; margin-top: 20px; }
.note { background: #f4f0ff; border: 1px solid #e3d9ff; color: #5a4a99; font-size: 13px; padding: 10px 12px; border-radius: 10px; margin-bottom: 20px; }

/* App shell (usuário e admin) */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
@media (max-width: 820px) { .shell { grid-template-columns: 1fr; } .side { display: none; } }
.side { background: var(--ink); color: #cfc9e6; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px; }
.side .brand { color: #fff; padding: 4px 8px 18px; }
.side a { color: #cfc9e6; padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.side a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.side a.active { background: linear-gradient(135deg, rgba(109,59,245,.35), rgba(155,107,255,.2)); color: #fff; }
.side .spacer { flex: 1; }
.side .badge-admin { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--blue-2); padding: 4px 8px; }

.main { padding: 28px 32px; max-width: 1000px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.topbar h1 { font-size: 24px; letter-spacing: -.02em; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 720px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }
.stat { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill-on { background: #e7f7ee; color: var(--ok); }
.pill-off { background: #f0edf7; color: var(--muted); }

.conn-item { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.conn-item .dot { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; }
.conn-item .grow { flex: 1; }

/* Toggle */
.switch { position: relative; width: 44px; height: 26px; display: inline-block; }
.switch input { display: none; }
.slider { position: absolute; inset: 0; background: #d4cde8; border-radius: 999px; transition: .2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--violet); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 28px 0 12px; }

/* Ações em tabela */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-mini { font-size: 12px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; font-weight: 600; }
.btn-mini:hover { background: #faf9fe; }
.btn-mini.danger { color: var(--danger); border-color: #f3c9c6; }
.btn-mini.ok { color: var(--ok); border-color: #bfe7d0; }
.pill-trial { background: #fff4e0; color: #a5701a; }
.pill-blocked { background: #fbe6e4; color: var(--danger); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(14,10,31,.5); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 420px; box-shadow: 0 30px 80px rgba(20,10,50,.3); }
.modal h3 { font-size: 18px; margin-bottom: 4px; }
.modal .muted { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
