/* ============================================================
   OMNIWARGA RT — aplikasi pengurus local-first
   Dunia visual: warisan penuh "MADING RT" (tokens.css).
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--wall);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--red); color: var(--paper); }
:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

.ic { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.125em; flex: none; }
.mono-note { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.09em; color: var(--cream-70); font-variant-numeric: tabular-nums; }
.dark-note { color: var(--ink-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 99; background: var(--paper); color: var(--ink); padding: 10px 16px; border-radius: 4px; font-weight: 700; text-decoration: none; transition: top .2s ease-out; }
.skip-link:focus { top: 12px; }

/* ---------- kunci layar (PIN) ---------- */
.lock {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, var(--felt) 0%, var(--wall) 58%, var(--wall-deep) 100%);
}
.lock-card {
  position: relative; width: min(100%, 380px); background: var(--paper); color: var(--ink);
  border: 1px solid var(--paper-edge); border-radius: 8px; box-shadow: var(--shadow-lift);
  padding: 34px 30px 28px; rotate: -0.8deg; display: grid; gap: 14px; text-align: center;
}
.lock-card .pin { position: absolute; top: -7px; left: 50%; translate: -50% 0; width: 15px; height: 15px; border-radius: 50%; background: radial-gradient(circle at 34% 30%, var(--pin-light), var(--red-deep) 68%); }
.lock-card h1 { font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; text-transform: uppercase; line-height: 1.05; }
.lock-card p { color: var(--ink-soft); font-size: 0.93rem; }
.lock-input {
  font-family: var(--font-mono); font-size: 1.4rem; letter-spacing: 0.4em; text-align: center;
  padding: 12px; border: 2px solid var(--paper-edge); border-radius: 6px; background: var(--panel); color: var(--ink); width: 100%;
}
.lock-input:focus { outline: none; border-color: var(--amber-deep); }
.lock-err { color: var(--red-deep); font-size: 0.85rem; min-height: 1.2em; font-weight: 600; }

/* ---------- pita info ---------- */
.data-strip {
  background: var(--wall-deep); color: var(--gold-light); text-align: center;
  padding: 7px 12px; border-bottom: 1px solid var(--line-on-wall);
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px;
  padding: 10px clamp(14px, 2.5vw, 28px);
  background: rgba(12, 40, 34, 0.97);
  border-bottom: 1px solid var(--line-on-wall);
}
.nav-toggle { display: none; background: none; border: 1px solid var(--line-on-wall); border-radius: 6px; color: var(--cream); width: 44px; height: 44px; font-size: 1.1rem; cursor: pointer; align-items: center; justify-content: center; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--cream); text-decoration: none; font-family: var(--font-display); font-size: 1.02rem; letter-spacing: 0.02em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; background: var(--red); color: var(--btn-text); border-radius: 6px; font-size: 1rem; }
.tenant { margin-left: auto; background: none; border: none; color: var(--cream); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-body); font-size: 0.92rem; min-height: 44px; }
.role-chip { background: rgba(240, 233, 214, 0.1); border: 1px solid var(--line-on-wall); border-radius: 99px; padding: 4px 10px; }
.iconbtn { background: none; border: 1px solid var(--line-on-wall); border-radius: 6px; color: var(--cream-70); width: 44px; height: 44px; font-size: 1rem; cursor: pointer; display: grid; place-items: center; }
.iconbtn:hover { color: var(--cream); border-color: var(--cream-70); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100dvh - 61px); }
.sidenav { background: var(--wall-deep); border-right: 1px solid var(--line-on-wall); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 61px; height: calc(100dvh - 61px); overflow-y: auto; }
.nav-list { list-style: none; display: grid; gap: 3px; }
.nav-group { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(240, 233, 214, 0.6); padding: 14px 12px 5px; }
.nav-list a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 6px;
  color: var(--cream-70); text-decoration: none; font-size: 0.94rem; font-weight: 500;
}
.nav-list a .ic { font-size: 1.05rem; }
.nav-list a:hover { color: var(--cream); background: rgba(240, 233, 214, 0.06); }
.nav-list a[aria-current="page"] { background: rgba(240, 233, 214, 0.1); color: var(--paper); }
.nav-badge { margin-left: auto; font-style: normal; font-family: var(--font-mono); font-size: 0.66rem; background: var(--red); color: var(--btn-text); border-radius: 99px; padding: 1px 7px; }
.sidenav-foot { margin-top: auto; padding: 14px 12px 4px; }

.content { padding: clamp(20px, 3vw, 36px) clamp(16px, 3vw, 40px) 80px; }
.view { display: grid; gap: 18px; animation: view-in .3s ease-out; }
.view[hidden] { display: none; }
@keyframes view-in { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
.view-head h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.5rem, 2.6vw, 2.1rem); letter-spacing: .01em; line-height: 1.05; text-transform: uppercase; }
.view-sub { color: var(--cream-70); max-width: 62ch; font-size: 0.95rem; }

