:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --bg: #f5f6f7;
  --panel: #ffffff;
  --text: #1d2125;
  --muted: #5f6770;
  --border: #d5d9dd;
  --border-light: #e7e9ec;
  --accent: #17663f;
  --accent-hover: #10512f;
  --accent-light: #eaf3ee;
  --ok: #17663f;
  --ok-bg: #eaf3ee;
  --bad: #b42318;
  --bad-bg: #fdeceb;
  --warn: #855400;
  --warn-bg: #fff5d9;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 14px;
}

p {
  margin: 0;
}

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

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- header ---------- */

.demo-bar {
  padding: 6px 24px;
  background: var(--warn-bg);
  border-bottom: 1px solid #ecd28f;
  color: var(--warn);
  font-size: 13px;
  text-align: center;
}

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: stretch;
  gap: 28px;
  max-width: 1280px;
  min-height: 52px;
  margin: 0 auto;
  padding: 0 24px;
}

.app-name {
  display: flex;
  align-items: baseline;
  align-self: center;
  gap: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.app-name small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.nav {
  display: flex;
  gap: 2px;
}

.nav a {
  display: flex;
  align-items: center;
  margin-bottom: -1px;
  padding: 0 10px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--text);
}

.nav a.active {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  font-size: 13px;
  white-space: nowrap;
}

/* ---------- halaman ---------- */

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.page.narrow {
  max-width: 880px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-header p {
  margin-top: 4px;
  color: var(--muted);
}

.page-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.panel-body {
  padding: 16px;
}

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
}

.panel-toolbar .input {
  flex: 1 1 260px;
  max-width: 360px;
}

.panel-toolbar .select {
  width: auto;
  min-width: 200px;
}

.note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- form ---------- */

.field {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.field > label,
.label {
  font-size: 13px;
  font-weight: 600;
}

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

.input,
.select {
  width: 100%;
  height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input[type="file"].input {
  height: auto;
  padding: 5px;
}

.input:focus,
.select:focus {
  border-color: var(--accent);
  outline: 2px solid #b9d6c5;
  outline-offset: 0;
}

.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.choice input {
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  background: #f1f3f4;
}

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

.btn-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.btn-danger {
  color: var(--bad);
}

.btn-danger:hover {
  border-color: #efb3ac;
  background: var(--bad-bg);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.filebox {
  position: relative;
  display: block;
  padding: 16px;
  border: 1px dashed #b9bfc5;
  border-radius: 4px;
  background: #fafbfb;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.filebox strong {
  color: var(--accent);
  font-weight: 600;
}

.filebox:hover,
.filebox.dragging {
  border-color: var(--accent);
  background: var(--accent-light);
}

.filebox input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: #fafbfb;
}

.file-line strong {
  overflow-wrap: anywhere;
}

.notice {
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: #f6f7f8;
  font-size: 13px;
}

.notice.ok {
  border-color: #c3dccd;
  background: var(--ok-bg);
  color: var(--ok);
}

.notice.error {
  border-color: #f2c4bf;
  background: var(--bad-bg);
  color: var(--bad);
}

.notice.warn {
  border-color: #ecd28f;
  background: var(--warn-bg);
  color: var(--warn);
}

.panel-body > .notice {
  margin-top: 12px;
}

dl.details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  margin: 12px 0;
}

dl.details dt {
  color: var(--muted);
}

dl.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* ---------- bubuhkan ---------- */

.stamp-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.preview {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #e9ebed;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  font-size: 13px;
}

.preview-empty {
  padding: 120px 20px;
  color: var(--muted);
  text-align: center;
}

.preview-canvas {
  display: flex;
  justify-content: center;
  overflow: auto;
  padding: 20px;
}

.page-wrap {
  position: relative;
  line-height: 0;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 10%), 0 1px 3px rgb(0 0 0 / 12%);
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

#page-canvas {
  display: block;
  background: #fff;
}

