/* UX refresh - O Baratao Auto Pecas */
:root {
    --brand-green: #0b5f34;
    --brand-green-2: #08703b;
    --brand-yellow: #f5e600;
    --ink: #111827;
    --paper: #ffffff;
    --soft-paper: #f6f8fa;
    --soft-line: #d8e0e6;
    --focus-ring: rgba(11, 95, 52, 0.2);
    --toast-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
}

body {
    min-height: 100vh;
    background: #eef3f1;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
    overflow-x: hidden;
}

body.theme-dark {
    background: #101826;
    --surface: #131c2b;
    --surface-soft: #1b2637;
    --text: #e7edf4;
    --muted: #a8b3c2;
    --line: #2d3a4d;
    --ok-bg: #123a2b;
    --err-bg: #431c1d;
    --danger: #ffb4a9;
    --toast-shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
}

.login-wrap {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.3)),
        linear-gradient(135deg, #eef3f1 0%, #ffffff 52%, #eef4d0 100%);
}

body.theme-dark .login-wrap {
    background: linear-gradient(135deg, #0b1220 0%, #111827 52%, #182318 100%);
}

.login-panel {
    border: 1px solid rgba(11, 95, 52, 0.14);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
}

.login-mark {
    border: 1px solid rgba(11, 95, 52, 0.12);
}

.login-title {
    font-size: 25px;
    color: var(--ink);
}

body.theme-dark .login-title {
    color: #f8fafc;
}

.sidebar {
    background: linear-gradient(180deg, #06381f 0%, #0b1220 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
    min-height: 52px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    box-shadow: 0 14px 26px rgba(0, 0, 0, 0.18);
}

.nav {
    gap: 6px;
}

.nav a,
.logout {
    border-radius: 8px;
    color: #e5edf0;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav a.active {
    background: rgba(245, 230, 0, 0.15);
    color: #ffffff;
    box-shadow: inset 3px 0 0 var(--brand-yellow);
}

.nav a:hover,
.logout:hover {
    background: rgba(255, 255, 255, 0.09);
    transform: translateX(2px);
}

.app-header {
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 8px 26px rgba(15, 23, 42, 0.06);
}

body.theme-dark .app-header {
    background: rgba(17, 24, 39, 0.9);
}

.content {
    max-width: 1480px;
    margin: 0 auto;
    width: 100%;
    min-width: 0;
}

.panel {
    border-color: rgba(15, 23, 42, 0.08);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
    min-width: 0;
}

body.theme-dark .panel {
    border-color: rgba(148, 163, 184, 0.18);
}

.metric,
.finance-kpi,
.client-payment-summary-item {
    position: relative;
    overflow: hidden;
}

.metric::before,
.finance-kpi::before,
.client-payment-summary-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--brand-green);
}

.metric span,
.finance-kpi span,
.client-payment-summary-item span {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric strong,
.finance-kpi strong,
.client-payment-summary-item strong {
    color: var(--brand-green);
}

body.theme-dark .metric strong,
body.theme-dark .finance-kpi strong,
body.theme-dark .client-payment-summary-item strong {
    color: #86efac;
}

.toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 16px 0;
    padding: 14px;
    border: 1px solid var(--soft-line);
    border-radius: 8px;
    background: var(--soft-paper);
    cursor: pointer;
}

.toggle-row input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--brand-green);
}

.toggle-row strong,
.toggle-row small {
    display: block;
}

.toggle-row small {
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.4;
}

.info-list {
    display: grid;
    gap: 10px;
    margin: 16px 0 0;
    padding-left: 18px;
    color: var(--text);
}

.info-list li {
    line-height: 1.45;
}

body.theme-dark .toggle-row {
    border-color: var(--line);
    background: var(--surface-soft);
}

.processing-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}

.processing-status-panel {
    overflow-x: auto;
}

.processing-status-panel table {
    min-width: 860px;
}

.processing-status-panel form {
    margin: 0;
}

.processing-status-panel button {
    min-width: 78px;
}

.service-unit-name {
    font-weight: 800;
}

.info-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 21px;
    height: 21px;
    margin-left: 8px;
    border: 1px solid rgba(11, 95, 52, 0.28);
    border-radius: 999px;
    background: #e8f5ef;
    color: var(--brand-green);
    cursor: help;
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
    vertical-align: middle;
}

.info-badge::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    z-index: 40;
    width: min(430px, calc(100vw - 48px));
    padding: 12px 14px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 8px;
    background: #111827;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
    opacity: 0;
    pointer-events: none;
    text-align: left;
    transform: translate(-50%, 6px);
    transition: opacity 0.16s ease, transform 0.16s ease;
    white-space: normal;
}

.info-badge::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 4px);
    z-index: 41;
    width: 10px;
    height: 10px;
    background: #111827;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 6px) rotate(45deg);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.info-badge:hover::after,
