:root {
    --bg: #f7efe3;
    --panel: rgba(255, 249, 240, 0.88);
    --panel-strong: rgba(255, 244, 228, 0.98);
    --ink: #29160b;
    --muted: #6d5743;
    --accent: #8a5a28;
    --accent-dark: #5f3814;
    --line: rgba(105, 66, 29, 0.18);
    --good: #266f45;
    --warn: #915f1a;
    --shadow: 0 20px 40px rgba(88, 54, 24, 0.15);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(208, 155, 82, 0.35), transparent 28%),
        linear-gradient(145deg, #f7efe3 0%, #f1e0c7 50%, #f9f4ea 100%);
}

body.auth-required .app-shell {
    opacity: 0;
    pointer-events: none;
    user-select: none;
}

body.privacy-locked .app-shell {
    opacity: 0;
    pointer-events: none;
    user-select: none;
}

.app-shell {
    min-height: 100vh;
    padding: 28px;
}

body:not(.show-home-hero) .hero {
    display: none;
}

.hero {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
    padding: 28px;
    border-radius: calc(var(--radius) + 4px);
    background: linear-gradient(135deg, rgba(83, 42, 7, 0.92), rgba(159, 110, 47, 0.9));
    color: #fff8ef;
    box-shadow: var(--shadow);
}

.eyebrow,
.hero-kicker {
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.74rem;
    opacity: 0.82;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2.2rem, 4vw, 4rem);
    line-height: 0.95;
}

.hero-copy {
    max-width: 40rem;
    margin: 14px 0 0;
    color: rgba(255, 248, 239, 0.9);
    font-size: 1rem;
}

.hero-panel {
    align-self: end;
    padding: 20px;
    border-radius: var(--radius);
    background: rgba(255, 248, 239, 0.12);
    backdrop-filter: blur(6px);
}

.hero-panel ul {
    margin: 0;
    padding-left: 18px;
}

.layout {
    display: grid;
    gap: 22px;
}

.section-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

body:not(.show-home-hero) .section-tabs .section-tab:not([data-section="home"]) {
    display: none;
}

body:not(.show-home-hero) .section-tabs {
    justify-content: flex-start;
}

.section-tab {
    white-space: nowrap;
}

.section-tab.active {
    background: var(--accent);
    color: #fff;
}

.app-section {
    display: none;
}

.app-section.active {
    display: block;
}

.panel {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.panel h2 {
    margin: 0;
    font-size: 1.1rem;
}

.ghost-button,
button {
    border: none;
    border-radius: 999px;
    padding: 11px 16px;
    font: inherit;
    cursor: pointer;
    transition: transform 160ms ease, opacity 160ms ease;
}

button {
    background: var(--accent);
    color: white;
}

.ghost-button {
    background: rgba(138, 90, 40, 0.08);
    color: var(--accent-dark);
}

button:hover,
.ghost-button:hover {
    transform: translateY(-1px);
}

.metrics-grid,
.three-up,
.two-up {
    display: grid;
    gap: 18px;
}

.metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.pawn-book-summary {
    margin: 12px 0 14px;
}

.metric {
    padding: 16px;
    border-radius: 18px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.metric-label {
    color: var(--muted);
    font-size: 0.82rem;
}

.metric-value {
    margin-top: 8px;
    font-size: 1.6rem;
    font-weight: 700;
}

.metric-compact .metric-value {
    font-size: 1.1rem;
}

.featured-card {
    margin-top: 18px;
    padding: 20px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(145, 95, 26, 0.12), rgba(255, 251, 244, 0.9));
    border: 1px solid rgba(145, 95, 26, 0.18);
}

.featured-card h3 {
    margin: 0 0 8px;
}

.two-up {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-up {
    grid-template-columns: 1.2fr 1.2fr 1fr;
}

.stacked-form,
.compact-grid {
    display: grid;
    gap: 14px;
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.compact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
    display: grid;
    gap: 6px;
    font-size: 0.92rem;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
    font: inherit;
}

.inventory-picker {
    display: grid;
    gap: 10px;
    max-height: 220px;
    overflow: auto;
}

.inventory-option,
.list-card,
.sale-card {
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
}

.list-card.is-editable {
    cursor: pointer;
}

.inventory-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.inventory-option input {
    width: auto;
    margin-top: 4px;
}

.list-grid,
.sales-list {
    display: grid;
    gap: 12px;
}

.meta {
    color: var(--muted);
    font-size: 0.85rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
}

.tag.active {
    background: rgba(38, 111, 69, 0.12);
    color: var(--good);
}

.tag.closed {
    background: rgba(145, 95, 26, 0.14);
    color: var(--warn);
}

.tag.alert {
    background: rgba(179, 50, 50, 0.14);
    color: #a22a2a;
}

.status-line {
    min-height: 20px;
    margin: 12px 0 0;
    color: var(--accent-dark);
}

.inline-search {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    margin-bottom: 12px;
}

.txn-inline-search {
    grid-template-columns: 1fr 1fr auto auto;
}

.reco-inline-search {
    grid-template-columns: 1.2fr 1fr 1fr auto auto;
}

.pawn-inline-actions {
    margin-top: 10px;
}

.correction-form {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
}

.pawn-transactions {
    margin-top: 10px;
    border-top: 1px dashed var(--line);
    padding-top: 10px;
}

.pawn-transactions h4 {
    margin: 0 0 8px;
    font-size: 0.85rem;
    color: var(--muted);
}

.txn-item {
    font-size: 0.82rem;
    color: var(--muted);
    padding: 4px 0;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-strong);
}

.selected-row {
    background: rgba(138, 90, 40, 0.08);
}

.pawn-detail-panel {
    margin-top: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 250, 243, 0.96), rgba(246, 234, 216, 0.92));
}

