:root {
    --navy: #003057;
    --navy-deep: #00243f;
    --navy-soft: #3d6a8c;
    --navy-fg: #ffffff;
    --surface: #f4f7fb;
    --surface-2: #e8eef5;
    --ink: #1c3348;
    --muted: #5c7388;
    --card: #ffffff;
    --line: #d7e1eb;
    --danger: #b42318;
    --danger-soft: #fef3f2;
    --ok: #027a48;
    --ok-soft: #ecfdf3;
    --warn: #b54708;
    --warn-soft: #fffaeb;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(0, 48, 87, .06), 0 8px 24px -12px rgba(0, 48, 87, .18);
    --green: var(--navy);
    --green-2: var(--navy-soft);
    --green-soft: var(--surface-2);
    --gold: var(--navy-soft);
    --gold-soft: #e4eef6;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: Inter, "Segoe UI", Tahoma, sans-serif;
    color: var(--ink);
    background: var(--surface);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -.02em; margin: 0; }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}
@keyframes fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.bg-institutional {
    background: linear-gradient(160deg, var(--navy-deep) 0%, var(--navy) 55%, #001a2e 100%);
}

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 22px 14px;
    color: #fff;
    transition: width .22s ease;
    z-index: 40;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 8px;
    min-height: 44px;
}
.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255,255,255,.12);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .72rem;
    letter-spacing: .04em;
    flex-shrink: 0;
}
.brand-text { min-width: 0; }
.sidebar-brand strong { display: block; font-size: .95rem; line-height: 1.2; }
.sidebar-brand .brand-text span { display: block; margin-top: 2px; font-size: .72rem; color: rgba(255,255,255,.6); }

.nav { margin-top: 16px; flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.nav-group { position: relative; }
.nav-link, .nav-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    color: rgba(255,255,255,.78);
    text-align: left;
    font: inherit;
    font-weight: 500;
    padding: 9px 12px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.nav-link:hover, .nav-toggle:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.nav-toggle { justify-content: space-between; }
.nav-toggle .left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-toggle svg.chev { width: 16px; height: 16px; transition: transform .2s; opacity: .7; flex-shrink: 0; }
.nav-group.open .nav-toggle svg.chev { transform: rotate(180deg); }
.nav-sub {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 2px 0 6px 12px;
}
.nav-group.open .nav-sub { display: flex; }
.nav-sub .nav-link { font-size: .86rem; padding: 7px 12px; color: rgba(255,255,255,.68); }
.nav-sub-title { display: none; }
.ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }

.sidebar-user {
    border-top: 1px solid rgba(255,255,255,.12);
    padding: 14px 8px 0;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-user-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,.12);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user strong { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user small { color: rgba(255,255,255,.55); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sair-btn { color: rgba(255,255,255,.7); }
.sair-btn:hover { background: rgba(255,80,80,.18); color: #fff; }

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header h1 { font-size: 1.2rem; color: var(--navy); }
.header .lead { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: .8rem;
    color: var(--navy);
    font-weight: 600;
}
.menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 0;
    cursor: pointer;
    color: var(--navy);
    flex-shrink: 0;
}
.menu-btn svg { width: 20px; height: 20px; }
.sidebar-backdrop { display: none; }

.app.sidebar-collapsed .sidebar { width: 78px; padding: 18px 10px; }
.app.sidebar-collapsed .brand-text,
.app.sidebar-collapsed .nav-toggle .left span,
.app.sidebar-collapsed .nav-toggle .chev,
.app.sidebar-collapsed .sidebar-user-info,
.app.sidebar-collapsed .sair-label { display: none; }
.app.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0 0 8px; }
.app.sidebar-collapsed .nav { overflow: visible; }
.app.sidebar-collapsed .nav-toggle { justify-content: center; padding: 10px; }
.app.sidebar-collapsed .nav-toggle .left { justify-content: center; }
.app.sidebar-collapsed .nav-group.open .nav-sub { display: none; }
.app.sidebar-collapsed .nav-group:hover .nav-sub,
.app.sidebar-collapsed .nav-group:focus-within .nav-sub {
    display: flex;
    position: absolute;
    left: calc(100% + 8px);
    top: 0;
    min-width: 210px;
    padding: 8px;
    background: var(--navy-deep);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 20, 40, .35);
    z-index: 50;
}
.app.sidebar-collapsed .nav-sub-title {
    display: block;
    padding: 6px 12px 8px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(255,255,255,.5);
}
.app.sidebar-collapsed .sidebar-user { align-items: center; }
.app.sidebar-collapsed .sidebar-user-row { justify-content: center; }
.app.sidebar-collapsed .sair-btn { justify-content: center; padding: 10px; }

.content { padding: 24px 28px 48px; animation: fade .35s ease; }

