:root {
    color-scheme: dark;
    --bg: #050b15;
    --surface: #0c1829;
    --surface-2: #13243a;
    --surface-3: #1a2e49;
    --line: #223753;
    --text: #f4f7fb;
    --muted: #91a4bd;
    --primary: #d6a84a;
    --primary-2: #f3d17f;
    --blue: #4e9df8;
    --cyan: #42d3d0;
    --danger: #ef6b76;
    --success: #36d399;
    --sidebar: 284px;
    --shadow: 0 20px 55px rgba(0, 0, 0, .26);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background:
        radial-gradient(circle at 85% -10%, rgba(55, 119, 190, .2), transparent 34%),
        radial-gradient(circle at 25% 110%, rgba(210, 164, 70, .09), transparent 30%),
        var(--bg);
    color: var(--text);
    font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--primary-2); text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 18px 14px 14px;
    background: linear-gradient(180deg, rgba(8, 17, 31, .99), rgba(5, 11, 21, .99));
    border-right: 1px solid var(--line);
    box-shadow: 18px 0 50px rgba(0, 0, 0, .18);
    z-index: 20;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 74px;
    padding: 5px 8px 16px;
    color: var(--text);
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand-mark {
    display: grid;
    place-items: center;
    flex: 0 0 58px;
    width: 58px;
    height: 58px;
    border: 1px solid rgba(214, 168, 74, .28);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(214, 168, 74, .13), rgba(78, 157, 248, .08));
}
.brand img {
    width: 50px;
    height: 50px;
    object-fit: contain;
}
.brand > span:last-child { min-width: 0; display: grid; gap: 2px; }
.brand strong {
    max-width: 180px;
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.brand small { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.sidebar nav {
    display: grid;
    gap: 3px;
    margin-top: 12px;
    overflow-y: auto;
}
.nav-section {
    padding: 14px 12px 6px;
    color: #637791;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.sidebar nav a, .logout {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--muted);
    text-align: left;
    transition: background .18s, color .18s, transform .18s;
}
.sidebar nav a:hover, .sidebar nav a.active {
    background: linear-gradient(90deg, rgba(214, 168, 74, .18), rgba(78, 157, 248, .07));
    color: var(--text);
    transform: translateX(2px);
}
.sidebar nav a.active {
    box-shadow: inset 3px 0 var(--primary);
}
.nav-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .045);
    color: var(--primary-2);
    font-size: 15px;
}
.sidebar-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: auto 5px 8px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 12px;
    background: rgba(255, 255, 255, .025);
}
.sidebar-status > span:last-child { display: grid; }
.sidebar-status b { font-size: 12px; }
.sidebar-status small { font-size: 10px; }
.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 5px rgba(54, 211, 153, .1), 0 0 18px rgba(54, 211, 153, .6);
}
.logout-form { margin-top: 0; }
.logout { color: var(--danger); }
.shell { margin-left: var(--sidebar); min-height: 100vh; }
header {
    position: sticky;
    top: 0;
    z-index: 10;
    height: 78px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 32px;
    background: rgba(5, 11, 21, .78);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}
