:root {
    --inv-ink: #142033;
    --inv-muted: #64748b;
    --inv-line: #dce5ef;
    --inv-blue: #2563eb;
    --inv-navy: #0f2747;
    --inv-teal: #0f9f8f;
    --inv-gold: #d97706;
    --inv-bg: #f5f8fc;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--inv-ink);
    background:
        radial-gradient(circle at 8% 5%, rgba(37, 99, 235, .12), transparent 28%),
        radial-gradient(circle at 94% 14%, rgba(15, 159, 143, .10), transparent 24%),
        var(--inv-bg);
}

.inventory-hero,
.inventory-shell {
    width: min(1480px, calc(100% - 36px));
    margin-inline: auto;
}

.inventory-hero {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 24px;
    padding: 28px 0 20px;
}

.inventory-eyebrow {
    display: block;
    color: var(--inv-blue);
    font-size: .76rem;
    font-weight: 900;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.inventory-hero h1 {
    margin: 5px 0;
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    letter-spacing: -.05em;
}

.inventory-hero p {
    max-width: 720px;
    margin: 0;
    color: var(--inv-muted);
    font-weight: 600;
}

.inventory-hero-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    gap: 9px;
}

.inventory-hero-kpis article {
    min-width: 120px;
    padding: 13px 15px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 16px;
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 14px 35px rgba(15, 39, 71, .08);
}

.inventory-hero-kpis span,
.report-kpis span {
    display: block;
    color: var(--inv-muted);
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.inventory-hero-kpis strong {
    display: block;
    margin-top: 5px;
    font-size: 1.35rem;
}

.inventory-shell { padding-bottom: 36px; }

.inventory-tabs {
    position: sticky;
    top: 8px;
    z-index: 20;
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    padding: 7px;
    overflow-x: auto;
    border: 1px solid rgba(148, 163, 184, .24);
    border-radius: 18px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 12px 32px rgba(15, 39, 71, .08);
    backdrop-filter: blur(16px);
}

.inventory-tabs button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 43px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    color: #415168;
    background: transparent;
    cursor: pointer;
    font-weight: 900;
    white-space: nowrap;
}

.inventory-tabs button.active {
    color: #fff;
    background: linear-gradient(135deg, var(--inv-navy), var(--inv-blue));
}

.inventory-panel { display: none; }
.inventory-panel.active { display: grid; gap: 16px; }
.inventory-two-col { display: grid; grid-template-columns: .8fr 1.2fr; gap: 16px; }

.inventory-card {
    padding: 21px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 22px;
    background: rgba(255, 255, 255, .91);
    box-shadow: 0 20px 50px rgba(15, 39, 71, .08);
}

.inventory-card-head {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.inventory-card-head.inline {
    justify-content: space-between;
    align-items: start;
}

.inventory-card h2,
.inventory-card h3,
.inventory-card p { margin: 0; }
.inventory-card h2 { font-size: 1.25rem; }
.inventory-card-head p { margin-top: 4px; color: var(--inv-muted); font-weight: 600; line-height: 1.45; }

.step {
    float: left;
    margin-right: 10px;
    color: var(--inv-blue);
    font-size: .76rem;
    font-weight: 900;
}

.inventory-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.inventory-form.compact { grid-template-columns: 1fr; }
.inventory-form label { display: grid; gap: 6px; color: #384860; font-size: .78rem; font-weight: 900; }
.inventory-form input,
.inventory-form select,
.inventory-form textarea,
.report-filters input,
.line-table input,
.line-table select {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--inv-line);
    border-radius: 11px;
    color: var(--inv-ink);
    background: #fff;
    font: inherit;
}

.inventory-form textarea { resize: vertical; }
.span-all { grid-column: 1 / -1; }

.inv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 900;
}

