@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Space+Grotesk:wght@600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    --bg: #070a11;
    --bg-2: #0e1421;
    --surface: rgba(255,255,255,0.065);
    --surface-strong: rgba(255,255,255,0.105);
    --border: rgba(255,255,255,0.13);
    --border-strong: rgba(255,255,255,0.24);
    --text: #f8fafc;
    --muted: #aeb9c9;
    --soft: #dbe4ef;
    --accent: #5be1ff;
    --accent-2: #8f9bff;
    --danger: #fb7185;
    --warning: #fbbf24;
    --success: #22c55e;
    --font-body: "Inter", system-ui, sans-serif;
    --font-heading: "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--text);
    background:
        radial-gradient(circle at 12% 10%, rgba(91,225,255,0.14), transparent 34%),
        radial-gradient(circle at 90% 20%, rgba(143,155,255,0.13), transparent 34%),
        linear-gradient(180deg, var(--bg), var(--bg-2));
}

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

.area-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px;
    border-right: 1px solid var(--border);
    background: rgba(7,10,17,0.72);
    backdrop-filter: blur(18px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #06111d;
    font-family: var(--font-heading);
    font-weight: 900;
}

.brand-title strong {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    letter-spacing: -0.04em;
}

.brand-title span {
    display: block;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.menu {
    display: grid;
    gap: 8px;
}

.menu a, .logout-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: 180ms ease;
}

.menu a:hover, .menu a.active, .logout-button:hover {
    color: #fff;
    background: rgba(255,255,255,0.075);
    border-color: var(--border);
}

.menu-section {
    margin: 24px 0 10px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.content {
    min-width: 0;
    padding: 28px clamp(18px, 4vw, 54px) 54px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 34px;
}

.page-title span {
    display: inline-flex;
    margin-bottom: 8px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.page-title h1 {
    font-family: var(--font-heading);
    font-size: clamp(2.2rem, 5vw, 4rem);
    line-height: 0.96;
    letter-spacing: -0.07em;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255,255,255,0.055);
    color: var(--soft);
    font-weight: 700;
}

.avatar {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #06111d;
    font-weight: 900;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 26px;
    padding: 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.045));
    backdrop-filter: blur(18px);
    box-shadow: 0 24px 80px rgba(0,0,0,0.18);
}

.card::before {
    content: "";
    position: absolute;
    right: -90px;
    top: -90px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(91,225,255,0.08);
    pointer-events: none;
}

.card > * { position: relative; z-index: 2; }

.metric strong {
    display: block;
    font-family: var(--font-mono);
    color: #fff;
    font-size: 2rem;
    margin-bottom: 8px;
}

.metric span {
    display: block;
    color: var(--muted);
    line-height: 1.5;
}

.table-card { padding: 0; overflow-x: auto; }

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

th, td {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
}

td {
    color: var(--soft);
}

.badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(91,225,255,0.10);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 800;
}

.badge.success { background: rgba(34,197,94,0.12); color: #86efac; }
.badge.warning { background: rgba(251,191,36,0.12); color: #fde68a; }
.badge.danger { background: rgba(251,113,133,0.12); color: #fecdd3; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 11px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.07);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    transition: 180ms ease;
}

.btn:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    background: rgba(255,255,255,0.11);
}

.btn-primary {
    color: #06111d;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
}

.btn-danger {
    color: #fff;
    background: rgba(251,113,133,0.14);
    border-color: rgba(251,113,133,0.24);
}

.form {
    display: grid;
    gap: 16px;
}

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

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 13px 14px;
    background: rgba(7,10,17,0.56);
    color: var(--text);
    font: inherit;
    outline: none;
}

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

input:focus, select:focus, textarea:focus {
    border-color: rgba(91,225,255,0.68);
    box-shadow: 0 0 0 4px rgba(91,225,255,0.08);
}

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.07);
    color: var(--soft);
}

