:root {
    color-scheme: dark;
    font-family: system-ui, sans-serif;
    background: #0b1120;
    color: #e5e7eb;
    --panel: #151f30;
    --border: #29364b;
    --accent: #2563eb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px clamp(18px,5vw,60px);
    border-bottom: 1px solid var(--border);
    background: #101827;
}
h1 { font-size: 24px; margin: 4px 0; }
h2 { font-size: 21px; margin-top: 0; }
h3 { margin: 0 0 12px; }
.eyebrow {
    font-size: 10px;
    letter-spacing: 2px;
    color: #93c5fd;
}
main {
    width: min(1200px,100%);
    margin: auto;
    padding: 24px;
    flex: 1;
}
.auth {
    max-width: 440px;
    margin: 5vh auto;
}
article {
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 16px;
}
label {
    display: block;
    font-size: 14px;
    margin-bottom: 16px;
}
input, select {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 7px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0b1120;
    color: inherit;
    font: inherit;
}
input[type=checkbox] {
    display: inline-block;
    width: auto;
    margin-right: 10px;
}
button {
    border: 0;
    border-radius: 8px;
    padding: 12px 18px;
    background: var(--accent);
    color: white;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
button:disabled {
    opacity: .5;
    cursor: wait;
}
.secondary {
    background: #243248;
}
.danger { background: #991b1b; }
form > button { width: 100%; }
.auth .secondary {
    width: 100%;
    margin-top: 12px;
}
nav, .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
nav button { background: #243248; }
nav button.selected { background: var(--accent); }
.welcome { margin-bottom: 24px; }
.tag {
    display: inline-block;
    border-radius: 6px;
    background: #243248;
    padding: 5px 10px;
    font-size: 12px;
}
.muted, p { color: #94a3b8; }
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(250px,1fr));
    gap: 16px;
}
#notice {
    padding: 14px;
    margin-bottom: 16px;
    background: #1e3a5f;
    border-radius: 8px;
    overflow-wrap: anywhere;
}
#notice.error { background: #7f1d1d; }
.table-wrap { overflow-x: auto; }
table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
}
th,td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
footer {
    padding: 20px;
    text-align: center;
    color: #64748b;
    font-size: 12px;
    border-top: 1px solid var(--border);
}
footer strong { color: #94a3b8; }
@media(max-width:600px) {
    main { padding: 16px; }
    article { padding: 18px; }
    nav button { flex: 1; padding: 10px; }
}

.confirm-dialog {
    width: min(440px,calc(100% - 32px));
    padding: 24px;
    color: #e5e7eb;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.confirm-dialog::backdrop {
    background: rgba(0,0,0,.75);
}
.confirm-dialog .actions {
    justify-content: flex-end;
    margin: 24px 0 0;
}
article > .actions {
    margin-top: 16px;
}
hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

#notice.success {
    background: #14532d;
    color: #dcfce7;
}
.lockout-warning {
    color: #fbbf24;
    font-weight: 600;
}

#content > div > button {
    margin-bottom: 20px;
}
.device-info:not(:empty) {
    padding: 14px;
    margin: 12px 0;
    background: #0b1120;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.device-info p {
    margin: 6px 0;
    overflow-wrap: anywhere;
}
form > button + button {
    margin-top: 10px;
}

/* Notifications v0.9.2 */
#notice:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

#notice > span {
    flex: 1;
    min-width: 0;
}

#notice.info {
    background: #1e3a5f;
    color: #dbeafe;
}

#notice.error {
    background: #7f1d1d;
    color: #fee2e2;
}

#notice .notice-close {
    flex-shrink: 0;
    background: transparent;
    color: inherit;
    padding: 2px 8px;
    font-size: 24px;
    line-height: 1;
    opacity: .85;
}

#notice .notice-close:hover {
    opacity: 1;
}

/* GPS foreground status */
.gps-status {
    color: #93c5fd;
    font-size: .85rem;
}

.gps-status.ready {
    color: #86efac;
}

button:disabled {
    cursor: not-allowed;
    opacity: .5;
}


/* Layout v1.1.0 */