.info-badge:focus::after,
.info-badge:hover::before,
.info-badge:focus::before {
    opacity: 1;
    transform: translate(-50%, 0) rotate(0deg);
}

.info-badge:hover::before,
.info-badge:focus::before {
    transform: translate(-50%, 0) rotate(45deg);
}

.info-badge:focus {
    outline: 0;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.processing-metrics {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
}

.processing-metrics .metric {
    min-height: 128px;
}

.processing-metrics .hint {
    overflow-wrap: anywhere;
}

.timer-signal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2f5;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.timer-signal span {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: currentColor;
}

.timer-signal-on {
    background: #e8f5ef;
    color: #0b5f34;
}

.timer-signal-on span {
    animation: timer-pulse 1.2s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(11, 95, 52, 0.35);
}

.timer-signal-off {
    background: #fff0ee;
    color: #b42318;
}

.timer-signal-static {
    background: #f1f5f9;
    color: #475569;
}

body.theme-dark .timer-signal-on {
    background: #123a2b;
    color: #86efac;
}

body.theme-dark .timer-signal-off {
    background: #431c1d;
    color: #fca5a5;
}

body.theme-dark .timer-signal-static {
    background: #263244;
    color: #cbd5e1;
}

@keyframes timer-pulse {
    70% {
        box-shadow: 0 0 0 8px rgba(11, 95, 52, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(11, 95, 52, 0);
    }
}

.dashboard-shell {
    display: grid;
    grid-template-columns: minmax(320px, 1.15fr) minmax(420px, 1.85fr);
    gap: 18px;
    align-items: stretch;
}

.dashboard-hero {
    display: flex;
    min-height: 230px;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(11, 95, 52, 0.96), rgba(8, 112, 59, 0.88)),
        #0b5f34;
    color: #ffffff;
}

.dashboard-hero strong {
    display: block;
    margin-top: 12px;
    color: #ffffff;
    font-size: clamp(30px, 4vw, 46px);
    line-height: 1;
}

.dashboard-hero p {
    margin: 12px 0 0;
    color: rgba(255, 255, 255, 0.82);
}

.dashboard-kicker,
.dashboard-card span,
.dashboard-mini span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.dashboard-hero .dashboard-kicker {
    color: rgba(255, 255, 255, 0.76);
}

.dashboard-hero .button-light {
    width: fit-content;
    background: #ffffff;
    color: var(--brand-green);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.dashboard-card {
    display: grid;
    min-height: 106px;
    gap: 8px;
    padding: 20px;
    border-top: 4px solid var(--brand-green);
}

.dashboard-card strong,
.dashboard-mini strong {
    color: var(--ink);
    font-size: 30px;
    line-height: 1;
}

.dashboard-card a {
    color: var(--brand-green);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.dashboard-card-warn {
    border-top-color: #ca8a04;
}

.dashboard-card-ok {
    border-top-color: #0f766e;
}

.dashboard-card-danger {
    border-top-color: #dc2626;
}

.dashboard-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.dashboard-mini {
    display: grid;
    gap: 8px;
    padding: 18px;
}

body.theme-dark .dashboard-card strong,
body.theme-dark .dashboard-mini strong {
    color: #f8fafc;
}

input,
select {
    border-radius: 8px;
    background: #fbfcfd;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
select:focus {
    outline: 0;
    border-color: var(--brand-green);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

button,
.button {
    border-radius: 8px;
    background: var(--brand-green);
    box-shadow: 0 10px 22px rgba(11, 95, 52, 0.16);
}

button:hover,
.button:hover {
    background: var(--brand-green-2);
}

button[aria-busy="true"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: wait;
    opacity: 0.82;
}

button[aria-busy="true"]::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
    animation: button-spin 0.75s linear infinite;
}

@keyframes button-spin {
    to {
        transform: rotate(360deg);
    }
}

.button-light {
    background: #ffffff;
    color: var(--ink);
    box-shadow: none;
}

body.theme-dark .button-light {
    background: #1f2937;
    color: #e5e7eb;
}

.message,
.error {
    border: 1px solid transparent;
}

.messages,
.errors {
    display: none !important;
}

.toast-stack {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    display: grid;
    gap: 10px;
    width: min(420px, calc(100vw - 28px));
    pointer-events: none;
}

.toast {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    align-items: start;
    padding: 14px 14px 14px 16px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-left-width: 5px;
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--toast-shadow);
    pointer-events: auto;
    animation: toast-in 0.22s ease-out both;
}

.toast strong {
    font-size: 13px;
}

.toast span {
    grid-column: 1;
    color: var(--muted);
    line-height: 1.35;
}

.toast button {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    font-size: 18px;
    line-height: 1;
}

.toast button:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.toast-success {
    border-left-color: #12805c;
}

.toast-error {
    border-left-color: #dc2626;
}

.toast-leaving {
    animation: toast-out 0.2s ease-in both;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

.message {
    border-color: rgba(17, 97, 73, 0.2);
}

.error {
    border-color: rgba(180, 35, 24, 0.2);
}

table {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    max-width: 100%;
}

thead {
    background: var(--surface-soft);
}

th {
    letter-spacing: 0.04em;
}

tbody tr {
    transition: background 0.14s ease;
}

tbody tr:hover {
    background: rgba(11, 95, 52, 0.045);
}

body.theme-dark tbody tr:hover {
    background: rgba(134, 239, 172, 0.06);
}

.badge {
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    gap: 6px;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.72;
}

.badge-ok {
    background: #e7f8ee;
    color: #0b5f34;
}

.badge-warn {
    background: #fff8c7;
    color: #755300;
}

.badge-danger {
    background: #fff0ee;
    color: #b42318;
}

.badge-off {
    background: #eef2f5;
    color: #64748b;
}

body.theme-dark .badge-ok {
    background: #123a2b;
    color: #86efac;
}

body.theme-dark .badge-warn {
    background: #3c2e10;
    color: #fde68a;
}

body.theme-dark .badge-danger {
    background: #431c1d;
    color: #fca5a5;
}

body.theme-dark .badge-off {
    background: #263244;
    color: #cbd5e1;
}

@media (max-width: 1100px) {
    .dashboard-shell,
    .processing-metrics,
    .dashboard-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-hero {
        grid-column: 1 / -1;
    }
}

.client-payment-head {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.client-payment-table {
    min-width: 0;
}

.client-payment-value {
    font-size: 15px;
}

.finance-toolbar {
    align-items: end;
}

.finance-charts {
    align-items: stretch;
}

.chart-panel h2 {
    font-size: 15px;
}

.chart-panel canvas {
    background: linear-gradient(180deg, #ffffff, #f7faf9);
}

body.theme-dark .chart-panel canvas {
    background: #111827;
}

.table-empty {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 18px;
    background: var(--surface-soft);
    color: var(--muted);
    font-weight: 700;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-empty::before {
    content: "";
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--brand-green);
    box-shadow: 0 0 0 5px rgba(11, 95, 52, 0.12);
}

.pagination {
    align-items: center;
    gap: 8px;
}

.pagination-summary {
    margin-right: auto;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.pagination a,
.pagination span:not(.pagination-summary) {
    border-radius: 8px;
}

.pagination a {
    min-width: 92px;
    text-align: center;
}

.pagination a.disabled {
    pointer-events: none;
}

@media (min-width: 1120px) {
    .sidebar,
    body:not(.menu-open) .sidebar,
    body.menu-open .sidebar {
        transform: translateX(0);
    }

    .app-header,
    .content,
    body:not(.menu-open) .app-header,
    body:not(.menu-open) .content,
    body.menu-open .app-header,
    body.menu-open .content {
        margin-left: 250px;
        width: auto;
        max-width: none;
    }

    .menu-toggle,
    body:not(.menu-open) .sidebar-overlay,
    body.menu-open .sidebar-overlay {
        display: none;
    }
}

@media (max-width: 720px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .content {
        width: 100%;
        max-width: 100%;
        padding: 14px;
    }

    .panel {
        width: 100%;
        max-width: 100%;
        padding: 16px;
    }

    .grid,
    .dashboard-shell,
    .dashboard-grid,
    .dashboard-strip,
    .processing-metrics,
    .filter-grid,
    .finance-form-grid,
    .finance-toolbar,
    .finance-kpis,
    .finance-charts,
    .metric-list,
    .client-payment-summary {
        grid-template-columns: minmax(0, 1fr) !important;
        min-width: 0;
    }

    .login-panel {
        padding: 24px;
    }

    .client-payment-head {
        display: grid;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
        width: 100%;
        min-width: 0 !important;
        max-width: 100%;
        white-space: normal !important;
    }

    table {
        border: 0;
        background: transparent;
        overflow: visible;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 10px;
    }

    tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        padding: 10px;
        box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
    }

    td {
        border: 0;
        padding: 8px 0;
        display: grid;
        grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        overflow-wrap: anywhere;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .table-actions {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .table-actions a,
    .table-actions button,
    .table-actions form {
        width: 100%;
    }

    .toast-stack {
        top: 10px;
        right: 10px;
        width: calc(100vw - 20px);
    }

    .pagination {
        grid-template-columns: 1fr 1fr;
    }

    .pagination-summary {
        grid-column: 1 / -1;
        margin-right: 0;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .finance-kpis,
    .client-payment-summary,
    .metric-list {
        grid-template-columns: 1fr;
    }
}
