/* ==========================================================================
   Painel PLS — identidade visual do webmail, layout de administração.
   ========================================================================== */

:root {
    --pls-blue: #074679;
    --pls-blue-dark: #053962;
    --pls-blue-night: #021c31;
    --pls-cyan: #67BCD8;
    --pls-cyan-soft: #9ad4ea;
    --pls-mist: #f1fafd;
    --pls-ice: #ddf1f8;
    --bg: #f4f8fb;
    --surface: #ffffff;
    --text: #10263a;
    --muted: #64798c;
    --line: #e2ecf3;
    --danger: #d64545;
    --danger-soft: #fdecec;
    --success: #1c9e6e;
    --success-soft: #e8f7f1;
    --warn: #b7791f;
    --warn-soft: #fdf3e2;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(7, 70, 121, .08), 0 8px 24px rgba(7, 70, 121, .06);
    --shadow-lift: 0 4px 10px rgba(7, 70, 121, .12), 0 16px 40px rgba(7, 70, 121, .10);
    --topbar-h: 58px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--pls-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

.ico { width: 18px; height: 18px; flex: none; }
.ico-lg { width: 22px; height: 22px; }
.ico-sm { width: 15px; height: 15px; }

/* ---------- Barra do topo ------------------------------------------------ */

.topbar {
    height: var(--topbar-h);
    background: linear-gradient(100deg, var(--pls-blue-night), var(--pls-blue) 55%, var(--pls-blue-dark));
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 2px 12px rgba(2, 28, 49, .25);
}

.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 26px; width: auto; display: block; }
.brand-sep { width: 1px; height: 22px; background: rgba(255, 255, 255, .3); }
.brand-name { font-weight: 600; letter-spacing: .3px; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.user-chip { display: flex; align-items: center; gap: 8px; color: #eaf6fb; font-size: .88rem; }
.user-mail { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: .74rem; font-weight: 700; letter-spacing: .5px;
    flex: none;
}
.avatar-lg { width: 40px; height: 40px; font-size: .9rem; }

.nav-toggle {
    display: none;
    background: transparent; border: 0; color: #fff; cursor: pointer;
    padding: 6px; border-radius: 8px;
}
.nav-toggle:hover { background: rgba(255, 255, 255, .12); }

/* ---------- Esqueleto ---------------------------------------------------- */

.app { display: flex; align-items: stretch; }

.sidebar {
    width: 216px;
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px; border-radius: 10px;
    color: var(--text); font-size: .93rem; text-decoration: none;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.side-links a:hover { background: var(--pls-mist); transform: translateX(2px); }
.side-links a.active { background: var(--pls-blue); color: #fff; }

.side-sep { border: 0; border-top: 1px solid var(--line); margin: 10px 2px; }

.side-note {
    display: flex; align-items: center; gap: 8px;
    color: var(--muted); font-size: .8rem; margin: 0; padding: 0 11px;
    word-break: break-all;
}

.content {
    flex: 1;
    min-width: 0;
    padding: 22px 26px 40px;
    animation: pageIn .22s ease both;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.page-head {
    display: flex; align-items: flex-start; gap: 16px;
    flex-wrap: wrap; margin-bottom: 18px;
}
.page-head .grow { flex: 1; min-width: 220px; }
.page-head p.sub { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }

.crumb {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--muted); font-size: .85rem; margin-bottom: 6px;
}
.crumb a { color: var(--muted); }

/* ---------- Botões ------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 15px; border-radius: 10px; border: 1px solid transparent;
    background: var(--pls-blue); color: #fff;
    font-size: .92rem; font-weight: 500; cursor: pointer; text-decoration: none;
    transition: background .15s ease, transform .12s ease, box-shadow .15s ease, color .15s ease;
    white-space: nowrap;
}
.btn:hover { background: var(--pls-blue-dark); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: none; }

.btn-small { padding: 6px 11px; font-size: .84rem; border-radius: 9px; }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .45); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, .16); }
.btn-outline { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-outline:hover { background: var(--pls-mist); border-color: var(--pls-cyan); color: var(--pls-blue); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b93a3a; }
.btn-quiet {
    background: transparent; color: var(--muted); border-color: transparent;
    padding: 6px; border-radius: 8px;
}
.btn-quiet:hover { background: var(--pls-mist); color: var(--pls-blue); box-shadow: none; transform: none; }
.btn-quiet.danger:hover { background: var(--danger-soft); color: var(--danger); }

.btn[disabled] { opacity: .5; pointer-events: none; }

.actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }

/* ---------- Cartões ------------------------------------------------------ */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.card > :last-child { margin-bottom: 0; }

.card-head {
    display: flex; align-items: center; gap: 10px;
    margin: -4px 0 14px;
}
.card-head h2 { margin: 0; }
.card-head .grow { flex: 1; min-width: 0; }

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.domain-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    display: flex; flex-direction: column; gap: 10px;
    min-width: 0;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
    animation: cardIn .28s ease both;
}
.domain-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--pls-cyan); }

@keyframes cardIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.domain-card .dc-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.domain-card .dc-name {
    font-weight: 600; font-size: 1.02rem; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.domain-card .dc-icon {
    width: 38px; height: 38px; border-radius: 10px; flex: none;
    background: var(--pls-mist); color: var(--pls-blue);
    display: flex; align-items: center; justify-content: center;
}
.domain-card .dc-stats { display: flex; gap: 18px; color: var(--muted); font-size: .86rem; }
.domain-card .dc-stats b { color: var(--text); font-weight: 600; }
.domain-card .dc-foot { display: flex; gap: 8px; margin-top: 2px; }

/* ---------- Tabela ------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

table.list {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}
table.list th {
    text-align: left; font-weight: 600; color: var(--muted);
    font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
    padding: 0 10px 8px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tbody tr { transition: background .14s ease; }
table.list tbody tr:hover { background: var(--pls-mist); }
table.list tbody tr:last-child td { border-bottom: 0; }

.cell-box { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-box .who { min-width: 0; }
.cell-box .mail { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-box .name { color: var(--muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px;
    font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge-ok    { background: var(--success-soft); color: var(--success); }
.badge-off   { background: var(--danger-soft); color: var(--danger); }
.badge-admin { background: var(--pls-ice); color: var(--pls-blue); }
.badge-alias { background: var(--pls-mist); color: var(--muted); font-weight: 500; }

.usage { min-width: 130px; }
.usage .bar {
    height: 6px; border-radius: 999px; background: var(--pls-ice);
    overflow: hidden; margin-top: 5px;
}
.usage .bar > span {
    display: block; height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--pls-cyan), var(--pls-blue));
    transition: width .5s ease;
}
.usage .bar.hot > span { background: linear-gradient(90deg, #eaa64b, var(--danger)); }
.usage .txt { font-size: .82rem; color: var(--muted); white-space: nowrap; }

.empty {
    text-align: center; color: var(--muted);
    padding: 34px 16px;
}
.empty .ico { width: 34px; height: 34px; opacity: .5; margin-bottom: 8px; }

/* ---------- Formulários -------------------------------------------------- */

.form-stack {
    display: flex; flex-direction: column; flex-wrap: nowrap;
    align-items: stretch; gap: 14px;
    max-width: 560px;
}
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row > label { font-weight: 600; font-size: .88rem; }
.form-row .hint { color: var(--muted); font-size: .82rem; }

.form-cols { display: flex; gap: 12px; flex-wrap: wrap; }
.form-cols > .form-row { flex: 1; min-width: 190px; }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
    font: inherit;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: 0;
    border-color: var(--pls-cyan);
    box-shadow: 0 0 0 3px rgba(103, 188, 216, .25);
}

.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group > input { flex: 1; min-width: 0; }

.input-suffix {
    display: flex; align-items: stretch;
    border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
    background: var(--surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input-suffix:focus-within { border-color: var(--pls-cyan); box-shadow: 0 0 0 3px rgba(103, 188, 216, .25); }
.input-suffix > input { border: 0; border-radius: 0; }
.input-suffix > input:focus { box-shadow: none; }
.input-suffix > .sfx {
    display: flex; align-items: center; padding: 0 12px;
    background: var(--pls-mist); color: var(--muted);
    font-size: .9rem; white-space: nowrap; border-left: 1px solid var(--line);
}

.form-foot { display: flex; gap: 10px; align-items: center; padding-top: 4px; }

.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.check input { width: auto; }

/* Senha gerada, para copiar e mandar pro cliente */
.password-box {
    display: flex; align-items: center; gap: 10px;
    background: var(--pls-mist); border: 1px dashed var(--pls-cyan);
    border-radius: 10px; padding: 10px 12px;
}
.password-box code {
    font-size: 1rem; letter-spacing: .5px; color: var(--pls-blue-dark);
    font-weight: 600; word-break: break-all;
}

/* ---------- Avisos e toasts ---------------------------------------------- */

.alert {
    padding: 11px 14px; border-radius: 10px; margin-bottom: 16px;
    font-size: .92rem; border: 1px solid transparent;
}
.alert-success { background: var(--success-soft); color: #14724f; border-color: #bfe8d8; }
.alert-error   { background: var(--danger-soft); color: #a13232; border-color: #f4cccc; }
.alert-info    { background: var(--pls-mist); color: var(--pls-blue-dark); border-color: var(--pls-ice); }
.alert-warn    { background: var(--warn-soft); color: var(--warn); border-color: #f2ddb4; }

.toasts {
    position: fixed; right: 18px; bottom: 18px;
    display: flex; flex-direction: column; gap: 8px; z-index: 80;
}
.toast {
    background: var(--pls-blue-night); color: #fff;
    padding: 10px 14px; border-radius: 10px; font-size: .9rem;
    box-shadow: var(--shadow-lift);
    animation: toastIn .25s ease both;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Zona de DNS -------------------------------------------------- */

pre.zone {
    background: var(--pls-blue-night); color: #d8ecf7;
    padding: 14px 16px; border-radius: 10px;
    overflow-x: auto; font-size: .82rem; line-height: 1.6;
    margin: 0;
}

/* ---------- Login -------------------------------------------------------- */

.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(103, 188, 216, .28), transparent 60%),
        var(--bg);
}
.login-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lift);
    padding: 30px 28px;
    width: 100%; max-width: 390px;
    animation: cardIn .3s ease both;
}
.login-card .logo { display: block; height: 40px; margin: 0 auto 6px; }
.login-card .tag {
    text-align: center; color: var(--muted); font-size: .88rem; margin: 0 0 20px;
}
.login-card .form-stack { max-width: none; }

/* ---------- Responsivo --------------------------------------------------- */

@media (min-width: 901px) {
    html, body { height: 100%; overflow: hidden; }
    .app { height: calc(100vh - var(--topbar-h)); }
    .sidebar { overflow-y: auto; }
    .content { overflow-y: auto; }
    body.login-page { overflow: auto; height: auto; }
}

@media (max-width: 900px) {
    .nav-toggle { display: inline-flex; }
    .user-mail { display: none; }

    .sidebar {
        position: fixed;
        top: var(--topbar-h); bottom: 0; left: 0;
        width: 240px;
        transform: translateX(-100%);
        transition: transform .22s ease;
        z-index: 45;
        box-shadow: var(--shadow-lift);
    }
    body.nav-open .sidebar { transform: none; }

    .nav-backdrop {
        position: fixed; inset: var(--topbar-h) 0 0 0;
        background: rgba(2, 28, 49, .38);
        opacity: 0; pointer-events: none;
        transition: opacity .22s ease;
        z-index: 44;
    }
    body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

    .content { padding: 16px 14px 32px; }

    /* A tabela de caixas vira lista de cartões */
    table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
    table.list thead { display: none; }
    table.list tr {
        background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--radius); box-shadow: var(--shadow);
        margin-bottom: 10px; padding: 12px;
    }
    table.list td { border: 0; padding: 4px 0; }
    table.list td[data-label]::before {
        content: attr(data-label);
        display: block; font-size: .72rem; text-transform: uppercase;
        letter-spacing: .04em; color: var(--muted); margin-bottom: 2px;
    }
    .actions { justify-content: flex-start; padding-top: 6px; }
    input, select, textarea { font-size: 16px; } /* evita o zoom do iOS */
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