html {
    scrollbar-gutter: stable;
}

@supports not (scrollbar-gutter: stable) {
    html { overflow-y: scroll; }
}

body {
    width: 100%;
    min-width: 0;
}

main {
    margin: 0 auto;
    min-width: 0;
}

#dashboard, #content, #content > div {
    width: 100%;
    min-width: 0;
}

#navigation {
    display: grid;
    grid-template-columns:
        repeat(auto-fit,minmax(130px,1fr));
    gap: 12px;
}

#navigation button {
    min-width: 0;
    min-height: 48px;
    padding: 12px;
    white-space: nowrap;
}

.actions {
    gap: 12px;
}

form > button {
    margin: 0 0 12px;
}

form > button + button {
    margin-top: 0;
}

form > button:last-child {
    margin-bottom: 0;
}

.success-button {
    background: #15803d;
}

.state-active {
    background: #14532d;
    color: #86efac;
}

.state-inactive {
    background: #7f1d1d;
    color: #fecaca;
}

.gate-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.connection-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #9ca3af;
}

.connection-dot.online {
    background: #22c55e;
}

.connection-dot.offline {
    background: #ef4444;
}

.settings-menu {
    display: grid;
    gap: 12px;
}

.settings-menu button {
    width: 100%;
    min-height: 64px;
    text-align: left;
}

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.editor-actions button {
    flex: 1;
    min-width: 120px;
}

#pending {
    display: inline-block;
    min-width: 28px;
    text-align: center;
}

textarea {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 7px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0b1120;
    color: inherit;
    font: inherit;
    resize: vertical;
}

@media(max-width:600px) {
    #navigation {
        grid-template-columns: repeat(2,minmax(0,1fr));
    }

    .cards {
        grid-template-columns: minmax(0,1fr);
    }

    .actions button {
        flex: 1 1 auto;
    }
}

/* Interface compacta v1.2.0 */

main {
    width: min(1440px,100%);
}

header {
    padding-top: 16px;
    padding-bottom: 16px;
}

.welcome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.welcome h2 {
    margin: 0;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.summary-item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
}

.summary-item span {
    display: block;
    font-size: 13px;
}

.summary-item strong {
    display: block;
    font-size: 26px;
    margin-top: 5px;
}

.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0;
}

.table-toolbar input {
    flex: 2 1 200px;
}

.table-toolbar select {
    flex: 1 1 135px;
}

.table-toolbar input,
.table-toolbar select {
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 10px 12px;
}

.compact-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
}

.compact-table {
    font-size: 14px;
}

.compact-table th {
    background: #101827;
    color: #94a3b8;
    font-size: 12px;
    white-space: nowrap;
}

.compact-table td,
.compact-table th {
    padding: 10px 14px;
    vertical-align: middle;
}

.compact-table tbody tr:last-child td {
    border-bottom: 0;
}

.compact-table tbody tr:hover {
    background: #1b2940;
}

.compact-table button {
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
}

