/* ==============================================================
   SOU ATÍPICO — Painel Administrativo (Design System Integrado)
   ============================================================== */

:root {
    --navy: #0D3B66;
    --navy-deep: #07223B;
    --blue: #0077B6;
    --teal: #00BFA6;
    --yellow: #FFC107;
    --coral: #FF6B4A;
    --purple: #8E44AD;

    --ink: #0F172A;
    --text: #334155;
    --muted: #64748B;
    --bg: #F3F6FA;
    --surface: #FFFFFF;
    --line: #E2E8F0;
    --line-soft: #EEF2F6;

    --font-head: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

    --sidebar-w: 272px;
    --topbar-h: 68px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;

    --sh-1: 0 1px 3px rgba(15, 23, 42, .05), 0 1px 2px rgba(15, 23, 42, .04);
    --sh-2: 0 10px 28px -8px rgba(13, 59, 102, .12), 0 4px 10px -4px rgba(13, 59, 102, .06);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
    font-family: var(--font-head);
    color: var(--navy);
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

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

.adm-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #071F36 0%, #0D3B66 100%);
    color: #E2E8F0;
    display: flex;
    flex-direction: column;
    z-index: 40;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, .08);
    transition: transform .25s ease;
}

.adm-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    color: #fff;
    text-decoration: none;
}
.adm-sidebar__brand:hover { text-decoration: none; }
.adm-sidebar__brand img { width: 38px; height: 38px; flex-shrink: 0; }
.adm-sidebar__title {
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 1.05rem;
    line-height: 1.1;
}
.adm-sidebar__title strong { color: #5EEAD4; font-weight: 900; }
.adm-sidebar__sub {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .58);
    margin-top: 2px;
    font-weight: 700;
}

.adm-nav {
    padding: 14px 12px 24px;
    flex: 1;
}

.adm-nav__group {
    margin-bottom: 18px;
}

.adm-nav__label {
    font-family: var(--font-head);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: rgba(255, 255, 255, .45);
    padding: 0 12px 6px;
}

.adm-nav__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: rgba(255, 255, 255, .82);
    font-weight: 600;
    font-size: 0.9rem;
    transition: background .16s ease, color .16s ease;
    text-decoration: none;
    margin-bottom: 2px;
}
.adm-nav__link svg { flex-shrink: 0; opacity: .82; }
.adm-nav__link:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    text-decoration: none;
}
.adm-nav__link.is-active {
    background: rgba(0, 191, 166, .18);
    color: #5EEAD4;
    box-shadow: inset 3px 0 0 #00BFA6;
}
.adm-nav__link.is-active svg { opacity: 1; color: #5EEAD4; }

.adm-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
    background:
        radial-gradient(960px 420px at 8% -4%, rgba(0, 119, 182, .05), transparent 60%),
        radial-gradient(760px 380px at 96% 0%, rgba(0, 191, 166, .045), transparent 60%),
        var(--bg);
}

.adm-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(15, 23, 42, .04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 36px;
    gap: 16px;
}

.adm-topbar__left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.adm-topbar__title {
    font-family: var(--font-head);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--navy);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.adm-menu-btn {
    display: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    color: var(--navy);
    cursor: pointer;
}

.adm-topbar__right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.adm-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--line);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--navy);
}
.adm-user-pill__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--teal);
}

.adm-content {
    padding: 28px 36px 52px;
    max-width: none;
    width: 100%;
    margin: 0;
}

/* ---------- Page Header & Cards ---------- */
.adm-head {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 22px 28px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #FFFFFF 0%, #F7FBFF 100%);
    border: 1px solid rgba(203, 213, 225, .85);
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .03), 0 10px 26px -16px rgba(13, 59, 102, .12);
}
.adm-head::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: linear-gradient(180deg, #0077B6 0%, #00BFA6 100%);
}
.adm-head h1 { font-size: 1.58rem; font-weight: 900; margin-bottom: 4px; color: var(--navy); }
.adm-head p { margin: 0; color: #475569; font-size: 0.94rem; }

.adm-card {
    background: var(--surface);
    border: 1px solid rgba(203, 213, 225, .85);
    border-radius: 18px;
    padding: 26px 28px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .03), 0 14px 34px -18px rgba(13, 59, 102, .1);
    margin-bottom: 24px;
}
.adm-card__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line-soft);
}
.adm-card__head h2, .adm-card__head h3 {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 800;
}