.stamp-ghost {
  position: absolute;
  outline: 1px dashed var(--accent);
  outline-offset: 2px;
  pointer-events: none;
}

.stamp-ghost img {
  display: block;
  width: 100%;
}

/* ---------- tabel ---------- */

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  vertical-align: top;
}

th {
  background: #fafbfb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

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

td.actions {
  white-space: nowrap;
  text-align: right;
}

td.actions .btn + .btn {
  margin-left: 4px;
}

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

td a.mono {
  white-space: nowrap;
}

td.empty {
  padding: 32px 12px;
  color: var(--muted);
  text-align: center;
}

.status {
  font-weight: 600;
  white-space: nowrap;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warn);
}

.status.bad {
  color: var(--bad);
}

.status.off {
  color: var(--muted);
}

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.summary div {
  flex: 1 1 150px;
  padding: 10px 16px;
  border-right: 1px solid var(--border-light);
}

.summary div:last-child {
  border-right: 0;
}

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

.summary strong {
  font-size: 18px;
  font-weight: 600;
}

/* ---------- laporan verifikasi ---------- */

.verify-col {
  display: grid;
  gap: 16px;
  max-width: 880px;
}

.report {
  border-left: 4px solid var(--muted);
}

.report.ok {
  border-left-color: var(--ok);
}

.report.bad {
  border-left-color: var(--bad);
}

.report.warn {
  border-left-color: #c58a00;
}

.report-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}

.report-head h2 {
  margin-top: 2px;
  font-size: 17px;
}

.report-head p {
  margin-top: 2px;
  color: var(--muted);
}

.report-status {
  font-size: 12px;
  font-weight: 700;
}

.report.ok .report-status {
  color: var(--ok);
}

.report.bad .report-status {
  color: var(--bad);
}

.report.warn .report-status {
  color: var(--warn);
}

.report-file {
  color: var(--muted);
  font-size: 13px;
}

.report .notice {
  margin: 12px 16px 0;
}

.report-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
}

.report-cols > section {
  padding: 14px 16px;
}

.report-cols > section + section {
  border-left: 1px solid var(--border-light);
}

.report-cols dl.details {
  margin: 8px 0 0;
}

.checks {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.checks li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
}

.checks li:last-child {
  border-bottom: 0;
}

.checks .mark {
  font-weight: 700;
}

.checks li.ok .mark {
  color: var(--ok);
}

.checks li.bad .mark {
  color: var(--bad);
}

.checks small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.report-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border-light);
  color: var(--muted);
  font-size: 13px;
}

/* ---------- dialog & notifikasi ---------- */

dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  box-shadow: 0 10px 30px rgb(0 0 0 / 18%);
}

dialog::backdrop {
  background: rgb(0 0 0 / 35%);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.dialog-body {
  padding: 16px 16px 2px;
}

.dialog-body > p {
  margin-bottom: 14px;
}

.dialog-body .notice {
  margin-bottom: 14px;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  background: #fafbfb;
}

.close {
  padding: 0 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: 380px;
  padding: 8px 12px;
  border-radius: 4px;
  background: #2b3036;
  color: #fff;
  font-size: 13px;
}

.toast.error {
  background: var(--bad);
}

/* ---------- login ---------- */

.login {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
}

.login-box {
  width: min(360px, 100%);
}

.login-box h1 {
  margin-bottom: 4px;
}

.login-box > p {
  margin-bottom: 16px;
}

/* ---------- layar kecil ---------- */

@media (max-width: 900px) {
  .stamp-grid,
  .report-cols {
    grid-template-columns: minmax(0, 1fr);
  }

  .report-cols > section + section {
    border-top: 1px solid var(--border-light);
    border-left: 0;
  }

  .topbar-inner {
    flex-wrap: wrap;
    gap: 0 16px;
    padding: 0 16px;
  }

  .app-name {
    min-height: 44px;
  }

  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .nav a {
    padding: 10px;
  }

  .page {
    padding: 16px;
  }

  .demo-bar {
    padding: 6px 16px;
  }
}
