:root {
    --bg: #f6f7f4;
    --surface: #ffffff;
    --surface-muted: #eef2ec;
    --text: #1b2420;
    --muted: #657069;
    --line: #dfe5dd;
    --primary: #136f63;
    --primary-dark: #0d5148;
    --accent: #b7791f;
    --danger: #b42318;
    --success: #16794f;
    --shadow: 0 18px 45px rgba(27, 36, 32, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0;
}

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

button,
input {
    font: inherit;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: #fbfcfa;
    padding: 20px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
}

.brand strong,
.brand span {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
}

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

.sidebar-nav {
    display: grid;
    gap: 4px;
    margin-top: 24px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    border-radius: var(--radius);
    color: #33413a;
    padding: 9px 10px;
}

.sidebar-nav a:hover,
.sidebar-nav a.is-active {
    background: var(--surface-muted);
    color: var(--primary-dark);
}

.nav-dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a8b5ad;
}

.sidebar-nav a.is-active .nav-dot {
    background: var(--primary);
}

.main-area {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
    border-bottom: 1px solid var(--line);
    background: rgba(246, 247, 244, 0.94);
    padding: 14px 28px;
}

.topbar-title {
    min-width: 0;
}

.topbar-title span,
.user-chip small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.topbar-title strong,
.user-chip span {
    display: block;
    overflow-wrap: anywhere;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    text-align: right;
}

.content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-header h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 700;
    padding: 9px 14px;
}

.button-primary {
    background: var(--primary);
    color: #ffffff;
}

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

.button-light {
    border-color: var(--line);
    background: var(--surface);
    color: var(--text);
}

.button-block {
    width: 100%;
}

.icon-button {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    padding: 10px;
}

.icon-button span {
    display: block;
    height: 2px;
    margin: 4px 0;
    background: var(--text);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.metric-card,
.panel,
.empty-state,
.auth-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric-card {
    padding: 18px;
}

.metric-card span,
.metric-card small {
    display: block;
    color: var(--muted);
}

.metric-card strong {
    display: block;
    margin: 8px 0 2px;
    color: var(--text);
    font-size: 28px;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    gap: 16px;
    margin-top: 18px;
}

.panel {
    padding: 18px;
}

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

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

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

.status-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.status-list div {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
}

.status-list.compact div {
    border-left-color: var(--accent);
}

.status-list strong,
.status-list span {
    display: block;
}

.status-list span {
    color: var(--muted);
}

.toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) auto;
    gap: 10px;
    width: min(100%, 760px);
}

.form-control,
.form-select,
.form-textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    padding: 10px 12px;
}

.form-control,
.form-select {
    min-height: 42px;
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-control:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(19, 111, 99, 0.16);
}

.data-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--line);
    padding: 13px 14px;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: #f9faf7;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

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

.link-danger {
    color: var(--danger);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 700;
    padding: 3px 9px;
}

.badge-muted {
    color: var(--muted);
}

.badge-warning {
    background: #fff6df;
    color: #8a5a00;
}

.badge-success {
    background: #e9f7ef;
    color: var(--success);
}

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

.form-grid .span-2 {
    grid-column: 1 / -1;
}

.field label,
.field > span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-weight: 700;
}

.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.checkbox-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 10px 12px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.detail-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 12px;
}

.detail-item span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.detail-item strong,
.detail-item p {
    display: block;
    margin: 4px 0 0;
    overflow-wrap: anywhere;
}

.muted {
    color: var(--muted);
}

.inline-form {
    display: inline;
}

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

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

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

.mini-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.mini-card strong {
    display: block;
    margin-top: 4px;
    font-size: 22px;
}

.print-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.document-sheet {
    max-width: 980px;
    margin: 0 auto;
    border: 1px solid var(--line);
    background: #fff;
    padding: 28px;
}

.document-head {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr) 210px;
    gap: 16px;
    align-items: center;
    border-bottom: 2px solid var(--text);
    padding-bottom: 16px;
    margin-bottom: 18px;
}

.document-logo {
    display: grid;
    place-items: center;
    width: 80px;
    height: 80px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 800;
    text-align: center;
}

.signature-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 44px;
}

.signature-line {
    border-top: 1px solid var(--text);
    padding-top: 8px;
    text-align: center;
    font-size: 12px;
}

.label-sheet {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    background: #fff;
    display: grid;
    grid-template-columns: repeat(5, 38.2mm);
    grid-auto-rows: 21.2mm;
    align-content: start;
    justify-content: center;
    padding: 7mm 0;
}

.label-cell {
    display: grid;
    grid-template-rows: 7mm 1fr 5mm;
    align-items: center;
    justify-items: center;
    overflow: hidden;
    border: 1px dashed #d8ded7;
    padding: 1mm 1.5mm;
    text-align: center;
}

.label-barcode {
    width: 32mm;
    height: 6mm;
    background: repeating-linear-gradient(90deg, #111 0 1px, #fff 1px 3px, #111 3px 4px, #fff 4px 6px);
}

.label-description {
    display: -webkit-box;
    overflow: hidden;
    color: #111;
    font-size: 7px;
    font-weight: 700;
    line-height: 1.1;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.label-price {
    color: #111;
    font-size: 10px;
    font-weight: 800;
}

.pdv-shell {
    display: grid;
    gap: 14px;
}

.pdv-top {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    gap: 10px;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
    padding: 12px;
}

.pdv-top div {
    border-right: 1px solid var(--line);
    padding: 4px 10px;
}

.pdv-top div:last-of-type {
    border-right: 0;
}

.pdv-top span,
.pdv-keybar span,
.pdv-cart-head span,
.pdv-selected span,
.pdv-product span,
.pdv-cart-item span,
.pdv-total span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.pdv-top strong,
.pdv-cart-head strong,
.pdv-selected strong,
.pdv-product strong,
.pdv-total strong {
    display: block;
    overflow-wrap: anywhere;
}

.pdv-keybar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pdv-keybar span {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 6px 10px;
}

.pdv-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
    gap: 14px;
    align-items: start;
}

.pdv-work,
.pdv-cart {
    min-width: 0;
}

.pdv-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.pdv-search-input {
    width: 100%;
    min-height: 68px;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-size: 24px;
    font-weight: 700;
    padding: 12px 16px;
}

.pdv-search-input:focus {
    outline: 4px solid rgba(19, 111, 99, 0.16);
}

.button-large {
    min-height: 56px;
    font-size: 16px;
}

.pdv-selected,
.pdv-product,
.pdv-cart,
.receipt-sheet {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
}

.pdv-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    margin: 12px 0;
    padding: 16px;
}