/* ---------- KPI Stats ---------- */
.adm-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}
.adm-kpi {
    background: var(--surface);
    border: 1px solid rgba(203, 213, 225, .85);
    border-radius: 16px;
    padding: 20px 22px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .03), 0 10px 26px -18px rgba(13, 59, 102, .12);
    display: flex;
    align-items: center;
    gap: 16px;
    text-decoration: none;
    color: inherit;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.adm-kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--sh-2);
    border-color: #CBD5E1;
    text-decoration: none;
}
.adm-kpi strong {
    display: block;
    font-family: var(--font-head);
    font-size: 1.65rem;
    font-weight: 900;
    color: var(--navy);
    line-height: 1.05;
}
.adm-kpi > div > span {
    display: block;
    font-size: 0.84rem;
    color: var(--muted);
    font-weight: 600;
    margin-top: 3px;
}

.adm-tile {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
}
.adm-tile svg,
.adm-nav__link svg,
.adm-alert svg {
    display: block;
    flex-shrink: 0;
}
.tone-blue   { background: #E0F2FE; color: #0077B6; }
.tone-teal   { background: #E3F8F5; color: #0B7A69; }
.tone-yellow { background: #FFF6DA; color: #B45309; }
.tone-coral  { background: #FFEDE8; color: #E04F33; }
.tone-purple { background: #F3EAF8; color: #7C3AED; }
.tone-navy   { background: #E6EEF5; color: #0D3B66; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 0.9rem;
    min-height: 40px;
    padding: 9px 17px;
    border-radius: 11px;
    border: 1.5px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s ease;
    line-height: 1.25;
    white-space: nowrap;
}
.btn svg { display: block; flex-shrink: 0; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.82rem; border-radius: 9px; }

.btn-primary {
    background: linear-gradient(135deg, #0D3B66 0%, #0A4D84 100%);
    color: #fff;
    box-shadow: 0 6px 14px -6px rgba(13, 59, 102, .45);
}
.btn-primary:hover { background: linear-gradient(135deg, #0077B6 0%, #0D3B66 100%); }

.btn-teal {
    background: var(--teal);
    color: #052e27;
    box-shadow: 0 6px 14px -6px rgba(0, 191, 166, .45);
}
.btn-teal:hover { filter: brightness(0.96); }

.btn-secondary {
    background: #fff;
    border-color: #CBD5E1;
    color: var(--navy);
}
.btn-secondary:hover { background: #F8FAFC; border-color: #94A3B8; }

.btn-danger {
    background: #FFF1F0;
    border-color: #FECACA;
    color: #B91C1C;
}
.btn-danger:hover { background: #FEE2E2; border-color: #FCA5A5; }

/* ---------- Tables ---------- */
.adm-table-wrap {
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
}
.adm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.91rem;
}
.adm-table th {
    background: #F4F7FB;
    color: #475569;
    font-family: var(--font-head);
    font-size: 0.73rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.adm-table td {
    padding: 15px 16px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
    color: var(--text);
}
.adm-table td strong {
    color: var(--navy);
    font-weight: 700;
}
.adm-table tbody tr { transition: background .14s ease; }
.adm-table tbody tr:last-child td { border-bottom: none; }
.adm-table tbody tr:hover { background: #F5FAFF; }

.adm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
}
.adm-table .adm-actions {
    flex-wrap: nowrap;
}

/* ---------- Badges ---------- */
.adm-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: all .15s ease;
}
.adm-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .78;
}
.adm-badge--on { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.adm-badge--off { background: #F8FAFC; border-color: #CBD5E1; color: #475569; }
.adm-badge--warn { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
button.adm-badge:hover { transform: translateY(-1px); filter: brightness(0.97); }

/* ---------- Forms & Filters ---------- */
.adm-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    margin-bottom: 22px;
    padding: 18px 20px;
    background: #F8FAFC;
    border: 1px solid var(--line);
    border-radius: 14px;
}
.adm-filters .form-group { margin-bottom: 0; min-width: 190px; flex: 1; }
.adm-filters .form-control,
.adm-filters .btn { height: 42px; min-height: 42px; }

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}
.adm-split {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(380px, 1fr);
    gap: 24px;
    align-items: start;
}

.adm-cfg-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.adm-cfg-item {
    background: #F9FBFD;
    border: 1px solid #E5ECF3;
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.adm-cfg-item--wide {
    grid-column: 1 / -1;
}
.adm-cfg-item__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.adm-cfg-item__head .form-label { margin-bottom: 0; }
.adm-cfg-code {
    font-size: 0.72rem;
    color: var(--blue);
    background: #EFF6FF;
    border: 1px solid #DBEAFE;
    padding: 2px 8px;
    border-radius: 6px;
}

.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-family: var(--font-head);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 7px;
}
.form-control {
    width: 100%;
    min-height: 42px;
    padding: 9px 14px;
    border-radius: 11px;
    border: 1.5px solid #D5DEE8;
    background: #fff;
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230D3B66' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}
.form-control:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0, 119, 182, .12);
}
textarea.form-control { min-height: 98px; resize: vertical; }
.form-hint {
    display: block;
    font-size: 0.79rem;
    color: var(--muted);
    margin-top: 5px;
    line-height: 1.45;
}

.form-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink);
    cursor: pointer;
}
.form-check input { width: 17px; height: 17px; accent-color: var(--navy); }

/* ---------- Tabs ---------- */
.adm-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 22px;
    padding: 7px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--sh-1);
}
.adm-tab {
    padding: 8px 15px;
    border-radius: 9px;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all .15s ease;
}
.adm-tab:hover { background: #F1F5F9; color: var(--navy); text-decoration: none; }
.adm-tab.is-active {
    background: linear-gradient(135deg, #0D3B66 0%, #0077B6 100%);
    color: #fff;
    box-shadow: 0 4px 10px -4px rgba(13, 59, 102, .45);
}

/* ---------- Alerts / Flash ---------- */
.adm-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 0.92rem;
    border: 1px solid transparent;
}
.adm-alert--success { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.adm-alert--error   { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
.adm-alert--info    { background: #EFF6FF; border-color: #BFDBFE; color: #1E40AF; }
.adm-alert--warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }

/* ---------- Visual Document Fields Builder ---------- */
.doc-fields-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}
.doc-field-row {
    display: grid;
    grid-template-columns: 1.1fr 1.2fr 0.75fr 1.2fr auto;
    gap: 8px;
    align-items: center;
    background: #F8FAFC;
    border: 1px solid var(--line);
    padding: 10px;
    border-radius: 10px;
}
.var-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}
.var-chip {
    background: #EFF6FF;
    color: #1D4ED8;
    border: 1px solid #BFDBFE;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: monospace;
    cursor: pointer;
}
.var-chip:hover { background: #DBEAFE; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .adm-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1020px) {
    .adm-split { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .adm-cfg-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .adm-sidebar { transform: translateX(-100%); }
    .adm-sidebar.is-open { transform: translateX(0); box-shadow: 0 0 0 9999px rgba(7, 34, 59, .45); }
    .adm-main { margin-left: 0; }
    .adm-menu-btn { display: inline-flex; }
    .form-grid-2, .form-grid-3, .adm-kpis { grid-template-columns: 1fr; }
    .doc-field-row { grid-template-columns: 1fr; }
    .adm-content { padding: 18px; }
    .adm-head, .adm-card { padding: 18px; }
    .adm-topbar { padding: 0 16px; }
    .adm-user-pill { display: none; }
}