.compact-table input[type=checkbox] {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.identity-cell {
    display: grid;
    gap: 4px;
    overflow-wrap: anywhere;
}

.identity-cell small {
    font-size: 12px;
}

.identity-cell .text-button {
    padding: 0;
    background: transparent;
    color: #93c5fd;
    text-align: left;
    white-space: normal;
    font-size: 14px;
}

.status-active {
    background: #14532d;
    color: #86efac;
}

.status-pending {
    background: #422006;
    color: #fde68a;
}

.status-blocked,
.status-inactive {
    background: #7f1d1d;
    color: #fecaca;
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin: 14px 0 24px;
    font-size: 12px;
}

.pagination {
    display: flex;
    gap: 8px;
}

.pagination button {
    padding: 8px 14px;
    font-size: 13px;
}

.profile-heading {
    margin-bottom: 20px;
}

.profile-heading h2 {
    margin: 16px 0 4px;
}

.profile-heading p {
    margin: 0 0 12px;
}

.profile-heading .tag {
    margin-right: 8px;
}

.profile-panel {
    padding: 18px;
}

.profile-panel form {
    max-width: 520px;
}

@media(max-width:600px) {
    .summary-grid {
        grid-template-columns: repeat(2,minmax(0,1fr));
        gap: 8px;
    }

    .summary-item {
        padding: 12px;
    }

    .summary-item strong {
        font-size: 22px;
    }

    .compact-table {
        min-width: 520px;
    }

    .compact-table td,
    .compact-table th {
        padding: 10px;
    }

    .table-toolbar {
        gap: 8px;
    }

    .table-toolbar input {
        flex-basis: 100%;
    }

    .table-toolbar select {
        flex-basis: 120px;
    }
}

/* Perfil e horarios v1.2.0 */

.profile-tabs {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 8px;
    margin-bottom: 20px;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.profile-tabs button {
    background: transparent;
    color: #94a3b8;
    padding: 12px 8px;
}

.profile-tabs button.selected {
    background: var(--accent);
    color: white;
}

.schedule-week {
    display: grid;
    gap: 8px;
}

.schedule-day {
    padding: 12px;
    background: #101827;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.schedule-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.schedule-heading button,
.schedule-interval button {
    font-size: 12px;
    padding: 8px 10px;
}

.schedule-interval {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.schedule-interval input {
    width: 90px;
    margin: 0;
    padding: 9px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.table-footer select {
    width: auto;
    margin: 0;
    padding: 8px;
}

@media(max-width:600px) {
    .profile-tabs {
        grid-template-columns: repeat(2,minmax(0,1fr));
    }

    .schedule-interval {
        flex-wrap: wrap;
        gap: 8px;
    }

    .schedule-interval input {
        width: 75px;
    }
}

/* Portoes compactos v1.2.0 */

.site-group {
    margin-bottom: 24px;
}

.site-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.site-heading h3 {
    margin: 0;
    font-size: 17px;
}

.site-heading span {
    font-size: 12px;
}

.gate-grid {
    grid-template-columns: repeat(auto-fill,minmax(230px,1fr));
    gap: 12px;
}

.operational-gate {
    padding: 16px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.operational-gate h3 {
    font-size: 15px;
    margin: 0;
}

.operational-gate p {
    margin: 0;
}

.operational-gate > button {
    width: 100%;
    margin-top: auto;
    min-height: 46px;
}

.operational-gate > .actions {
    margin: 0;
}

.operational-gate > .actions button {
    width: 100%;
    padding: 8px;
    font-size: 13px;
}

.compact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.compact-actions button {
    padding: 7px 10px;
    font-size: 12px;
}

@media(max-width:600px) {
    .gate-grid {
        grid-template-columns: minmax(0,1fr);
        gap: 10px;
    }

    .operational-gate {
        padding: 14px;
    }

    .site-heading h3 {
        font-size: 15px;
    }
}

/* Historico v1.2.0 */

.history-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(170px,1fr));
    gap: 12px;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.history-filters label {
    margin: 0;
    color: #94a3b8;
    font-size: 12px;
}

.history-filters input,
.history-filters select {
    min-width: 0;
    padding: 10px;
    font-size: 13px;
}

.history-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0;
}

.history-controls select {
    width: auto;
    margin: 0;
    padding: 10px;
    margin-left: auto;
}

.audit-success {
    background: #14532d;
    color: #86efac;
}

.audit-denied,
.audit-error {
    background: #7f1d1d;
    color: #fecaca;
}

.audit-pending {
    background: #422006;
    color: #fde68a;
}

.audit-details {
    min-width: 200px;
    max-width: 420px;
    overflow-wrap: anywhere;
}

@media(max-width:600px) {
    .history-filters {
        grid-template-columns: repeat(2,minmax(0,1fr));
        padding: 12px;
        gap: 8px;
    }

    .history-controls select {
        margin-left: 0;
    }
}

.compact-table .text-button {
    background: transparent;
    color: #93c5fd;
    padding: 0;
    text-align: left;
    white-space: normal;
}

.compact-table input[type=checkbox]:disabled {
    cursor: not-allowed;
}

.compact-table td {
    overflow-wrap: anywhere;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 3px;
}
