:root {
    --ink: #132238;
    --muted: #64748b;
    --line: #e2e8f0;
    --surface: #ffffff;
    --soft: #f6f8fb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --sidebar: #0f172a;
}

* { box-sizing: border-box; }

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

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    width: 280px;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    background: var(--sidebar);
    color: #fff;
}

.brand {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 58px;
    margin-bottom: 28px;
    color: #fff;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 800;
}

.brand-logo {
    width: 100%;
    max-width: 224px;
    height: auto;
    max-height: 58px;
    display: block;
    object-fit: contain;
    object-position: left center;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
}

.sidebar-nav { gap: 6px; }

.sidebar .nav-link,
.logout {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 600;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active,
.logout:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.logout { margin-top: auto; }

.main-content {
    width: 100%;
    margin-left: 280px;
    padding: 28px;
}

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

.topbar h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0;
}

.topbar-kicker {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: .88rem;
    font-weight: 700;
    text-transform: uppercase;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    font-weight: 700;
}

.btn-icon {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    background: #fff;
}

.panel,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .05);
}

.panel { padding: 20px; }

.stat-card {
    padding: 18px;
    min-height: 132px;
}

.stat-card .icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    margin-bottom: 12px;
    border-radius: 8px;
    background: #eef4ff;
    color: var(--primary);
    font-size: 1.2rem;
}

.stat-card p { margin: 0; color: var(--muted); font-weight: 700; }
.stat-card strong { display: block; margin-top: 6px; font-size: 1.55rem; }

.dashboard-chart {
    position: relative;
    width: 100%;
}

.dashboard-chart-compact {
    height: 210px;
}

.dashboard-chart-pie {
    max-width: 360px;
    height: 260px;
    margin: 0 auto;
}

.table {
    --bs-table-bg: transparent;
    vertical-align: middle;
}

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

.quote-items-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
}

.quote-items-table {
    margin-bottom: 0;
}

.quote-items-table thead th {
    background: #f8fafc;
}

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

.quote-items-table .form-select {
    min-width: 420px;
}

.quote-product-search {
    position: relative;
    flex: 1 1 380px;
    min-width: 380px;
}

.quote-material-entry {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 430px;
}

.quote-manual-toggle {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.quote-manual-toggle:hover,
.quote-manual-toggle:focus {
    color: var(--primary-dark);
    border-color: var(--primary);
    background: #eff6ff;
}

.quote-manual-panel {
    display: none;
}

.quote-material-entry .quote-manual-panel {
    flex: 1 1 380px;
}

.quote-quantity-input {
    min-width: 88px;
    max-width: 104px;
}

.quote-row-manual-active [data-quote-material-control] {
    display: none;
}

.quote-row-manual-active .quote-manual-panel {
    display: block;
}

.quote-product-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 2060;
    display: none;
    max-height: 260px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 16px 36px rgba(15, 23, 42, .16);
}

.quote-product-search.open .quote-product-results {
    display: block;
}

.quote-product-results::after {
    content: attr(data-empty);
    display: block;
    padding: 8px 10px;
    color: var(--muted);
    font-size: .88rem;
}

.quote-product-results[data-empty=""]::after {
    display: none;
}

.quote-product-option {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink);
    text-align: left;
    line-height: 1.25;
}

.quote-product-option:hover,
.quote-product-option:focus {
    background: #eff6ff;
    color: var(--primary-dark);
    outline: none;
}

.quote-preview-control {
    min-height: 44px;
    display: flex;
    align-items: center;
    white-space: normal;
    line-height: 1.25;
}

.quote-grand-total {
    color: var(--primary-dark);
    font-size: 1.05rem;
}

.status-menu {
    min-width: 170px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, .14);
    border-color: var(--line);
    border-radius: 8px;
    padding: 6px;
}

.status-menu.dropdown-menu-floating {
    position: fixed !important;
    z-index: 2050;
    display: block;
}

.report-client-row td {
    background: #f8fafc;
    color: var(--ink);
    font-weight: 800;
}

