* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    padding: 2rem;
    font-size: 16px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

header {
    background: #2d6a4f;
    color: white;
    padding: 1.4rem 2rem;
    border-radius: 10px 10px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

#tunnel-badge {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border: 1px solid rgba(255,255,255,0.4);
}

.card {
    background: white;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 2rem;
}

/* Formulário de adição */
.add-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.8rem;
    flex-wrap: wrap;
    align-items: center;
}

.add-form input {
    flex: 1;
    min-width: 160px;
    padding: 0.75rem 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.add-form select {
    flex: 0 0 auto;
    padding: 0.75rem 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
}

.add-form input:focus,
.add-form select:focus {
    outline: none;
    border-color: #2d6a4f;
}

/* qual tunel publica o equipamento, na tabela */
.tag-tunel { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 12px;
             font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.tag-vps { background: #d8f3dc; color: #1b4332; }
.tag-cf  { background: #ffe8cc; color: #8a3b00; }

.add-form input::placeholder {
    color: #aaa;
}

#in-porta {
    max-width: 100px;
    flex: 0 0 100px;
}

/* Campo de subdomínio composto */
.subdomain-wrap {
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 6px;
    overflow: hidden;
    flex: 2;
    min-width: 300px;
    transition: border-color 0.2s;
}

.subdomain-wrap:focus-within {
    border-color: #2d6a4f;
}

.subdomain-prefix,
.subdomain-suffix {
    background: #f0f2f5;
    color: #555;
    padding: 0.75rem 0.7rem;
    font-size: 1rem;
    white-space: nowrap;
    user-select: none;
}

.subdomain-wrap input {
    flex: 1;
    min-width: 100px;
    border: none;
    border-radius: 0;
    padding: 0.75rem 0.5rem;
    font-size: 1rem;
}

/* Botões */
.btn {
    padding: 0.75rem 1.3rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.btn:hover { opacity: 0.85; }

.btn-green { background: #2d6a4f; color: white; }
.btn-blue  { background: #2563eb; color: white; }
.btn-red   { background: #dc2626; color: white; padding: 0.5rem 0.9rem; font-size: 0.95rem; }

/* Tabela */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}

thead tr {
    background: #e9f5ee;
    color: #1b4332;
}

th, td {
    padding: 0.9rem 1.1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

th { font-weight: 600; white-space: nowrap; }

tbody tr:hover { background: #f9fafb; }

tr.row-default { background: #e9f5ee; }
tr.row-default:hover { background: #d8eddf; }

.tag-raspberry {
    background: #2d6a4f;
    color: white;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 0.4rem;
}

td a {
    color: #2563eb;
    text-decoration: none;
}

td a:hover { text-decoration: underline; }

td.actions { white-space: nowrap; }

.empty-msg {
    text-align: center;
    color: #999;
    padding: 2rem;
    font-style: italic;
    font-size: 1rem;
}

/* Toast */
#toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #1b4332;
    color: white;
    padding: 0.9rem 1.4rem;
    border-radius: 8px;
    font-size: 1rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

#toast.show {
    opacity: 1;
    transform: translateY(0);
}

.save-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.2rem;
}

/* Barra de IPs */
.ip-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    background: white;
    padding: 0.7rem 1.5rem;
    border-top: 1px solid #d1fae5;
    border-left: 4px solid #2d6a4f;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    margin-bottom: 0.2rem;
}

.ip-label {
    font-size: 0.85rem;
    color: #6b7280;
    margin-right: 0.3rem;
    white-space: nowrap;
}

.ip-chip {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.88rem;
    font-family: 'Courier New', monospace;
}

.ip-chip-vpn {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1d4ed8;
}

/* ---- tela de login ---- */

.login-caixa {
    max-width: 420px;
    margin: 8vh auto 0;
}

.login-caixa header {
    justify-content: center;
}

.login-texto {
    color: #555;
    font-size: 0.95rem;
    margin-bottom: 1.2rem;
    line-height: 1.5;
}

#form-login {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

#form-login input {
    padding: 0.75rem 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
}

#form-login input:focus {
    outline: none;
    border-color: #2d6a4f;
}

.login-erro {
    color: #dc2626;
    font-size: 0.95rem;
    margin-top: 0.9rem;
    min-height: 1.2rem;
}

/* ---- botao Sair no cabecalho ---- */

.header-dir {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ================= painel do tunel ================= */

.pill {
    padding: 0.3rem 0.9rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    border: 1px solid transparent;
}
.pill-on  { background: rgba(255,255,255,0.2); color: #fff; border-color: rgba(255,255,255,0.45); }
.pill-off { background: #7f1d1d; color: #fecaca; border-color: #b91c1c; }

.cartas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin: 1.2rem 0;
}

.carta {
    background: #fff;
    border: 1px solid #e2e5ea;
    border-radius: 10px;
    padding: 1rem 1.1rem;
}

.carta .rot {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
}

.carta .val       { font-size: 1.6rem; font-weight: 700; margin-top: 0.25rem; color: #2d6a4f; }
.carta .val-menor { font-size: 1.05rem; word-break: break-all; }
.carta .obs       { font-size: 0.78rem; color: #9099a5; margin-top: 0.35rem; }
.carta .obs a     { color: #2563eb; text-decoration: none; }
.carta .obs a:hover { text-decoration: underline; }

.card-topo {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.9rem;
}

.aviso-salvar {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    border-radius: 20px;
    padding: 0.2rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.9rem;
}

.vazio {
    text-align: center;
    color: #9099a5;
    padding: 2rem 1rem;
}

.alcance { font-size: 0.85rem; color: #6b7280; }
.alcance-ok   { color: #2d6a4f; font-weight: 600; }
.alcance-erro { color: #dc2626; font-weight: 600; }

.btn-mini {
    background: #eef1f5;
    border: 1px solid #d5dae1;
    border-radius: 5px;
    padding: 0.15rem 0.55rem;
    font-size: 0.78rem;
    cursor: pointer;
    color: #4b5563;
}
.btn-mini:hover { border-color: #2563eb; color: #2563eb; }

.previa {
    margin-top: 0.9rem;
    color: #4b5563;
    font-size: 0.95rem;
}
.previa strong {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    color: #2d6a4f;
}

.nota {
    margin-top: 1rem;
    padding: 0.9rem 1.1rem;
    background: #f8fafc;
    border-left: 3px solid #2563eb;
    border-radius: 6px;
    color: #4b5563;
    font-size: 0.88rem;
    line-height: 1.55;
}
.nota code {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    background: #e8edf3;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
}
