:root {
  --bg: #f4f7f5;
  --card: #ffffff;
  --text: #173128;
  --muted: #6a7a73;
  --line: #dce6df;
  --primary: #12924c;
  --primary-2: #0d7c40;
  --soft: #eef8f1;
  --danger: #b83838;
  --shadow: 0 18px 45px rgba(18, 60, 39, 0.12);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #f8fff9 0%, var(--bg) 44%, #edf4ef 100%);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.9rem 1rem;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(18, 146, 76, 0.45);
  box-shadow: 0 0 0 4px rgba(18, 146, 76, 0.12);
}
textarea { resize: vertical; min-height: 90px; }
label { display: block; }
label span {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 0.55rem;
}
small, .muted { color: var(--muted); }
code {
  background: #f3f7f4;
  padding: 0.15rem 0.4rem;
  border-radius: 10px;
}
.card {
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.62);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 1.15rem;
}
.glassy {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.88));
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 18px;
  padding: 0.82rem 1rem;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
  font-weight: 700;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.01); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}
.btn-soft {
  background: var(--soft);
  color: var(--primary-2);
}
.btn-danger { background: #fff1f1; color: var(--danger); }
.btn-lg { min-height: 52px; }
.btn-sm { padding: 0.5rem 0.8rem; font-size: 0.88rem; border-radius: 14px; }
.badge {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #e3f6e9;
  color: var(--primary-2);
  font-size: 0.82rem;
  font-weight: 800;
}
.badge-soft { background: #f3f6f4; color: var(--muted); }
.eyebrow {
  margin: 0 0 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--primary-2);
  font-weight: 800;
}
.alert {
  margin: 1rem 0;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  font-weight: 700;
}
.alert.success { background: #e7f8ec; color: #17703d; }
.alert.error { background: #fff1f1; color: #a93f3f; }
.stack-lg > * + * { margin-top: 1rem; }
.section-gap { margin-top: 1.2rem; }
.grid-cards, .grid-2, .grid-3 {
  display: grid;
  gap: 1rem;
}
.grid-cards { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.compact-grid { gap: 0.85rem; }

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}
.login-card {
  width: min(100%, 520px);
  padding: 1.4rem;
}
.brand-mark {
  width: 100px;
  margin: 0 auto 0.9rem;
}
.text-center { text-align: center; }
.text-center h1 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.4rem); }
.quick-access {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 0.65rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
}
.sidebar {
  background: linear-gradient(180deg, #0d7c40 0%, #09562d 100%);
  color: #fff;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.sidebar-logo {
  width: 58px;
  background: rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 0.35rem;
}
.sidebar h2 { margin: 0; font-size: 1.2rem; }
.nav-list {
  display: grid;
  gap: 0.5rem;
}
.nav-link {
  padding: 0.9rem 1rem;
  border-radius: 16px;
  font-weight: 700;
  background: rgba(255,255,255,0.06);
}
.nav-link.active, .nav-link:hover {
  background: rgba(255,255,255,0.16);
}
.nav-link.danger { color: #ffd6d6; }
.sidebar-foot {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.18);
  display: grid;
  gap: 0.2rem;
  color: rgba(255,255,255,0.9);
}
.main-content {
  padding: 1rem;
}
.topbar {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.topbar h1 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.topbar-meta {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.stat-card h3 {
  margin: 0.2rem 0 0.35rem;
  font-size: clamp(1.5rem, 3.4vw, 2rem);
}
.stat-card.accent {
  background: linear-gradient(135deg, rgba(18,146,76,0.16), rgba(255,255,255,0.95));
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.section-head h2 { margin: 0; font-size: 1.15rem; }
.summary-stack { display: grid; gap: 0.8rem; }
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: #f7fbf8;
  border-radius: 18px;
}
.summary-row.total {
  background: linear-gradient(135deg, #e8f8ee, #f5fbf6);
}
.list-stack { display: grid; gap: 0.8rem; }
.list-item {
  display: grid;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.letters-layout { align-items: start; }
.preview-card { position: sticky; top: 1rem; }
.preview-sheet {
  border: 1px dashed var(--line);
  border-radius: 22px;
  padding: 1rem;
  background: #fafdfb;
}
.preview-header {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 1rem;
  align-items: center;
}
.preview-header img { width: 84px; }
.preview-title { text-align: center; display: grid; gap: 0.15rem; }
.preview-title strong { font-size: 1.2rem; }
.template-note { margin-top: 1rem; color: #355347; line-height: 1.65; }
.template-note ul { margin: 0.8rem 0 0; padding-left: 1.2rem; }
.signature-box {
  padding: 0.95rem;
  border-radius: 22px;
  background: #f8fbf9;
  border: 1px solid var(--line);
}
.signature-pad-wrap {
  padding: 0.8rem;
  border-radius: 18px;
  background: #fff;
  border: 1px dashed var(--line);
}
.signature-pad {
  width: 100%;
  height: 160px;
  display: block;
  background: repeating-linear-gradient(180deg, #fff 0, #fff 34px, #f7faf8 35px);
  border-radius: 12px;
  touch-action: none;
}
.signature-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  background: #fff;
}
th, td {
  padding: 0.88rem 0.95rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
thead th {
  background: #f3faf5;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.empty { text-align: center; color: var(--muted); }
.action-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.pill {
  display: inline-flex;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}
.pill.in { background: #e7f9ee; color: #13713c; }
.pill.out { background: #fff1f1; color: #b23f3f; }
.tabs {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.tab-link {
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: #eff7f1;
  color: var(--primary-2);
  font-weight: 800;
}
.tab-panel { padding-top: 0.2rem; }
.mini-card {
  padding: 1rem;
  border-radius: 20px;
  background: #f8fbf9;
  border: 1px solid var(--line);
}

.public-body { padding: 1rem; }
.public-shell { max-width: 1200px; margin: 0 auto; }
.public-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.public-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.public-brand img { width: 86px; }
.public-cards { margin-top: 1rem; }

.print-body {
  background: #dfe4e2;
  padding: 1rem;
}
.no-print { display: flex; }
.print-toolbar {
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.paper {
  width: min(100%, 850px);
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 16px 40px rgba(0,0,0,0.15);
  min-height: 1122px;
  padding: 58px 72px 42px;
  position: relative;
}
.letterhead {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1rem;
  align-items: start;
}
.logo-zone img { width: 106px; }
.org-zone { text-align: center; }
.org-line {
  font-weight: 800;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  line-height: 1.12;
}
.org-line:nth-child(2), .org-line:nth-child(3) { font-size: 1.15rem; }
.org-sub {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.92rem;
  margin-top: 0.15rem;
}
.letter-meta-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  margin-top: 1.1rem;
  font-family: Georgia, "Times New Roman", serif;
}
.meta-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  margin-bottom: 0.2rem;
  align-items: start;
}
.meta-row strong, .meta-right { font-weight: 600; }
.meta-subject strong { font-weight: 800; }
.meta-right {
  text-align: right;
  line-height: 1.5;
}
.letter-section {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.06rem;
  line-height: 1.52;
}
.recipients-section { margin-top: 1.3rem; }
.recipient-line { margin-bottom: 0.2rem; }
.recipient-line.indent { padding-left: 1.15rem; font-weight: 700; }
.di-line { margin-top: 0.8rem; }
.paragraph { margin-top: 1rem; }
.paragraph p { margin: 0 0 1rem; text-align: justify; }
.event-table {
  margin: 0.5rem auto 1rem 70px;
  border-collapse: collapse;
  font-family: Georgia, "Times New Roman", serif;
}
.event-table td {
  border: none;
  padding: 0.05rem 0.45rem 0.05rem 0;
}
.italic-tight { font-style: italic; line-height: 1.5; }
.signature-panel {
  margin-top: 4rem;
  font-family: Georgia, "Times New Roman", serif;
}
.org-sign-title {
  text-align: center;
  font-weight: 800;
  margin-bottom: 1rem;
}
.signature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
  align-items: end;
}
.sign-col { text-align: center; }
.sign-position { font-weight: 700; margin-bottom: 0.5rem; }
.sign-image-wrap {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.signature-image {
  max-height: 96px;
  max-width: 180px;
  object-fit: contain;
}
.sign-name {
  display: inline-block;
  border-top: 1px solid #000;
  padding-top: 0.3rem;
  min-width: 180px;
}
.tembusan-block {
  margin-top: 2rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
}
.letter-footer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
}
.footer-social {
  margin-left: 62px;
  margin-bottom: 12px;
  color: #1b5f39;
  font-weight: 700;
  font-size: 0.92rem;
}
.footer-web {
  justify-self: start;
  margin-bottom: 12px;
  background: #1e9e53;
  color: #fff;
  padding: 0.25rem 0.8rem;
  border-radius: 0;
  font-weight: 700;
}
.footer-shape {
  justify-self: stretch;
  height: 14px;
  background: linear-gradient(135deg, transparent 0 28%, #78d393 28% 52%, #31b765 52% 72%, #10984d 72%);
}
.lpj-head {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}
.lpj-head img { width: 88px; }
.lpj-head h1, .lpj-head h2 { margin: 0; }
.lpj-head p { margin: 0.35rem 0 0; color: #334; }
.lpj-summary {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.lpj-signature {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 2rem;
}
.sign-space { height: 90px; }

@media (min-width: 760px) {
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1080px) {
  .app-shell { grid-template-columns: 290px 1fr; }
  .main-content { padding: 1.2rem 1.2rem 2rem; }
  .grid-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .paper {
    padding: 34px 22px 80px;
    min-height: auto;
  }
  .letterhead {
    grid-template-columns: 74px 1fr;
  }
  .logo-zone img { width: 70px; }
  .org-line { font-size: 0.95rem; }
  .org-line:nth-child(2), .org-line:nth-child(3) { font-size: 1rem; }
  .org-sub { font-size: 0.78rem; }
  .letter-meta-grid {
    grid-template-columns: 1fr;
  }
  .meta-right { text-align: left; }
  .event-table { margin-left: 0; }
  .signature-grid { gap: 1rem; }
  .sign-name { min-width: 120px; }
  .letter-footer {
    grid-template-columns: 1fr;
    height: 48px;
  }
  .footer-social, .footer-web { display: none; }
  .footer-shape { height: 10px; }
}

@media print {
  body { background: #fff; padding: 0; }
  .no-print { display: none !important; }
  .paper {
    width: 100%;
    max-width: none;
    min-height: auto;
    box-shadow: none;
    margin: 0;
    page-break-after: always;
  }
  @page {
    size: A4;
    margin: 0;
  }
}
