/* =====================================================================
   Aurum Jewellery Manager - interface styles
   Flat, neutral business UI. One accent colour, used sparingly.
   ===================================================================== */
:root {
    --ink: #111827;
    --ink-2: #1f2937;
    --slate: #374151;
    --muted: #6b7280;
    --line: #e5e7eb;
    --line-strong: #d1d5db;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --text: #1f2937;
    --accent: #8a6a1c;
    --accent-hover: #725716;
    --accent-soft: #f6f0df;
    --accent-line: #d9c48a;
    --sidebar-w: 248px;
    --radius: 8px;

    --bs-primary: #8a6a1c;
    --bs-primary-rgb: 138, 106, 28;
    --bs-link-color: #725716;
    --bs-link-color-rgb: 114, 87, 22;
    --bs-link-hover-color: #5a4411;
    --bs-link-hover-color-rgb: 90, 68, 17;
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-body-font-family: "Segoe UI", "Inter", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: .875rem;
    --bs-border-color: var(--line);
    --bs-border-radius: 6px;
    --bs-border-radius-sm: 5px;
    --bs-border-radius-lg: 8px;
}

html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); font-size: .875rem; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: 0; color: var(--ink); }
.text-gold { color: var(--accent) !important; }
.text-muted { color: var(--muted) !important; }
.tabular { font-variant-numeric: tabular-nums; }
.fs-7 { font-size: .78rem; }
a { text-underline-offset: 2px; }
.font-serif { font-family: inherit; }

