* {
    box-sizing: border-box;
}

body{
    margin:0;
    font-family: Arial;
    background:#0f172a;
    color:white;
    padding:20px;
    overflow-x: hidden;
}

.card{
    background:#1e293b;
    padding:20px;
    margin-bottom:15px;
    border-radius:10px;
}

.status-online{ color:#22c55e; }
.status-offline{ color:#ef4444; }

button{
    padding:10px 15px;
    border:none;
    border-radius:6px;
    cursor:pointer;
    margin-right:10px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

button:active {
    transform: translateY(0);
}

.on{ background:#22c55e; color:white; }
.off{ background:#ef4444; color:white; }

.login-container,
.panel-container {
    width: min(640px, 100%);
    margin: 24px auto;
    background: #1e293b;
    border-radius: 12px;
    padding: 24px;
    box-sizing: border-box;
}

.panel-container {
    width: min(1200px, 100%);
}

h1, h2, h3 {
    margin-top: 0;
}

form {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #e2e8f0;
    box-sizing: border-box;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

.erro {
    background: rgba(239, 68, 68, 0.22);
    border: 1px solid #ef4444;
    border-radius: 8px;
    padding: 10px;
}

.sucesso {
    background: rgba(34, 197, 94, 0.22);
    border: 1px solid #22c55e;
    border-radius: 8px;
    padding: 10px;
}

.aviso {
    background: rgba(234, 179, 8, 0.22);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 10px;
}

.login-links {
    margin-top: 8px;
    display: grid;
    gap: 8px;
}

.login-links a,
.inline-links a,
.top-links a {
    color: #7dd3fc;
    text-decoration: none;
}

.login-links a:hover,
.inline-links a:hover,
.top-links a:hover {
    text-decoration: underline;
}

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #334155;
    color: #e2e8f0 !important;
    border: 1px solid #475569;
    border-radius: 6px;
    text-decoration: none !important;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
}

.link-btn:hover {
    background: #475569;
    border-color: #64748b;
    color: #f1f5f9 !important;
}

.top-links {
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th,
td {
    border-bottom: 1px solid #334155;
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

th {
    color: #cbd5e1;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(180deg, #2563eb, #1d4ed8);
    color: #eff6ff;
    border-color: #60a5fa;
}

.btn-primary:hover {
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.28);
}

.btn-secondary {
    background: linear-gradient(180deg, #334155, #1f2937);
    color: #f8fafc;
    border-color: #475569;
}

.btn-secondary:hover {
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.3);
}

.btn-warning {
    background: #f59e0b;
    color: #111827;
}

/* Badges de status Online/Offline */
.device-badge {
    display: inline-block;
    font-size: 0.60rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 10px;
    border-radius: 999px;
    vertical-align: middle;
    margin-left: 6px;
}
.device-badge-online  { background: rgba(34,197,94,0.15);  border: 1px solid #22c55e; color: #22c55e; }
.device-badge-offline { background: rgba(249,115,22,0.15); border: 1px solid #f97316; color: #f97316; }

.btn-danger {
    background: linear-gradient(180deg, #ef4444, #dc2626);
    color: white;
    border-color: #f87171;
}

.btn-danger:hover {
    box-shadow: 0 8px 16px rgba(239, 68, 68, 0.28);
}

@media (max-width: 720px) {
    body {
        padding: 12px;
    }

    .card,
    .login-container,
    .panel-container {
        padding: 16px;
        border-radius: 10px;
    }

    .login-container,
    .panel-container {
        margin: 12px auto;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .top-links {
        flex-direction: column;
        align-items: stretch;
    }

    .top-links .link-btn,
    .top-links a,
    .actions .link-btn {
        justify-content: center;
        text-align: center;
    }

    table {
        min-width: 640px;
    }

    th,
    td {
        padding: 8px;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    button:not(.menu-btn) {
        width: 100%;
        margin-right: 0;
    }
}