:root { --bg: #f7f8fa; --panel: #ffffff; --text: #18202a; --muted: #687381; --line: #dfe4ea; --brand: #0f766e; --accent: #2563eb; }
[data-theme="dark"] { --bg: #111418; --panel: #191f26; --text: #edf2f7; --muted: #a3adba; --line: #2d3742; --brand: #2dd4bf; --accent: #60a5fa; }
html, body { min-height: 100%; }
body { background: var(--bg); color: var(--text); font-size: .94rem; }
a { color: var(--accent); }
.app-header { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.navbar, .dropdown-menu { background: var(--panel); }
.nav-link, .navbar-brand, .dropdown-item { color: var(--text); }
.app-menu-toggle { border: 2px solid var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent); }
.app-menu-toggle .navbar-toggler-icon { filter: contrast(1.6); }
[data-theme="dark"] .app-menu-toggle .navbar-toggler-icon { filter: invert(1) contrast(1.8); }
.app-menu-toggle:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 26%, transparent); }
.app-main { padding: 22px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; overflow-x: auto; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-height: 108px; }
.metric .label { color: var(--muted); font-size: .82rem; text-transform: uppercase; }
.metric .value { font-size: 1.8rem; font-weight: 700; }
.form-control, .form-select, .input-group-text { background-color: var(--panel); color: var(--text); border-color: var(--line); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); border-color: var(--line); }
.table thead th { color: var(--muted); font-weight: 600; }
[data-theme="dark"] .table { --bs-table-color: #f8fafc; --bs-table-striped-color: #f8fafc; --bs-table-hover-color: #ffffff; color: #f8fafc; }
[data-theme="dark"] .table td,
[data-theme="dark"] .table th { color: #f8fafc; border-color: var(--line); }
[data-theme="dark"] .table thead th,
[data-theme="dark"] tfoot th { color: #ffffff; }
[data-theme="dark"] .dataTables_wrapper,
[data-theme="dark"] .dt-container,
[data-theme="dark"] .dt-info,
[data-theme="dark"] .dt-length label,
[data-theme="dark"] .dt-search label,
[data-theme="dark"] .dataTables_info,
[data-theme="dark"] .dataTables_length label,
[data-theme="dark"] .dataTables_filter label { color: #f8fafc !important; }
[data-theme="dark"] .dt-input,
[data-theme="dark"] .dataTables_wrapper .form-control,
[data-theme="dark"] .dataTables_wrapper .form-select { background-color: var(--panel) !important; color: #f8fafc !important; border-color: var(--line) !important; }
[data-theme="dark"] .page-link { background-color: var(--panel); color: #f8fafc; border-color: var(--line); }
[data-theme="dark"] .active > .page-link,
[data-theme="dark"] .page-link.active { background-color: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-brand:hover { filter: brightness(.95); color: #fff; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.auth-menu .nav-link { color: var(--text); }
.auth-menu .btn-link { text-decoration: none; }
.login-link { border: 1px solid var(--brand); border-radius: 6px; padding-inline: 14px !important; color: var(--brand) !important; }
.login-shell { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 28px 12px; }
.login-panel { width: min(940px, 100%); display: grid; grid-template-columns: .95fr 1.05fr; gap: 24px; align-items: stretch; }
.login-brand { border-radius: 8px; padding: 34px; color: #fff; background: linear-gradient(135deg, #0f766e, #2563eb); display: flex; flex-direction: column; justify-content: space-between; min-height: 390px; box-shadow: 0 24px 54px rgba(15, 118, 110, .22); }
.login-brand h1 { font-size: 2rem; margin: 18px 0 8px; }
.login-brand p { opacity: .88; max-width: 270px; }
.login-mark { width: 64px; height: 64px; border-radius: 8px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3); display: grid; place-items: center; font-weight: 800; font-size: 1.35rem; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 34px; box-shadow: 0 18px 44px rgba(15, 23, 42, .08); }
.login-card h2 { margin-bottom: 22px; }
[data-theme="dark"] .login-card { box-shadow: 0 18px 44px rgba(0, 0, 0, .28); }
.bill-filter { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)) auto; gap: 12px; align-items: end; }
.filter-actions { display: flex; gap: 8px; }
.dt-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.dt-buttons .btn { border-radius: 6px; }
tfoot th { border-top: 2px solid var(--line); color: var(--text); }
.receipt { width: 80mm; margin: 0 auto; background: #fff; color: #000; padding: 8px; font-size: 12px; }
.barcode { font-family: monospace; font-size: 28px; line-height: 1; letter-spacing: 1px; }
.invoice-title .text-muted { color: var(--muted) !important; }
.invoice-workspace { display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(460px, .85fr); gap: 18px; align-items: start; }
.invoice-validation { grid-column: 1 / -1; }
.catalog-pane, .invoice-pane { display: grid; gap: 16px; }
.invoice-pane { position: sticky; top: 78px; }
.invoice-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; box-shadow: 0 12px 30px rgba(15, 23, 42, .06); }
[data-theme="dark"] .invoice-card { box-shadow: 0 14px 34px rgba(0, 0, 0, .26); }
.section-kicker { color: var(--muted); font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 8px; }
.service-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; }
.service-filter { border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 92%, var(--brand)); color: var(--text); border-radius: 8px; padding: 12px; text-align: left; transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.service-filter span { display: block; font-weight: 700; line-height: 1.2; }
.service-filter small { color: var(--muted); display: block; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.service-filter:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 10px 22px rgba(15, 118, 110, .12); }
.service-filter.active { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 12px 26px rgba(15, 118, 110, .22); }
.service-filter.active small { color: rgba(255,255,255,.78); }
.catalog-head, .detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.catalog-search { max-width: 230px; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-height: calc(100vh - 318px); overflow: auto; padding: 2px 4px 4px 2px; }
.item-card { min-height: 132px; border: 1px solid var(--line); background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 88%, white), var(--panel)); color: var(--text); border-radius: 8px; padding: 12px; text-align: left; display: flex; flex-direction: column; gap: 5px; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
[data-theme="dark"] .item-card { background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 90%, white), var(--panel)); }
.item-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 14px 28px rgba(37, 99, 235, .14); }
.item-card strong { font-size: 1rem; line-height: 1.2; }
.item-card small { color: var(--muted); min-height: 18px; }
.item-service { color: var(--brand); font-size: .75rem; font-weight: 700; text-transform: uppercase; }
.item-price { margin-top: auto; align-self: flex-start; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); border-radius: 999px; padding: 4px 10px; font-weight: 800; }
.invoice-head-card { border-top: 4px solid var(--brand); }
.invoice-detail-card { border-top: 4px solid var(--accent); }
.line-cards { display: grid; gap: 10px; max-height: calc(100vh - 430px); min-height: 190px; overflow: auto; padding-right: 4px; }
.line-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: color-mix(in srgb, var(--panel) 94%, var(--accent)); display: grid; gap: 10px; transition: border-color .16s ease, box-shadow .16s ease; }
.line-card:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.line-money { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.line-money label { color: var(--muted); font-size: .76rem; font-weight: 700; }
.line-note { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.customer-balance { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: color-mix(in srgb, var(--brand) 8%, transparent); }
.customer-balance span { color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; }
.customer-balance strong { color: var(--brand); font-size: 1.05rem; }
.quick-customer-modal { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.quick-customer-modal .modal-header,
.quick-customer-modal .modal-footer { border-color: var(--line); }
[data-theme="dark"] .quick-customer-modal .btn-close { filter: invert(1); }
.invoice-total-bar { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: center; }
.invoice-total-bar span { display: block; color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; }
.invoice-total-bar strong { font-size: 1.5rem; line-height: 1; }
.total-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 1100px) {
    .navbar-collapse { padding-top: 12px; }
    .navbar-nav { gap: 4px; }
    .dropdown-menu { border-color: var(--line); }
    .page-title { align-items: flex-start; }
    .page-title > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
    .invoice-workspace { grid-template-columns: 1fr; }
    .invoice-pane { position: static; }
    .item-grid, .line-cards { max-height: none; }
    .bill-filter { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}
@media (max-width: 768px) {
    body { font-size: .9rem; }
    .page-title { flex-direction: column; }
    .page-title h1 { font-size: 1.35rem; }
    .page-title > a,
    .page-title .btn,
    .page-title > div:last-child { width: 100%; }
    .page-title > div:last-child .btn { flex: 1; }
    .panel { padding: 14px; }
    .metric { min-height: 92px; }
    .metric .value { font-size: 1.35rem; }
    .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
    .actions .btn,
    .actions form,
    .actions form button { width: 100%; }
    .table:not(.table-sm) { border-collapse: separate; border-spacing: 0 10px; }
    .table:not(.table-sm) thead { display: none; }
    .table:not(.table-sm) tbody,
    .table:not(.table-sm) tr,
    .table:not(.table-sm) td { display: block; width: 100%; }
    .table:not(.table-sm) tbody tr { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: color-mix(in srgb, var(--panel) 96%, var(--accent)); }
    .table:not(.table-sm) td { border: 0; padding: 8px 0; text-align: right; min-height: 34px; }
    .table:not(.table-sm) td::before { content: attr(data-label); float: left; max-width: 48%; padding-right: 12px; color: var(--muted); font-weight: 700; text-align: left; }
    .table:not(.table-sm) td:empty { display: none; }
    .table:not(.table-sm) td.actions { text-align: left; padding-top: 12px; }
    .table:not(.table-sm) td.actions::before { content: none; }
    .table:not(.table-sm) tfoot,
    .table:not(.table-sm) tfoot tr,
    .table:not(.table-sm) tfoot th { display: block; width: 100%; text-align: right !important; }
    .table:not(.table-sm) tfoot tr { border-top: 2px solid var(--line); padding-top: 10px; }
    .dt-container .row,
    .dataTables_wrapper .row { gap: 10px; }
    .dt-search,
    .dt-length,
    .dataTables_filter,
    .dataTables_length { width: 100%; text-align: left !important; }
    .dt-search input,
    .dataTables_filter input { width: 100% !important; margin: 6px 0 0 !important; }
    .dt-buttons { width: 100%; }
    .dt-buttons .btn { flex: 1; }
    .pagination { flex-wrap: wrap; justify-content: center; }
    .modal-dialog { margin: 12px; }
}
@media (max-width: 640px) {
    .app-main { padding: 14px; }
    .navbar-brand { font-size: 1rem; }
    .navbar .container-fluid { align-items: center; }
    .nav-link { padding: 10px 8px; }
    .dropdown-menu { padding: 6px; }
    .form-control,
    .form-select,
    .btn { min-height: 40px; }
    .row.g-3 { --bs-gutter-y: .75rem; }
    .service-buttons { grid-template-columns: 1fr; }
    .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .item-card { min-height: 116px; padding: 10px; }
    .invoice-card { padding: 14px; }
    .catalog-head, .detail-head, .invoice-total-bar { align-items: stretch; grid-template-columns: 1fr; flex-direction: column; }
    .catalog-search { max-width: none; }
    .line-money { grid-template-columns: 1fr; }
    .line-note { grid-template-columns: 1fr; }
    .total-actions { justify-content: stretch; }
    .total-actions .btn { width: 100%; }
    .bill-filter { grid-template-columns: 1fr; }
    .filter-actions .btn { flex: 1; }
    .login-panel { grid-template-columns: 1fr; }
    .login-brand { min-height: 210px; padding: 24px; }
    .login-card { padding: 24px; }
}
@media (max-width: 420px) {
    .item-grid { grid-template-columns: 1fr; }
    .actions { grid-template-columns: 1fr; }
    .receipt { width: 100%; }
}
@media print { body { background: #fff; } .app-header, .no-print { display: none !important; } .app-main { padding: 0; } @page { size: 80mm auto; margin: 3mm; } }
