* {
    box-sizing: border-box;
}

:root {
    --bg: #f3f4f6;
    --panel: rgba(255,255,255,0.9);

    --brand: rgb(112, 125, 166);
    --brand-toggled: rgb(172, 177, 214);

    --brand-rgb: 112, 125, 166; /*linked ao brand-hover*/
    --brand-hover: rgba(var(--brand-rgb), 0.1);
    --brand-input: #d9deea;

    --line: rgba(255, 255, 255, 0.40);
    --line-soft: rgba(255, 255, 255, 0.22);

    --text: #4b4b4b;
    --muted: #7c89a3;
    --accent: #6f7ea5;
    --accent-strong: #5d6d95;
    --accent-soft: rgba(111, 126, 165, 0.12);
    
    --danger: rgb(231, 59, 64);
    --danger-rgb: 231, 59, 64;
    --danger-hover: rgba(var(--danger-rgb), 0.5);

    --shadow-soft: 0 10px 30px rgba(31, 41, 55, 0.08);

    /* Radius */
    --r-full: 999px;
    --r-sharp: 5px;
    --r-round: 20px;

    --p-small: 20px;

    --sidebar-width: 260px;
    --sidebar-width-collapsed: 84px;
    --topbar-height: 86px;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    color: var(--text);
    background: #f4f4f4;
}

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

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

label{
    font-weight: 500;
}

strong {
    font-weight: 600;
}

/* BTN */
.btn {
    position: relative;
    isolation: isolate;
    overflow: hidden;

    height: 48px;
    width: max-content;
    border-radius: var(--r-full);
    border: none;
    background: var(--brand);
    color: #fff;
    padding: 0 25px;
    cursor: pointer;
}

.btn:hover {
    background: var(--brand-toggled);
}

.btn-danger {
    background: var(--danger);
    color: #fff !important;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-icon {
    width: 46px;
    height: 46px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-full);
    flex-shrink: 0;
}

.btn-icon svg,
.btn-icon i {
    width: 18px;
    height: 18px;
}

/* INPUT*/

.input-select {
    width: 100%;
    height: 46px;
    padding: 0 40px 0 12px; /* space for arrow */
    border-radius: var(--r-sharp);
    border: 1px solid var(--brand-input);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8L10 12L14 8' stroke='%236f7ea5' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.input-select:focus {
    outline: none;
    border-color: var(--brand-input);
}

/* disabled / readonly style */
.input-select[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* GUEST */

.guest-body {
    background: var(--bg);
}

.guest-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--brand-input);
    border-radius: var(--r-sharp);
    color: var(--text);
    outline: none;
    background: #fff;
}

.login-form button,
.logout-btn {
    height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--r-sharp);
    background: #111827;
    color: #fff;
    cursor: pointer;
}

.error-message {
    color: #c62828;
    margin-bottom: 14px;
}

/* APP */

.app-shell-body {
    overflow-x: hidden;
}

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

.app-sidebar {
    width: var(--sidebar-width-collapsed);
    min-width: var(--sidebar-width-collapsed);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1100;

    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px 12px;

    background: rgba(255,255,255,0.5);
    border-right: 1px solid rgba(111, 126, 165, 0.10);
    border-radius: 0;
    box-shadow: none;

    backdrop-filter: blur(20px) saturate(170%);
    -webkit-backdrop-filter: blur(20px) saturate(170%);
    transition: width 0.22s ease, min-width 0.22s ease, padding 0.22s ease;
}

.app-sidebar-top {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
}

.app-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-brand-mark.logo-mark {
    width: 44px;
    height: 44px;
    min-width: 44px;
    max-width: 44px;
    flex: 0 0 44px;
    background: transparent;
    border-radius: 0;
    overflow: hidden;
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-brand-mark.logo-mark svg {
    width: 44px;
    height: 44px;
    max-width: 44px;
    max-height: 44px;
    display: block;
    flex-shrink: 0;
    transition: none;
    transform: none;
}

.app-brand:hover .app-brand-mark.logo-mark svg,
.app-sidebar:hover .app-brand-mark.logo-mark svg {
    width: 44px;
    height: 44px;
    transform: none;
}

.app-brand-mark.logo-mark svg,
.app-brand-mark.logo-mark svg * {
    fill: currentColor;
    stroke: currentColor;
}


.app-brand-text {
    font-size: 22px;
    font-weight: 800;
    color: var(--brand);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.mobile-menu-btn,
.topbar-icon-btn {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: var(--r-sharp);
    background: rgba(255,255,255,0.56);
    color: var(--accent-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.42);
}

.mobile-menu-btn svg,
.topbar-icon-btn svg,
.nav-link svg,
.sidebar-logout-btn svg,
.nav-chevron,
.app-search-pill svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.9;
    flex-shrink: 0;
}

.app-sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.app-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(111, 126, 165, 0.18);
    border-radius: 999px;
}

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

.nav-link,
.nav-sublink {
    border: 0;
    width: 100%;
    text-align: left;
}

