:root {
    --bg: #0b1220;
    --panel: #111a2e;
    --panel-2: #16233b;
    --card: #ffffff;
    --muted: #64748b;
    --text: #111827;
    --white: #ffffff;
    --line: #e5e7eb;
    --primary: #2563eb;
    --primary-2: #1d4ed8;
    --secondary: #0f172a;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --purple: #7c3aed;
    --radius: 20px;
    --shadow: 0 22px 60px rgba(15, 23, 42, .18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #eef3fb;
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.login-shell,
.install-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 12% 10%, rgba(37, 99, 235, .32), transparent 32%),
        radial-gradient(circle at 88% 18%, rgba(124, 58, 237, .26), transparent 34%),
        linear-gradient(135deg, #0b1220 0%, #111827 50%, #172554 100%);
}

.login-card,
.install-card {
    width: min(100%, 460px);
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 28px;
    padding: 34px;
    box-shadow: var(--shadow);
}

.brand-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.login-card h1,
.install-card h1 {
    margin: 18px 0 8px;
    font-size: clamp(28px, 5vw, 42px);
    line-height: 1;
}

.login-card p,
.install-card p {
    color: var(--muted);
    line-height: 1.55;
}

.login-form,
.form-grid.single {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

label {
    display: grid;
    gap: 8px;
    color: #334155;
    font-weight: 700;
    font-size: 14px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: var(--text);
    border-radius: 14px;
    padding: 13px 14px;
    outline: none;
    transition: border .2s, box-shadow .2s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .18s, box-shadow .18s, background .18s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn.primary {
    color: var(--white);
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 16px 30px rgba(37, 99, 235, .25);
}

.btn.secondary {
    color: var(--white);
    background: var(--secondary);
}

.btn.ghost {
    color: #dbeafe;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .12);
}

.btn.full {
    width: 100%;
}

.btn.small {
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 12px;
}

.form-message {
    min-height: 20px;
    color: var(--danger);
    font-weight: 700;
}

.alert {
    padding: 14px 16px;
    border-radius: 16px;
    margin: 18px 0;
    font-weight: 700;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

.alert.danger {
    background: #fee2e2;
    color: #991b1b;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    background: linear-gradient(180deg, #0b1220, #111827);
    color: var(--white);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .1);
}

.sidebar-brand strong {
    display: block;
    font-size: 18px;
}

.sidebar-brand small {
    display: block;
    color: #94a3b8;
    margin-top: 3px;
    line-height: 1.35;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-nav a {
    padding: 13px 14px;
    border-radius: 14px;
    color: #cbd5e1;
    font-weight: 800;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
    background: rgba(37, 99, 235, .2);
    color: #fff;
}

.sidebar .btn {
    margin-top: auto;
}

.main-panel {
    min-width: 0;
    padding: 28px;
}

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

.topbar h1,
.section-card h2 {
    margin: 0;
    letter-spacing: -.03em;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-weight: 900;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .1em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.section-card {
    display: none;
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(203, 213, 225, .8);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .08);
    margin-bottom: 22px;
}

.section-card.active-section {
    display: block;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 14px;
}

.stat-card {
    border-radius: 18px;
    padding: 18px;
    background: linear-gradient(180deg, #fff, #f8fafc);
    border: 1px solid #e2e8f0;
}

.stat-card span,
.stat-card small {
    display: block;
    color: var(--muted);
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin: 8px 0 4px;
    font-size: clamp(24px, 4vw, 34px);
    letter-spacing: -.04em;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.form-grid .wide {
    grid-column: span 2;
}

.subheading {
    margin: 28px 0 12px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 820px;
}

th,
td {
    padding: 14px;
    border-bottom: 1px solid #edf2f7;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

td small {
    color: var(--muted);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-weight: 900;
    font-size: 11px;
    white-space: nowrap;
}

.status-DISPONIVEL .status-badge,
.invoice-PAID {
    background: #dcfce7;
    color: #166534;
}

.status-LOCADO .status-badge,
.contract-ACTIVE,
.invoice-OPEN {
    background: #ffedd5;
    color: #9a3412;
}

.status-EM_MANUTENCAO .status-badge,
.contract-CLOSED {
    background: #fee2e2;
    color: #991b1b;
}

.status-EM_TRANSITO_ENTREGA .status-badge,
.status-EM_TRANSITO_RETIRADA .status-badge,
.contract-DELIVERY,
.contract-PICKUP {
    background: #dbeafe;
    color: #1e40af;
}

.equipment-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 16px;
}

.equipment-card {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    background: #fff;
}

.equipment-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.equipment-head strong,
.equipment-head small {
    display: block;
}

.equipment-head small,
.equipment-card p,
.maintenance-meter small {
    color: var(--muted);
}

.equipment-card p {
    margin: 0;
    line-height: 1.5;
}

.maintenance-meter {
    display: grid;
    gap: 8px;
}

.maintenance-meter > div {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.maintenance-meter span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--warning));
}

.equipment-values {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.equipment-values span {
    padding: 8px 10px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    font-weight: 800;
    font-size: 12px;
}

.month-picker {
    max-width: 190px;
}

.hint {
    margin: -8px 0 16px;
    color: var(--muted);
    font-weight: 700;
}

.gantt-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    max-height: 68vh;
}

.gantt-header,
.gantt-row {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-width: max-content;
}

.gantt-header {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}

.gantt-label {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #fff;
    padding: 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.header-label {
    z-index: 5;
    background: #f8fafc;
    font-weight: 900;
    color: #475569;
}

.gantt-label strong,
.gantt-label small {
    display: block;
}

.gantt-label small {
    color: var(--muted);
    margin-top: 4px;
}

.gantt-days {
    display: flex;
    background: #f8fafc;
}

.gantt-day {
    flex: 0 0 auto;
    padding: 14px 0;
    text-align: center;
    border-right: 1px solid #e2e8f0;
    color: #475569;
    font-weight: 900;
    font-size: 12px;
}

.gantt-track {
    position: relative;
    display: grid;
    min-height: 70px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.gantt-track > span {
    border-right: 1px solid #f1f5f9;
}

.gantt-bar {
    position: absolute;
    top: 17px;
    height: 36px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 4px 0 13px;
    color: #fff;
    font-weight: 900;
    font-size: 12px;
    cursor: default;
    box-shadow: 0 12px 26px rgba(15, 23, 42, .16);
    overflow: hidden;
}

.gantt-bar span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gantt-bar.contract-DELIVERY {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.gantt-bar.contract-ACTIVE {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.gantt-bar.contract-PICKUP {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
}

.resize-handle {
    flex: 0 0 22px;
    width: 22px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .35);
    cursor: ew-resize;
    touch-action: none;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.photo-card {
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.photo-card img {
    width: 100%;
    aspect-ratio: 1 / .75;
    display: block;
    object-fit: cover;
    background: #e2e8f0;
}

.photo-card span {
    display: block;
    padding: 10px;
    font-weight: 900;
    font-size: 12px;
    color: #334155;
}

.empty-message {
    color: var(--muted);
    font-weight: 700;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(420px, calc(100vw - 36px));
    padding: 14px 16px;
    border-radius: 16px;
    color: #fff;
    background: #111827;
    box-shadow: var(--shadow);
    font-weight: 800;
    z-index: 50;
}

.toast.success {
    background: #166534;
}

.toast.danger {
    background: #991b1b;
}

@media (max-width: 1180px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .equipment-grid,
    .photo-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 820px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 16px;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 8px;
    }

    .sidebar-nav a {
        white-space: nowrap;
    }

    .sidebar .btn {
        margin-top: 0;
    }

    .main-panel {
        padding: 16px;
    }

    .topbar,
    .section-title-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions,
    .topbar-actions .btn {
        width: 100%;
    }

    .stats-grid,
    .equipment-grid,
    .photo-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .wide {
        grid-column: span 1;
    }

    .gantt-header,
    .gantt-row {
        grid-template-columns: 190px 1fr;
    }

    .gantt-label {
        max-width: 190px;
    }
}

@media (max-width: 520px) {
    .login-card,
    .install-card,
    .section-card {
        border-radius: 20px;
        padding: 20px;
    }

    .topbar h1 {
        font-size: 28px;
    }

    .sidebar-brand {
        align-items: flex-start;
    }
}
