/* ==========================================================================
   Klasifikasi Barang
   Gaya sederhana: satu kolom, kartu bergaris tipis, tanpa hiasan berlebih.
   ========================================================================== */

:root {
    --bg: #f2f3f5;
    --card: #fff;
    --line: #d6d9de;
    --line-soft: #e8eaed;
    --head: #eef0f3;
    --text: #202124;
    --muted: #4b5563;
    --primary: #1d4ed8;
    --primary-dark: #1a45bb;
    --primary-wash: #eef3fd;
    --danger: #b42318;
    --ok: #1b7a43;
    --radius: 4px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

h1,
h2,
h3 {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: bold;
}

h1 {
    font-size: 20px;
}

p {
    margin: 0 0 10px;
}

a {
    color: var(--primary);
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

a[href],
button,
summary,
select,
label[for],
input[type="checkbox"],
input[type="file"] {
    cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

img {
    max-width: 100%;
}

/* Header dan navigasi */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 12px;
}

.brand {
    padding: 13px 0;
    font-weight: bold;
    color: var(--text);
    text-decoration: none;
    margin-right: 8px;
    white-space: nowrap;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0 2px;
}

.nav-link {
    padding: 15px 10px 13px;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.nav-link:hover {
    color: var(--text);
    background: var(--line-soft);
}

.nav-link.is-active {
    color: var(--primary);
    font-weight: bold;
    border-bottom-color: var(--primary);
    background: transparent;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    padding: 8px 0;
    font-size: 13px;
    color: var(--muted);
}

.topbar-user form {
    margin: 0;
}

.topbar-role {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0 6px;
    font-size: 12px;
}

/* Konten */

.content {
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 16px 44px;
}

.page-title {
    margin-bottom: 2px;
    font-size: 19px;
}

.page-subtitle {
    margin-bottom: 18px;
    color: var(--muted);
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    margin: 0;
    font-size: 15px;
}

.panel-edit {
    border-color: var(--primary);
}

.stat-band-compact .stat-value {
    font-size: 18px;
}

.panel-tag {
    font-size: 12px;
    color: var(--muted);
}

.panel-note {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.panel-head-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.action-note {
    margin: -2px 0 16px;
    font-size: 12px;
    color: var(--muted);
}

/* Ringkasan angka */

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

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.stat-value {
    display: block;
    font-size: 22px;
    font-weight: bold;
}

.stat-value-text {
    font-size: 16px;
}

.stat-meta {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.stat-divider {
    margin: 0 2px;
    color: var(--muted);
}

/* Dua kolom ringkas */

.dashboard-main,
.risk-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.dashboard-main .panel,
.risk-grid .panel {
    margin-bottom: 0;
}

.dashboard-main,
.risk-grid {
    margin-bottom: 16px;
}

.model-score-label,
.model-score-meta {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.simulation-value {
    display: block;
    font-size: 28px;
    font-weight: bold;
}

.metric-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin: 0;
    min-width: 180px;
}

.metric-list dt {
    font-size: 12px;
    color: var(--muted);
}

.metric-list dd {
    margin: 0;
    font-weight: bold;
}

.simulation-result {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.simulation-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

/* Tabel */

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

.table-wrap:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.data-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
    font-size: 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.matrix-table caption {
    text-align: left;
    font-size: 12px;
    font-weight: bold;
    color: var(--muted);
    padding: 8px 10px;
    background: #fafbfc;
    border-bottom: 1px solid var(--line);
}

/* Judul panel sudah menyebut periode, jadi caption tabel data cukup untuk pembaca layar. */
.data-table caption {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

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

.data-table thead th {
    background: var(--head);
    border-bottom: 1px solid var(--line);
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}

.data-table thead th:first-child {
    border-top-left-radius: var(--radius);
}

.data-table thead th:last-child {
    border-top-right-radius: var(--radius);
}

.data-table tbody tr:nth-child(even) {
    background: #fbfbfc;
}

.data-table tbody tr:hover {
    background: var(--primary-wash);
}

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

.align-right {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-code {
    font-family: Consolas, monospace;
    font-size: 12px;
    color: #374151;
    white-space: nowrap;
}

.cell-strong {
    display: block;
    font-weight: bold;
    line-height: 1.35;
}

.cell-sub,
.cell-note {
    display: block;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.35;
}

.cell-note {
    max-width: 210px;
}

.cell-negative {
    color: var(--danger);
    font-weight: bold;
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.matrix-table th,
.matrix-table td {
    border-bottom: 1px solid var(--line-soft);
    padding: 7px 12px;
    text-align: left;
}

.matrix-table thead th {
    background: var(--head);
    border-bottom: 1px solid var(--line);
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.matrix-table tbody th {
    background: #fbfbfc;
    font-weight: bold;
    width: 1%;
    white-space: nowrap;
}

.matrix-table tbody td {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Metrik evaluasi: pasangan label-nilai ringkas, bukan tabel lebar. */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0 24px;
    margin: 0 0 14px;
    padding: 0;
}

.metric-grid > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13px;
}

.metric-grid > div:last-child,
.metric-grid > div:nth-last-child(2):nth-child(odd) {
    border-bottom: 0;
}

.metric-grid dt {
    color: var(--muted);
}

.metric-grid dd {
    margin: 0;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.metric-caption {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: bold;
    color: var(--muted);
}

.row-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.row-actions form {
    margin: 0;
}

.prob-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.prob-cell progress {
    width: 64px;
    flex: none;
}

.prob-cell span {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* Indikator sederhana */

progress {
    appearance: none;
    -webkit-appearance: none;
    height: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #eee;
    overflow: hidden;
}

progress::-webkit-progress-bar {
    background: #eee;
}

progress::-webkit-progress-value {
    background: var(--primary);
}

progress::-moz-progress-bar {
    background: var(--primary);
}

.importance-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.importance-list li {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) 48px;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 13px;
}

.importance-value {
    text-align: right;
    color: var(--muted);
}

.risk-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.risk-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

.risk-list li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

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

.risk-code,
.risk-prob {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.risk-figure {
    text-align: right;
    white-space: nowrap;
}

/* Form */

.form {
    margin: 0;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.field-wide {
    grid-column: 1 / -1;
}

.field label {
    font-size: 13px;
    font-weight: bold;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="month"],
input[type="file"],
select {
    width: 100%;
    min-height: 34px;
    padding: 4px 8px;
    font: inherit;
    border: 1px solid #b9b9b9;
    border-radius: var(--radius);
    background: #fff;
}

input[type="file"] {
    padding: 3px 4px;
}

.field-help {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.check-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.form-status {
    font-size: 12px;
    color: var(--muted);
}

.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-bar .field {
    flex: 1 1 180px;
}

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

.action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.action-row form {
    margin: 0;
}

.action-row-inline {
    align-items: center;
    margin-top: 12px;
}

.calc-line {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

.calc-line strong {
    color: var(--text);
}

.calc-sep {
    margin: 0 6px;
}

.drawer {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 10px;
}

.drawer > summary {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: bold;
    list-style: none;
}

.drawer > summary::-webkit-details-marker {
    display: none;
}

.drawer > summary::after {
    content: "+";
    margin-left: 6px;
}

.drawer[open] > summary::after {
    content: "\2212";
}

.drawer[open] > summary {
    border-bottom: 1px solid var(--line);
}

.drawer > .form,
.drawer > .param-list {
    padding: 12px;
}

.param-list {
    margin: 0;
}

.param-list > div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 0;
    font-size: 12px;
    border-bottom: 1px dashed var(--line);
}

.param-list dt {
    color: var(--muted);
}

.param-list dd {
    margin: 0;
    font-weight: bold;
}

/* Tombol dan lencana */

.btn {
    display: inline-block;
    min-height: 34px;
    padding: 6px 12px;
    font: inherit;
    font-size: 13px;
    border: 1px solid #b9b9b9;
    border-radius: var(--radius);
    background: #f0f0f0;
    color: var(--text);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
}

.btn:hover {
    background: #e4e4e4;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

.btn-secondary {
    background: #fff;
}

.btn-secondary:hover {
    background: #f0f0f0;
}

.btn-quiet {
    background: transparent;
    border-color: transparent;
    color: var(--primary);
}

.btn-quiet:hover {
    background: #eef2f7;
    color: var(--primary);
}

.btn-danger {
    border-color: var(--danger);
    color: var(--danger);
    background: #fff;
}

.btn-danger:hover {
    background: #f7e9e7;
}

.btn-small {
    min-height: 30px;
    padding: 3px 8px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
}

.badge {
    display: inline-block;
    padding: 1px 6px;
    font-size: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f0f0f0;
}

.badge-laku {
    background: #e8f3ec;
    border-color: #c2ddcb;
    color: var(--ok);
}

.badge-neutral {
    background: #f0f0f0;
    border-color: var(--line);
    color: #444;
}

.badge-tidak {
    background: #f7e9e7;
    border-color: #e0c3bd;
    color: var(--danger);
}

/* Peringatan */

.alert {
    padding: 8px 12px;
    margin-bottom: 14px;
    font-size: 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.alert p {
    margin: 0 0 4px;
}

.alert p:last-child {
    margin: 0;
}

.alert-success {
    background: #e8f3ec;
    border-color: #c2ddcb;
    color: #1d5232;
}

.alert-error {
    background: #f7e9e7;
    border-color: #e0c3bd;
    color: #7a2419;
}

.alert-warning {
    background: #fdf6e3;
    border-color: #e6d9ae;
    color: #6b5410;
}

/* Empty state */

.empty-state {
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: #fafafa;
}

.empty-state h3 {
    margin-bottom: 4px;
    color: var(--text);
}

.empty-state .btn {
    margin-top: 6px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
}

/* Login dan halaman error */

.login-wrap {
    max-width: 340px;
    margin: 0 auto;
    padding: 60px 16px;
}

.login-brand {
    margin-bottom: 0;
}

.login-sub {
    margin-bottom: 20px;
    color: var(--muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.error-page {
    max-width: 480px;
    margin: 0 auto;
    padding: 60px 16px;
}

.error-page h1 {
    font-size: 18px;
}

/* Cetak */

.body-print {
    background: #fff;
}

.print-page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.print-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--text);
}

.print-company {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.print-period {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

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

.print-summary {
    font-size: 13px;
    padding: 10px;
    margin-bottom: 12px;
    background: #f7f7f7;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.print-table {
    min-width: 0;
    font-size: 12px;
}

.print-foot {
    margin-top: 14px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    color: var(--muted);
}

@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .print-page {
        max-width: none;
        padding: 0;
    }

    .print-table thead th {
        background: #eee;
    }

    .print-table tr {
        break-inside: avoid;
    }
}

/* Layar kecil */

@media (max-width: 900px) {
    .stat-band {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-main,
    .risk-grid,
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .topbar-inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 6px 10px;
    }

    .nav {
        grid-column: 1 / -1;
        gap: 2px 14px;
        padding-top: 2px;
    }

    .topbar-user {
        margin-left: 0;
        justify-self: end;
    }

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

    .filter-bar .field {
        flex: 0 0 auto;
    }

    .filter-actions .btn {
        flex: 1;
    }

    .importance-list li {
        grid-template-columns: minmax(0, 1fr) 48px;
        grid-template-rows: auto auto;
    }

    .importance-list progress {
        grid-column: 1 / -1;
    }

    .data-table {
        min-width: 760px;
    }

    .data-table th,
    .data-table td {
        padding: 7px 10px;
    }

    /* Di layar sempit, nama barang jangan dipotong jadi banyak baris;
       tabel tetap bisa digeser ke samping. */
    .data-table .cell-strong,
    .data-table .cell-sub {
        white-space: nowrap;
    }
}

@media (max-width: 420px) {
    .topbar-user span:first-child {
        display: none;
    }

    .stat-band {
        gap: 8px;
    }

    .stat-value {
        font-size: 18px;
    }
}
