/* --- Design Tokens --- */
:root {
  --bg-app: #f6f8fa;
  --surface: #ffffff;
  --surface-subtle: #f1f3f5;
  --border: #e6e8eb;
  --border-active: #d0d5dd;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #8c95a2;
  --primary: #18181b;
  --primary-accent: #e11d48;
  --primary-accent-subtle: #ffe4e6;
  --tag-bg: #f3f4f6;
  --tag-match-bg: #fef08a;
  --tag-match-text: #854d0e;
  --pill-jawa-bg: #fef3c7;
  --pill-jawa-text: #92400e;
  --pill-luar-bg: #e0f2fe;
  --pill-luar-text: #0369a1;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: #0c0d0e;
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Mobile Frame Wrapper */
.mobile-viewport {
  width: 100%;
  max-width: 460px;
  background-color: var(--bg-app);
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 32px);
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.3);
}

/* Header & Sticky Controls */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: rgba(246, 248, 250, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(230, 232, 235, 0.8);
  padding: calc(env(safe-area-inset-top, 14px) + 6px) 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.header-branding .eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-accent);
  display: block;
  margin-bottom: 2px;
}

.header-branding .header-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

/* Search Bar */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-field {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 38px 10px 36px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s var(--ease);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.search-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}

.clear-search-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.clear-search-btn .icon {
  width: 18px;
  height: 18px;
}

/* Segmented Control Pill */
.segmented-control {
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  padding: 3px;
  gap: 3px;
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 7px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}

.segment-btn.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Custom Select Trigger (Non-Native) */
.custom-select-trigger {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.custom-select-trigger:active {
  background: var(--surface-subtle);
}

.trigger-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trigger-hint {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.trigger-value {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.chevron-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Result Metrics Bar */
.metrics-bar {
  padding: 10px 16px 4px;
}

.count-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Card Feed */
.card-feed {
  padding: 6px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.area-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.kab-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.25;
}

.prov-name {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

.pill-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 9999px;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.pill-jawa {
  background: var(--pill-jawa-bg);
  color: var(--pill-jawa-text);
}

.pill-luar {
  background: var(--pill-luar-bg);
  color: var(--pill-luar-text);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 11px;
  background: var(--tag-bg);
  color: var(--text-secondary);
  padding: 3px 7px;
  border-radius: 5px;
  font-weight: 500;
  line-height: 1.35;
}

.tag.highlighted {
  background: var(--tag-match-bg);
  color: var(--tag-match-text);
  font-weight: 700;
}

.card-bottom {
  border-top: 1px solid #f1f3f5;
  padding-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-item {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

mark {
  background: var(--tag-match-bg);
  color: var(--tag-match-text);
  border-radius: 2px;
  padding: 0 2px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  margin-top: 10px;
}

.empty-state h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
}

/* --- Bottom Sheet Modal (Non-Native Dropdown) --- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--ease);
}

.sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 460px;
  max-height: 82vh;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.16);
  transition: transform 0.32s var(--ease);
  overflow: hidden;
}

.bottom-sheet.active {
  transform: translate(-50%, 0);
}

.sheet-handle {
  width: 38px;
  height: 4px;
  background: #d4d7dc;
  border-radius: 2px;
  margin: 10px auto 4px;
}

.sheet-head {
  padding: 10px 18px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-close-btn {
  background: var(--surface-subtle);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
}

.sheet-search-wrap {
  padding: 0 16px 10px;
}

.sheet-search-input {
  width: 100%;
  background: var(--surface-subtle);
  border: 1px solid transparent;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  outline: none;
}

.sheet-search-input:focus {
  border-color: var(--border-active);
  background: #ffffff;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px calc(env(safe-area-inset-bottom, 16px) + 16px);
  -webkit-overflow-scrolling: touch;
}

.sheet-options {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sheet-option-item {
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sheet-option-item:active {
  background: var(--surface-subtle);
}

.sheet-option-item.selected {
  font-weight: 700;
  color: var(--text-primary);
  background: #f4f5f7;
}

.check-icon {
  width: 16px;
  height: 16px;
  color: var(--primary-accent);
}