* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #718096;
    --line: #e7ebf2;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --green: #16a34a;
    --orange: #ea580c;
    --red: #dc2626;
    --sidebar: #111827;
}

body {
    margin: 0;
    font-family: Inter, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

.app {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 250px;
    background: var(--sidebar);
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 38px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    background: var(--primary);
    border-radius: 12px;
    font-size: 20px;
    font-weight: 800;
}

.brand strong {
    display: block;
    font-size: 16px;
    letter-spacing: .5px;
}

.brand span {
    display: block;
    color: #9ca3af;
    font-size: 10px;
    margin-top: 3px;
}

nav a {
    display: block;
    padding: 12px 14px;
    color: #d1d5db;
    text-decoration: none;
    border-radius: 10px;
    font-size: 14px;
}

nav a.active {
    background: #1f2937;
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    color: #6b7280;
    font-size: 11px;
}

.main {
    flex: 1;
    padding: 30px;
    max-width: 1600px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 25px;
}

h1 {
    margin: 0 0 7px;
    font-size: 28px;
}

.topbar p {
    margin: 0;
    color: var(--muted);
}

.connection {
    font-size: 13px;
    color: var(--green);
    font-weight: 600;
}

.dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
    background: var(--green);
    margin-right: 5px;
}

.toolbar {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    align-items: end;
    gap: 12px;
    margin-bottom: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label, .field label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

input, select, textarea {
    border: 1px solid #d9dee8;
    border-radius: 9px;
    padding: 10px 12px;
    background: #fff;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
}

.btn {
    border: 0;
    border-radius: 9px;
    padding: 11px 17px;
    cursor: pointer;
    font-weight: 700;
}

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

.btn.primary:hover {
    background: var(--primary-dark);
}

.btn.secondary {
    background: #eef2f7;
    color: var(--text);
}

.last-update {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
}

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

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
}

.card span {
    color: var(--muted);
    font-size: 12px;
}

.card strong {
    display: block;
    margin-top: 8px;
    font-size: 26px;
}

.card.pending strong { color: var(--orange); }
.card.route strong { color: var(--primary); }
.card.delivered strong { color: var(--green); }
.card.problem strong { color: var(--red); }

.progress-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    margin-top: 14px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.progress-header span {
    color: var(--muted);
    font-size: 12px;
}

.progress-header strong {
    margin-left: 10px;
}

.progress {
    height: 9px;
    background: #edf1f6;
    border-radius: 20px;
    overflow: hidden;
}

.progress div {
    width: 0;
    height: 100%;
    background: var(--green);
    transition: width .3s ease;
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-top: 18px;
    overflow: hidden;
}

.panel-header {
    padding: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    border-bottom: 1px solid var(--line);
}

.panel-header h2 {
    margin: 0 0 5px;
    font-size: 17px;
}

.panel-header p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.search {
    width: 310px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .4px;
    background: #fafbfc;
}

.status {
    display: inline-flex;
    padding: 6px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
}

.status.pendente {
    background: #fff7ed;
    color: var(--orange);
}

.status.em-rota {
    background: #eff6ff;
    color: var(--primary);
}

.status.entregue {
    background: #f0fdf4;
    color: var(--green);
}

.status.problema {
    background: #fef2f2;
    color: var(--red);
}

.details {
    border: 0;
    background: transparent;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    display: flex;
    justify-content: flex-end;
    z-index: 10;
}

.modal.hidden {
    display: none;
}

.modal-box {
    width: min(460px, 100%);
    height: 100%;
    background: #fff;
    padding: 26px;
    box-shadow: -10px 0 35px rgba(0,0,0,.12);
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
}

.eyebrow {
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.modal-header h2 {
    margin: 5px 0;
}

.modal-header p {
    margin: 0;
    color: var(--muted);
}

.close {
    border: 0;
    background: #f1f5f9;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 20px;
}

.modal-grid > div {
    padding: 13px;
    background: #f8fafc;
    border-radius: 10px;
}

.modal-grid label {
    display: block;
    margin-bottom: 5px;
}

.modal-box > label {
    display: block;
    margin: 15px 0 7px;
}

.modal-box select,
.modal-box textarea {
    width: 100%;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

@media (max-width: 1000px) {
    .sidebar {
        width: 205px;
    }

    .cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 720px) {
    .sidebar {
        display: none;
    }

    .main {
        padding: 18px;
    }

    .topbar {
        flex-direction: column;
        gap: 12px;
    }

    .toolbar {
        flex-wrap: wrap;
    }

    .last-update {
        width: 100%;
        margin-left: 0;
    }

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

    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .search {
        width: 100%;
    }
}