.header-title { display: grid; gap: 2px; }
.header-title strong { font-size: 18px; }
.eyebrow { color: var(--primary); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}
.header-user > span:last-child { display: grid; min-width: 92px; }
.header-user b { font-size: 12px; }
.header-user small { font-size: 10px; }
#headerClock { color: var(--muted); font-size: 12px; margin-right: 8px; }
.avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(214, 168, 74, .4);
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(214, 168, 74, .24), rgba(78, 157, 248, .16));
    color: var(--primary-2);
    font-weight: 800;
}
#menuButton { display: none; background: none; border: 0; color: var(--text); font-size: 24px; }
#menuBackdrop { display: none; }
main { padding: 30px 32px 46px; max-width: 1600px; margin: auto; }
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
h1, h2, h3, p { margin-top: 0; }
.page-head p, .muted, small { color: var(--muted); }
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.card, .panel {
    background: linear-gradient(145deg, rgba(20, 37, 60, .94), rgba(10, 22, 39, .96));
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.card {
    position: relative;
    min-height: 126px;
    padding: 20px;
    overflow: hidden;
}
.card::after {
    content: "";
    position: absolute;
    width: 90px;
    height: 90px;
    right: -32px;
    bottom: -42px;
    border-radius: 50%;
    background: rgba(78, 157, 248, .1);
}
.card.warn::after { background: rgba(239, 107, 118, .12); }
.card.gold::after { background: rgba(214, 168, 74, .13); }
.card strong { display: block; margin-top: 7px; font-size: 30px; letter-spacing: -.03em; }
.card-foot { display: block; margin-top: 8px; color: #6f849e; font-size: 11px; }
.metric-icon {
    position: absolute;
    top: 17px;
    right: 17px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 10px;
    background: rgba(255, 255, 255, .04);
    color: var(--primary-2);
}
.panel { padding: 22px; margin-bottom: 20px; }
.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.panel-title h2 { margin: 0; font-size: 17px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.dashboard-main { grid-template-columns: minmax(0, 1.4fr) minmax(310px, .6fr); }
.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 126px;
    margin-bottom: 20px;
    padding: 24px 26px;
    border: 1px solid rgba(214, 168, 74, .2);
    border-radius: 20px;
    background:
        linear-gradient(110deg, rgba(214, 168, 74, .13), transparent 44%),
        linear-gradient(145deg, rgba(20, 39, 65, .95), rgba(8, 19, 34, .97));
    box-shadow: var(--shadow);
}
.dashboard-hero h2 { margin: 3px 0 5px; font-size: clamp(22px, 3vw, 32px); }
.dashboard-hero p { margin: 0; color: var(--muted); }
.hero-state { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.hero-state .status-dot { width: 11px; height: 11px; }
.service-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.service {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border: 1px solid rgba(255,255,255,.05);
    border-radius: 11px;
    background: rgba(255,255,255,.025);
}
.online-list { display: grid; gap: 8px; }
.online-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.online-item:last-child { border-bottom: 0; }
.extension-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(54, 211, 153, .1);
    color: var(--success);
    font-weight: 800;
}
.online-item > span:nth-child(2) { display: grid; min-width: 0; }
.online-item small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { display: grid; gap: 6px; color: var(--muted); }
input, select {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
    background: #09162a;
    color: var(--text);
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(214, 173, 85, .12); }
input[type="checkbox"] { width: 18px; min-height: 18px; }
input[type="file"] { padding: 7px; }
.check { display: flex; align-items: center; gap: 8px; align-self: end; min-height: 42px; }
.full-row { grid-column: 1 / -1; }
.field-help { margin: -3px 0 0; color: var(--muted); font-size: 12px; }
.member-picker {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    max-height: 260px;
    overflow-y: auto;
}
.member-option {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 52px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255,255,255,.025);
}
.member-option span { display: grid; }
.member-option small { margin-top: 2px; }
.member-tags { display: flex; flex-wrap: wrap; gap: 5px; max-width: 360px; }
.member-tags span {
    padding: 4px 7px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 999px;
    background: rgba(255,255,255,.045);
    font-size: 12px;
}
.member-tags span.online {
    border-color: rgba(54,211,153,.35);
    background: rgba(54,211,153,.1);
    color: #baf6dc;
}
.table-subtitle { display: block; margin-top: 3px; }
.dial-number {
    display: inline-grid;
    place-items: center;
    min-width: 54px;
    padding: 5px 9px;
    border-radius: 8px;
    background: rgba(214,168,74,.13);
    color: var(--primary-2);
    font-weight: 800;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text);
}
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: linear-gradient(135deg, #b88729, var(--primary)); border-color: var(--primary); color: #111827; font-weight: 700; }
.btn.danger { color: #fff; background: #9d2f3b; border-color: #bd4652; }
.btn.big { width: 100%; min-height: 48px; }
.toolbar, .actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 15px; }
.actions { justify-content: flex-end; margin-top: 16px; margin-bottom: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #5b2631; color: #ffd9de; font-size: 12px; }
.badge.ok { background: #124a3c; color: #baf6dc; }
dialog { width: min(720px, calc(100vw - 28px)); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); padding: 22px; }
dialog::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(4px); }
.form-error { grid-column: 1 / -1; margin: 4px 0 0; border: 1px solid #c55b68; }
.page-error { position: sticky; top: 82px; z-index: 30; border: 1px solid #c55b68; box-shadow: 0 12px 32px #0007; }
audio { width: 240px; height: 38px; }
pre { overflow: auto; padding: 15px; border-radius: 10px; background: #050b16; color: #cce0ff; white-space: pre-wrap; }
.log-panel { padding-bottom: 14px; }
.log-console {
    height: min(68vh, 760px);
    margin: 0;
    border: 1px solid rgba(78,157,248,.16);
    background: #030812;
    color: #b9d5f5;
    font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
    white-space: pre;
}
#toast { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 12px 15px; border-radius: 10px; background: #174638; box-shadow: 0 10px 30px #0008; }
.toast.error { background: #7e2c37; }
#loading { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; place-items: center; gap: 12px; background: var(--bg); transition: opacity .2s; }
#loading img { width: 120px; height: 120px; object-fit: contain; animation: pulse 1.3s infinite; }
#loading.hidden { opacity: 0; pointer-events: none; }
@keyframes pulse { 50% { transform: scale(.94); opacity: .7; } }
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card, .setup-card {
    width: min(470px, 100%);
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(12, 26, 47, .96);
    box-shadow: 0 24px 70px #0008;
    text-align: center;
}
.setup-card { width: min(760px, 100%); }
.logo-sistema {
    display: block;
    width: min(220px, 70vw);
    height: auto;
    max-height: 220px;
    margin: 0 auto 16px;
    object-fit: contain;
}

.config-final-body {
    align-items: flex-start;
    padding: 32px 16px;
}

.config-final-card {
    width: min(760px, 100%);
}

.config-service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 24px 0;
}

.service-status {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 68px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, .04);
    text-align: left;
}

.service-status > span {
    width: 11px;
    height: 11px;
    flex: 0 0 11px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 5px rgba(239, 68, 68, .13);
}

.service-status.online > span {
    background: #22c55e;
    box-shadow: 0 0 0 5px rgba(34, 197, 94, .13);
}

.service-status strong,
.service-status small {
    display: block;
}

.service-status small {
    margin-top: 3px;
    color: var(--muted);
}
.login-card form, .setup-form { display: grid; gap: 14px; text-align: left; }
.developer { margin-bottom: 4px; }
.support { display: inline-block; margin-bottom: 20px; font-weight: 700; }
fieldset { display: grid; gap: 13px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; }
legend { padding: 0 8px; color: var(--primary-2); }
.alert { padding: 11px; margin-bottom: 14px; border-radius: 9px; background: #183c61; }
.alert.error { background: #702c38; }
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
    #menuBackdrop {
        position: fixed;
        inset: 0;
        z-index: 19;
        border: 0;
        background: rgba(0, 0, 0, .64);
        backdrop-filter: blur(3px);
    }
    body.menu-open #menuBackdrop { display: block; }
    .shell { margin-left: 0; }
    #menuButton { display: block; }
    main { padding: 20px 14px; }
    .grid.two, .grid.dashboard-main, .form-grid { grid-template-columns: 1fr; }
    #headerClock { display: none; }
    .header-user > span:last-child { display: none; }
    .dashboard-hero { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
    header { padding: 0 15px; }
    .page-head { align-items: flex-start; }
    .config-service-grid { grid-template-columns: 1fr; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card { min-height: 112px; padding: 16px; }
    .card strong { font-size: 25px; }
    .metric-icon { display: none; }
}