/* ---------- stat ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--paper); color: var(--ink); border: 1px solid var(--paper-edge); border-radius: 8px; padding: 15px 17px; display: grid; gap: 3px; }
.stat b { font-family: var(--font-display); font-weight: 400; font-size: 1.7rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat b small { font-size: 0.95rem; color: var(--ink-soft); }
.stat .mono-note { color: var(--ink-soft); }

/* ---------- panel ---------- */
.panel { background: var(--paper); color: var(--ink); border: 1px solid var(--paper-edge); border-radius: 10px; box-shadow: var(--shadow-soft); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px dashed var(--paper-edge); }
.panel-head h2 { font-size: 1rem; font-weight: 700; letter-spacing: -0.005em; }
.panel-body { padding: 18px; display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.bar { height: 9px; border-radius: 99px; background: var(--paper-deep); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--w, 0%); background: var(--amber-deep); border-radius: 99px; }
.bar.lg { height: 12px; }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--font-body); font-weight: 700; font-size: 0.95rem;
  padding: 13px 22px; border-radius: 8px; border: none; cursor: pointer; text-decoration: none;
  transition: translate .2s cubic-bezier(.16,1,.3,1), box-shadow .2s cubic-bezier(.16,1,.3,1), background .2s;
}
.btn-solid { background: var(--red); color: var(--btn-text); }
.btn-solid:hover { background: var(--red-deep); translate: 0 -1px; box-shadow: var(--shadow-lift); }
.btn-ghost-dark { background: none; color: var(--ink); box-shadow: inset 0 0 0 2px var(--paper-edge); }
.btn-ghost-dark:hover { box-shadow: inset 0 0 0 2px var(--ink-soft); }
.btn-sm { padding: 10px 15px; font-size: 0.88rem; min-height: 44px; }
.btn-block { width: 100%; }
.btn-danger { background: none; color: var(--red-deep); box-shadow: inset 0 0 0 2px currentColor; }
.btn-danger:hover { background: var(--red-deep); color: var(--btn-text); }
.btn:disabled { opacity: .5; cursor: not-allowed; translate: none; box-shadow: none; }
.textlink { color: var(--ink-soft); font-weight: 600; font-size: 0.88rem; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.textlink:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.wa-link { color: var(--green); }

/* ---------- form ---------- */
.field { display: grid; gap: 6px; }
.field input, .field select, .field textarea {
  font-family: var(--font-body); font-size: 1rem; color: var(--ink);
  padding: 11px 13px; border: 1.5px solid var(--paper-edge); border-radius: 6px; background: var(--panel); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--amber-deep); }
.field textarea { resize: vertical; min-height: 74px; }
.form-inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.form-inline .field { flex: 1 1 170px; }
.form-stack { display: grid; gap: 12px; }
.search { display: flex; align-items: center; gap: 9px; background: var(--panel); border: 1.5px solid var(--paper-edge); border-radius: 6px; padding: 0 12px; flex: 1 1 220px; min-height: 44px; }
.search:focus-within { border-color: var(--amber-deep); }
.search input { border: none; background: none; padding: 11px 0; width: 100%; font-family: var(--font-body); font-size: 1rem; color: var(--ink); }
.search input:focus { outline: none; }
.search .mono-note { color: var(--ink-soft); }

/* ---------- tabel ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--paper-edge); border-radius: 10px; background: var(--panel); }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 560px; }
.tbl th { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); text-align: left; padding: 11px 14px; background: var(--paper-deep); border-bottom: 1px solid var(--paper-edge); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px dashed var(--paper-edge); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: rgba(38, 33, 23, 0.03); }
.tbl .neg { color: var(--red-deep); }
.tbl .pos { color: var(--green); }
.tbl .actions-cell { display: flex; gap: 7px; flex-wrap: wrap; }

/* ---------- pill ---------- */
.pill { font-style: normal; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.08em; padding: 3px 9px; border-radius: 99px; white-space: nowrap; display: inline-block; }
.pill-green { background: rgba(61, 112, 72, 0.14); color: var(--green-deep); }
.pill-red { background: rgba(178, 58, 46, 0.12); color: var(--red-deep); }
.pill-amber { background: rgba(181, 115, 23, 0.14); color: var(--amber-deep); }
.pill-blue { background: rgba(46, 90, 158, 0.12); color: var(--blue-deep); }
.pill-gray { background: rgba(38, 33, 23, 0.08); color: var(--ink-soft); }

/* ---------- subtabs ---------- */
.subtabs { display: flex; gap: 4px; background: var(--paper-deep); border: 1px solid var(--paper-edge); border-radius: 8px; padding: 4px; width: fit-content; max-width: 100%; overflow-x: auto; }
.subtabs button { font-family: var(--font-body); font-size: 0.88rem; font-weight: 600; color: var(--ink-soft); background: none; border: none; border-radius: 6px; padding: 8px 15px; min-height: 44px; cursor: pointer; white-space: nowrap; }
.subtabs button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: inset 0 -3px 0 var(--red); }
.subpanel { display: grid; gap: 14px; }
.subpanel[hidden] { display: none; }