.nav-link {
    min-height: 52px;
    padding: 0 14px;
    border-radius: var(--r-sharp);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    color: var(--brand);
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-link:hover,
.nav-link.active,
.nav-group.is-active > .nav-link,
.nav-group.is-open > .nav-link {
    background: var(--brand-hover);
}

.nav-link-main {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-label {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.nav-chevron {
    flex-shrink: 0;
    transition: transform 0.18s ease;
}

.nav-group.is-open .nav-chevron,
.nav-group.is-active.has-children .nav-chevron {
    transform: rotate(180deg);
}

.nav-submenu {
    display: none;
    padding: 2px 0 2px 30px;
    flex-direction: column;
    gap: 6px;
}

.nav-submenu.is-open {
    display: flex;
}

.nav-sublink {
    min-height: 42px;
    padding: 0 14px;
    border-radius: var(--r-sharp);
    display: flex;
    align-items: center;
    color: var(--brand);
    font-size: 12px;
    font-weight: 500;
    transition: background 0.18s ease, color 0.18s ease;
}

.nav-sublink:hover,
.nav-sublink.active {
    background: var(--brand-hover);
}

.app-sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(111, 126, 165, 0.10);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(180deg, #8d9abd, #7281a6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sidebar-user-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-user-meta strong {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-meta span {
    font-size: 12px;
    color: var(--muted);
    text-transform: capitalize;
}

.sidebar-logout-form {
    margin: 0;
}

.sidebar-logout-btn {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: var(--r-sharp);
    background: transparent;
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
}

.sidebar-logout-btn:hover {
    background: var(--brand-hover);
}

.app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width-collapsed);
    padding: 18px 18px 18px 18px;
    transition: margin-left 0.22s ease;
}

.app-topbar {
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 8px 10px 8px 18px;
}

.app-topbar-left,
.app-topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mobile-menu-btn {
    display: none;
}

.app-search-pill {
    width: min(520px, 100%);
    min-height: 54px;
    padding: 0 18px;
    border-radius: var(--r-full);
    background: rgba(255,255,255,0.62);
    border: 1px solid rgba(255,255,255,0.42);
    box-shadow:
        0 10px 26px rgba(31, 41, 55, 0.06),
        inset 0 1px 0 rgba(255,255,255,0.44);

    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.app-search-pill input {
    width: 100%;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
}

.app-search-pill input::placeholder {
    color: #8a95ad;
}

.app-content {
    padding: 8px 18px 24px;
}

.page-header {
    margin-bottom: 22px;
}

.page-header h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.1;
    font-weight: 800;
    color: var(--brand);
    letter-spacing: -0.02em;
}

.dashboard-card,
.card {
    background: rgba(255,255,255,0.82);
    border-radius: var(--r-sharp);
    padding: var(--p-small);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 14px 10px;
    border-bottom: 1px solid #eceef3;
}

.data-table th {
    font-size: 14px;
    color: #5e6b86;
    font-weight: 700;
}

.app-sidebar-overlay {
    display: none;
}

.nav-link,
.nav-sublink,
.sidebar-logout-btn,
.topbar-icon-btn,
.mobile-menu-btn {
    overflow: hidden;
}

.nav-link svg,
.sidebar-logout-btn svg,
.topbar-icon-btn svg,
.mobile-menu-btn svg,
.app-search-pill svg {
    display: block;
}

@media (min-width: 981px) {
    .app-sidebar:hover {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        padding-left: 18px;
        padding-right: 18px;
    }

    /* estado colapsado */
    .app-sidebar .app-brand-text,
    .app-sidebar .nav-label,
    .app-sidebar .nav-chevron,
    .app-sidebar .sidebar-user-meta,
    .app-sidebar .sidebar-logout-btn span {
        display: none;
    }

    /* estado expandido no hover */
    .app-sidebar:hover .app-brand-text,
    .app-sidebar:hover .nav-label,
    .app-sidebar:hover .nav-chevron,
    .app-sidebar:hover .sidebar-user-meta,
    .app-sidebar:hover .sidebar-logout-btn span {
        display: inline;
    }

    .app-sidebar:hover .sidebar-user-meta {
        display: flex;
        flex-direction: column;
    }

    .app-sidebar .nav-link {
        min-height: 50px;
        padding: 0;
        justify-content: center;
    }

    .app-sidebar:hover .nav-link {
        padding: 0 14px;
        justify-content: space-between;
    }

    .app-sidebar .nav-link-main {
        justify-content: center;
        gap: 0;
        width: auto;
    }

    .app-sidebar:hover .nav-link-main {
        justify-content: flex-start;
        gap: 12px;
        width: 100%;
    }

    .app-sidebar .app-sidebar-top {
        justify-content: center;
    }

    .app-sidebar:hover .app-sidebar-top {
        justify-content: flex-start;
    }

    .app-sidebar .app-brand {
        justify-content: center;
        width: 100%;
    }

    .app-sidebar:hover .app-brand {
        justify-content: flex-start;
    }

    .app-sidebar .sidebar-user {
        justify-content: center;
    }

    .app-sidebar:hover .sidebar-user {
        justify-content: flex-start;
    }

    .app-sidebar .sidebar-logout-btn {
        justify-content: center;
        padding: 0;
    }

    .app-sidebar:hover .sidebar-logout-btn {
        justify-content: center;
        padding: 0 14px;
        gap: 10px;
    }

    .app-sidebar .nav-submenu {
        display: none !important;
    }

    .app-sidebar:hover .nav-submenu.is-open {
        display: flex !important;
    }
}



/* MOBILE */

@media (max-width: 980px) {
    .app-sidebar {
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        width: min(320px, 88vw);
        min-width: min(320px, 88vw);
        padding-left: 18px;
        padding-right: 18px;
    }

    .app-sidebar .app-brand-text,
    .app-sidebar .nav-label,
    .app-sidebar .nav-chevron,
    .app-sidebar .sidebar-user-meta,
    .app-sidebar .sidebar-logout-btn span {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .app-sidebar .nav-link {
        min-height: 52px;
        padding: 0 14px;
        justify-content: space-between;
    }

    .app-sidebar .nav-link-main {
        justify-content: flex-start;
        gap: 12px;
        width: auto;
    }

    .app-sidebar .app-sidebar-top,
    .app-sidebar .app-brand,
    .app-sidebar .sidebar-user {
        justify-content: flex-start;
    }

    .app-sidebar .nav-submenu.is-open {
        display: flex !important;
    }

    .app-sidebar .sidebar-logout-btn {
        justify-content: center;
        padding: 0 14px;
        gap: 10px;
    }

    .app-main {
        margin-left: 0;
        padding: 10px;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }

    .app-topbar {
        min-height: 74px;
        padding: 8px 4px 8px 6px;
    }

    .app-search-pill {
        min-height: 50px;
        width: 100%;
    }

    .app-content {
        padding: 4px 6px 20px;
    }

    .page-header {
        margin-bottom: 16px;
    }

    .page-header h1 {
        font-size: 28px;
    }

    body.sidebar-mobile-open .app-sidebar {
        transform: translateX(0);
    }

    body.sidebar-mobile-open .app-sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(21, 26, 38, 0.26);
        z-index: 1050;
    }
}

@media (max-width: 640px) {
    .app-topbar {
        align-items: stretch;
    }

    .app-topbar-left {
        width: 100%;
    }

    .app-topbar-right {
        gap: 8px;
    }

    .app-search-pill {
        min-width: 0;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .dashboard-card,
    .card {
        padding: 18px;
        border-radius: var(--r-sharp);
    }
}

.app-mobile-header {
    display: none;
}

.app-mobile-header-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    min-width: 0;
}

@media (max-width: 980px) {
    .app-mobile-header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 6px 6px 12px;
    }

    .page-header {
        display: none;
    }
}

