:root {
    /* Azul-marinho da marca MeuBess (estimado visualmente a partir do
       logo - ajustar se o valor exato do manual de marca for diferente). */
    --brand: #16253f;
    --brand-light: #24365a;
    --accent: #2f6fed;
    --bg: #eef1f7;
    --panel: #ffffff;
    --card: #f5f7fb;
    --border: #e2e7f0;
    --text: #1a2130;
    --text-dim: #6b7684;
    --accent-green: #1e8e5a;
    --accent-orange: #b5690a;
    --accent-red: #c62f2f;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 10px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
    flex: 0 0 auto;
    box-shadow: 0 2px 12px rgba(10, 16, 30, 0.18);
    z-index: 1;
}

.topbar .brand {
    font-weight: 800;
    font-size: 1.35rem;
    color: #ffffff;
    letter-spacing: 0.2px;
}

.topbar .brand::before {
    content: "";
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #4ade80;
    margin-right: 9px;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
}

.topbar h1 {
    font-size: 0.95rem;
    font-weight: 500;
    color: #aebbd6;
    margin: 0;
    padding-left: 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

.columns {
    display: grid;
    grid-template-columns: 3.3fr 1fr;
    grid-template-areas: "orders routes";
    gap: 14px;
    padding: 14px;
    flex: 1 1 auto;
    min-height: 0;
}

.column.orders { grid-area: orders; }
.column.routes { grid-area: routes; }

.column {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.column h2 {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    margin: 0 0 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--card);
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    color: var(--brand);
}

#orders-page-indicator {
    font-weight: 600;
    color: #ffffff;
    background: var(--accent);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 8px;
    letter-spacing: 0.3px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}

thead th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-dim);
    background: var(--card);
}

/* Pedidos Pendentes: painel de TV sem mouse, precisa caber sem rolagem */
.column.orders {
    overflow: hidden;
}

.orders-table {
    table-layout: fixed;
    font-size: 0.85rem;
    flex: 1 1 auto;
    border-radius: 8px;
    overflow: hidden;
}

.orders-table th, .orders-table td {
    padding: 2px 5px;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
}

.orders-table tbody tr:nth-child(even):not([class*="row-status"]) {
    background: rgba(0, 0, 0, 0.015);
}

.orders-table th:nth-child(1) { width: 8%; }
.orders-table th:nth-child(2) { width: 7%; }
.orders-table th:nth-child(3) { width: 14%; }
.orders-table th:nth-child(4) { width: 10%; }
.orders-table th:nth-child(5) { width: 6%; }
.orders-table th:nth-child(6) { width: 6%; }
.orders-table th:nth-child(7) { width: 6%; }
.orders-table th:nth-child(8) { width: 43%; }

.orders-table th {
    position: relative;
}

.orders-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.orders-table th.sortable:hover {
    color: var(--brand);
    background: #e9edf6;
}

.orders-table th.sort-asc::after {
    content: " \25B2";
    font-size: 0.6rem;
    color: var(--accent);
}

.orders-table th.sort-desc::after {
    content: " \25BC";
    font-size: 0.6rem;
    color: var(--accent);
}

.orders-table .col-resizer {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 1;
}

.orders-table .col-resizer:hover,
.orders-table .col-resizer.resizing {
    background: var(--accent);
}

.vehicle-list {
    list-style: none;
    padding: 0;
    margin: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    flex: 1 1 auto;
}

.vehicle-list li {
    background: var(--card);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
}

.vehicle-list li.stale {
    opacity: 0.6;
}

.vehicle-location {
    color: var(--text-dim);
    font-size: 0.75rem;
}

.summary-cards {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex: 0 0 auto;
}

.summary-cards .card {
    flex: 1;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
    color: #fff;
    border-radius: 8px;
    padding: 14px 8px;
    text-align: center;
    font-weight: 700;
    font-size: 1.05rem;
    box-shadow: 0 2px 6px rgba(22, 37, 63, 0.25);
}

/* Rotas raramente tem mais que umas poucas linhas - usar o espaço
   vertical sobrando (em vez de deixá-lo em branco) com fonte/padding
   maiores em vez de manter tudo pequeno igual à tabela de pedidos. */
.column.routes table {
    font-size: 1rem;
}

.column.routes th, .column.routes td {
    padding: 14px 10px;
}

.column.routes tbody tr:hover {
    background: var(--card);
}

.column.routes .editable {
    min-height: 1.2em;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.status-atrasado {
    color: var(--accent-red);
    font-weight: 600;
}

.status-atenção, .status-pendente, .status-planejado, .status-parado {
    color: var(--accent-orange);
    font-weight: 600;
}

.status-no-prazo, .status-entregue, .status-confirmado, .status-em-trânsito {
    color: var(--accent-green);
    font-weight: 600;
}

/* Pílula colorida para a coluna "Status" dos pedidos - uma cor suave por
   valor, para escanear a lista rapidamente sem ler cada célula. */
.status-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.78em;
    white-space: nowrap;
    /* Cor padrão para qualquer status novo que ainda não tenha uma cor
       dedicada abaixo (o relatório de origem já mudou o conjunto de
       status algumas vezes). */
    background: var(--card);
    color: var(--text-dim);
}

.order-status-pedido-confirmado,
.order-status-confirmado {
    background: #dce9fc;
    color: #1a4d99;
}

.order-status-em-produção {
    background: #fdf0d0;
    color: #8a5a00;
}

.order-status-aguardando-faturamento-do-cliente {
    background: #fde3d3;
    color: #a3480f;
}

.order-status-aguardando-envio {
    background: #ead7fb;
    color: #6b2fa0;
}

.order-status-em-cancelamento {
    background: #fbdada;
    color: #a32626;
}

.order-status-pagamento-parcial {
    background: #d3f3e8;
    color: #106b4f;
}

.order-status-entregue-e-finalizado {
    background: #dcf1de;
    color: #266b32;
}

/* Mesma paleta acima, aplicada na linha inteira (bem mais clara que a
   pílula, pra não brigar com a leitura do texto). */
.row-status-pedido-confirmado,
.row-status-confirmado {
    background: #f2f7fe;
}

.row-status-em-produção {
    background: #fefaee;
}

.row-status-aguardando-faturamento-do-cliente {
    background: #fef4ec;
}

.row-status-aguardando-envio {
    background: #f8f2fd;
}

.row-status-em-cancelamento {
    background: #fdf1f1;
}

.row-status-pagamento-parcial {
    background: #eefaf5;
}

.row-status-entregue-e-finalizado {
    background: #eff8f0;
}

.editable {
    cursor: text;
}

.editable:hover {
    outline: 1px dashed var(--accent);
    background: var(--card);
}

.editable.save-error {
    outline: 1px solid var(--accent-red);
}

#add-route-btn {
    margin-top: 10px;
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    align-self: flex-start;
    box-shadow: 0 2px 6px rgba(47, 111, 237, 0.3);
    transition: background 0.15s ease, transform 0.1s ease;
}

#add-route-btn:hover {
    background: #2559c7;
}

#add-route-btn:active {
    transform: scale(0.97);
}
