:root {
    --primary: #8b1116;
    --primary-dark: #650b0f;
    --primary-light: #b91c1c;
    --primary-soft: #fff1f2;

    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-soft: #fafafa;

    --text: #111827;
    --muted: #6b7280;
    --muted-light: #9ca3af;

    --border: #e5e7eb;
    --border-soft: #f1f5f9;

    --success: #15803d;
    --success-bg: #dcfce7;

    --danger: #b91c1c;
    --danger-bg: #fee2e2;

    --warning: #b45309;
    --warning-bg: #fef3c7;

    --info: #0369a1;
    --info-bg: #e0f2fe;

    --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 14px 34px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;

    --sidebar-width: 280px;
    --transition: all 0.22s ease;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(139, 17, 22, 0.10), transparent 32%),
        linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

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

::selection {
    background: var(--primary);
    color: #fff;
}

/* SIDEBAR */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    height: 100vh;
    background:
        linear-gradient(180deg, #4a070a 0%, #7f1117 48%, #3b0709 100%);
    color: #fff;
    padding: 22px 18px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 18px 0 44px rgba(17, 24, 39, 0.18);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 20px;
}

.sidebar-brand {
    padding: 10px 10px 22px;
    margin-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-link {
    display: block;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: #fff;
}

.sidebar-brand span {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.68);
    text-transform: uppercase;
    letter-spacing: 0.09em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-section-title {
    margin: 18px 10px 8px;
    color: rgba(255, 255, 255, 0.52);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.menu-link,
.menu-toggle {
    width: 100%;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 14px;
    color: rgba(255, 255, 255, 0.88);
    background: transparent;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 700;
    transition: var(--transition);
    list-style: none;
}

.menu-link:hover,
.menu-toggle:hover,
.menu-link.active {
    background: rgba(255, 255, 255, 0.13);
    color: #fff;
    transform: translateX(2px);
}

.sidebar-group {
    border-radius: 16px;
}

.sidebar-group[open] {
    background: rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
}

.sidebar-group summary::-webkit-details-marker {
    display: none;
}

.menu-arrow {
    transition: transform 0.22s ease;
    opacity: 0.7;
}

.sidebar-group[open] .menu-arrow {
    transform: rotate(180deg);
}

.submenu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 2px 8px 4px 16px;
}

.submenu a {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.74);
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
}

.submenu a:hover,
.submenu a.active {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

/* MAIN */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.content-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 76px;
    padding: 0 32px;
    background: rgba(255, 255, 255, 0.76);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(229, 231, 235, 0.8);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-topbar h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #111827;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: 13px;
}

.user-area span {
    padding: 9px 13px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
}

.user-area a {
    padding: 9px 14px;
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    font-weight: 700;
    transition: var(--transition);
}

.user-area a:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.page-content {
    padding: 32px;
}

/* HEADERS */

.welcome,
.page-title,
.clean-title {
    background:
        linear-gradient(135deg, rgba(139, 17, 22, 0.08), rgba(255, 255, 255, 0.92)),
        #fff;
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.page-title.clean-title,
.clean-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.welcome h2,
.page-title h2,
.clean-title h2 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
    letter-spacing: -0.04em;
    font-weight: 850;
    color: #111827;
}

.welcome p,
.page-title p,
.clean-title p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.clean-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* CARDS */

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.card {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.card::after {
    content: "";
    position: absolute;
    right: -28px;
    top: -28px;
    width: 96px;
    height: 96px;
    background: radial-gradient(circle, rgba(139, 17, 22, 0.16), transparent 70%);
}

.card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card strong {
    display: block;
    margin-top: 10px;
    color: var(--text);
    font-size: 31px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: -0.05em;
}

/* PANELS */

.clean-panel,
.form-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(229, 231, 235, 0.95);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.clean-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 18px;
}

.clean-panel-header h3,
.form-card h3 {
    margin: 0;
    color: var(--text);
    font-size: 19px;
    font-weight: 850;
    letter-spacing: -0.03em;
}

.clean-panel-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

/* FORMS */

label {
    display: block;
    margin: 0 0 7px;
    color: #374151;
    font-size: 13px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #d1d5db;
    border-radius: 13px;
    padding: 11px 13px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: var(--transition);
    font-size: 14px;
}

textarea {
    min-height: 118px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(139, 17, 22, 0.10);
}

input[type="file"] {
    padding: 10px;
    background: #f9fafb;
}

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

.form-grid .full {
    grid-column: 1 / -1;
}

.actions,
.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.table-search {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.table-search input,
.table-search select {
    width: auto;
    min-width: 180px;
}

button,
.btn,
.btn-small {
    border: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border-radius: 13px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(139, 17, 22, 0.22);
    transition: var(--transition);
}

button:hover,
.btn:hover,
.btn-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(139, 17, 22, 0.28);
}

button:disabled,
.btn:disabled,
.btn-small:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary,
button.btn-secondary,
.muted {
    background: #f3f4f6;
    color: #374151;
    box-shadow: none;
    border: 1px solid var(--border);
}

