/* ===== Tokens (AduaSys) ===== */
:root {
    --primary: #14457a;
    --primary-hover: #0c2f55;
    --primary-soft: #e8f0f9;
    --nav-bg: #0f2f52;
    --nav-text: #c9d6e4;
    --nav-muted: #7f97b3;
    --nav-accent: #7fb3ea;
    --text: #1c2633;
    --text-2: #4a5563;
    --muted: #6b7684;
    --faint: #9aa6b2;
    --border: #e3e8ee;
    --border-input: #d5dde6;
    --border-soft: #eef1f4;
    --box-border: #b8c2cc;
    --surface: #fff;
    --surface-2: #f7f9fb;
    --bg: #f3f6f9;
    --hover: #f5f8fb;
    --danger: #d2452b;
    --danger-text: #8a2a17;
    --success: #2f9e5b;
    --success-text: #1f7a43;
    --warn-text: #b45309;
    --badge-on-bg: #e3f1e8;
    --badge-on-text: #1f6b3a;
    --badge-off-bg: #eef1f4;
    --radius: 12px;
    --radius-sm: 8px;
}

/* ===== Base ===== */
* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
    background: var(--bg);
    font-family: Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
}

input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

h1 { margin: 0; font-size: 24px; }
h1:focus { outline: none; }

input:disabled, select:disabled, textarea:disabled {
    background: #f2f5f8 !important;
    color: var(--muted) !important;
    border-color: var(--border) !important;
    border-style: dashed !important;
    cursor: not-allowed;
    opacity: 1;
    -webkit-text-fill-color: var(--muted);
}

button:disabled { opacity: .45; cursor: not-allowed !important; }