/* ----------------------------------------------------------------- buttons */
.btn { font-weight: 500; border-radius: 6px; padding: .42rem .9rem; font-size: .875rem; box-shadow: none !important; }
.btn-sm { padding: .25rem .6rem; font-size: .8125rem; border-radius: 5px; }
.btn-primary {
    --bs-btn-color: #fff; --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--accent-hover); --bs-btn-hover-border-color: var(--accent-hover);
    --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--accent-hover); --bs-btn-active-border-color: var(--accent-hover);
    --bs-btn-disabled-color: #fff; --bs-btn-disabled-bg: #b9a265; --bs-btn-disabled-border-color: #b9a265;
}
.btn-dark { --bs-btn-bg: var(--ink-2); --bs-btn-border-color: var(--ink-2); --bs-btn-hover-bg: #000; --bs-btn-hover-border-color: #000; --bs-btn-active-bg: #000; }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--line-strong); --bs-btn-color: var(--slate); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-border-color: var(--line-strong); --bs-btn-active-bg: #f3f4f6; --bs-btn-active-border-color: var(--line-strong); }
.btn-outline-primary { --bs-btn-color: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); --bs-btn-hover-color: #fff; --bs-btn-active-bg: var(--accent); --bs-btn-active-border-color: var(--accent); }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn-group .btn-light { border-color: var(--line-strong); }

/* ----------------------------------------------------------------- forms */
.form-control, .form-select { border-color: var(--line-strong); padding: .42rem .65rem; background-color: #fff; border-radius: 6px; font-size: .875rem; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 106, 28, .15); }
.form-control-sm, .form-select-sm { padding: .25rem .5rem; font-size: .8125rem; }
.form-control:disabled { background: var(--surface-2); }
.form-label { font-size: .75rem; font-weight: 600; color: var(--slate); margin-bottom: .25rem; letter-spacing: 0; text-transform: none; }
.form-text { font-size: .76rem; color: var(--muted); }
.input-group-text { background: var(--surface-2); border-color: var(--line-strong); color: var(--muted); font-size: .875rem; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 106, 28, .15); }
.invalid-feedback { font-size: .76rem; }
.form-control.is-invalid, .form-select.is-invalid { background-image: none; }
.req::after { content: " *"; color: #b42318; }

/* ----------------------------------------------------------------- shell */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040; background: var(--ink);
    color: #9ca3af; display: flex; flex-direction: column; transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: 0 1.1rem; height: 56px; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); flex: none; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; font-size: .95rem; color: #fff;
    background: var(--accent); flex: none; overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { color: #fff; font-size: .9375rem; line-height: 1.2; font-weight: 600; }
.brand-sub { color: #6b7280; font-size: .68rem; letter-spacing: .04em; }
.side-scroll { flex: 1; overflow-y: auto; padding: .5rem .6rem 1rem; scrollbar-width: thin; scrollbar-color: #374151 transparent; }
.side-heading { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: #6b7280; padding: 1.1rem .7rem .35rem; font-weight: 600; }
.side-link {
    display: flex; align-items: center; gap: .65rem; padding: .45rem .7rem; margin: 1px 0; border-radius: 6px;
    color: #c7ccd6; text-decoration: none; font-weight: 450; font-size: .8125rem; position: relative;
}
.side-link i { font-size: .95rem; width: 1.1rem; text-align: center; color: #7c8494; }
.side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-link:hover i { color: #c7ccd6; }
.side-link.active { background: rgba(255,255,255,.09); color: #fff; font-weight: 550; }
.side-link.active i { color: #e1c36f; }
.side-link.active::before { content: ""; position: absolute; left: -.6rem; top: 7px; bottom: 7px; width: 3px; border-radius: 0 2px 2px 0; background: #e1c36f; }
.side-foot { padding: .7rem .85rem; border-top: 1px solid rgba(255,255,255,.08); display: flex; gap: .65rem; align-items: center; flex: none; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: .8rem; flex: none;
    background: #e8e1cc; color: #5a4411;
}
.side-foot .avatar { background: #374151; color: #e5e7eb; }
.side-foot .who { min-width: 0; line-height: 1.25; }
.side-foot .who b { color: #f3f4f6; font-size: .8rem; font-weight: 550; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { color: #7c8494; font-size: .72rem; text-transform: capitalize; }

.app-main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem; height: 56px;
    background: #fff; border-bottom: 1px solid var(--line);
}
.topbar .page-title { font-size: .9375rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.rate-chip {
    display: inline-flex; align-items: center; gap: .4rem; padding: .22rem .6rem; border-radius: 5px; background: var(--surface-2);
    border: 1px solid var(--line); font-size: .76rem; font-weight: 550; text-decoration: none; color: var(--slate); white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.rate-chip i { color: var(--muted); }
.rate-chip.stale { border-color: #f0d28a; background: #fffaeb; color: #8a5a00; }
.rate-chip.stale i { color: #b7791f; }
.content { padding: 1.5rem; flex: 1; max-width: 1560px; width: 100%; }
.app-footer { padding: .85rem 1.5rem; color: var(--muted); font-size: .75rem; border-top: 1px solid var(--line); background: #fff; }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: 0 0 30px rgba(0,0,0,.35); }
    .app-sidebar.open { transform: none; }
    .app-main { margin-left: 0; }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(17, 24, 39, .55); z-index: 1035; }
    .content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
}

/* ----------------------------------------------------------------- cards & tables */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16, 24, 40, .04); background: var(--surface); }
.card-header { background: var(--surface); border-bottom: 1px solid var(--line); padding: .75rem 1.1rem; font-weight: 600; font-size: .875rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; border-radius: var(--radius) var(--radius) 0 0; }
.card-header .bi { color: var(--muted) !important; }
.card-body { padding: 1.1rem; }
.card-footer { background: var(--surface-2); border-top: 1px solid var(--line); padding: .65rem 1.1rem; border-radius: 0 0 var(--radius) var(--radius); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.15rem; }
.page-head h1 { font-size: 1.25rem; margin: 0; font-weight: 600; }
.page-head p { margin: .1rem 0 0; color: var(--muted); font-size: .84rem; }

/* KPI cards: label, figure, note. The icon is a quiet marker, not a coloured tile. */
.stat-card { padding: 1rem 1.1rem; display: flex; gap: .75rem; align-items: flex-start; height: 100%; }
.stat-card > div:not(.stat-icon) { min-width: 0; flex: 1; order: 1; }
.stat-icon { order: 2; width: auto; height: auto; background: none !important; font-size: 1.15rem; color: #9ca3af !important; display: block; margin-left: auto; }
.stat-label { color: var(--muted); font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.45rem; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat-sub { font-size: .76rem; color: var(--muted); }
.stat-card .stat-value.text-danger { color: #b42318 !important; }
.stat-card .stat-value.text-success { color: #067647 !important; }

.kpi-strip { display: grid; grid-template-columns: repeat(4, 1fr); }
.kpi-strip .kpi { padding: 1rem 1.25rem; border-right: 1px solid var(--line); }
.kpi-strip .kpi:last-child { border-right: 0; }
@media (max-width: 991.98px) {
    .kpi-strip { grid-template-columns: repeat(2, 1fr); }
    .kpi-strip .kpi:nth-child(2) { border-right: 0; }
    .kpi-strip .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 575.98px) { .kpi-strip { grid-template-columns: 1fr; } .kpi-strip .kpi { border-right: 0; border-bottom: 1px solid var(--line); } .kpi-strip .kpi:last-child { border-bottom: 0; } }

.table { --bs-table-bg: transparent; margin-bottom: 0; vertical-align: middle; font-size: .84rem; }
.table > :not(caption) > * > * { padding: .6rem .85rem; border-bottom-color: var(--line); }
.table thead th {
    background: var(--surface-2); color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
    white-space: nowrap; border-bottom: 1px solid var(--line); border-top: 0;
}
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--surface-2); }
.table tfoot td, .table tfoot th { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--line-strong); }
.table-wrap { overflow-x: auto; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table a.fw-semibold { color: var(--accent-hover); text-decoration: none; }
.table a.fw-semibold:hover { text-decoration: underline; }
.empty-state { text-align: center; padding: 2.75rem 1rem; color: var(--muted); }
.empty-state i { font-size: 1.9rem; color: #c3c8d1; display: block; margin-bottom: .5rem; }

.badge { font-weight: 550; letter-spacing: .01em; border-radius: 4px; padding: .3em .55em; font-size: .72rem; }
.badge-soft-success { background: #dcfae6; color: #067647; }
.badge-soft-warning { background: #fef0c7; color: #93370d; }
.badge-soft-danger { background: #fee4e2; color: #b42318; }
.badge-soft-primary { background: #e0eaff; color: #1d4ed8; }
.badge-soft-info { background: #d9f0fa; color: #0b6a8a; }
.badge-soft-secondary { background: #eef0f3; color: #4b5563; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .5rem; border-radius: 4px; background: #eef0f3; font-size: .75rem; font-weight: 550; color: var(--slate); }

.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem .75rem; align-items: end; }
.filter-bar .form-control, .filter-bar .form-select { min-width: 130px; }
.pagination { --bs-pagination-active-bg: var(--ink-2); --bs-pagination-active-border-color: var(--ink-2); --bs-pagination-active-color: #fff; --bs-pagination-color: var(--slate); --bs-pagination-border-color: var(--line-strong); --bs-pagination-hover-bg: var(--surface-2); margin-bottom: 0; }

.alert { border-radius: 6px; border: 1px solid transparent; box-shadow: none; font-size: .86rem; }
.alert-success { background: #ecfdf3; border-color: #abefc6; color: #067647; }
.alert-danger { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.alert-warning { background: #fffaeb; border-color: #fedf89; color: #93370d; }
.alert-info { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }
.alert-light { background: var(--surface-2); border-color: var(--line); }
.nav-pills .nav-link { color: var(--slate); font-weight: 500; border-radius: 6px; padding: .4rem .9rem; }
.nav-pills .nav-link.active { background: var(--ink-2); color: #fff; }
.modal-content { border-radius: 10px; border: 0; box-shadow: 0 20px 50px -12px rgba(16, 24, 40, .35); }
.modal-header { border-bottom-color: var(--line); padding: .85rem 1.15rem; }
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-footer { border-top-color: var(--line); }
.dropdown-menu { border-radius: 8px; border-color: var(--line); box-shadow: 0 10px 30px -8px rgba(16, 24, 40, .25); padding: .3rem; font-size: .84rem; }
.dropdown-item { border-radius: 5px; padding: .4rem .7rem; }
.toast-container { z-index: 2000; }
.list-group { --bs-list-group-bg: transparent; --bs-list-group-border-color: var(--line); }
.modal { --bs-modal-bg: #fff; }
.dropdown-menu { --bs-dropdown-bg: #fff; }
.pagination { --bs-pagination-bg: #fff; --bs-pagination-disabled-bg: #fff; }
.form-select { --bs-form-select-bg-img: none; }
.form-select { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }

/* ----------------------------------------------------------------- sign-in */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 5fr 4fr; background: #fff; }
.auth-hero { color: #fff; display: flex; flex-direction: column; justify-content: space-between; padding: 2.5rem 3rem; background: var(--ink); }
.auth-hero .auth-name { font-size: 2rem; font-weight: 600; line-height: 1.2; max-width: 420px; color: #fff; }
.auth-hero .auth-tag { color: #9ca3af; margin-top: .6rem; max-width: 420px; }
.auth-form-side { display: grid; place-items: center; padding: 2rem 1.25rem; background: #fff; }
.auth-card { width: 100%; max-width: 360px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ----------------------------------------------------------------- billing screen */
.bill-grid { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 1.1rem; align-items: start; }
.bill-summary { position: sticky; top: 72px; }
@media (max-width: 1199.98px) { .bill-grid { grid-template-columns: 1fr; } .bill-summary { position: static; } }
.scan-box { position: relative; }
.scan-box .form-control { padding-left: 2.5rem; font-size: 1rem; height: 2.85rem; border: 1px solid var(--line-strong); background: var(--surface-2); }
.scan-box .form-control:focus { background: #fff; }
.scan-box i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); font-size: 1.1rem; color: var(--muted); }
.cart-line { border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: .7rem; overflow: hidden; }
.cart-line.warn { border-color: #f0b44c; }
.cart-head { display: flex; align-items: flex-start; gap: .7rem; padding: .65rem .85rem; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cart-head .idx { width: 22px; height: 22px; border-radius: 4px; background: var(--ink-2); color: #fff; font-size: .72rem; display: grid; place-items: center; flex: none; margin-top: 2px; }
.cart-body { padding: .75rem .85rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: .6rem .7rem; }
.cart-body .form-label { font-size: .7rem; margin-bottom: .15rem; color: var(--muted); font-weight: 600; }
.cart-more { padding: 0 .85rem .7rem; }
.cart-total { font-weight: 600; font-size: 1rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.sum-row { display: flex; justify-content: space-between; padding: .26rem 0; font-variant-numeric: tabular-nums; }
.sum-row.big { font-size: 1.15rem; font-weight: 650; border-top: 1px solid var(--line-strong); margin-top: .4rem; padding-top: .65rem; color: var(--ink); }
.sum-row.big .text-gold { color: var(--ink) !important; }
.pay-row { display: grid; grid-template-columns: 100px 1fr 1fr 32px; gap: .4rem; margin-bottom: .4rem; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; box-shadow: 0 10px 24px -8px rgba(16, 24, 40, .25); max-height: 260px; overflow: auto; margin-top: 2px; }
.suggest button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .5rem .75rem; font-size: .84rem; }
.suggest button:hover, .suggest button.active { background: var(--surface-2); }

/* ----------------------------------------------------------------- documents (invoice / receipts / labels) */
.doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); max-width: 980px; margin: 0 auto; padding: 2rem 2.25rem; }
.doc-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid var(--ink); padding-bottom: .9rem; margin-bottom: 1rem; }
.doc-title { font-size: 1.35rem; font-weight: 700; letter-spacing: 0; color: var(--ink); }
.doc table { font-size: .82rem; }
.doc .table > :not(caption) > * > * { padding: .4rem .5rem; }
.doc .table thead th { background: #f3f4f6; }
.doc-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.watermark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font-size: 6rem; font-weight: 800; color: rgba(180, 35, 24, .1); transform: rotate(-20deg); letter-spacing: .2em; }

.label-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-label { background: #fff; border: 1px dashed #b8bdc7; border-radius: 3px; padding: 2mm 2.5mm; display: flex; gap: 2mm; align-items: center; overflow: hidden; color: #000; font-family: Arial, sans-serif; }
.tag-label svg { flex: none; max-height: 100%; }
.tag-meta { line-height: 1.15; min-width: 0; font-size: 7pt; }
.tag-meta b { display: block; font-size: 7.5pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ----------------------------------------------------------------- misc */
.progress-thin { height: 5px; border-radius: 3px; background: #eceef2; }
.progress-thin .progress-bar { background: var(--ink-2); }
.divider { height: 1px; background: var(--line); margin: .9rem 0; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .5rem; }
.perm-grid label { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; background: #fff; }
.perm-grid label:hover { border-color: var(--line-strong); background: var(--surface-2); }
.report-tile { display: block; text-decoration: none; color: inherit; height: 100%; transition: border-color .15s, box-shadow .15s; }
.report-tile:hover { border-color: var(--accent-line); box-shadow: 0 2px 8px rgba(16, 24, 40, .08); color: inherit; }
.report-tile .stat-icon { display: block; margin: 0 0 .6rem; font-size: 1.35rem; color: var(--accent) !important; }
.nowrap { white-space: nowrap; }
.cursor-pointer { cursor: pointer; }

/* ----------------------------------------------------------------- responsive tables -> stacked rows on phones */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack tbody tr { display: block; padding: .5rem .25rem; border-bottom: 1px solid var(--line); }
    .table-stack tbody td { display: flex; justify-content: space-between; gap: 1rem; border: 0 !important; padding: .2rem .85rem !important; text-align: right; }
    .table-stack tbody td::before { content: attr(data-label); font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; text-align: left; flex: none; padding-top: 2px; }
    .table-stack tbody td.actions { justify-content: flex-end; }
    .table-stack tbody td.actions::before { display: none; }
    .table-stack tfoot { display: none; }
    .pay-row { grid-template-columns: 1fr 1fr 32px; }
    .pay-row > :nth-child(3) { grid-column: 1 / 3; grid-row: 2; }
    .page-head h1 { font-size: 1.15rem; }
    .doc { padding: 1.1rem; }
}

/* ----------------------------------------------------------------- print */
@media print {
    @page { margin: 10mm; }
    body { background: #fff !important; font-size: 11pt; }
    .app-sidebar, .topbar, .app-footer, .no-print, .sidebar-backdrop, .toast-container, .alert { display: none !important; }
    .app-main { margin: 0 !important; }
    .content { padding: 0 !important; max-width: none; }
    .doc { border: 0; padding: 0; max-width: none; }
    .card { box-shadow: none; }
    a { color: inherit; text-decoration: none; }
    .tag-label { border: 0; break-inside: avoid; page-break-inside: avoid; }
    .label-grid { gap: 0; }
    body.print-labels .content { padding: 0 !important; }
    body.print-labels { background: #fff; }
}

/* =====================================================================
   Billing screen (new invoice / edit invoice)
   ===================================================================== */
.invoice-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.invoice-head-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.invoice-head-no { font-size: 1.5rem; font-weight: 650; color: var(--ink); line-height: 1.2; font-variant-numeric: tabular-nums; }
.invoice-steps { align-items: center; gap: .6rem; color: var(--muted); font-size: .8rem; }
.invoice-steps .step b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #e5e7eb; color: var(--slate); font-size: .7rem; margin-right: .3rem; }
.invoice-steps i { font-size: .7rem; color: #c3c8d1; }
.step-no { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--ink-2); color: #fff; font-size: .72rem; margin-right: .55rem; font-weight: 600; }

.scan-box .scan-hint { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); font-size: .68rem; font-weight: 600; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 .35rem; background: #fff; }

/* item rows */
.bill-cols, .bill-main { grid-template-columns: 26px minmax(0, 1fr) 112px 178px 138px 72px; column-gap: .75rem; }
.bill-cols { display: none; padding: 0 .75rem .35rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.bill-row { border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: .55rem; transition: border-color .15s; }
.bill-row:hover { border-color: var(--line-strong); }
.bill-row.warn { border-color: #f0b44c; background: #fffdf7; }
.bill-main { display: grid; align-items: center; padding: .65rem .75rem; }
.bill-main .idx { width: 22px; height: 22px; border-radius: 5px; background: var(--ink-2); color: #fff; font-size: .72rem; display: grid; place-items: center; }
.bill-item { min-width: 0; }
.bill-f .form-label { display: none; }
.bill-f-making .input-group { flex-wrap: nowrap; }
.making-type { max-width: 64px; padding-right: .2rem; background-position: right .25rem center; background-color: var(--surface-2); }
.bill-amt { text-align: right; }
.bill-act { display: flex; gap: .25rem; justify-content: flex-end; }
.bill-act .btn.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-hover); }
.bill-extra { border-top: 1px dashed var(--line); background: var(--surface-2); }
.bill-extra-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem .75rem; padding: .75rem; }
.bill-extra-grid .form-label { font-size: .68rem; color: var(--muted); margin-bottom: .15rem; }
.bill-break { padding: .3rem .75rem .5rem 3.1rem; font-size: .74rem; color: var(--muted); }
@media (min-width: 992px) { .bill-cols { display: grid !important; } }
@media (max-width: 991.98px) {
    .bill-main { grid-template-columns: 26px minmax(0, 1fr) auto; row-gap: .6rem; }
    .bill-item { grid-column: 2 / 3; }
    .bill-amt { grid-column: 3; grid-row: 1; }
    .bill-f { grid-column: 2 / 4; }
    .bill-f .form-label { display: block; font-size: .68rem; color: var(--muted); margin-bottom: .15rem; }
    .bill-act { grid-column: 2 / 4; justify-content: flex-start; }
    .bill-break { padding-left: .75rem; }
}

/* payment panel */
.pay-card { overflow: hidden; }
.pay-hero { background: var(--ink-2); color: #fff; padding: 1.1rem 1.25rem; }
.pay-hero-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: #9ca3af; font-weight: 600; }
.pay-hero-amt { font-size: 2rem; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; color: #f1d98a; }
.pay-hero-sub { font-size: .8rem; color: #9ca3af; }
.pay-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-bottom: .6rem; }
.pay-chip { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .45rem .2rem; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--slate); font-size: .74rem; font-weight: 550; cursor: pointer; transition: border-color .12s, background .12s; }
.pay-chip i { font-size: 1.1rem; color: var(--muted); }
.pay-chip:hover { border-color: var(--accent-line); background: var(--surface-2); }
.pay-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); box-shadow: 0 0 0 1px var(--accent) inset; }
.pay-chip.active i { color: var(--accent); }
.kbd { display: inline-block; font-size: .66rem; border: 1px solid rgba(255,255,255,.55); border-radius: 4px; padding: 0 .3rem; margin-left: .5rem; opacity: .85; font-weight: 600; vertical-align: 1px; }
.drcr { font-size: .72em; font-weight: 600; color: var(--muted); }

/* =====================================================================
   Invoice page (view / print)
   ===================================================================== */
.inv-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.1rem; align-items: start; }
.inv-side { position: sticky; top: 72px; display: grid; gap: 1rem; }
@media (max-width: 1199.98px) { .inv-layout { grid-template-columns: 1fr; } .inv-side { position: static; } }
.inv-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.status-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .7rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.status-pill.paid { background: #dcfae6; color: #067647; }
.status-pill.due { background: #fef0c7; color: #93370d; }
.status-pill.cancelled { background: #eef0f3; color: #4b5563; }
.pay-progress { height: 8px; border-radius: 6px; background: #eceef2; overflow: hidden; }
.pay-progress > div { height: 100%; background: #12b76a; }
.pay-progress.due > div { background: #f79009; }
.pay-item { display: flex; justify-content: space-between; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .84rem; }
.pay-item:last-child { border-bottom: 0; }

.doc.invoice-doc { max-width: none; padding: 2rem 2.25rem; position: relative; }
.invoice-doc .doc-head { border-bottom: 0; padding-bottom: 0; margin-bottom: 1.1rem; }
.invoice-doc .brand-block { display: flex; gap: 1rem; align-items: flex-start; }
.invoice-doc .logo-box { width: 64px; height: 64px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; background: #fff; flex: none; }
.invoice-doc .logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.invoice-doc .logo-box i { font-size: 1.6rem; color: var(--accent); }
.inv-title-block { text-align: right; }
.inv-title { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.inv-no { font-size: 1.55rem; font-weight: 700; color: var(--ink); line-height: 1.25; font-variant-numeric: tabular-nums; }
.inv-rule { height: 3px; background: var(--ink-2); border-radius: 2px; margin-bottom: 1.1rem; position: relative; }
.inv-rule::after { content: ""; position: absolute; left: 0; top: 0; height: 100%; width: 90px; background: var(--accent); border-radius: 2px; }
.inv-meta { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.5rem; margin-bottom: 1.2rem; }
.inv-box { border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; }
.inv-items { width: 100%; border-collapse: collapse; font-size: .82rem; }
.inv-items thead th { background: var(--ink-2); color: #fff; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; padding: .5rem .55rem; font-weight: 600; white-space: nowrap; }
.inv-items tbody td { padding: .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.inv-items tbody tr:nth-child(even) td { background: #fafafb; }
.inv-items tfoot td { padding: .55rem; font-weight: 700; background: #f3f4f6; border-top: 2px solid var(--ink-2); }
.inv-items .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-totals { width: 100%; font-size: .86rem; }
.inv-totals td { padding: .32rem 0; font-variant-numeric: tabular-nums; }
.inv-totals td:last-child { text-align: right; }
.inv-net { background: var(--ink-2); color: #fff; border-radius: 8px; padding: .75rem 1rem; display: flex; justify-content: space-between; align-items: center; margin: .5rem 0; }
.inv-net b { font-size: 1.35rem; color: #f1d98a; font-variant-numeric: tabular-nums; }
.inv-words { border-left: 3px solid var(--accent); padding: .3rem .8rem; background: var(--accent-soft); border-radius: 0 6px 6px 0; }
@media (max-width: 767.98px) { .inv-meta { grid-template-columns: 1fr; gap: .8rem; } .doc.invoice-doc { padding: 1.1rem; } .inv-title-block { text-align: left; } .invoice-doc .doc-head { flex-direction: column; } }
@media print {
    .inv-layout { display: block; }
    .inv-side, .inv-toolbar { display: none !important; }
    .inv-items thead th, .inv-net { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .inv-words { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .inv-rule, .inv-rule::after { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* grid children must be allowed to shrink, otherwise wide tables push the side panel on top of them */
.inv-layout > *, .bill-grid > * { min-width: 0; }
.invoice-doc .inv-items { font-size: .78rem; }
.invoice-doc .inv-items tbody td, .invoice-doc .inv-items thead th, .invoice-doc .inv-items tfoot td { padding: .45rem .4rem; }
.invoice-doc .inv-items .item-col { min-width: 150px; }

/* ---- layout fixes after visual review ---- */
/* grid items with auto margins shrink-wrap their content and overflow the column; pin them to the track */
.inv-layout > .doc, .inv-layout > .doc.invoice-doc { margin: 0; width: 100%; max-width: 100%; min-width: 0; }
.doc.invoice-doc { padding: 1.75rem 1.75rem; }
.invoice-doc .doc-head { flex-wrap: wrap; }
.invoice-doc .brand-block { min-width: 0; flex: 1 1 320px; }
.invoice-doc .inv-title-block { flex: 0 0 auto; }
.invoice-doc .inv-items { font-size: .76rem; }

/* item rows: name on top, rate and making underneath with visible labels */
.bill-cols { display: none !important; }
.bill-main { grid-template-columns: 26px minmax(0, 1fr) auto auto; column-gap: .75rem; row-gap: .6rem; align-items: start; }
.bill-main > .idx { grid-column: 1; grid-row: 1; margin-top: 2px; }
.bill-main > .bill-item { grid-column: 2; grid-row: 1; }
.bill-main > .bill-amt { grid-column: 3; grid-row: 1; }
.bill-main > .bill-act { grid-column: 4; grid-row: 1; }
.bill-main > .bill-inputs { grid-column: 2 / -1; grid-row: 2; display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.bill-inputs .bill-f { width: 128px; }
.bill-inputs .bill-f-making { width: 210px; }
.bill-f .form-label { display: block; font-size: .68rem; color: var(--muted); margin-bottom: .15rem; }
.making-type { max-width: none; width: 80px; flex: none; padding-right: 1.6rem; }
.bill-break { padding-left: 3.1rem; }
@media (max-width: 575.98px) { .bill-main { grid-template-columns: 26px minmax(0, 1fr) auto; } .bill-main > .bill-act { grid-column: 2 / -1; grid-row: 3; justify-content: flex-start; } .bill-inputs .bill-f, .bill-inputs .bill-f-making { width: 100%; } }
