/* ==========================================================================
   RT Dua — Sistem Informasi Rukun Tetangga
   Design tokens + base + components
   Adapted from the Rukunin (Squadron Team) visual language
   ========================================================================== */

:root {
  /* Brand — deep green + gold, taken from the RT 002 Kemang Pratama 3 emblem.
     --primary is the green (main brand); --gold is the accent. */
  --primary: #0d5e35;
  --primary-600: #0a4d2b;
  --primary-700: #083d22;
  --primary-soft: #e6f2ea;
  --primary-softer: #f2f9f5;

  --gold: #c9a227;
  --gold-600: #b18d1e;
  --gold-700: #96771a;
  --gold-soft: #faf3dd;
  --gold-softer: #fdfaf0;

  /* Brand RGB channel for translucent overlays */
  --primary-rgb: 13, 94, 53;
  --gold-rgb: 201, 162, 39;

  /* Semantic */
  --success: #4caf50;
  --success-soft: #e9f7ea;
  --error: #ef5350;
  --error-soft: #fdecec;
  --warning: #d9a520;
  --warning-soft: #fbf4e0;
  --info: #2f8354;
  --info-soft: #e8f4ec;
  --purple: #4e9e6f;
  --purple-soft: #eef7f1;
  --teal: #16a085;
  --teal-soft: #e5f5f2;

  /* Stat-card tints (used by summary tiles that pair a soft bg with a
     strong value colour). Themed in theme.css. */
  --stat-success-bg: #f6fdf6;
  --stat-success-border: #c8e6c9;
  --stat-success-text: #2e7d32;
  --stat-error-bg: #fef8f8;
  --stat-error-border: #ffcdd2;
  --stat-error-text: #c62828;

  /* Neutrals */
  --text: #212121;
  --text-2: #5f6368;
  --text-3: #8b9096;
  --border: #e4e6ea;
  --border-2: #f0f1f3;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;

  /* Shape */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 4px 12px rgba(16, 24, 40, .07);
  --shadow-md: 0 10px 26px rgba(16, 24, 40, .09);
  --shadow-lg: 0 22px 48px rgba(16, 24, 40, .13);

  /* Type */
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --sidebar-w: 258px;
  --topbar-h: 66px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
p { margin: 0; }

/* --------------------------------------------------------------------------
   Mobile safety net
   --------------------------------------------------------------------------
   The layout is built from flex/grid containers plus generated SVG charts.
   Two rules keep those honest on narrow screens:
     1. Flex and grid children default to min-width:auto, so a child with a
        fixed intrinsic width (a 168px donut, a long unbroken word) stretches
        its whole column past the viewport. min-width:0 lets them shrink.
     2. Generated SVG charts are drawn at a fixed pixel size; clamping them
        to 100% lets them scale down instead of forcing a horizontal scroll. */
.gen-svg, .card svg, .donut-wrap svg, .chart-bars svg { max-width: 100%; }
.card, .card-body, .card-head, .main, .content { min-width: 0; }


::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d3d6db; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b9bdc4; background-clip: content-box; }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.hidden { display: none !important; }
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.grow { flex: 1; }
.muted { color: var(--text-2); }
.muted-3 { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  transition: .16s ease;
  white-space: nowrap;
  line-height: 1.2;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(13, 94, 53, .3); }