.pdv-results {
    display: grid;
    gap: 10px;
}

.pdv-product {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px 190px;
    gap: 12px;
    align-items: center;
    padding: 14px;
}

.pdv-product.is-disabled {
    opacity: 0.58;
}

.pdv-product-price {
    text-align: right;
}

.pdv-product-price strong {
    font-size: 24px;
}

.pdv-add {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px;
}

.pdv-cart {
    position: sticky;
    top: 88px;
    overflow: hidden;
}

.pdv-cart-head,
.pdv-cart-item,
.pdv-total,
.pdv-payment {
    padding: 14px;
}

.pdv-cart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
}

.pdv-cart-items {
    display: grid;
    max-height: min(44vh, 460px);
    overflow-y: auto;
}

.pdv-cart-empty {
    color: var(--muted);
    padding: 18px 14px;
}

.pdv-cart-item {
    display: grid;
    gap: 10px;
    border-bottom: 1px solid var(--line);
}

.pdv-qty {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.pdv-cart-line-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.pdv-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--line);
    background: #f9faf7;
}

.pdv-total strong {
    color: var(--primary-dark);
    font-size: 34px;
    line-height: 1;
}

.pdv-payment {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    border-top: 1px solid var(--line);
}

.pdv-payment .button-block,
.pdv-payment .span-2 {
    grid-column: 1 / -1;
}

.pix-copy {
    min-height: 90px;
    margin-top: 8px;
    font-size: 12px;
}

.receipt-sheet {
    max-width: 620px;
}

.receipt-head {
    display: grid;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 14px;
    padding-bottom: 14px;
    text-align: center;
}

.receipt-head strong {
    font-size: 22px;
}

.receipt-head span,
.receipt-message,
.receipt-payments span {
    color: var(--muted);
}

.receipt-table th,
.receipt-table td {
    padding: 9px 8px;
}

.receipt-total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-top: 2px solid var(--text);
    margin-top: 14px;
    padding-top: 14px;
}

.receipt-total strong {
    font-size: 28px;
}

.receipt-payments {
    display: grid;
    gap: 4px;
    margin-top: 16px;
}

.receipt-message {
    margin: 18px 0 0;
    text-align: center;
}

.code-block {
    overflow: auto;
    max-height: 520px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f9faf7;
    color: var(--text);
    font-size: 13px;
    line-height: 1.45;
    padding: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

@media print {
    body {
        background: #fff;
    }

    .sidebar,
    .topbar,
    .print-actions,
    .page-header,
    .flash {
        display: none !important;
    }

    .app-shell,
    .main-area,
    .content {
        display: block;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .document-sheet {
        border: 0;
        box-shadow: none;
        max-width: none;
        padding: 10mm;
    }

    .label-sheet {
        margin: 0;
        page-break-after: always;
    }

    .receipt-sheet {
        max-width: 80mm;
        padding: 4mm;
    }

    .receipt-table {
        font-size: 11px;
    }
}

.empty-state {
    padding: 28px;
}

.empty-state h2 {
    margin: 0 0 8px;
}

.empty-state p {
    max-width: 640px;
    margin: 0 0 18px;
    color: var(--muted);
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    padding: 12px 14px;
}

.flash button {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
}

.flash-success {
    background: #e9f7ef;
    color: var(--success);
}

.flash-error {
    background: #fdeceb;
    color: var(--danger);
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.auth-shell {
    width: min(100%, 430px);
}

.auth-panel {
    padding: 28px;
}

.auth-brand {
    margin-bottom: 24px;
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-form label span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-weight: 700;
}

.auth-form input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    padding: 10px 12px;
}

.auth-form input:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(19, 111, 99, 0.16);
}

.auth-note {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 20;
        width: min(86vw, 320px);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .icon-button {
        display: block;
    }

    .topbar {
        padding: 12px 18px;
    }

    .content {
        padding: 22px 18px;
    }

    .metric-grid,
    .dashboard-grid,
    .form-grid,
    .detail-grid,
    .kpi-grid,
    .pdv-top,
    .pdv-layout,
    .pdv-product,
    .signature-grid {
        grid-template-columns: 1fr;
    }

    .pdv-cart {
        position: static;
    }

    .pdv-product-price {
        text-align: left;
    }

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

    .filters {
        grid-template-columns: 1fr;
        width: 100%;
    }
}

@media (max-width: 620px) {
    .topbar {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .user-menu {
        width: 100%;
        justify-content: space-between;
    }

    .user-chip {
        text-align: left;
    }

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

    .page-header h1 {
        font-size: 26px;
    }

    .pdv-search {
        grid-template-columns: 1fr;
    }

    .pdv-search-input {
        min-height: 58px;
        font-size: 20px;
    }

    .pdv-payment {
        grid-template-columns: 1fr;
    }
}