/* ---------- feed ---------- */
.feed { list-style: none; display: grid; gap: 0; }
.feed li { display: flex; gap: 14px; align-items: flex-start; padding: 12px 2px; border-bottom: 1px dashed var(--paper-edge); }
.feed li:last-child { border-bottom: none; }
.feed-date { flex: none; width: 52px; text-align: center; color: var(--ink-soft); padding-top: 2px; }
.feed li > div { flex: 1; display: grid; gap: 1px; }
.feed li b { font-size: 0.94rem; }
.feed li .small { color: var(--ink-soft); font-size: 0.85rem; }
.feed .pill, .feed > li > em { align-self: center; }

/* ---------- permintaan surat ---------- */
.req-list { list-style: none; display: grid; gap: 10px; }
.req { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border: 1px solid var(--paper-edge); border-radius: 8px; padding: 12px 14px; background: var(--panel); }
.req.is-done { opacity: .55; }
.req > div:first-child { display: grid; gap: 1px; }
.req-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--ink-soft); padding: 18px; font-size: 0.9rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; translate: -50% 0; z-index: 90;
  background: var(--wall-deep); color: var(--paper); font-size: 0.78rem;
  padding: 11px 18px; border-radius: 8px; box-shadow: var(--shadow-lift);
  border: 1px solid var(--line-on-wall); max-width: min(92vw, 480px); text-align: center;
}

/* ---------- dialog ringan ---------- */
.dialog-scrim { position: fixed; inset: 0; background: rgba(10, 26, 22, 0.6); z-index: 70; display: grid; place-items: center; padding: 20px; }
.dialog { width: min(100%, 480px); max-height: 86dvh; overflow-y: auto; background: var(--paper); color: var(--ink); border-radius: 10px; border: 1px solid var(--paper-edge); box-shadow: var(--shadow-lift); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; border-bottom: 1px dashed var(--paper-edge); }
.dialog-head h2 { font-size: 1rem; font-weight: 700; }
.dialog-body { padding: 18px; display: grid; gap: 12px; }
.dialog-foot { display: flex; gap: 9px; justify-content: flex-end; padding: 0 18px 18px; }

/* ---------- cetak surat ---------- */
.print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { display: block; position: absolute; inset: 0; background: #fff; color: #000; padding: 24px 30px; font-size: 12.5pt; line-height: 1.6; }
  .print-kop { text-align: center; border-bottom: 3px double #000; padding-bottom: 10px; margin-bottom: 18px; }
  .print-kop b { font-size: 15pt; display: block; }
  .print-kop span { font-size: 10.5pt; }
  .print-meta { display: flex; justify-content: space-between; font-size: 10.5pt; margin-bottom: 16px; }
  .print-judul { text-align: center; text-decoration: underline; font-weight: 700; text-transform: uppercase; margin-bottom: 16px; }
  .print-body p { margin-bottom: 10px; text-align: justify; }
  .print-ttd { margin-top: 30px; display: flex; justify-content: flex-end; text-align: center; }
  .print-ttd div { min-width: 220px; }
  .print-ttd .nama { font-weight: 700; text-decoration: underline; margin-top: 62px; }
  @page { margin: 18mm; }
}

/* ---------- responsif ---------- */
@media (max-width: 920px) {
  .nav-toggle { display: inline-flex; }
  .shell { grid-template-columns: 1fr; }
  .sidenav { position: fixed; left: 0; top: 0; bottom: 0; height: 100dvh; width: min(78vw, 290px); z-index: 80; translate: -102% 0; transition: translate .28s cubic-bezier(.16,1,.3,1); }
  .sidenav.is-open { translate: 0 0; box-shadow: 24px 0 60px -30px rgba(10,26,22,.7); }
  .nav-scrim { position: fixed; inset: 0; background: rgba(10,26,22,.6); z-index: 75; }
}
@media (max-width: 640px) {
  .tenant .tenant-name { display: none; }
  .stat b { font-size: 1.4rem; }
  .form-inline .field { flex-basis: 100%; }
}

/* ---------- utilitas render JS (CSP-safe: tanpa inline style) ---------- */
.clickable { cursor: pointer; }
.justify-start { justify-self: start; }
.hint { font-size: .93rem; color: var(--ink-soft); line-height: 1.6; }
.file-input { font-size: .9rem; }
.nomor-terbit { font-family: var(--font-mono); font-size: .85rem; color: var(--ink); letter-spacing: .04em; }
.cmp-num { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.7rem, 3vw, 2.3rem); line-height: 1; font-variant-numeric: tabular-nums; }
.cmp-from { font-size: .9rem; color: var(--ink-soft); font-family: var(--font-body); }
.panel-form { padding: 16px 18px; }
.poll-row { display: grid; gap: 5px; }
.poll-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.poll-line .opt-label { font-size: .93rem; }
.poll-bar { flex: 1; }
.dialog-close { color: var(--ink-soft); border-color: var(--paper-edge); }
.noscript-note { padding: 40px; text-align: center; font-family: system-ui; }
.poll-actions { gap: 8px; align-items: center; }