.pawn-detail-panel h3 {
    margin: 0;
}

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

.data-table th,
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 0.84rem;
    color: var(--ink);
    white-space: nowrap;
}

.data-table th {
    position: sticky;
    top: 0;
    background: #f6ead8;
    color: var(--accent-dark);
    font-weight: 600;
}

.auth-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: #f7efe3;
    z-index: 9999;
    padding: 18px;
    overflow-y: auto;
}

.auth-overlay.visible {
    display: flex;
}

.auth-card {
    width: min(420px, 100%);
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 20px;
    display: grid;
    gap: 12px;
}

.auth-card h3 {
    margin: 0;
}

.review-card {
    width: min(760px, 100%);
    max-height: calc(100vh - 36px);
    overflow-y: auto;
}

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

.review-item {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.7);
}

.review-item strong {
    display: block;
    margin-bottom: 4px;
    color: var(--accent-dark);
    font-size: 0.82rem;
}

.status-inline-action {
    margin-left: 8px;
}

.print-sheet {
    display: none;
}

.pawn-mobile-list {
    display: none;
    margin-bottom: 12px;
}

.risk-mobile-list,
.txn-mobile-list {
    display: none;
    margin-bottom: 12px;
}

.scroll-controls {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: grid;
    gap: 10px;
    z-index: 50;
}

.scroll-button {
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 50%;
    background: rgba(138, 90, 40, 0.18);
    color: var(--accent-dark);
    border: 1px solid rgba(138, 90, 40, 0.24);
    backdrop-filter: blur(6px);
    box-shadow: 0 10px 24px rgba(88, 54, 24, 0.12);
}

.scroll-button:hover {
    background: rgba(138, 90, 40, 0.28);
}

.print-sheet-inner {
    width: 7.6in;
    min-height: 10.1in;
    margin: 0 auto;
    background: #fff;
    color: #1f1308;
    font-family: "Segoe UI", sans-serif;
    position: relative;
    overflow: hidden;
}

.print-watermark {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: rgba(95, 56, 20, 0.08);
    transform: rotate(-28deg);
    pointer-events: none;
    text-align: center;
    padding: 24px;
}

.print-content {
    position: relative;
    z-index: 1;
}

.print-header {
    border-bottom: 2px solid #8a5a28;
    padding-bottom: 10px;
    margin-bottom: 18px;
}

.print-header h1 {
    margin: 0;
    font-size: 24px;
}

.print-sub {
    color: #6d5743;
    font-size: 12px;
    margin-top: 4px;
}

.print-title {
    margin: 18px 0 10px;
    font-size: 18px;
    font-weight: 700;
}

.print-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
    margin-bottom: 18px;
}

.print-row strong {
    display: block;
    font-size: 12px;
    color: #6d5743;
    margin-bottom: 4px;
}

.print-row div {
    font-size: 14px;
}

