:root {
    --bg: #0f1720;
    --panel: #17212b;
    --panel-2: #1e2a36;
    --border: #2a3a48;
    --text: #e6edf3;
    --muted: #93a4b3;
    --accent: #2f9e6b;
    --accent-2: #3aa7ff;
    --danger: #e5534b;
    --warning: #d9a13b;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Cursor de "mão" em tudo que é clicável (links, botões, toggles). */
a, button, summary, label[for], [role="button"],
input[type="submit"], input[type="button"], input[type="reset"] { cursor: pointer; }

/* ---- Topbar ---- */
.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 18px; flex: 1; }
.nav a { color: var(--muted); font-weight: 500; }
.nav a:hover { color: var(--text); text-decoration: none; }
.logout button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
}
.logout button:hover { color: var(--text); border-color: var(--muted); }

/* ---- Layout ---- */
.container { max-width: 1040px; margin: 32px auto; padding: 0 20px; }
.footer { text-align: center; color: var(--muted); padding: 24px; font-size: 13px; }

/* ---- Cards ---- */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.card.center { text-align: center; }
.card h1 { margin-top: 0; }

/* ---- Auth ---- */
.auth-wrap { max-width: 380px; margin: 8vh auto; }
.auth-wrap .card { padding: 28px; }
.auth-logo { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.auth-logo span { color: var(--accent); }

/* ---- Forms ---- */
label { display: block; margin: 16px 0 6px; color: var(--muted); font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=datetime-local], input[type=number], textarea, select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-2); border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }

/* Mensagem de erro de campo — separada do input, com cor de alerta. */
.field-error { display: block; margin-top: 6px; color: #ffb4ae; font-size: 13px; }

/* Barra de ações do formulário (botões agrupados com respiro consistente). */
.form-actions { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    background: var(--accent);
    color: #fff;
    border: 1px solid transparent;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: filter .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn-secondary { background: var(--panel-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-danger { background: var(--danger); }
.btn-sm { min-height: 0; padding: 6px 12px; font-size: 13px; }

/* Botão de copiar discreto (ghost): ocupa pouco espaço, sem competir com as ações. */
.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 0;
    padding: 2px 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    vertical-align: middle;
    transition: color .12s ease, border-color .12s ease;
}
.btn-copy:hover { color: var(--text); border-color: var(--muted); }
.btn-copy:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* Coluna de ações das chaves: botões empilhados com respiro vertical.
   Usa margin (não flex gap) para funcionar em qualquer navegador. */
.key-actions { display: flex; flex-direction: column; align-items: flex-start; }
.key-actions > * { margin: 0; }
.key-actions > * + * { margin-top: 8px; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; font-size: 14px; }
.alert-error { background: rgba(229,83,75,.15); border: 1px solid var(--danger); color: #ffb4ae; }
.alert-success { background: rgba(47,158,107,.15); border: 1px solid var(--accent); color: #9fe3c2; }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
.table tr:hover td { background: var(--panel-2); }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-active { background: rgba(47,158,107,.2); color: #6fd3a5; }
.badge-used { background: rgba(58,167,255,.2); color: #8fcbff; }
.badge-expired { background: rgba(217,161,59,.2); color: #e8c07a; }
.badge-revoked { background: rgba(229,83,75,.2); color: #ffaba4; }
.badge-inactive { background: rgba(147,164,179,.2); color: var(--muted); }

/* ---- Utilities ---- */
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 22px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.nowrap { white-space: nowrap; }

/* Barra de busca/filtro: campo cresce, botão alinhado à base do input. */
.searchbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.searchbar .field { flex: 1 1 240px; min-width: 0; }
.searchbar .field label { margin-top: 0; }
.searchbar .btn { flex: 0 0 auto; }

/* Barra de abas de status (filtros rápidos). */
.tabbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---- Dashboard stats ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
    display: block;
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 3px solid var(--muted);
    border-radius: var(--radius);
    padding: 18px 18px 18px 20px;
    color: var(--text);
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
a.stat:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.35); text-decoration: none; }
.stat .num { font-size: 32px; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat--green { border-left-color: var(--accent); }
.stat--green .num { color: var(--accent); }
.stat--blue { border-left-color: var(--accent-2); }
.stat--blue .num { color: var(--accent-2); }
.stat--amber { border-left-color: var(--warning); }
.stat--amber .num { color: var(--warning); }
.stat--red { border-left-color: var(--danger); }
.stat--red .num { color: var(--danger); }
.stat--muted { border-left-color: var(--muted); }
.key-code {
    font-family: ui-monospace, monospace;
    background: var(--panel-2);
    border: 1px dashed var(--border);
    padding: 10px 14px;
    border-radius: var(--radius);
    display: inline-block;
    letter-spacing: .05em;
}