.btn-primary:hover { background: var(--primary-600); box-shadow: 0 5px 16px rgba(13, 94, 53, .38); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: #cdd1d7; background: var(--surface-2); }
.btn-soft { background: var(--primary-soft); color: var(--primary-700); }
.btn-soft:hover { background: #cfe6da; }
.btn-danger { background: var(--error-soft); color: #c62828; }
.btn-danger:hover { background: #fbdada; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-2);
  transition: .15s;
  position: relative;
}
.icon-btn:hover { background: var(--border-2); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--error); border: 2px solid var(--surface);
}

/* --------------------------------------------------------------------------
   Cards & surfaces
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: 20px; }
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h3 { font-size: 15px; }
.card-body { padding: 20px; }

/* --------------------------------------------------------------------------
   Badges & chips
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3.5px 10px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: #2e7d32; }
.badge-error { background: var(--error-soft); color: #c62828; }
.badge-warning { background: var(--warning-soft); color: #b26a00; }
.badge-info { background: var(--info-soft); color: #1565c0; }
.badge-primary { background: var(--primary-soft); color: var(--primary-700); }
.badge-purple { background: var(--purple-soft); color: #6b3fb0; }
.badge-neutral { background: #eef0f2; color: var(--text-2); }
.badge .dot-i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  padding: 7px 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  transition: .15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--primary); color: var(--primary-700); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field label .req { color: var(--error); }
.input, .select, .textarea {
  width: 100%;
  padding: 10.5px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: .15s;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(13, 94, 53, .16);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 92px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-3); pointer-events: none;
}
.search-wrap .input { padding-left: 37px; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
/* Key/value spec tables rendered inside modals share the same look but are
   never the source of a page-level horizontal scroll — the modal body clips
   them. They still need to shrink on a phone. */
.modal-body table.data { width: 100%; table-layout: fixed; }
.modal-body table.data td { overflow-wrap: anywhere; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data thead th {
  text-align: left;
  padding: 11px 16px;
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .045em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--primary-softer); }
table.data .name-cell { font-weight: 600; color: var(--text); }
.right { text-align: right; }
.center { text-align: center; }

/* --------------------------------------------------------------------------
   Avatars
   -------------------------------------------------------------------------- */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex: none;
  letter-spacing: .01em;
}
.avatar-lg { width: 52px; height: 52px; font-size: 17px; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.av-0 { background: #0d5e35; } .av-1 { background: #2f8354; }
.av-2 { background: #c9a227; } .av-3 { background: #4e9e6f; }
.av-4 { background: #b18d1e; } .av-5 { background: #2f8354; }
.av-6 { background: #8a6f3a; } .av-7 { background: #6fb98f; }

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */
.empty {
  text-align: center;
  padding: 52px 24px;
  color: var(--text-3);
}
.empty svg { width: 46px; height: 46px; margin-bottom: 12px; opacity: .45; }
.empty h4 { font-size: 15px; color: var(--text-2); margin-bottom: 4px; }
.empty p { font-size: 13px; }

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, .5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  width: 100%; max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(.98);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1);
}
.modal-backdrop.open .modal { transform: none; }
.modal-wide { max-width: 700px; }
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--surface); z-index: 2;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot {
  padding: 16px 22px;
  border-top: 1px solid var(--border-2);
  display: flex; justify-content: flex-end; gap: 10px;
  position: sticky; bottom: 0; background: var(--surface);
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
#toast-host {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 400;
  display: flex; flex-direction: column; gap: 10px;
  align-items: flex-end;
}
.toast {
  background: #1f2430; color: #fff;
  padding: 12px 17px;
  border-radius: var(--r);
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .28s cubic-bezier(.16, 1, .3, 1);
  max-width: 380px;
}
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.success svg { color: #6ee7a8; }
.toast.error svg { color: #ff8a8a; }
.toast.info svg { color: #ffd166; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Progress bars
   -------------------------------------------------------------------------- */
.bar { height: 7px; background: #edf0f3; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--primary); transition: width .5s ease; }
.bar.success > span { background: var(--success); }
.bar.error > span { background: var(--error); }
.bar.info > span { background: var(--info); }

/* --------------------------------------------------------------------------
   Page header (inside dashboard)
   -------------------------------------------------------------------------- */
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 23px; margin-bottom: 4px; }
.page-head p { color: var(--text-2); font-size: 13.5px; }

/* --------------------------------------------------------------------------
   Grid helpers
   -------------------------------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* --------------------------------------------------------------------------
   Loading skeleton
   -------------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, #eef0f2 25%, #f6f7f9 50%, #eef0f2 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --------------------------------------------------------------------------
   Responsive ladder
   --------------------------------------------------------------------------
   Ordered widest → narrowest. Each step only relaxes what the step above it
   could not fit, so a phone gets a single readable column instead of a grid
   that quietly scrolls sideways. */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  /* Rows that hold chips / buttons / badges have to wrap, otherwise the last
     control pushes the page wider than the screen. */
  .row, .between { flex-wrap: wrap; }
  .filter-bar { gap: 8px; }
  .filter-bar .search-wrap { min-width: 100%; max-width: none; }
  .card-head { flex-wrap: wrap; padding: 14px 15px; gap: 9px; }
  .card-head h3 { flex: 1 1 100%; }
  .card-body, .card-pad { padding: 15px; }
  .content { padding: 16px 13px 52px; }
  .page-head h1 { font-size: 19px; }
  .stat-val { font-size: 22px; }
  .stat { padding: 15px; }
  .modal-backdrop { padding: 10px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; }
  #toast-host { left: 12px; right: 12px; bottom: 14px; align-items: stretch; }
  .toast { max-width: none; }
  /* Long unbroken identifiers (emails, ids, phone numbers) must not set the
     document width. */
  .content, .card, .card-body { overflow-wrap: anywhere; }
  .btn { white-space: normal; }
  .chip { padding: 6px 12px; font-size: 12px; }
  table.data { font-size: 12.8px; }
  table.data thead th, table.data tbody td { padding: 10px 12px; }
}
@media (max-width: 400px) {
  .content { padding: 14px 11px 48px; }
  .card-body, .card-pad, .card-head { padding-left: 13px; padding-right: 13px; }
  .hero-pill { min-width: 0; flex: 1; }
  .filter-bar .search-wrap { min-width: 0; }
  .pub-nav-inner { padding: 0 14px; height: 60px; }
}