.inv-btn.primary { color: #fff; background: linear-gradient(135deg, var(--inv-navy), var(--inv-blue)); }
.inv-btn.accent { color: #fff; background: linear-gradient(135deg, #b45309, var(--inv-gold)); }
.inv-btn.secondary { color: #334155; border-color: #cbd5e1; background: #fff; }
.inv-btn.small { min-height: 35px; padding-inline: 11px; font-size: .78rem; }
.inventory-form + .inv-btn { margin-top: 14px; }

.inventory-table-wrap {
    overflow: auto;
    border: 1px solid var(--inv-line);
    border-radius: 15px;
}

.inventory-table-wrap table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
    background: #fff;
}

.inventory-table-wrap th,
.inventory-table-wrap td {
    padding: 10px 11px;
    border-bottom: 1px solid #e7edf4;
    text-align: left;
    vertical-align: middle;
}

.inventory-table-wrap th {
    color: #4b5e76;
    background: #f7f9fc;
    font-size: .72rem;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.stock-pill,
.document-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    color: #047857;
    background: #d1fae5;
    font-size: .72rem;
    font-weight: 900;
}

.stock-pill.low { color: #b45309; background: #fef3c7; }
.stock-pill.out { color: #be123c; background: #ffe4e6; }
.document-badge { align-self: flex-start; color: #1d4ed8; background: #dbeafe; }
.document-badge.sales { color: #047857; background: #d1fae5; }

.line-editor { margin-top: 20px; }
.line-editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.line-table { min-width: 1120px !important; }
.line-table td { padding: 7px; }
.line-table select { min-width: 190px; }
.line-table .number { min-width: 90px; }
.line-table .remove-line {
    width: 34px;
    height: 34px;
    border: 1px solid #fecdd3;
    border-radius: 9px;
    color: #be123c;
    background: #fff1f2;
    cursor: pointer;
}

.stock-rule {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 9px !important;
    color: #0369a1;
    font-size: .82rem;
    font-weight: 800;
}

.document-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 13px;
    color: var(--inv-muted);
    font-weight: 900;
}

.document-total strong { color: var(--inv-navy); font-size: 1.5rem; }
.document-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }

.report-head { gap: 18px; }
.report-filters { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.report-filters input,
.report-filters select { width: auto; min-width: 145px; }

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 10px;
    color: #047857;
    font-size: .76rem;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.live-indicator i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 5px #d1fae5;
}

.live-indicator small {
    color: var(--inv-muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}

.report-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 11px;
    margin: 18px 0;
}

.report-kpis article {
    position: relative;
    overflow: hidden;
    padding: 15px;
    border: 1px solid var(--inv-line);
    border-radius: 16px;
    background: linear-gradient(145deg, #fff, #f6f9fc);
}

.report-kpis article::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    content: "";
    background: #94a3b8;
}

.report-kpis article.purchase::before { background: #f59e0b; }
.report-kpis article.sale::before { background: #0ea5e9; }
.report-kpis article.profit::before { background: #10b981; }
.report-kpis article.balance::before { background: #7c3aed; }
.report-kpis strong { display: block; margin: 7px 0 3px; font-size: 1.45rem; }
.report-kpis small { color: var(--inv-muted); font-weight: 700; }
.report-section { margin-top: 20px; }
.report-section h3 { margin-bottom: 9px; }

.report-view-tabs {
    display: flex;
    gap: 7px;
    padding: 6px;
    border: 1px solid var(--inv-line);
    border-radius: 14px;
    background: #f8fafc;
    overflow-x: auto;
}

.report-view-tabs button {
    padding: 9px 16px;
    border: 0;
    border-radius: 10px;
    color: #475569;
    background: transparent;
    font-weight: 850;
    white-space: nowrap;
    cursor: pointer;
}

.report-view-tabs button.active {
    color: #fff;
    background: var(--inv-navy);
    box-shadow: 0 6px 15px #0f27472b;
}

.report-view { display: none; }
.report-view.active { display: block; }
.report-overview-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 14px; }

.report-summary-card {
    padding: 17px;
    border: 1px solid var(--inv-line);
    border-radius: 16px;
    background: #fbfdff;
}

.movement-flow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 95px;
}

.movement-flow > div { min-width: 88px; text-align: center; }
.movement-flow span, .analysis-list span { display: block; color: var(--inv-muted); font-size: .75rem; font-weight: 800; }
.movement-flow strong { display: block; margin-top: 7px; color: var(--inv-navy); font-size: 1.25rem; }
.movement-flow .in strong { color: #047857; }
.movement-flow .out strong { color: #be123c; }
.movement-flow .close { padding: 11px; border-radius: 12px; background: #ede9fe; }
.movement-flow > i { color: #94a3b8; }

.analysis-list { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.analysis-list div { padding: 11px; border-radius: 11px; background: #f1f5f9; }
.analysis-list strong { display: block; margin-top: 5px; color: var(--inv-navy); }

.report-note { margin: -2px 0 12px; color: var(--inv-muted); font-size: .82rem; font-weight: 650; }
.activity-kind, .payment-pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: .7rem; font-weight: 900; }
.activity-kind.purchase { color: #92400e; background: #fef3c7; }
.activity-kind.sale { color: #075985; background: #e0f2fe; }
.payment-pill.paid { color: #047857; background: #d1fae5; }
.payment-pill.pending { color: #b45309; background: #fef3c7; }
.payment-pill.part-paid { color: #6d28d9; background: #ede9fe; }

.row-print {
    width: 34px;
    height: 34px;
    border: 1px solid #bfdbfe;
    border-radius: 9px;
    color: #1d4ed8;
    background: #eff6ff;
    cursor: pointer;
}

.inventory-empty { padding: 22px !important; color: var(--inv-muted); text-align: center !important; }
.inventory-print-sheet { display: none; }

@media print {
    body > *:not(.inventory-print-sheet) { display: none !important; }
    .inventory-print-sheet {
        display: block !important;
        color: #111827;
        background: #fff;
        font-family: Arial, sans-serif;
    }
    .print-document { padding: 12mm; }
    .print-header { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #0f2747; padding-bottom: 12px; }
    .print-header h1, .print-header p { margin: 0; }
    .print-meta, .print-party { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; margin: 18px 0; }
    .print-document table { width: 100%; border-collapse: collapse; }
    .print-document th, .print-document td { padding: 8px; border: 1px solid #cbd5e1; text-align: left; }
    .print-document th { background: #f1f5f9; }
    .print-totals { margin: 14px 0 0 auto; width: min(360px, 100%); }
    .print-totals div { display: flex; justify-content: space-between; padding: 6px 0; }
    .print-signatures { display: flex; justify-content: space-between; margin-top: 54px; }
}

@media (max-width: 900px) {
    .inventory-hero { align-items: stretch; flex-direction: column; }
    .inventory-two-col, .report-kpis { grid-template-columns: 1fr 1fr; }
    .report-overview-grid { grid-template-columns: 1fr; }
    .report-head { flex-direction: column; }
    .report-filters { justify-content: flex-start; }
}

@media (max-width: 620px) {
    .inventory-hero, .inventory-shell { width: min(100% - 20px, 1480px); }
    .inventory-hero-kpis, .inventory-two-col, .report-kpis { grid-template-columns: 1fr; }
    .inventory-card { padding: 15px; border-radius: 17px; }
    .inventory-card-head.inline { flex-direction: column; }
    .report-filters, .report-filters input, .report-filters select, .report-filters .inv-btn { width: 100%; }
    .movement-flow { align-items: stretch; flex-direction: column; }
    .movement-flow > i { transform: rotate(90deg); align-self: center; }
}