.print-notes {
    margin-top: 20px;
    border-top: 1px solid #d9c0a1;
    padding-top: 12px;
    font-size: 12px;
    color: #5f3814;
}

.print-transactions {
    margin-top: 18px;
}

.print-transactions h3 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #5f3814;
}

.print-transactions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.print-transactions-table th,
.print-transactions-table td {
    border: 1px solid #d9c0a1;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

.print-transactions-table th {
    background: #f6ead8;
    color: #5f3814;
}

.print-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin-top: 56px;
}

.print-signature-line {
    border-top: 1px solid #5f3814;
    padding-top: 6px;
    font-size: 12px;
    color: #6d5743;
}

@media (max-width: 960px) {
    .hero,
    .two-up,
    .three-up,
    .compact-grid,
    .inline-search {
        grid-template-columns: 1fr;
    }

    .app-shell {
        padding: 16px;
    }

    .hero {
        padding: 18px;
    }

    .panel {
        padding: 16px;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-actions {
        width: 100%;
    }

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

    .section-tabs {
        position: sticky;
        top: 0;
        z-index: 20;
        margin: 0 -16px 14px;
        padding: 10px 16px;
        overflow-x: auto;
        flex-wrap: nowrap;
        background: rgba(247, 239, 227, 0.95);
        backdrop-filter: blur(6px);
        border-bottom: 1px solid var(--line);
    }

    .section-tab {
        flex: 0 0 auto;
    }

    .list-card {
        padding: 12px;
    }

    .pawn-inline-actions.compact-grid {
        grid-template-columns: 1fr;
    }

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

    .data-table {
        min-width: 0;
        table-layout: fixed;
    }

    .data-table th,
    .data-table td {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
        font-size: 0.78rem;
        padding: 8px 9px;
    }

    #section-pawn-book .table-wrap,
    #section-pawn-update .table-wrap,
    #section-pawn-corrections .table-wrap {
        display: none;
    }

    #section-pawn-book .pawn-mobile-list,
    #section-pawn-update .pawn-mobile-list,
    #section-pawn-corrections .pawn-mobile-list {
        display: grid;
    }

    #section-pawn-book .pawn-book-summary {
        display: none;
    }

    #section-pawn-book .pawn-detail-panel,
    #section-pawn-update .pawn-detail-panel,
    #section-pawn-corrections .pawn-detail-panel {
        margin-top: 10px;
        padding: 12px;
    }

    #section-pawn-risk .table-wrap,
    #section-pawn-transactions .table-wrap {
        display: none;
    }

    #section-pawn-risk .risk-mobile-list,
    #section-pawn-transactions .txn-mobile-list {
        display: grid;
    }
}

@media (max-width: 600px) {
    .hero h1 {
        font-size: 2rem;
    }

    button,
    .ghost-button {
        width: 100%;
    }

    .section-tabs {
        position: static;
        margin: 0 0 12px;
        padding: 0;
        overflow-x: visible;
        flex-wrap: wrap;
        background: transparent;
        backdrop-filter: none;
        border-bottom: 0;
    }

    .section-tab {
        width: calc(50% - 6px);
    }

    body:not(.show-home-hero) .section-tabs .section-tab[data-section="home"] {
        width: auto;
    }

    .auth-card {
        padding: 16px;
    }

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

    .review-card {
        max-height: calc(100vh - 24px);
        padding-bottom: 16px;
    }

    #section-pawn-book .data-table,
    #section-pawn-update .data-table,
    #section-pawn-corrections .data-table,
    #section-pawn-risk .data-table {
        min-width: 860px;
    }

    #section-pawn-book .data-table,
    #section-pawn-update .data-table,
    #section-pawn-corrections .data-table {
        min-width: 0;
    }

    #section-pawn-update .inline-search,
    #section-pawn-update .pawn-inline-actions.compact-grid,
    #section-pawn-corrections .inline-search,
    #section-pawn-corrections .pawn-inline-actions.compact-grid {
        grid-template-columns: 1fr;
    }

    .scroll-controls {
        right: 12px;
        bottom: 12px;
    }

    .scroll-button {
        width: 42px;
        height: 42px;
    }
}

@media print {
    @page {
        size: 8.5in 11in;
        margin: 0.45in;
    }

    body {
        background: #fff;
    }

    .app-shell,
    .auth-overlay {
        display: none !important;
    }

    .print-sheet {
        display: block !important;
    }

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