* { scrollbar-width: thin; scrollbar-color: #c3ccd6 transparent; }

/* ===== Utilitários ===== */
.muted { color: var(--muted); }
.secondary { color: var(--text-2); }
.accent { color: var(--primary); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.center { text-align: center; }
.ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack-0 { display: flex; flex-direction: column; }
.stack-3 { display: flex; flex-direction: column; gap: 3px; }
.stack-12 { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.divider { height: 1px; background: var(--border-soft); margin: 2px 0; }

/* ===== Shell / navegação ===== */
.shell { height: 100vh; display: flex; overflow: hidden; position: relative; }

.sidebar {
    width: 212px;
    flex: none;
    background: var(--nav-bg);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    gap: 3px;
    overflow: auto;
    z-index: 15;
}

.sidebar-brand { font-size: 18px; font-weight: 700; color: #fff; padding: 2px 8px 12px; }

.nav-group { font-size: 11px; font-weight: 500; letter-spacing: .08em; color: var(--nav-muted); padding: 16px 10px 4px; }

.nav-item {
    display: block;
    text-decoration: none;
    color: var(--nav-text);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--nav-accent); }

.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 8px 0;
    border-top: 1px solid rgba(255,255,255,.1);
}

.me {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    padding: 6px;
    margin: -6px 0 -6px -6px;
    text-decoration: none;
    color: inherit;
    transition: background .12s;
}
.me:hover { background: rgba(255,255,255,.1); color: inherit; }
.me.active { background: rgba(255,255,255,.14); }

.me-avatar {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--nav-accent);
    color: var(--nav-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.me-name { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: 11px; color: var(--nav-muted); }

.sidebar-footer form { margin: 0; }
.logout { border: none; background: none; color: var(--nav-text); cursor: pointer; font-size: 12px; }
.logout:hover { color: #fff; }

.main { flex: 1; min-width: 0; overflow: auto; padding: 28px 32px 60px; }

.nav-toggle { display: none; }
.nav-backdrop { display: none; }
.topbar { display: none; }

/* ===== Layout das páginas ===== */
.page { display: flex; flex-direction: column; gap: 14px; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title { display: flex; align-items: baseline; gap: 10px; }
.page-title-center { display: flex; align-items: center; gap: 10px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ask { align-self: center; color: var(--danger-text); }

.back { font-size: 13px; text-decoration: none; align-self: flex-start; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.card-flush { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-foot-line {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: baseline;
    font-size: 13px;
    color: var(--text-2);
    border-top: 1px solid var(--border-soft);
    padding-top: 12px;
}
.card-foot-line b { font-weight: 500; }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border-soft); padding-top: 14px; }

.section-label { font-size: 11.5px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }

/* ===== Formulários ===== */
.field { display: flex; flex-direction: column; gap: 5px; }
.inline-field { display: flex; gap: 8px; align-items: center; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field-error { color: var(--danger); font-size: 12px; }
.field-ok { color: var(--success-text); font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); }
.hint-lg { font-size: 12.5px; color: var(--muted); }
.warn { font-size: 12.5px; color: var(--warn-text); }

.input {
    height: 38px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    outline: none;
    min-width: 0;
    background: #fff;
}
.input:focus { border-color: var(--primary); }
.input.has-error { border-color: var(--danger); }
.input-lg { height: 40px; }
.select { height: 34px; padding: 0 8px; min-width: 160px; }
.search { flex: 1; min-width: 220px; border-radius: 10px; padding: 0 14px; }

/* ===== Botões ===== */
.btn {
    height: 36px;
    padding: 0 16px;
    border-radius: 99px;
    border: 1px solid var(--border-input);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--hover); color: var(--text); }
.btn-sm { height: 34px; }
.btn-accent { color: var(--primary); font-weight: 500; }
.btn-accent:hover { color: var(--primary); }
.btn-primary { border: none; background: var(--primary); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-danger { border: none; background: var(--danger); color: #fff; font-weight: 500; }
.btn-danger:hover { background: #b33a23; color: #fff; }
.btn-danger-outline { color: var(--danger); font-weight: 500; }
.btn-danger-outline:hover { color: var(--danger); }

.chip {
    height: 34px;
    padding: 0 14px;
    border-radius: 99px;
    border: 1px solid var(--border-input);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-weight: 500;
}
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== Badges / avatares ===== */
.badge { justify-self: center; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 99px; }
.badge-sm { font-size: 11.5px; padding: 2px 8px; }
.badge-on { background: var(--badge-on-bg); color: var(--badge-on-text); }
.badge-off { background: var(--badge-off-bg); color: var(--muted); }

.avatar {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #dbe7f4;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11.5px;
}
.avatar.off { background: var(--badge-off-bg); color: #8a94a0; }
.avatar-lg { width: 32px; height: 32px; font-size: 12px; }

/* ===== Usuários: tabela ===== */
.table-wrap { overflow-x: auto; }
.usr-table { min-width: 680px; }
.usr-grid {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(200px, 1.2fr) 140px 110px 120px;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
    align-items: center;
}
.usr-head {
    padding: 10px 16px;
    background: var(--surface-2);
    border-bottom-color: var(--border);
    font-size: 11.5px;
    color: var(--muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: center;
}
.usr-row { text-decoration: none; color: inherit; cursor: pointer; }
.usr-row:hover { background: var(--hover); color: inherit; }
.usr-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.usr-name b { font-weight: 600; }
.you { font-size: 11.5px; color: var(--muted); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ===== Usuários: lista (smartphone) ===== */
.list { display: flex; flex-direction: column; }
.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-soft);
    text-decoration: none;
    color: inherit;
}
.list-row:active { background: var(--hover); }
.list-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.list-title { font-weight: 600; font-size: 15px; }
.list-sub { font-size: 13px; color: var(--muted); }
.list-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chevron { color: var(--faint); font-size: 22px; }

.only-phone { display: none; }

/* ===== Abas ===== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { border: none; background: none; padding: 8px 12px; cursor: pointer; color: var(--text-2); font-weight: 500; }
.tab.on { color: var(--primary); box-shadow: inset 0 -2px 0 var(--primary); }

/* ===== Permissões ===== */
.perm-help { margin-top: -4px; }
.perm-total { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.perm-groups { display: flex; flex-direction: column; gap: 12px; }
.perm-group { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.perm-group-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface-2); }
.perm-group-title { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; color: var(--text-2); }
.perm-count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.perm-screen {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 8px 14px;
    align-items: center;
    padding: 10px 14px;
    border-top: 1px solid var(--border-soft);
}
.perm-screen-head { display: flex; align-items: center; gap: 10px; }
.perm-screen-label { font-weight: 500; }
.perm-funcs { display: flex; flex-wrap: wrap; gap: 6px; }
.perm-func {
    height: 30px;
    padding: 0 12px;
    border-radius: 99px;
    border: 1px solid var(--border-input);
    background: #fff;
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 500;
    cursor: default;
}
.perm-func.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.perm-func.dim { color: var(--faint); }
.perm-func.locked { border-style: dashed; }
.clickable { cursor: pointer !important; }

.box {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1.5px solid var(--box-border);
    background: #fff;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}
.box.on { background: var(--primary); border-color: var(--primary); }
.box-sm { width: 16px; height: 16px; font-size: 11px; }

/* ===== Atividade ===== */
.timeline { gap: 12px; }
.timeline-item { display: flex; gap: 10px; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex: none; }

/* ===== Minha conta: senha ===== */
.card-pw { gap: 16px; }
.pw-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px 24px; align-items: start; }
.pw-input { position: relative; display: flex; }
.pw-input .input { flex: 1; padding-right: 84px; }
.pw-toggle {
    position: absolute;
    right: 4px;
    top: 4px;
    height: 32px;
    padding: 0 10px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--primary);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
}
.pw-toggle:hover { background: #eef3f8; }
.pw-meter { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.pw-bars { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.pw-bars span { height: 4px; border-radius: 99px; }
.pw-strength { font-size: 12px; font-weight: 500; min-width: 44px; text-align: right; }
.pw-rules {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.pw-rules-title { font-size: 12px; color: var(--text-2); font-weight: 500; }
.pw-rule { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); }
.pw-rule.ok { color: var(--success-text); }
.pw-rule-mark {
    flex: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid var(--box-border);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pw-rule.ok .pw-rule-mark { background: var(--success); border-color: var(--success); }

/* ===== Acesso restrito ===== */
.denied { padding: 40px 24px; align-items: center; gap: 10px; text-align: center; margin-top: 40px; }
.denied-title { font-size: 18px; }
.denied-text { color: var(--muted); max-width: 380px; }
.denied .btn { margin-top: 6px; }

/* ===== Toast ===== */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 11px 18px;
    border-radius: 10px;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    z-index: 40;
}

/* ===== Login ===== */
.login { min-height: 100vh; display: flex; }
.login-art {
    flex: 1.2;
    position: relative;
    background: repeating-linear-gradient(135deg, #123a63 0 14px, #0f3359 14px 28px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px;
    color: #dbe5f0;
}
.login-brand { font-size: 22px; font-weight: 700; color: #fff; }
.login-panel {
    width: min(460px, 100%);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.login-form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 14px; }
.login-title { font-size: 26px; font-weight: 700; }
.login-error { color: var(--danger); font-size: 13px; }
.btn-login { height: 42px; box-shadow: 0 2px 6px rgba(20,69,122,.25); }

/* ===== Tablet ===== */
@media (max-width: 1100px) {
    .main { padding: 24px 22px 60px; }
}

/* ===== Smartphone ===== */
@media (max-width: 720px) {
    .main { padding: 0 16px 60px; }

    .sidebar { position: absolute; top: 0; bottom: 0; left: 0; display: none; }
    .nav-toggle:checked ~ .sidebar { display: flex; }
    .nav-toggle:checked ~ .nav-backdrop { display: block; position: absolute; inset: 0; background: rgba(15,47,82,.35); z-index: 14; }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 5;
        margin: 0 -16px 14px;
        height: 52px;
        padding: 0 8px;
        background: var(--nav-bg);
        color: #fff;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .topbar b { font-size: 16px; }
    .topbar-menu { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; }

    .only-wide { display: none; }
    .only-phone { display: flex; }

    .grid-2, .pw-grid, .perm-screen { grid-template-columns: minmax(0, 1fr); }
    .input { height: 44px; font-size: 15px; }
    .select { height: 44px; }

    .login-art { display: none; }
    .login-panel { flex: 1; padding: 28px; }
}

/* ===== Blazor ===== */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Ocorreu um erro.";
}
