:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --ink: #1d1f24;
  --muted: #6b6f78;
  --line: #e4e1da;
  --brand: #1f4e79;
  --brand-ink: #ffffff;
  --brand-soft: #e6eef6;
  --red: #b3261e;
  --red-soft: #fbe9e7;
  --green: #2e7d32;
  --green-soft: #e7f3e8;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.01em; }
h3 { margin: 0 0 12px; font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.1; }
.logo {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; font-family: Georgia, serif;
}
.logo.big { width: 52px; height: 52px; font-size: 1.5rem; margin: 0 auto 10px; }
.logo-img { display: block; height: 36px; width: auto; max-width: 140px; object-fit: contain; }
.logo-img.big { height: 72px; max-width: 220px; margin: 0 auto 12px; }
.logo-preview { display: flex; align-items: center; justify-content: center; min-height: 96px; padding: 12px;
  border: 1px dashed #cfcbc2; border-radius: 8px; background: repeating-conic-gradient(#f4f2ee 0 25%, #fff 0 50%) 0 0 / 16px 16px; margin-bottom: 12px; }
.logo-preview img { max-height: 80px; max-width: 100%; }
.danger-card { border-color: #e3b9b5; }
.danger-card h3 { color: var(--red); }
.danger-card + .danger-card { margin-top: 0; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: 6px 12px; border-radius: 6px; color: var(--ink); }
.topbar nav a:hover { background: var(--bg); text-decoration: none; }
.topbar nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.me { display: flex; gap: 14px; font-size: .9rem; }

/* ---------- Layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px; }
.head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px;
}
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 440px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-2.wide-left { grid-template-columns: 2fr 1fr; }
.grid-2 > .card { margin-bottom: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 14px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  font: inherit; font-weight: 400; color: var(--ink); background: #fff;
  border: 1px solid #cfcbc2; border-radius: 7px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

.btn {
  display: inline-block; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid #cfcbc2; border-radius: 7px; background: #fff; color: var(--ink);
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--red); border-color: #e3b9b5; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn.full { width: 100%; padding: 11px; }
form.inline { display: inline; }
.btn.danger-text { color: var(--red); }
.btn.danger-text:hover { background: var(--red-soft); }
label > a.small { display: inline-block; margin-top: 6px; font-weight: 500; }
p.label { font-weight: 600; font-size: .88rem; margin: 4px 0 8px; }
label.check {
  display: flex; gap: 10px; align-items: flex-start; font-weight: 600; margin-bottom: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
label.check:hover { background: #faf9f6; }
label.check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
label.check small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
th.c, td.c { text-align: center; }
th.c { font-size: .7rem; max-width: 110px; }
.yes { color: var(--green); font-weight: 700; }
.no { color: #c8c4bb; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert.ok  { background: var(--green-soft); color: var(--green); }
.alert.err { background: var(--red-soft); color: var(--red); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600;
       background: var(--bg); color: var(--muted); vertical-align: middle; }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.blue { background: var(--brand-soft); color: var(--brand); }

/* ---------- Nomor surat ---------- */
.nomor { font-family: var(--mono); font-size: 1.35rem; font-weight: 700; color: var(--brand); word-break: break-all; margin: 6px 0 14px; }
.nomor.big { font-size: 2rem; }
.nomor b { color: var(--muted); }
.nomor .extra { background: #fff3c4; color: #7a5a00; border-radius: 4px; padding: 0 3px; }
.hero { text-align: center; padding: 30px 20px; border-top: 4px solid var(--brand); }
.hero.void .nomor { text-decoration: line-through; color: var(--muted); }
.preview { background: var(--brand-soft); border-color: #cddbe9; }

dl.info { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; }
.danger-zone { margin-top: 8px; }
.danger-zone form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat span { display: block; font-size: .82rem; color: var(--muted); }
.stat b { font-size: 1.6rem; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; }
.filters select, .filters input { width: auto; margin: 0; }
.filters input { flex: 1; min-width: 180px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #faf9f6; }
tbody tr:hover { background: #faf9f6; }
tbody tr:last-child td { border-bottom: 0; }
tr.void td { color: var(--muted); }
tr.void a.mono { text-decoration: line-through; color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); margin: 0; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; }

/* ---------- Login ---------- */
.login { min-height: 80vh; display: grid; place-items: center; }
.login .card { width: 100%; max-width: 380px; padding: 30px; }
.login-head { text-align: center; margin-bottom: 20px; }
.login-head p { margin: 2px 0 0; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .wrap { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .grid-2, .grid-2.wide-left, .row { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .nomor.big { font-size: 1.4rem; }
}
@media print {
  .topbar, .filters, .btn, .pager { display: none !important; }
  body { background: #fff; }
}
