:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #64707d;
  --border: #e1e6eb;
  --primary: #0f766e;
  --primary-dark: #0b5d57;
  --primary-soft: #e6f4f2;
  --danger: #c2410c;
  --danger-soft: #fff1ea;
  --xls: #15803d;
  --doc: #1d4ed8;
  --pdf: #b91c1c;
  --csv: #0e7490;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── Kerangka ─────────────────────────────────────────── */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; min-height: 58px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a, .account a { color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover, .account a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); }
.account { display: flex; align-items: center; gap: 6px; }
.account form { margin: 0; }
.who { display: flex; align-items: center; gap: 8px; margin-right: 6px; }
.who-name { font-weight: 600; }
.link-btn { background: none; border: 0; font: inherit; color: var(--muted); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.link-btn:hover { background: var(--bg); color: var(--danger); }

.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.crumbs { margin: 0 0 12px; font-size: 0.9rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card.narrow { max-width: 560px; }
.card-title { margin-bottom: 14px; }
.card.empty { text-align: center; padding: 48px 20px; }
.card.empty p { margin: 8px 0 0; }
.card.empty .btn { margin-top: 12px; }
.table-card { padding: 0; overflow: hidden; }
.danger-zone { border-color: #f5c9b3; }

/* ── Tombol & form ────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f2c4ad; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }

label { display: block; font-weight: 500; font-size: 0.9rem; }
input[type=text], input[type=password], input[type=search], select {
  display: block; width: 100%; margin-top: 6px; padding: 9px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid #cfd6dd; border-radius: 8px;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.stack > * + * { margin-top: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-form { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 12px; align-items: end; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; font-size: 0.92rem; }
.alert-success { background: #ecfdf3; border-color: #abefc6; color: #05603a; }
.alert-error { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.alert-warning { background: #fffaeb; border-color: #fedf89; color: #93370d; }
.note { background: #fffaeb; border: 1px solid #fedf89; color: #93370d; padding: 8px 12px; border-radius: 8px; font-size: 0.88rem; margin: 0 0 10px; }

/* ── Login ────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-page > .alert { width: 100%; max-width: 380px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px; box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06); }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { margin-top: 10px; font-size: 1.4rem; }
.auth-brand p { margin: 4px 0 0; }
.auth-card .stack { margin-bottom: 16px; }

/* ── Daftar berkas ────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.stat-num { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-xls { background: var(--xls); } .dot-doc { background: var(--doc); } .dot-pdf { background: var(--pdf); }

.filters { display: grid; grid-template-columns: 1fr 150px 170px 160px auto auto; gap: 10px; padding: 14px; align-items: center; }
.filters input, .filters select { margin-top: 0; }
.result-count { margin: 0 0 8px; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; background: #f9fafb; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table tr.inactive td { opacity: 0.55; }
.actions-col { text-align: right; width: 1%; white-space: nowrap; }
.actions-col .row-actions { justify-content: flex-end; flex-wrap: nowrap; }

.file-link { display: flex; align-items: center; gap: 12px; color: var(--text); min-width: 0; }
.file-link:hover { text-decoration: none; }
.file-link:hover .file-title { color: var(--primary); text-decoration: underline; }
.file-name { display: flex; flex-direction: column; min-width: 0; }
.file-title { font-weight: 600; word-break: break-word; }
.file-desc { color: var(--muted); font-size: 0.85rem; }
.file-meta-sm { display: none; color: var(--muted); font-size: 0.8rem; }

.badge { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 26px; padding: 0 6px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; color: #fff; }
.badge-xls { background: var(--xls); } .badge-doc { background: var(--doc); } .badge-pdf { background: var(--pdf); } .badge-csv { background: var(--csv); } .badge-other { background: var(--muted); }
.badge-lg { min-width: 56px; height: 56px; font-size: 0.85rem; border-radius: 10px; }
.chip { display: inline-block; white-space: nowrap; padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--text); font-size: 0.82rem; }
.chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.role { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.role-admin { background: #f3e8ff; color: #6b21a8; }
.role-gudang { background: var(--primary-soft); color: var(--primary-dark); }
.role-viewer { background: #eef2f6; color: #475467; }
.role-legend { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; }

/* ── Upload ───────────────────────────────────────────── */
.dropzone { position: relative; border: 2px dashed #c4cdd5; border-radius: var(--radius); padding: 40px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; background: #fafbfc; transition: border-color 0.15s, background 0.15s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-ico { width: 36px; height: 36px; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 6px; }
.picked { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 8px; }
.picked li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.picked li:last-child { border-bottom: 0; }
.picked .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked li.bad { background: #fef3f2; color: #b42318; }
.progress { display: flex; align-items: center; gap: 12px; }
.progress-bar { flex: 1; height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }

/* ── Pratinjau ────────────────────────────────────────── */
.file-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.file-head-main { display: flex; gap: 16px; align-items: flex-start; min-width: 0; flex: 1; }
.file-head-title { font-size: 1.25rem; word-break: break-word; }
.file-head-desc { margin: 4px 0 0; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 10px 0 0; font-size: 0.88rem; }
.meta div { display: flex; gap: 6px; align-items: center; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.viewer { margin-top: 4px; }
.pdf-frame { width: 100%; height: 80vh; min-height: 480px; border: 1px solid var(--border); border-radius: var(--radius); background: #525659; display: block; }
.viewer > .muted { margin-top: 8px; }

.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; font: inherit; font-size: 0.9rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--xls); border-bottom-color: var(--xls); font-weight: 600; }
.sheet-scroll { width: fit-content; max-width: 100%; overflow: auto; max-height: 75vh; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.grid { border-collapse: collapse; font-size: 0.85rem; }
.grid th, .grid td { border: 1px solid #e3e7eb; padding: 4px 8px; }
.grid td { white-space: pre-wrap; max-width: 360px; vertical-align: top; }
.grid td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid thead th { position: sticky; top: 0; background: #f3f5f7; color: var(--muted); font-weight: 600; z-index: 2; text-align: center; min-width: 60px; }
.grid tbody th { position: sticky; left: 0; background: #f3f5f7; color: var(--muted); font-weight: 500; text-align: right; z-index: 1; }
.grid .corner { left: 0; z-index: 3; min-width: 44px; }

.paper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); max-width: 860px; margin: 0 auto; padding: 48px 56px; overflow-x: auto; }
.paper img { max-width: 100%; height: auto; }
.paper table { border-collapse: collapse; margin: 12px 0; }
.paper td, .paper th { border: 1px solid #cfd6dd; padding: 4px 8px; vertical-align: top; }
.paper h1 { font-size: 1.5rem; margin: 18px 0 10px; }
.paper h2 { font-size: 1.25rem; margin: 16px 0 8px; }
.viewer > .paper + .muted { text-align: center; }

/* ── Layar kecil ──────────────────────────────────────── */
@media (max-width: 960px) {
  .hide-md { display: none; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input[type=search] { grid-column: 1 / -1; }
  .grid-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .file-meta-sm { display: block; }
  .container { padding: 16px 12px 40px; }
  .topbar-inner { padding: 8px 12px; gap: 8px 12px; }
  .topbar { position: static; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; }
  .who { display: none; }
  .account a, .link-btn { padding: 6px 8px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-num { font-size: 1.15rem; }
  .stats .stat:first-child { grid-column: 1 / -1; }
  .grid-2, .grid-form { grid-template-columns: 1fr; }
  .table td, .table th { padding: 10px; }
  .paper { padding: 24px 18px; }
  .file-head .row-actions { width: 100%; }
}