/* TOOLBARS */

.toolbar-wrap {
    position: sticky;
    top: 12px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;
    isolation: isolate;
}

.toolbar-wrap::before {
    content: "";
    position: absolute;
    inset: -12px -8px -20px -8px;
    z-index: -1;
    pointer-events: none;

    background: var(--bg);
}

.toolbar {
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr) auto;
    gap: 14px;
    align-items: end;
    padding: 14px;
    background: rgba(255,255,255,0.92);
    border-radius: var(--r-sharp);
    backdrop-filter: blur(20px) saturate(170%);
    -webkit-backdrop-filter: blur(20px) saturate(170%);
}

.toolbar-extra {
    display: grid;
    grid-template-columns: auto minmax(220px, 320px) auto auto;
    gap: 12px;
    align-items: center;

    padding: 0 14px;
    max-height: 0;
    opacity: 0;
    transform: translateY(-8px);
    overflow: hidden;
    pointer-events: none;

    background: var(--brand-hover);
    border-radius: var(--r-sharp);
    backdrop-filter: blur(20px) saturate(170%);
    -webkit-backdrop-filter: blur(20px) saturate(170%);

    transition:
        max-height 0.25s ease,
        opacity 0.2s ease,
        transform 0.25s ease,
        padding 0.25s ease;
}

.toolbar-extra.is-visible {
    max-height: 90px;
    opacity: 1;
    transform: translateY(0);
    padding: 14px;
    pointer-events: auto;
}

.toolbar-form {
    margin: 0;
}

.toolbar-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toolbar-count {
    white-space: nowrap;
    color: var(--text);
    font-weight: 600;
}

.toolbar-content {
    margin-top: 28px;
}

@media (max-width: 820px) {
    .toolbar {
        grid-template-columns: 1fr;
    }

    .toolbar-extra,
    .toolbar-extra.is-visible {
        grid-template-columns: 1fr;
    }

    .toolbar-extra.is-visible {
        max-height: 260px;
    }
}