/* dPindah - mobile-first stylesheet */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #0d6efd;
  --primary-dark: #0a58ca;
  --success: #198754;
  --warning: #f59e0b;
  --danger: #dc3545;
  --border: #e5e7eb;
  --shadow: 0 1px 2px rgba(0,0,0,0.05), 0 4px 12px rgba(15,23,42,0.04);
  --radius: 12px;
  --space: 16px;
  --max-w: 720px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body { padding-bottom: 80px; min-height: 100vh; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; color: #374151; }

.muted { color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); font-style: italic; padding: 12px 0; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 0.85rem; color: #374151; background: #f1f5f9;
        padding: 2px 6px; border-radius: 6px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--primary);
  color: #fff;
  padding-top: env(safe-area-inset-top);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
}
.brand strong { font-size: 1.1rem; letter-spacing: 0.3px; }
.brand-sub { display: block; font-size: 0.75rem; opacity: 0.85; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-row {
  padding: 6px 16px 10px;
  background: var(--primary-dark);
  color: #fff;
  font-size: 0.85rem;
}
.user-greet { opacity: 0.95; }

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.role-organik { background: rgba(255,255,255,0.25); }
.role-pencacah { background: rgba(255,255,255,0.2); }
.role-pengawas { background: rgba(255,255,255,0.2); }

/* ---------- content ---------- */
.content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.hero h2 { margin-bottom: 6px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 8px;
}
.card h3 { margin-top: 14px; }
.card h3:first-child { margin-top: 0; }

/* ---------- stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--primary);
}
.stat-card.stat-pending  { border-color: var(--warning); }
.stat-card.stat-approved { border-color: var(--success); }
.stat-card.stat-executed { border-color: #0a58ca; }
.stat-card.stat-rejected { border-color: var(--danger); }
.stat-num {
  font-size: 1.6rem; font-weight: 700; line-height: 1;
  color: var(--text);
}
.stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

.status-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-top: 8px;
}
.status-pill {
  background: #f8fafc;
  text-align: center;
  padding: 10px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.status-pill:hover { background: #f1f5f9; text-decoration: none; }
.status-pill .num { font-weight: 700; font-size: 1.1rem; }
.status-pill .num + div { font-size: 0.7rem; color: var(--muted); }

/* ---------- desa block ---------- */
.desa-block {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}
.desa-block summary {
  cursor: pointer;
  padding: 6px 0;
  list-style: none;
}
.desa-block summary::-webkit-details-marker { display: none; }
.desa-block summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s;
  color: var(--muted);
}
.desa-block[open] summary::before { transform: rotate(90deg); }
.subsls-list {
  list-style: none; margin: 8px 0 0; padding: 0;
}
.subsls-list li a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--border);
  color: var(--text);
}
.subsls-list .code { flex: 0 0 auto; }
.subsls-list .name { flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subsls-list .count {
  background: var(--primary); color: #fff;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
}

/* ---------- table list ---------- */
.table-list {
  display: flex; flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.table-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
}
.table-row:hover { background: #f8fafc; text-decoration: none; }
.table-row.static { background: #f8fafc; }
.row-main { flex: 1; min-width: 0; }
.row-title {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-weight: 600;
}
.row-sub { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.row-meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.row-reason {
  font-size: 0.85rem; color: #475569;
  margin-top: 4px; font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-side { flex: 0 0 auto; font-size: 0.75rem; color: var(--muted); }

/* ---------- status tags ---------- */
.status-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #e5e7eb;
  color: #374151;
}
.status-tag.status-lg { font-size: 0.85rem; padding: 4px 12px; }
.status-tag.status-open      { background: #dbeafe; color: #1d4ed8; }
.status-tag.status-assigned  { background: #fef3c7; color: #b45309; }
.status-tag.status-completed { background: #d1fae5; color: #065f46; }
.status-tag.status-pending   { background: #fef3c7; color: #b45309; }
.status-tag.status-approved  { background: #d1fae5; color: #065f46; }
.status-tag.status-executed  { background: #dbeafe; color: #1e3a8a; }
.status-tag.status-rejected  { background: #fee2e2; color: #b91c1c; }
.status-tag.status-cancelled { background: #e5e7eb; color: #4b5563; }

.badge {
  background: var(--primary); color: #fff;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600;
}

/* ---------- buttons / forms ---------- */
.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #f1f5f9;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { display: block; width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-link { background: transparent; color: var(--primary); padding: 6px 8px; }
.btn-link:hover { background: #eff6ff; }

.input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 1rem;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
textarea { resize: vertical; }
.input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

label { display: block; font-size: 0.85rem; color: var(--muted);
        margin: 8px 0 4px; font-weight: 600; }

.checkbox-inline {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.9rem; color: var(--text);
  cursor: pointer;
  font-weight: 500;
}
.checkbox-inline input { width: 18px; height: 18px; }
input[type="checkbox"] { accent-color: var(--primary); }

/* ---------- login ---------- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a8a, #0d6efd);
}
.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: calc(100% - 32px);
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}
.login-title { font-size: 1.6rem; color: var(--primary); margin-bottom: 0; }
.login-sub { color: var(--muted); margin-top: 4px; font-size: 0.85rem; }
.login-foot { color: var(--muted); font-size: 0.75rem; margin-top: 14px;
              text-align: center; }

/* ---------- selection list ---------- */
.select-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: #f1f5f9;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 10px;
}
.assign-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.assign-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background 0.15s;
}
.assign-item.static { background: #f8fafc; }
.assign-item label {
  display: flex; gap: 10px;
  margin: 0; padding: 12px;
  cursor: pointer;
  align-items: flex-start;
}
.assign-item input[type="checkbox"] {
  width: 22px; height: 22px; flex: 0 0 auto;
  margin-top: 2px;
}
.assign-item input[type="checkbox"]:disabled + .assign-body {
  opacity: 0.55;
}
.assign-body { flex: 1; min-width: 0; }
.assign-title {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 0.95rem;
}
.assign-title strong { word-break: break-all; }
.assign-meta { font-size: 0.9rem; margin-top: 4px; }
.assign-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px;
              overflow: hidden; text-overflow: ellipsis;
              display: -webkit-box; -webkit-line-clamp: 2;
              -webkit-box-orient: vertical; }
.assign-foot {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 6px; font-size: 0.85rem; color: var(--muted);
}
.ico-tag {
  background: #e0e7ff; color: #3730a3;
  padding: 1px 6px; border-radius: 6px;
  font-size: 0.7rem;
}

/* ---------- sticky bar ---------- */
.sticky-bar {
  position: fixed;
  left: 0; right: 0; bottom: 60px;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
  z-index: 60;
}
.sticky-meta {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
}
.sticky-meta > div:first-child { flex: 0 0 auto; font-size: 0.9rem; }
.sticky-meta > button { flex: 1; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff;
  width: 100%;
  max-width: var(--max-w);
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(0,0,0,0.2);
}
.modal-card h3 { margin-bottom: 4px; }
.form-row { margin-top: 10px; }
.form-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 14px;
}

/* ---------- proposal detail ---------- */
.mov-block {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px;
  align-items: center; margin-bottom: 14px;
}
.mov-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.mov-name { font-weight: 600; margin-top: 4px; }
.mov-code { font-family: ui-monospace, SFMono-Regular, monospace;
            font-size: 0.85rem; color: var(--muted); }
.mov-arrow { font-size: 1.4rem; color: var(--primary); }
.reason-box {
  background: #fffbeb;
  border-left: 3px solid var(--warning);
  padding: 10px 12px;
  border-radius: 6px;
  white-space: pre-wrap;
}
.action-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 14px;
}
.action-grid form { display: flex; flex-direction: column; gap: 6px; }
.action-grid textarea { font-size: 0.85rem; padding: 8px; }

.audit-list {
  list-style: none; margin: 0; padding: 0;
  font-size: 0.85rem;
}
.audit-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

/* ---------- FASIH banner ---------- */
.fasih-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  margin-top: 8px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  background: #fee2e2;
  color: #7f1d1d;
  border: 1px solid #fecaca;
}
.fasih-banner.ok {
  background: #d1fae5;
  color: #065f46;
  border-color: #a7f3d0;
}
.fasih-banner .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.fasih-banner .label { flex: 1; }
.approver-note {
  background: #f1f5f9;
  border-left: 3px solid var(--primary);
  padding: 8px 12px;
  border-radius: 6px;
  margin: 12px 0;
  font-size: 0.85rem;
}
.approver-note code {
  background: #e2e8f0;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.78rem;
}

/* ---------- filter bar ---------- */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 8px;
}

/* ---------- error ---------- */
.error-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.error-card h1 { color: var(--danger); }

/* ---------- flashes ---------- */
.flashes {
  display: flex; flex-direction: column; gap: 8px;
}
.flash {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  border-left: 4px solid var(--primary);
  background: #eff6ff;
  color: #1e3a8a;
}
.flash-error   { background: #fee2e2; color: #b91c1c; border-color: var(--danger); }
.flash-success { background: #d1fae5; color: #065f46; border-color: var(--success); }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:hover { text-decoration: none; }
.nav-item.active {
  color: var(--primary);
}
.nav-icon { font-size: 1.2rem; line-height: 1; }

/* ---------- inline form ---------- */
form.inline { display: inline; }
form.inline button { padding: 4px 8px; }

/* ---------- responsive ---------- */
@media (min-width: 600px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .status-row { grid-template-columns: repeat(4, 1fr); }
  .sticky-bar { bottom: 0; }
}
@media (max-width: 360px) {
  .action-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
