:root {
    --bg: #161b24;
    --sidebar: #1c2431;
    --card: #243041;
    --card-2: #2c3a4e;
    --line: rgba(255, 255, 255, 0.16);
    --text: #f5f7fb;
    --muted: #d5deea;
    --accent: #e3a008;
    --ink: #1c1403;
    --danger: #e15b55;
    --ok: #3cba8b;
    --info: #4c8dff;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
    --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: #161b24 url("marca/fundo.jpg") center / cover no-repeat fixed; color: var(--text); }
body { font-family: "Segoe UI", system-ui, sans-serif; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: var(--text); }
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: var(--accent);
    color: var(--ink);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 0.68rem 1rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
button:hover { background: #f0b429; border-color: #f0b429; }
button.perigo, form[action$="/cache"] button {
    background: rgba(225, 91, 85, 0.16);
    color: #ffd4d1;
    border-color: var(--danger);
}
form[action$="/cache"] button { background: transparent; color: var(--text); border-color: var(--line); }
button.perigo:hover { background: rgba(225, 91, 85, 0.28); }
input, select, textarea {
    width: 100%;
    background: #1a2230;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    padding: 0.68rem 0.8rem;
    min-height: 44px;
}
textarea { min-height: 6.5rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus, button:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 0.15rem rgba(227, 160, 8, 0.25);
}
select {
    color-scheme: dark;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23f5f7fb' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    background-size: 12px;
    padding-right: 2rem;
}
input[type="color"] { width: 52px; min-width: 52px; height: 44px; padding: 0.2rem; }
input[type="range"] { padding: 0; accent-color: var(--accent); background: transparent; border: 0; box-shadow: none; }
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; min-height: 0; accent-color: var(--accent); }
input[type="file"]::file-selector-button {
    background: var(--card-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 8px; padding: 0.35rem 0.7rem; margin-right: 0.7rem; cursor: pointer;
}
label { display: grid; gap: 0.35rem; color: var(--text); font-weight: 650; font-size: 0.92rem; }
output { color: var(--accent); }

.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 16.5rem;
    flex: 0 0 16.5rem;
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.sidebar-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; padding: 1.1rem 1rem; border-bottom: 1px solid var(--line); }
.marca-logo { height: 46px; width: auto; max-width: 100%; display: block; }
.marca-icone, .login-marca i {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: rgba(227, 160, 8, 0.16); color: #f0c14b; font-size: 1.25rem;
}
.sidebar-brand strong { display: block; font-size: 1.05rem; }
.sidebar-brand span, .nav-label, .nota, .metric span { color: var(--muted); }
.sidebar-brand span { font-size: 0.78rem; }
.credito, .rodape, .home-marca, .login-marca strong { color: var(--accent); letter-spacing: 0.02em; max-width: 100%; overflow-wrap: anywhere; line-height: 1.25; }
.sidebar-brand .credito { font-size: 0.72rem; font-weight: 700; }
.rodape { text-align: center; margin: 1.6rem 0 0.2rem; font-size: 0.82rem; }
.sidebar-scroll { overflow-y: auto; padding: 0.75rem 0.7rem 1rem; flex: 1; }
.nav-label { margin: 0.85rem 0.55rem 0.35rem; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.nav-link-item {
    display: flex; align-items: center; gap: 0.7rem;
    color: #d5dbe6; border-radius: 10px; padding: 0.55rem 0.7rem; margin-bottom: 0.15rem;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}
.nav-link-item .fa { width: 1.1rem; text-align: center; }
.nav-link-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; transform: translateX(2px); }
.nav-link-item.is-active { background: rgba(227, 160, 8, 0.16); color: #ffd56a; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--line);
    background: rgba(12, 15, 20, 0.92); position: sticky; top: 0; z-index: 20;
}
.menu-button {
    width: 42px; height: 42px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.topbar-title { font-weight: 650; }
.user-chip { margin-left: auto; }
.user-chip a {
    display: inline-flex; align-items: center; gap: 0.4rem;
    background: rgba(225, 91, 85, 0.16); color: #ffc1bd;
    border-radius: 999px; padding: 0.35rem 0.75rem; font-size: 0.85rem;
}
.page-body { padding: 1.35rem 1.25rem 2.5rem; background: transparent; }
.pedido-acoes { display: flex; align-items: center; gap: 0.6rem; }
.pedido-popup { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.62); z-index: 40; display: grid; place-items: center; padding: 1rem; }
.pedido-popup[hidden] { display: none; }
.pedido-caixa { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1.3rem; text-align: center; box-shadow: var(--shadow); }
.pedido-caixa h2 { margin: 0 0 0.4rem; }
#pedido-quem { white-space: pre-line; }
.confirma { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.62); z-index: 50; display: grid; place-items: center; padding: 1rem; }
.confirma[hidden] { display: none; }
.confirma-caixa { width: min(460px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1.3rem 1.3rem 1.1rem; text-align: left; box-shadow: var(--shadow); }
.confirma-caixa h2 { margin: 0 0 0.55rem; font-size: 1.25rem; }
.confirma-caixa p { margin: 0; color: var(--text); }
.confirma-acoes { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.1rem; }
#confirma-voltar { background: transparent; color: var(--text); border-color: var(--line); }
table small { color: var(--muted); }
.pedido-caixa img { width: 220px; height: 220px; object-fit: contain; background: #fff; border-radius: 12px; margin: 0.8rem auto; }
.pedido-caixa .zap { color: var(--accent); font-size: 1.35rem; font-weight: 800; margin: 0.2rem 0 1rem; }
.codigo-dl { margin: 0; font-size: 2.6rem; letter-spacing: 0.14em; font-weight: 800; color: var(--accent); }
.codigo-dl + .nota { margin-top: 0.35rem; }
.page-body > * { animation: subir 0.38s ease both; }
.page-body > *:nth-child(2) { animation-delay: 0.05s; }
.page-body > *:nth-child(3) { animation-delay: 0.1s; }
.page-body > *:nth-child(4) { animation-delay: 0.14s; }
@keyframes subir { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.metric-grid, .shortcut-grid { display: grid; gap: 0.85rem; }
.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 1rem; }
.metric {
    display: flex; align-items: center; gap: 0.85rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1rem; min-width: 0; box-shadow: var(--shadow);
    transition: transform 0.16s ease, border-color 0.16s ease;
}
.metric:hover { transform: translateY(-3px); border-color: rgba(227, 160, 8, 0.45); }
.metric-icon {
    width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
    background: rgba(227, 160, 8, 0.14); color: #f0c14b; flex: 0 0 auto; font-size: 1.05rem;
}
.metric strong { display: block; font-size: 1.35rem; line-height: 1.1; }
.shortcut-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 1rem; }
.shortcut-grid a {
    display: flex; align-items: center; gap: 0.55rem; min-height: 52px;
    padding: 0.7rem 0.85rem; border-radius: 12px; background: var(--card-2);
    border: 1px solid var(--line); transition: border-color 0.16s ease, transform 0.16s ease;
}
.shortcut-grid a:hover { border-color: rgba(227, 160, 8, 0.45); transform: translateY(-2px); }
.shortcut-grid .fa { color: var(--accent); width: 1.1rem; text-align: center; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 0.2rem; font-size: 1.5rem; }
.page-head h1 .fa { color: var(--accent); margin-right: 0.4rem; }
.page-head p { margin: 0; color: var(--muted); max-width: 42rem; }
.panel-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.15rem; margin-bottom: 1rem; min-width: 0;
}
.panel-card h2 { margin: 0 0 0.9rem; font-size: 1.05rem; }
.panel-card h2 .fa { color: var(--accent); margin-right: 0.4rem; }
.ficha, .filtros, .rolagem, .tv {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel-card > .ficha, .panel-card > .filtros, .panel-card .rolagem {
    background: transparent; border: 0; box-shadow: none; border-radius: 0; padding: 0; margin: 0;
}
.ficha { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.85rem; padding: 1.1rem; margin-bottom: 1rem; align-items: end; }
.ficha .nota, .ficha .larga { grid-column: 1 / -1; margin: 0; }
.ficha.ficha-coluna { grid-template-columns: 1fr; }
label small { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.contato-app { background: #121820; border-radius: 16px; padding: 1.1rem; display: grid; gap: 0.75rem; }
.contato-app strong { font-size: 1.15rem; }
.contato-app p { margin: 0; }
.contato-app .canal { color: var(--accent); font-weight: 700; }
.contato-app .acao { display: block; text-align: center; background: #ffeb3b; color: #291b32; border-radius: 10px; padding: 0.75rem 1rem; font-weight: 700; }
.contato-app .nota { margin: 0; }
.ficha button[type="submit"] { justify-self: start; }
.vazio { margin: 0.2rem 0 0.4rem; color: var(--muted); }
.lista-status { list-style: none; margin: 0; padding: 0; }
.lista-status li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.lista-status li:last-child { border-bottom: 0; }
.lista-status small { color: var(--muted); }
.aviso-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.35rem 1rem; align-items: center; padding: 0.9rem 0; border-bottom: 1px solid var(--line); }
.aviso-item:last-child { border-bottom: 0; padding-bottom: 0; }
.aviso-item p { margin: 0; }
.aviso-item small { color: var(--muted); grid-column: 2; }
.duas { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.8fr); gap: 1rem; align-items: start; }
.duas .panel-card { margin-bottom: 0; }
form.ajustes { display: grid; grid-template-columns: 1fr; gap: 0.65rem; align-items: stretch; }
form.ajustes button { justify-self: start; }
form.aparelho { display: grid; gap: 0.55rem; margin-top: 0.35rem; }
form.aparelho input { width: 100%; max-width: none; min-width: 0; }
form.aparelho .nota, form.aparelho .codigo-tv { margin: 0; }
form.aparelho button { justify-self: start; }
.cliente-rodape form.linha { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; flex: 1 1 16rem; gap: 0.55rem; }
.cliente-rodape form.linha label { min-width: 0; }
.cliente-rodape form.linha select, .cliente-rodape form.linha input { width: 100%; max-width: none; min-width: 0; }
.aviso-item { align-items: start; }
.aviso-item form { justify-self: end; }
.lista-status li { align-items: flex-start; }
.lista-status small, .lista-status li div { overflow-wrap: anywhere; }
.cliente-barra { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.cliente-barra .filtros { margin: 0; padding: 0; background: transparent; border: 0; box-shadow: none; flex: 1; }
.cliente-barra-fim { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); }
.cliente { border: 1px solid var(--line); border-radius: 14px; padding: 0.95rem 1rem 0.8rem; margin-bottom: 0.75rem; background: rgba(255, 255, 255, 0.025); }
.cliente-topo { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem 1rem; }
.cliente-topo strong { display: block; font-size: 1.05rem; }
.cliente-topo span { color: var(--muted); }
.cliente-meta { font-size: 0.85rem; }
.cliente-grade { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 1rem; margin-top: 0.85rem; }
.cliente-grade h3 { margin: 0 0 0.45rem; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: #c5cedb; }
.cliente-grade .nota { margin: 0 0 0.45rem; }
.cliente-rodape { display: flex; justify-content: space-between; align-items: end; gap: 0.8rem; flex-wrap: wrap; margin-top: 0.85rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.cliente-rodape form.linha label { min-width: 14rem; font-size: 0.78rem; color: var(--muted); font-weight: 650; }
.ficha-cliente .grupo, .ficha-coluna .grupo { margin: 0.2rem 0 0; font-weight: 700; color: #c5cedb; }
.servidor { border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem 0.85rem; margin-bottom: 0.85rem; background: rgba(255, 255, 255, 0.03); }
.servidor-topo { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.servidor-topo strong { display: block; font-size: 1.08rem; }
.servidor-topo span { color: var(--muted); font-size: 0.85rem; }
.servidor-dados { display: grid; gap: 0.7rem; margin-top: 0.95rem; }
.servidor-par { display: grid; grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr); gap: 0.7rem; }
.servidor-dados button { justify-self: start; }
.servidor-manutencao { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.7rem; align-items: end; margin-top: 0.95rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
.servidor-manutencao input { width: 100%; max-width: none; min-width: 0; }
.servidor-manutencao .cheque { align-self: center; margin-bottom: 0.35rem; white-space: nowrap; }
.servidor-manutencao button { justify-self: start; }
.servidor-rodape { display: flex; justify-content: flex-end; margin-top: 0.75rem; }
.selo.faixa { background: rgba(76, 141, 255, 0.18); color: #9dbbff; }
.selo.popup { background: rgba(227, 160, 8, 0.18); color: #f3c15a; }
.selo.urgente { background: rgba(225, 91, 85, 0.18); color: #ffb4b0; }
.selo.manutencao { background: rgba(227, 160, 8, 0.18); color: #f3c15a; }
.selo.livre { background: rgba(60, 186, 139, 0.18); color: #8ee0c0; }
.filtros { display: flex; gap: 0.8rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; padding: 1rem; }
.filtros label { min-width: 12rem; flex: 1; }
.page-body > form:not(.ficha):not(.filtros) { margin: 0 0 1rem; }
.nota { margin: 0.2rem 0 1rem; }
.rolagem { overflow-x: auto; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 0.8rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: #c5cedb; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }
tbody tr:nth-child(odd) td { background: rgba(255, 255, 255, 0.025); }
tbody tr:hover td { background: rgba(227, 160, 8, 0.06); }
tr:last-child td { border-bottom: 0; }
td form + form { margin-top: 0.45rem; }
form.linha { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
form.linha input, form.linha select { width: auto; min-width: 8rem; max-width: 15rem; flex: 1 1 8rem; min-height: 38px; padding: 0.45rem 0.65rem; }
form.linha input[type="checkbox"] { width: 1.05rem; min-width: 0; max-width: none; height: 1.05rem; min-height: 0; flex: 0 0 auto; padding: 0; }
form.linha button { padding: 0.45rem 0.75rem; }
form.aparelho { margin-top: 0.45rem; }
input.codigo, .codigo-tv { font-weight: 800; letter-spacing: 0.14em; color: var(--accent); }
.codigo-tv { display: inline-block; margin-right: 0.35rem; }
label.cheque { display: flex; align-items: center; gap: 0.5rem; }
label.cheque input { width: auto; }
.selo { display: inline-block; border-radius: 999px; padding: 0.18rem 0.6rem; font-size: 0.8rem; font-weight: 700; }
.selo.ativo { background: rgba(60, 186, 139, 0.18); color: #8ee0c0; }
.selo.vencendo { background: rgba(227, 160, 8, 0.18); color: #f3c15a; }
.selo.vencido { background: rgba(225, 91, 85, 0.18); color: #ffb4b0; }
.selo.aguardando { background: rgba(76, 141, 255, 0.18); color: #9dbbff; }
.flash { margin: 0 0 1rem; padding: 0.75rem 0.9rem; border-radius: 12px; border: 1px solid transparent; }
.flash.ok { background: rgba(60, 186, 139, 0.14); border-color: rgba(60, 186, 139, 0.35); }
.flash.erro { background: rgba(225, 91, 85, 0.14); border-color: rgba(225, 91, 85, 0.4); }
.flash.aviso { background: rgba(227, 160, 8, 0.16); border-color: rgba(227, 160, 8, 0.4); color: #f3c15a; }
#ficha-aparencia { grid-template-columns: 1fr 1fr; }
#ficha-aparencia .icone-grade, #ficha-aparencia .botoes-aparencia, #ficha-aparencia label:has(textarea) { grid-column: 1 / -1; }
.aparencia-grade { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.85fr); gap: 1rem; align-items: start; }
.aparencia-grade .ficha { margin-bottom: 0; }
.tv { position: relative; min-height: 420px; overflow: hidden; display: grid; justify-items: center; align-content: center; gap: 0.7rem; padding: 1rem; }
.panel-card > .tv { background: #121820; box-shadow: none; }
.tv-fundo { position: absolute; inset: 0; background-size: cover; background-repeat: no-repeat; background-position: center; }
#tv-logo { position: relative; object-fit: contain; width: 34%; height: 64px; }
.home-grade { position: relative; display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 0.45rem; width: min(100%, 420px); }
.home-item { min-height: 72px; border-radius: 12px; background: rgba(22, 27, 36, 0.72); border: 1px solid rgba(255,255,255,0.16); display: grid; justify-items: center; align-content: center; gap: 0.2rem; padding: 0.4rem; }
.home-item.grande { grid-row: span 2; min-height: 150px; }
.home-item i, .home-item img { width: 28px; height: 28px; object-fit: contain; font-size: 22px; }
.home-item span, .home-marca { position: relative; text-align: center; }
.home-marca { margin: 0; font-size: 0.78rem; letter-spacing: 0.04em; }
.icone-grade { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.icone-item { display: grid; gap: 0.25rem; }
.botoes-aparencia { display: flex; flex-wrap: wrap; gap: 0.5rem; }
button.fantasma { background: transparent; color: var(--text); border-color: var(--line); }
.sidebar-backdrop { display: none; }

.login-body {
    min-height: 100vh; display: grid; place-items: center; padding: 1.2rem;
    background: #161b24 url("marca/fundo.jpg") center / cover no-repeat fixed;
}
.login-marca img { height: 72px; width: auto; max-width: 100%; }
.login-card {
    width: min(420px, 100%); background: rgba(18, 22, 30, 0.96);
    border: 1px solid var(--line); border-radius: 18px; padding: 1.6rem 1.4rem;
    box-shadow: var(--shadow); display: grid; gap: 0.8rem; animation: subir 0.4s ease both;
}
.login-marca { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.45rem; }
.login-marca strong { font-size: 0.82rem; text-align: center; }
.login-card h1 { margin: 0; text-align: center; font-size: 1.35rem; }
.login-card form { display: grid; gap: 0.8rem; }
.login-card button { width: 100%; }

@media (max-width: 1100px) {
    .metric-grid, .shortcut-grid { grid-template-columns: 1fr 1fr; }
    form.ajustes, .cliente-grade { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .sidebar { position: fixed; z-index: 30; transform: translateX(-105%); transition: transform 0.22s ease; height: 100vh; }
    body.menu-aberto .sidebar { transform: none; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 25; }
    body.menu-aberto .sidebar-backdrop { display: block; }
    .metric-grid, .shortcut-grid, .ficha, #ficha-aparencia, .filtros, .aparencia-grade, .duas, form.ajustes, .aviso-item, .servidor-par, .servidor-manutencao, .cliente-rodape form.linha { grid-template-columns: 1fr; }
    .aviso-item small { grid-column: 1; }
    .page-body { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
    .page-body > *, .metric, .nav-link-item, .shortcut-grid a, .sidebar { animation: none; transition: none; }
}
