/* ===========================================================
   E-Surat Usulan – tema aplikasi
   Warna diambil dari lambang Kalimantan Tengah: merah, hijau, emas
   =========================================================== */
:root {
  --brand: #0f7a4a;
  --brand-600: #0b6a3f;
  --brand-50: #e8f6ef;
  --accent: #c8102e;
  --gold: #f2b705;
  --ink: #16202b;
  --muted: #667085;
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e6e9ee;
  --sidebar: #0d2a1e;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 24px rgba(16, 24, 40, .06);
}
[data-bs-theme="dark"] {
  --bg: #0e1412;
  --card: #151d1a;
  --line: #24302b;
  --ink: #e7ece9;
  --muted: #98a6a0;
  --brand-50: #12291f;
  --sidebar: #08130e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .35);
}
html, body { background: var(--bg); color: var(--ink); }
body { font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: .925rem; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600); --bs-btn-active-bg: var(--brand-600); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); }
.text-brand { color: var(--brand) !important; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(15, 122, 74, .15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
a { color: var(--brand); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex: 0 0 260px; background: var(--sidebar);
  background-image: radial-gradient(120% 60% at 0% 0%, rgba(15, 122, 74, .55), transparent 60%),
                    radial-gradient(90% 50% at 100% 100%, rgba(200, 16, 46, .35), transparent 60%);
  color: #dfe9e4; padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; z-index: 1040; transition: transform .25s ease;
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: #fff; padding: 6px 8px; }
.brand img { width: 42px; height: 52px; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.brand-title { font-weight: 800; letter-spacing: .2px; }
.brand-sub { font-size: .75rem; opacity: .7; }
.sidebar .nav-link { color: #cfe0d7; border-radius: 12px; padding: 10px 12px; display: flex; gap: 12px; align-items: center; font-weight: 500; margin-bottom: 2px; transition: all .15s; }
.sidebar .nav-link i { font-size: 1.1rem; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar .nav-link.active { background: linear-gradient(90deg, rgba(242, 183, 5, .22), rgba(242, 183, 5, .05)); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.sidebar-foot { margin-top: auto; }
.main { flex: 1; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.page-title { font-size: 1.25rem; font-weight: 700; margin: 0; }
.content { padding: 24px 28px 48px; }
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1030; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .save-bar { margin: 16px -16px -48px; padding: 10px 16px; }
}

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: 14px 18px; font-weight: 700; }
.stat { position: relative; overflow: hidden; padding: 18px 20px; }
.stat .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; }
.stat .val { font-size: 1.45rem; font-weight: 800; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat::after { content: ""; position: absolute; right: -30px; bottom: -30px; width: 110px; height: 110px; border-radius: 50%; background: currentColor; opacity: .04; }
.ico-green { background: #e3f5ec; color: #0f7a4a; }
.ico-red { background: #fde8eb; color: #c8102e; }
.ico-gold { background: #fff4d6; color: #a77a00; }
.ico-blue { background: #e6efff; color: #2459d6; }
[data-bs-theme="dark"] .ico-green { background: #133526; } [data-bs-theme="dark"] .ico-red { background: #3a1419; }
[data-bs-theme="dark"] .ico-gold { background: #3a2f0e; } [data-bs-theme="dark"] .ico-blue { background: #15244a; }

.hero {
  border-radius: 20px; padding: 26px 28px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(120deg, #0b5c38 0%, #0f7a4a 45%, #139159 100%);
}
.hero::before { content: ""; position: absolute; inset: 0; background: url("../img/logo-default.png") no-repeat right -40px center / 220px; opacity: .10; }
.hero h2 { font-weight: 800; }
.hero .btn-light { font-weight: 600; }

/* ---------- Tables ---------- */
.table-modern { --bs-table-bg: transparent; margin: 0; }
.table-modern thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 60%, transparent); white-space: nowrap; }
.table-modern td { vertical-align: middle; border-color: var(--line); }
.table-modern tbody tr { transition: background .12s; }
.table-modern tbody tr:hover { background: var(--brand-50); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.chip-draft { background: #fff4d6; color: #8a6400; }
.chip-final { background: #e3f5ec; color: #0b6a3f; }
.num { font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state i { font-size: 3rem; opacity: .5; }

/* ---------- Form surat ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.editor.preview-hidden { grid-template-columns: minmax(0, 1fr); }
.editor.preview-hidden .preview-col { display: none; }
@media (max-width: 1399.98px) { .editor { grid-template-columns: minmax(0, 1fr); } .preview-col { display: none; } .editor.show-preview-mobile .preview-col { display: block; } }
.section-card { scroll-margin-top: 90px; }
.section-card .card-header { display: flex; align-items: center; gap: 10px; }
.step-no { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--brand); color: #fff; font-size: .8rem; font-weight: 800; }
.stepper { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.stepper a { white-space: nowrap; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .82rem; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.stepper a.active, .stepper a:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-50); }
.stepper-wrap { position: sticky; top: 64px; z-index: 1010; background: var(--bg); padding: 8px 0 12px; margin-top: -8px; }
.form-label { font-weight: 600; font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
.token-btn { font-size: .72rem; padding: 2px 8px; border-radius: 8px; }

.rincian-table { font-size: .82rem; }
.rincian-table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: color-mix(in srgb, var(--bg) 60%, transparent); white-space: nowrap; }
.rincian-table td { padding: 6px; vertical-align: top; }
.rincian-table .form-control { font-size: .82rem; padding: 6px 8px; border-radius: 8px; }
.rincian-table textarea { resize: vertical; min-height: 31px; }
.rincian-table .f-kode, .rincian-table .f-nama { min-height: 34px; }
.rincian-table .input-group-text { font-size: .7rem; color: var(--muted); padding: 4px 7px; }
.rincian-table .f-ket { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.rincian-table .money { text-align: right; font-variant-numeric: tabular-nums; }
.rincian-table tr.sortable-ghost { opacity: .35; }
.rincian-table tr.row-new { animation: flashIn 1.2s ease; }
@keyframes flashIn { from { background: #fff4d6; } to { background: transparent; } }
.drag-handle { cursor: grab; color: var(--muted); padding: 8px 2px; }
.row-no { font-weight: 700; color: var(--muted); padding-top: 8px; display: inline-block; min-width: 18px; text-align: center; }
.delta { font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; display: inline-block; margin-top: 4px; }
.delta.up { background: #e3f5ec; color: #0b6a3f; }
.delta.down { background: #fde8eb; color: #b0122a; }
.delta.eq { background: #eef1f4; color: #5b6673; }
.summary-bar { display: flex; flex-wrap: wrap; gap: 10px; }
.summary-bar .s { flex: 1 1 160px; background: var(--brand-50); border-radius: 12px; padding: 10px 14px; }
.summary-bar .s small { color: var(--muted); font-weight: 600; display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.summary-bar .s b { font-size: 1rem; font-variant-numeric: tabular-nums; }
.balance-ok { color: #0b6a3f; } .balance-no { color: #b0122a; }

.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 18px; display: flex; gap: 16px; align-items: center; cursor: pointer; transition: all .15s; background: color-mix(in srgb, var(--bg) 50%, transparent); }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-50); }
.dropzone img { width: 72px; height: 88px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; border: 1px solid var(--line); }

.save-bar { position: sticky; bottom: 0; z-index: 1015; margin: 18px -28px -48px; padding: 12px 28px; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); display: none; }
.is-dirty .dirty-dot { display: inline-block; }

/* ---------- Pratinjau surat (kertas) ---------- */
.preview-col { position: sticky; top: 76px; }
.preview-shell { background: #5b6770; border-radius: 16px; padding: 14px; height: calc(100vh - 100px); overflow: auto; }
[data-bs-theme="dark"] .preview-shell { background: #2a3230; }
.preview-toolbar { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; color: #fff; }
.preview-toolbar .btn { --bs-btn-color: #fff; --bs-btn-border-color: rgba(255,255,255,.35); --bs-btn-hover-bg: rgba(255,255,255,.15); --bs-btn-hover-color: #fff; }
.paper-scaler { transform-origin: top left; }
.paper {
  --pw: 215mm; width: var(--pw); min-height: 330mm; background: #fff; color: #000; margin: 0 auto 14px;
  padding: 10mm 15mm 10mm 15mm; box-shadow: 0 10px 30px rgba(0,0,0,.35);
  font-family: Arial, "Liberation Sans", Helvetica, sans-serif; font-size: 11pt; line-height: 1.25;
}
.paper.a4 { --pw: 210mm; min-height: 297mm; }
.paper * { color: #000; }
.kop { position: relative; text-align: center; padding-bottom: 2px; min-height: 24mm; }
.kop img { position: absolute; left: 0; top: 0; height: 24mm; max-width: 32mm; object-fit: contain; }
.kop .k1 { font-weight: 700; font-size: 16pt; line-height: 1.1; }
.kop .k2 { font-size: 22pt; line-height: 1.1; }
.kop .k3 { font-size: 10pt; padding-left: 20mm; }
.kop .k4 { font-size: 9pt; padding-left: 26mm; }
.kop-line { border-bottom: 3px solid #000; box-shadow: 0 2px 0 #fff, 0 3px 0 #000; margin: 3px 0 16px; }
.l-tgl { text-align: right; margin-bottom: 14px; }
.l-head { display: grid; grid-template-columns: 20mm 5.3mm 81.3mm; line-height: 1.45; }
.l-head .perihal { text-align: justify; padding-right: 7mm; }
.l-yth { display: grid; grid-template-columns: 11.9mm 1fr; column-gap: 2mm; line-height: 1.45; margin-top: 1.45em; }
.l-yth .yth { text-align: right; }
.l-body { margin-left: 25mm; text-indent: 12.5mm; text-align: justify; line-height: 1.5; margin-top: 14px; }
.l-table { width: 181mm; border-collapse: collapse; font-size: 9pt; margin: 6px auto 12px; table-layout: fixed; }
.l-table th, .l-table td { border: 1px solid #000; padding: 1px 4px; vertical-align: top; word-wrap: break-word; }
.l-table th { font-weight: 700; text-align: center; vertical-align: middle; height: 10mm; }
.l-table th:nth-child(2), .l-table th:nth-child(3) { text-align: left; }
.l-table tfoot td { font-weight: 700; background: #f2f2f2; }
.l-ttd { margin-left: 105mm; margin-top: 14px; line-height: 1.35; }
.l-ttd .pre { display: inline-block; width: 7.5mm; margin-left: -7.5mm; }
.l-ttd .gap { height: 22mm; }
.l-ttd .nm { font-weight: 700; }
.l-tembusan { font-size: 10pt; margin-top: 28px; }
.l-tembusan ol { padding-left: 7.5mm; margin: 0; }
.placeholder-txt { color: #b3b3b3 !important; font-style: italic; }

/* ---------- Misc ---------- */
.install-bg { min-height: 100vh; background: linear-gradient(135deg, #0b5c38, #0f7a4a 50%, #8f0c21); }
.glass { background: rgba(255,255,255,.96); border-radius: 22px; }
.ttd-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; transition: all .15s; height: 100%; background: var(--card); }
.ttd-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); }
.avatar { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; background: var(--brand-50); color: var(--brand); }
.kbd { font-size: .7rem; border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; color: var(--muted); }
.fade-up { animation: fadeUp .35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; }
  .paper { box-shadow: none; margin: 0; }
}

/* kolom terkunci (diambil dari referensi) */
.rincian-table .locked { background: color-mix(in srgb, var(--bg) 70%, var(--card)); color: var(--ink); cursor: not-allowed; }
.rincian-table .locked:focus { box-shadow: none; border-color: var(--line); }
.lock-wrap { position: relative; }
.lock-wrap .lock-ico { position: absolute; right: 8px; top: 8px; font-size: .7rem; color: var(--muted); }
.lock-wrap .f-nama { padding-right: 24px; }
.rincian-table .lock-addon { padding: 4px 6px; font-size: .65rem; }

/* kolom Tambah/Kurang otomatis di form */
.rincian-table output.f-delta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; font-size: .8rem; font-variant-numeric: tabular-nums; }
.rincian-table output.f-delta.up { color: #0b6a3f; background: #e3f5ec; }
.rincian-table output.f-delta.down { color: #b0122a; background: #fde8eb; }
.rincian-table output.f-delta.eq { color: var(--muted); background: color-mix(in srgb, var(--bg) 70%, var(--card)); }

/* halaman lampiran */
.paper.lampiran { padding-top: 12mm; }
.lamp-title { font-weight: 700; }
.l-head.lamp-head { grid-template-columns: 20mm 5.3mm 1fr; margin-bottom: 0; }
.lamp-line { border-bottom: 3px solid #000; margin: 2px 0 2.2em; height: 1.2em; }
.l-tembusan { margin-top: 40px; }

/* ---------- akun di sidebar ---------- */
.user-box { display: flex; align-items: center; gap: 6px; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.06); }
.user-box a { color: #fff; }
.user-box a.active .user-ava, .user-box a:hover .user-ava { box-shadow: 0 0 0 2px var(--gold); }
.user-ava { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--gold); color: #3a2c00; }
.min-w-0 { min-width: 0; }

/* ---------- halaman login ---------- */
.login-body { min-height: 100vh; background: var(--bg); }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { position: relative; overflow: hidden; color: #fff; padding: 48px;
  background: radial-gradient(120% 70% at 0% 0%, rgba(242,183,5,.25), transparent 55%),
              radial-gradient(90% 60% at 100% 100%, rgba(200,16,46,.45), transparent 60%),
              linear-gradient(140deg, #0b3d27, #0f7a4a 55%, #0b5c38); }
.login-hero::after { content: ""; position: absolute; right: -80px; bottom: -60px; width: 420px; height: 520px;
  background: url("../img/logo-default.png") no-repeat center / contain; opacity: .07; }
.login-hero-in { position: relative; z-index: 1; max-width: 520px; height: 100%; display: flex; flex-direction: column; justify-content: center; }
.login-logo { width: 64px; height: 78px; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
.login-title { font-weight: 800; font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.15; margin-bottom: 16px; }
.login-title span { color: var(--gold); }
.login-lead { opacity: .85; font-size: 1.02rem; max-width: 460px; }
.login-list { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 10px; }
.login-list i { color: var(--gold); margin-right: 8px; }
.login-foot { margin-top: 48px; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 32px; box-shadow: var(--shadow); }
.captcha-baris { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.captcha-gambar { display: block; width: 207px; height: 69px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.captcha-isian { letter-spacing: .5em; font-weight: 700; }
@media (max-width: 991.98px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-card { padding: 24px; }
}