.btn-secondary:hover,
button.btn-secondary:hover,
.muted:hover {
    background: #e5e7eb;
    box-shadow: none;
}

.btn-danger,
button.btn-danger {
    background: linear-gradient(135deg, #991b1b, #dc2626);
    color: #fff;
    box-shadow: 0 10px 22px rgba(185, 28, 28, 0.22);
}

.btn-small {
    min-height: 34px;
    padding: 8px 11px;
    font-size: 12px;
    border-radius: 10px;
    box-shadow: none;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

/* TABLES */

.clean-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.clean-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 980px;
}

.clean-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f9fafb;
    color: #4b5563;
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}

.clean-table tbody td {
    padding: 15px 16px;
    vertical-align: top;
    border-bottom: 1px solid #f1f5f9;
    color: #374151;
}

.clean-table tbody tr {
    transition: var(--transition);
}

.clean-table tbody tr:hover {
    background: #fff7f7;
}

.clean-table tbody tr:last-child td {
    border-bottom: 0;
}

.clean-table td strong {
    display: block;
    color: #111827;
    font-weight: 850;
}

.clean-table td span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.col-acoes {
    min-width: 210px;
}

/* BADGES */

.badge,
.tag {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 26px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px !important;
    font-weight: 850;
    line-height: 1;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.tag-muted {
    background: #f3f4f6;
    color: #4b5563;
}

.tag-info {
    background: var(--info-bg);
    color: var(--info);
}

.tag-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.rule-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ALERTS */

.erro,
.sucesso {
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 18px;
    font-weight: 750;
    box-shadow: var(--shadow-sm);
}

.erro {
    background: var(--danger-bg);
    border: 1px solid #fecaca;
    color: var(--danger);
}

.sucesso {
    background: var(--success-bg);
    border: 1px solid #bbf7d0;
    color: var(--success);
}

/* DETAILS */

.details-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
    align-items: start;
}

.details-main {
    min-width: 0;
}

.details-sidebar {
    min-width: 0;
}

.sticky-card {
    position: sticky;
    top: 96px;
}

.action-card .btn,
.action-card button {
    width: 100%;
    margin-top: 8px;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.info-item {
    padding: 14px;
    background: #f9fafb;
    border: 1px solid #eef2f7;
    border-radius: 14px;
}

.info-item strong {
    display: block;
    margin-bottom: 6px;
    color: #374151;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-item span,
.info-item div {
    color: #111827;
    font-size: 14px;
}

/* COMMENTS / TIMELINE */

.comment-box {
    position: relative;
    margin: 0 0 16px 18px;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.comment-box::before {
    content: "";
    position: absolute;
    left: -18px;
    top: 22px;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--primary);
}

.comment-box::after {
    content: "";
    position: absolute;
    left: -10px;
    top: 38px;
    bottom: -22px;
    width: 1px;
    background: #e5e7eb;
}

.comment-box:last-child::after {
    display: none;
}

.comment-box small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

/* MODALS */

.modal-acao-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: rgba(15, 23, 42, 0.50);
    backdrop-filter: blur(8px);
}

.modal-acao-overlay.open {
    display: flex;
}

.modal-acao,
.clean-modal {
    width: min(560px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 24px;
    padding: 26px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.55);
    animation: modalIn 0.18s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-acao h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.modal-acao p {
    margin: 8px 0 18px;
    color: var(--muted);
}

/* PAGINATION */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 18px;
    color: var(--muted);
}

.pagination div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination a {
    padding: 8px 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: #374151;
    font-weight: 750;
}

.pagination a:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

/* LOGIN */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(139, 17, 22, 0.25), transparent 35%),
        linear-gradient(135deg, #3b0709, #8b1116);
}

.login-card {
    width: min(430px, 100%);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 28px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.login-card p {
    margin: 0 0 22px;
    color: var(--muted);
}

/* RESPONSIVE */

@media (max-width: 1200px) {
    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .details-layout {
        grid-template-columns: 1fr;
    }

    .sticky-card {
        position: static;
    }
}

@media (max-width: 860px) {
    :root {
        --sidebar-width: 100%;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-radius: 0 0 24px 24px;
    }

    .main-content {
        margin-left: 0;
    }

    .content-topbar {
        position: static;
        height: auto;
        padding: 18px;
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .page-content {
        padding: 18px;
    }

    .page-title.clean-title,
    .clean-title,
    .clean-panel-header {
        flex-direction: column;
        align-items: stretch;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .cards {
        grid-template-columns: 1fr;
    }

    .table-search {
        justify-content: flex-start;
    }

    .table-search input,
    .table-search select,
    .table-search button,
    .table-search .btn {
        width: 100%;
    }

    .user-area {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .user-area span,
    .user-area a {
        width: 100%;
    }
}

@media print {
    .sidebar,
    .content-topbar,
    .clean-actions,
    .actions,
    .modal-acao-overlay,
    button,
    .btn,
    .btn-small {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    body {
        background: #fff;
    }

    .clean-panel,
    .form-card,
    .card,
    .welcome,
    .page-title {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