.alert.success {
    border-color: rgba(34,197,94,0.24);
    background: rgba(34,197,94,0.10);
}

.alert.error {
    border-color: rgba(251,113,133,0.24);
    background: rgba(251,113,133,0.10);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 460px);
    border: 1px solid var(--border);
    border-radius: 32px;
    padding: 34px;
    background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.045));
    box-shadow: 0 30px 120px rgba(0,0,0,0.35);
    backdrop-filter: blur(18px);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo strong {
    display: block;
    font-family: var(--font-heading);
    font-size: 3rem;
    letter-spacing: -0.08em;
}

.login-logo span {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.ticket-message {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    background: rgba(255,255,255,0.055);
}

.ticket-message + .ticket-message { margin-top: 12px; }

.message-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.88rem;
}

.empty {
    color: var(--muted);
    line-height: 1.7;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

@media (max-width: 980px) {
    .area-shell { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .menu { grid-template-columns: repeat(2, 1fr); }
    .grid-4, .grid-3, .grid-2, .form-row { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
    .content { padding: 22px 16px 42px; }
    .sidebar { padding: 18px 16px; }
    .menu { grid-template-columns: 1fr; }
    .login-card { padding: 24px; border-radius: 24px; }
}

/* Extra AMH Área Reservada: perfil, password reset, permissões e imagem de perfil */

.card-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}

.checkbox-line {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    width: 100% !important;
}

.checkbox-line input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    flex: 0 0 18px !important;
    margin: 0 !important;
    accent-color: var(--accent);
}

.small-checkbox {
    margin-top: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255,255,255,0.045);
}

.permission-card {
    display: block;
    margin-top: 8px;
}

.permission-card .checkbox-line {
    margin: 0 0 18px 0 !important;
    padding: 14px 16px !important;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255,255,255,0.055);
    color: var(--soft);
}

.permissions-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    width: 100% !important;
}

.permission-item {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    width: 100% !important;
    min-height: 54px;
    padding: 14px 16px !important;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255,255,255,0.055);
    color: var(--soft);
    cursor: pointer;
}

.permission-item input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    flex: 0 0 18px !important;
    margin: 0 !important;
    accent-color: var(--accent);
}

.permission-item span,
.permission-card .checkbox-line span {
    display: inline-block;
    line-height: 1.35;
}

.permission-item:hover,
.permission-card .checkbox-line:hover,
.small-checkbox:hover {
    border-color: var(--border-strong);
    background: rgba(255,255,255,0.085);
}

/* Imagem de perfil */

.avatar {
    overflow: hidden;
}

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

.profile-photo-panel {
    display: grid;
    grid-template-columns: 112px 1fr;
    gap: 20px;
    align-items: center;
    margin: 10px 0 22px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: rgba(255,255,255,0.045);
}

.profile-photo-preview {
    width: 112px;
    height: 112px;
    border-radius: 28px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #06111d;
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 900;
    box-shadow: 0 18px 55px rgba(0,0,0,0.22);
}

.profile-photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-photo-actions {
    display: grid;
    gap: 10px;
}

.profile-photo-actions input[type="file"] {
    padding: 12px;
}

@media (max-width: 720px) {
    .permissions-grid {
        grid-template-columns: 1fr !important;
    }

    .profile-photo-panel {
        grid-template-columns: 1fr;
    }
}

/* Menu do perfil no topo */

.profile-dropdown {
    position: relative;
    flex: 0 0 auto;
}

.profile-dropdown summary {
    list-style: none;
}

.profile-dropdown summary::-webkit-details-marker {
    display: none;
}

.profile-dropdown[open] .user-pill {
    border-color: var(--border-strong);
    background: rgba(255,255,255,0.105);
    box-shadow: 0 18px 55px rgba(0,0,0,0.22);
}

.profile-dropdown[open] .profile-chevron {
    transform: rotate(180deg);
}