.card, .stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}
.stat { padding: 18px 20px; transition: box-shadow .2s; }
.stat:hover, .card:hover { box-shadow: 0 18px 40px -20px rgba(0, 48, 87, .35); }
.stat b { display: block; font-size: 1.7rem; color: var(--navy); margin-top: 8px; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--surface); color: var(--navy);
    display: grid; place-items: center;
}
.card { padding: 22px 24px; }
.card h2 { margin: 0 0 14px; font-size: .95rem; color: var(--navy); }
.card-page, .page-form { width: 100%; max-width: 720px; margin: 0 auto; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1.2fr .8fr; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.table tbody tr:hover { background: var(--surface); }

.btn, button.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px; padding: 9px 14px;
    min-height: 40px;
    font: inherit; font-weight: 600; cursor: pointer;
    background: var(--navy); color: #fff; text-decoration: none;
    transition: background .15s, color .15s, border-color .15s;
    white-space: nowrap;
}
.btn:hover { background: var(--navy-deep); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); }
.btn-gold { background: var(--navy-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1d16; }
.btn-ghost.btn-danger {
    background: #fff;
    color: var(--danger);
    border-color: var(--line);
}
.btn-ghost.btn-danger:hover { background: var(--danger-soft); }
.actions, .pass-actions, .row-end, .org-account-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.actions form, .pass-actions form, .row-end form, .org-account-meta form, .table form {
    display: inline-flex;
    margin: 0;
}

label { display: block; font-size: .86rem; font-weight: 600; color: var(--navy); margin: 0 0 6px; }
input, select, textarea {
    width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--line); background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--navy) 35%, white);
    outline-offset: 1px; border-color: var(--navy-soft);
}
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.req { color: var(--navy-soft); }

.flash, .errors { border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; }
.flash { background: var(--ok-soft); color: var(--ok); }
.errors { background: var(--danger-soft); color: var(--danger); }
.errors ul { margin: 0; padding-left: 18px; }

.badge {
    display: inline-flex; padding: 3px 9px; border-radius: 999px;
    font-size: .72rem; font-weight: 600;
    background: var(--surface-2); color: var(--navy);
}
.badge-gold { background: #e8f1f8; color: var(--navy); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #eef2f5; color: var(--muted); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 220px; }
.code-xl { font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700; letter-spacing: .2em; font-size: 1.6rem; color: var(--navy); }

.topbar { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 22px; }
.topbar h1 { font-size: 1.35rem; color: var(--navy); }
.lead { color: var(--muted); }

.dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; }
.dl dt { color: var(--muted); }
.muted { color: var(--muted); }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; }
.empty { color: var(--muted); padding: 24px 0; }

.pass {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 18px;
    align-items: center;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(90deg, #f4f8fb 0%, #fff 28%);
    margin-bottom: 12px;
}
.pass:last-child { margin-bottom: 0; }
.pass-code small {
    display: block;
    font-size: .68rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}
.pass-code strong {
    display: block;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 1.7rem;
    letter-spacing: .22em;
    color: var(--navy);
    line-height: 1.1;
    margin-bottom: 8px;
}
.pass-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pass-meta small {
    display: block;
    color: var(--muted);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.pass-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }

.auth-split { display: flex; min-height: 100vh; }
.auth-hero {
    display: none;
    width: 46%;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    color: #fff;
}
.auth-hero h2 { font-size: 1.85rem; line-height: 1.25; max-width: 18ch; }
.auth-hero p { color: rgba(255,255,255,.65); max-width: 36ch; }
.auth-form-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    background: #fff;
}
.auth-form { width: min(380px, 100%); animation: rise .45s cubic-bezier(.22,1,.36,1); }
.auth-form h1 { color: var(--navy); font-size: 1.5rem; }
.auth-form > p { color: var(--muted); margin: 6px 0 24px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 18px; font-size: .88rem; }

.auth-center {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background: var(--surface);
}
.auth-box { width: min(440px, 100%); animation: rise .45s cubic-bezier(.22,1,.36,1); }
.auth-box .card { padding: 28px; }

.steps { display: flex; gap: 6px; margin-bottom: 10px; }
.steps span { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-2); }
.steps span.on { background: var(--navy); }
.steps-meta { display: flex; justify-content: space-between; font-size: .78rem; margin-bottom: 22px; }
.steps-meta b { color: var(--navy); }
.otp { letter-spacing: .4em; text-align: center; font-size: 1.4rem; font-weight: 700; }

.loja-lookup { max-width: 720px; margin: 0 auto; }
.loja-lookup input[name="code"] {
    font-size: 1.7rem; letter-spacing: .35em; text-align: center; font-weight: 700; height: 56px;
}
.loja-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.loja-meta div { background: var(--surface); padding: 12px 14px; border-radius: 12px; }
.loja-meta small { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.warn { background: var(--warn-soft); color: var(--warn); padding: 14px 16px; border-radius: 12px; margin: 16px 0; }

.org-city {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 20px 22px 12px;
    margin-bottom: 16px;
}
.org-city > h2 {
    margin: 0 0 14px;
    font-size: 1.15rem;
    color: var(--navy);
    letter-spacing: .04em;
    text-transform: uppercase;
}
.org-city-campo {
    border-color: var(--navy);
    background: linear-gradient(180deg, #f3f7fb 0%, #fff 42%);
}
.org-note {
    margin: -8px 0 14px;
    color: var(--muted);
    font-size: .88rem;
}
.org-place {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: var(--surface);
}
.org-place h3 { margin: 0 0 10px; font-size: .95rem; color: var(--navy); }
.org-place h3 span { color: var(--muted); font-weight: 500; }
.org-account {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
}
.org-account:last-child { margin-bottom: 0; }
.org-account strong { display: block; }
.org-account small { color: var(--muted); }
.org-account-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack-new { display: grid; gap: 8px; margin-top: 8px; }

@media (min-width: 980px) {
    .auth-hero { display: flex; }
}
@media (max-width: 980px) {
    .sidebar {
        position: fixed; z-index: 40; transform: translateX(-105%);
        transition: transform .25s ease;
        width: 260px;
    }
    .sidebar.open { transform: none; }
    .app.drawer-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 20, 40, .45);
        z-index: 35;
    }
    .grid-4, .grid-2, .grid-3, .loja-meta, .dl, .pass, .pass-meta { grid-template-columns: 1fr; }
    .content, .header { padding-left: 16px; padding-right: 16px; }
}