.table thead th {
    color: var(--muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: 0;
}

.badge-status {
    border-radius: 8px;
    padding: 7px 10px;
    font-weight: 800;
}

.status-pendente { background: #fff7ed; color: var(--warning); }
.status-aprovado { background: #ecfdf5; color: var(--success); }
.status-recusado { background: #fef2f2; color: var(--danger); }
.status-novo { background: #eff6ff; color: var(--primary); }
.status-em_andamento { background: #fefce8; color: #a16207; }
.status-concluido { background: #f0fdf4; color: #15803d; }
.status-aguardando_material { background: #f5f3ff; color: #6d28d9; }

.form-label { font-weight: 700; color: #334155; }
.form-control, .form-select { border-radius: 8px; border-color: var(--line); min-height: 44px; }
.btn { border-radius: 8px; font-weight: 700; }

.delete-modal {
    border: 0;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
}

.delete-modal .modal-header {
    align-items: flex-start;
    padding: 22px 22px 0;
}

.delete-modal .modal-body,
.delete-modal .modal-footer {
    padding-left: 22px;
    padding-right: 22px;
}

.delete-modal-icon {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 8px;
    background: #fef2f2;
    color: var(--danger);
    font-size: 1.35rem;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(37,99,235,.92), rgba(15,23,42,.95)),
        url("https://images.unsplash.com/photo-1503387762-592deb58ef4e?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-shell {
    width: min(440px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.login-logo {
    width: min(72%, 300px);
    max-height: 230px;
    height: auto;
    display: block;
    object-fit: contain;
    filter: drop-shadow(0 18px 34px rgba(15, 23, 42, .28));
}

.login-card {
    width: 100%;
    padding: 30px;
    border-radius: 8px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 24px 70px rgba(15,23,42,.28);
}

@media (max-height: 680px) {
    .login-page { padding: 16px; }
    .login-shell { gap: 18px; }
    .login-logo { width: min(64%, 240px); max-height: 180px; }
    .login-card { padding: 24px; }
}

.quote-print { background: #fff; color: #111827; }

.quote-materials-table {
    table-layout: fixed;
    width: 100%;
    min-width: 0;
}

.quote-materials-table .col-material { width: 56%; }
.quote-materials-table .col-quantity { width: 16%; }
.quote-materials-table .col-unit-price { width: 14%; }
.quote-materials-table .col-total { width: 14%; }

.quote-material-name {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.25;
}

.quote-nowrap {
    white-space: nowrap;
}

@media print {
    .sidebar, .topbar, .no-print, .alert { display: none !important; }
    .main-content { margin: 0; padding: 0; }
    .panel { border: 0; box-shadow: none; padding: 0; }
    .stat-card { box-shadow: none; }
    .quote-print .table-responsive {
        overflow: visible !important;
    }
    .quote-materials-table {
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
        font-size: 12px;
    }
    .quote-materials-table th,
    .quote-materials-table td {
        padding: 6px 7px;
        vertical-align: middle;
    }
    .quote-materials-table .quote-nowrap {
        white-space: nowrap !important;
        overflow-wrap: normal !important;
        word-break: normal !important;
    }
    .quote-materials-table .quote-material-name {
        white-space: normal !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
        line-height: 1.25;
    }
    .no-print-link { color: #111827 !important; text-decoration: none !important; }
    .report-stats {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px !important;
        margin-bottom: 14px !important;
    }
    .report-stats > [class*="col-"] {
        width: auto !important;
        max-width: none !important;
        padding: 0 !important;
    }
    .report-stats .stat-card {
        min-height: 78px;
        padding: 10px;
        border: 1px solid #d1d5db;
        page-break-inside: avoid;
    }
    .report-stats .stat-card .icon {
        display: none;
    }
    .report-stats .stat-card p {
        font-size: 10px;
        margin-bottom: 4px;
    }
    .report-stats .stat-card strong {
        font-size: 15px;
        line-height: 1.15;
        word-break: normal;
    }
    body { background: #fff; }
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content {
        margin-left: 0;
        padding: 18px;
    }
    .topbar { align-items: flex-start; }
    .user-chip { display: none; }
}