.user-pill {
    cursor: pointer;
    user-select: none;
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    min-width: 0 !important;
    padding: 9px 12px !important;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255,255,255,0.065);
    color: var(--soft);
    transition: 220ms ease;
}

.user-pill:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    background: rgba(255,255,255,0.095);
}

.profile-name {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-heading);
    font-weight: 800;
}

.profile-chevron {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    stroke: currentColor;
    stroke-width: 2.4;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    color: var(--muted);
    transition: 220ms ease;
}

.profile-dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 100;
    width: min(320px, calc(100vw - 32px));
    padding: 10px;
    border: 1px solid var(--border-strong);
    border-radius: 24px;
    background:
        radial-gradient(circle at top right, rgba(91,225,255,0.12), transparent 36%),
        rgba(10,15,25,0.96);
    backdrop-filter: blur(24px);
    box-shadow: 0 28px 95px rgba(0,0,0,0.40);
    animation: profileMenuIn 180ms ease both;
}

@keyframes profileMenuIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.profile-dropdown-header {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 18px;
    background: rgba(255,255,255,0.055);
    border: 1px solid var(--border);
}

.profile-dropdown-header strong {
    display: block;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 0.98rem;
    line-height: 1.25;
}

.profile-dropdown-header span:not(.avatar) {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.86rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-dropdown-item {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: var(--soft);
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
    transition: 180ms ease;
}

.profile-dropdown-item:hover {
    color: #fff;
    background: rgba(255,255,255,0.075);
    transform: translateX(3px);
}

.profile-dropdown-item.danger {
    color: #fecaca;
}

.profile-dropdown-item.danger:hover {
    color: #fff;
    background: rgba(248,113,113,0.13);
}

.profile-dropdown-item svg {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.profile-dropdown-menu form {
    margin: 0;
}

/* Avatar robusto */

.user-pill .avatar,
.avatar {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    flex: 0 0 38px !important;
    display: grid !important;
    place-items: center !important;
    overflow: hidden !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important;
    color: #06111d !important;
    font-family: var(--font-heading) !important;
    font-weight: 900 !important;
    font-size: 0.95rem !important;
    line-height: 1 !important;
}

.avatar.large {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    flex-basis: 48px !important;
}

.user-pill .avatar img,
.avatar img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    display: block !important;
    object-fit: cover !important;
    border-radius: inherit !important;
}

@media (max-width: 720px) {
    .profile-name {
        max-width: 120px;
    }

    .profile-dropdown-menu {
        right: auto;
        left: 0;
    }
}

/* Ajuste do perfil: deixa a alteração de password mais compacta */
.content > .grid.grid-2:has(.profile-photo-panel) {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    align-items: start;
}

.content > .grid.grid-2:has(.profile-photo-panel) > .card:nth-child(2) {
    width: min(100%, 430px);
    justify-self: end;
    padding: 22px;
}

.content > .grid.grid-2:has(.profile-photo-panel) > .card:nth-child(2) .card-title {
    margin-bottom: 4px;
    font-size: 1.22rem;
}

.content > .grid.grid-2:has(.profile-photo-panel) > .card:nth-child(2) .form,
.content > .grid.grid-2:has(.profile-photo-panel) > .card:nth-child(2).form {
    gap: 12px;
}

.content > .grid.grid-2:has(.profile-photo-panel) > .card:nth-child(2) input {
    padding: 10px 12px;
    min-height: 42px;
    border-radius: 14px;
}

.content > .grid.grid-2:has(.profile-photo-panel) > .card:nth-child(2) .btn {
    min-height: 42px;
    padding: 10px 14px;
}

@media (max-width: 980px) {
    .content > .grid.grid-2:has(.profile-photo-panel) {
        grid-template-columns: 1fr;
    }

    .content > .grid.grid-2:has(.profile-photo-panel) > .card:nth-child(2) {
        width: 100%;
        justify-self: stretch;
    }
}
