/* ==========================================================================
   LUNAR COMMERCE DESIGN SYSTEM — ADAPTED FOR E-KINERJA PUSKESMAS TAMBORA
   Token-driven, WCAG 2.2 AA compliant, Light/Dark mode, Content-first
   ========================================================================== */

:root {
  --font-primary: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica Neue, Arial, sans-serif;
  --text-primary: #31374a;
  --text-strong: #141824;
  --text-secondary: #525b75;
  --text-muted: #8a94ad;
  --text-link: #3874ff;

  --surface-page: #f5f7fa;
  --surface-card: #ffffff;
  --surface-soft: #eff2f6;
  --surface-hover: #f1f4f9;

  --border: #cbd0dd;
  --border-soft: #e3e6ed;

  --primary: #3874ff;
  --primary-hover: #2563e9;
  --primary-soft: #e5edff;
  --primary-bg: #eef2ff;

  --success: #1c9a6c;
  --success-hover: #148058;
  --success-soft: #d9f5ea;

  --warning: #d97d10;
  --warning-hover: #b56509;
  --warning-soft: #fff0d0;

  --danger: #d13f4c;
  --danger-hover: #b82e3a;
  --danger-soft: #ffe3e5;

  --purple: #7257d9;
  --purple-hover: #5d43be;
  --purple-soft: #ebe6ff;

  --shadow-sm: 0 1px 3px rgba(36, 40, 46, .06);
  --shadow-md: 0 4px 16px rgba(36, 40, 46, .08);
  --shadow-popover: 0 14px 36px rgba(36, 40, 46, .14);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --topbar-height: 64px;
  --sidebar-width: 252px;
  --motion-fast: 200ms ease;
  --motion-normal: 300ms ease;
}

[data-theme="dark"] {
  --text-primary: #d9e0ee;
  --text-strong: #f5f7fa;
  --text-secondary: #aeb9cf;
  --text-muted: #7e8aa3;

  --surface-page: #10131a;
  --surface-card: #181c26;
  --surface-soft: #202633;
  --surface-hover: #232a38;

  --border: #3b4354;
  --border-soft: #2c3342;

  --primary-soft: #1c315f;
  --primary-bg: #162447;
  --success-soft: #173b32;
  --warning-soft: #46341b;
  --danger-soft: #45232a;
  --purple-soft: #302a4e;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .25);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .3);
  --shadow-popover: 0 18px 44px rgba(0, 0, 0, .45);
}

/* Base resets & typography */
* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: hidden; scroll-behavior: smooth; }
body {
  max-width: 100%;
  margin: 0;
  overflow-x: hidden;
  color: var(--text-primary);
  background: var(--surface-page);
  font: 400 13px/1.5 var(--font-primary);
  -webkit-font-smoothing: antialiased;
  transition: background var(--motion-fast), color var(--motion-fast);
}

button, input, select, textarea { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--text-link); text-decoration: none; transition: color var(--motion-fast); }
a:hover { color: var(--primary-hover); }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 3px solid rgba(56, 116, 255, .35);
  outline-offset: 2px;
}
::selection {
  background: var(--primary-soft);
  color: var(--text-strong);
}
[hidden] { display: none !important; }

.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;
  top: 10px;
  left: 10px;
  z-index: 999;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--primary);
  transform: translateY(-150%);
  transition: transform var(--motion-fast);
}
.skip-link:focus { transform: translateY(0); }

/* App Shell */
.app-shell { min-height: 100vh; }

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1030;
  height: var(--topbar-height);
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(260px, 460px) 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-soft);
  transition: grid-template-columns var(--motion-fast), background var(--motion-fast), border-color var(--motion-fast);
}

.sidebar-collapsed .topbar {
  grid-template-columns: 76px minmax(260px, 460px) 1fr;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--text-strong);
  text-decoration: none;
}
.brand:hover { color: var(--text-strong); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #fff;
  background: linear-gradient(135deg, #3874ff, #7257d9);
  border-radius: 9px;
  transform: rotate(-5deg);
  box-shadow: 0 4px 12px rgba(56, 116, 255, .25);
  flex-shrink: 0;
}
.brand-mark svg { width: 20px; height: 20px; stroke-width: 2; }

.brand-name {
  white-space: nowrap;
  line-height: 1.1;
}
.brand-name span {
  color: var(--text-muted);
  font-weight: 500;
}

/* Global Search */
.global-search {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  color: var(--text-muted);
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background var(--motion-fast);
}
.global-search:focus-within {
  border-color: var(--primary);
  background: var(--surface-card);
  box-shadow: 0 0 0 3px rgba(56, 116, 255, .14);
}
.global-search svg { flex: 0 0 auto; width: 17px; height: 17px; color: var(--text-muted); }
.global-search input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--text-primary);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 12.5px;
}
.global-search input::placeholder { color: var(--text-muted); }
.global-search kbd {
  padding: 2px 6px;
  font: 600 10px var(--font-primary);
  color: var(--text-muted);
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  white-space: nowrap;
}

/* Topbar Actions */
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: color var(--motion-fast), background var(--motion-fast), transform 150ms ease;
}
.icon-button:hover {
  color: var(--text-strong);
  background: var(--surface-hover);
}
.icon-button:active { transform: scale(.94); }
.icon-button.bordered {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.has-indicator { position: relative; }
.has-indicator::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border: 2px solid var(--surface-card);
  border-radius: 50%;
  transition: border-color var(--motion-fast);
}

/* Theme Toggle Icons */
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }
[data-theme="dark"] .theme-icon-sun { display: block; color: #f59e0b; }
[data-theme="dark"] .theme-icon-moon { display: none; }

/* Profile Pill */
.profile-button {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 6px;
  padding: 4px 8px 4px 4px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}
.profile-button:hover, .profile-button[aria-expanded="true"] {
  background: var(--surface-hover);
  border-color: var(--border-soft);
}
.profile-button > svg { width: 15px; height: 15px; color: var(--text-muted); }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 50%;
  text-transform: uppercase;
}
.avatar-photo {
  background: linear-gradient(135deg, #7257d9, #3874ff 55%, #5ac8b2);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
}

.profile-copy {
  display: grid;
  line-height: 1.25;
}
.profile-copy strong {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-strong);
  white-space: nowrap;
}
.profile-copy small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.mobile-only { display: none; }

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  position: fixed;
  z-index: 1020;
  inset: var(--topbar-height) auto 0 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  overflow-y: auto;
  overflow-x: hidden;
  color: var(--text-secondary);
  background: var(--surface-card);
  border-right: 1px solid var(--border-soft);
  transition: width var(--motion-fast), transform var(--motion-fast), background var(--motion-fast), border-color var(--motion-fast);
}

.sidebar nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-label {
  margin: 18px 10px 6px;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.nav-label:first-child { margin-top: 2px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 38px;
  margin: 2px 0;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 12.8px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: color var(--motion-fast), background var(--motion-fast);
}
.nav-item svg, .nav-item i {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  color: inherit;
  transition: transform var(--motion-fast);
}
.nav-item:hover {
  color: var(--text-strong);
  background: var(--surface-hover);
}
.nav-item.active {
  color: var(--primary);
  font-weight: 700;
  background: var(--primary-soft);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 7px;
  color: var(--primary);
  font-size: 9px;
  font-weight: 800;
  text-align: center;
  background: var(--primary-soft);
  border-radius: 999px;
}
.nav-badge.warning { color: var(--warning); background: var(--warning-soft); }
.nav-badge.danger { color: var(--danger); background: var(--danger-soft); }
.nav-badge.success { color: var(--success); background: var(--success-soft); }
.nav-badge.neutral { color: var(--text-secondary); background: var(--surface-soft); }

.status-dot {
  margin-left: auto;
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--success-soft);
}
.status-dot.danger {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.sidebar-collapse {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border-soft);
  cursor: pointer;
  transition: color var(--motion-fast), background var(--motion-fast);
}
.sidebar-collapse:hover {
  color: var(--primary);
  background: var(--surface-hover);
}
.sidebar-collapse svg { width: 16px; height: 16px; transition: transform var(--motion-fast); }

.sidebar-backdrop { display: none; }

/* Collapsed Sidebar */
.sidebar-collapsed { --sidebar-width: 76px; }
.sidebar-collapsed .sidebar .nav-label,
.sidebar-collapsed .sidebar .nav-item span,
.sidebar-collapsed .sidebar .nav-badge,
.sidebar-collapsed .sidebar-collapse span { display: none !important; }
.sidebar-collapsed .sidebar nav { padding-inline: 8px; }
.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 10px; }
.sidebar-collapsed .sidebar-collapse { justify-content: center; padding: 0; }
.sidebar-collapsed .sidebar-collapse svg { transform: rotate(180deg); }

/* ==========================================================================
   MAIN CONTENT & PAGE HEADINGS
   ========================================================================== */
.main-content {
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--motion-fast);
}
.sidebar-collapsed .main-content {
  margin-left: 76px;
}

.content-body {
  flex: 1;
  padding: 28px 32px 40px;
  max-width: 1550px;
  width: 100%;
  margin-inline: auto;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, h3, h4, h5, h6, p { margin-top: 0; }
h1, .page-title {
  margin-bottom: 4px;
  color: var(--text-strong);
  font-size: clamp(22px, 2.5vw, 28px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.6px;
}
h2 {
  margin-bottom: 3px;
  color: var(--text-strong);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.25px;
}
.page-subtitle, .page-heading p:last-child {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Breadcrumbs */
.breadcrumb {
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 600;
}
.breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.active { color: var(--text-secondary); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--border); }

/* ==========================================================================
   METRIC GRID & KPI CARDS (LUNAR PHOENIX STYLE)
   ========================================================================== */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 20px 22px;
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--motion-fast), box-shadow var(--motion-fast), border-color var(--motion-fast);
}
.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.metric-icon {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  flex-shrink: 0;
}
.metric-icon svg, .metric-icon i {
  width: 22px;
  height: 22px;
  font-size: 20px;
}
.metric-icon.blue { color: var(--primary); background: var(--primary-soft); }
.metric-icon.green { color: var(--success); background: var(--success-soft); }
.metric-icon.orange { color: var(--warning); background: var(--warning-soft); }
.metric-icon.red { color: var(--danger); background: var(--danger-soft); }
.metric-icon.purple { color: var(--purple); background: var(--purple-soft); }

.metric-info {
  min-width: 0;
  flex: 1;
}
.metric-label {
  margin: 0 0 4px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.metric-value {
  color: var(--text-strong);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.metric-meta {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 800;
  border-radius: var(--radius-xs);
  padding: 1px 5px;
}
.trend.positive { color: var(--success); background: var(--success-soft); }
.trend.negative { color: var(--danger); background: var(--danger-soft); }

/* ==========================================================================
   PANELS & CARDS (LUNAR PHOENIX STYLE)
   ========================================================================== */
.panel, .card-custom, .card {
  min-width: 0;
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}

.panel-header, .card-custom .card-header, .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: transparent;
  border-bottom: 1px solid var(--border-soft);
}
.panel-header h2, .panel-header h3, .card-header h5, .card-header {
  margin: 0;
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.2px;
}
.panel-header p {
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: 11.5px;
}

.panel-body, .card-custom .card-body, .card-body {
  padding: 22px;
}

/* Promo Card Banner (From Lunar) */
.promo-card {
  position: relative;
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  min-height: 220px;
  overflow: hidden;
  background: linear-gradient(145deg, var(--surface-card) 50%, #eaf3ff);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}
[data-theme="dark"] .promo-card {
  background: linear-gradient(145deg, var(--surface-card) 50%, #1a2942);
}
.promo-content {
  position: relative;
  z-index: 2;
  align-self: center;
  padding: 28px;
}
.promo-content h2 {
  margin: 10px 0 8px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.5px;
}
.promo-content p {
  max-width: 480px;
  margin-bottom: 18px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}
.promo-art {
  position: relative;
  min-width: 140px;
}
.orb {
  position: absolute;
  display: block;
  border-radius: 50%;
}
.orb-one { width: 180px; height: 180px; top: 10px; right: -40px; background: rgba(56, 116, 255, .15); filter: blur(4px); }
.orb-two { width: 120px; height: 120px; right: 40px; bottom: -20px; background: rgba(114, 87, 217, .18); filter: blur(4px); }

/* ==========================================================================
   BUTTONS (LUNAR STYLE)
   ========================================================================== */
.button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 16px;
  font-size: 12.8px;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--motion-fast), background var(--motion-fast), border-color var(--motion-fast), transform 150ms ease, box-shadow var(--motion-fast);
}
.button svg, .btn svg, .btn i {
  width: 16px;
  height: 16px;
  font-size: 15px;
  flex-shrink: 0;
}
.button:active, .btn:active { transform: translateY(1px); }
.button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }

.button-primary, .btn-primary {
  color: #fff !important;
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}
.button-primary:hover, .btn-primary:hover {
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  box-shadow: 0 3px 12px rgba(56, 116, 255, .28);
}

.button-secondary, .btn-outline-secondary, .btn-light {
  color: var(--text-primary) !important;
  background: var(--surface-card) !important;
  border-color: var(--border) !important;
}
.button-secondary:hover, .btn-outline-secondary:hover, .btn-light:hover {
  color: var(--primary) !important;
  border-color: var(--primary) !important;
  background: var(--primary-soft) !important;
}

.button-success, .btn-success {
  color: #fff !important;
  background: var(--success) !important;
  border-color: var(--success) !important;
}
.button-success:hover, .btn-success:hover {
  background: var(--success-hover) !important;
  border-color: var(--success-hover) !important;
  box-shadow: 0 3px 12px rgba(16, 185, 129, .28);
}

.button-danger, .btn-danger {
  color: #fff !important;
  background: var(--danger) !important;
  border-color: var(--danger) !important;
}
.button-danger:hover, .btn-danger:hover {
  background: var(--danger-hover) !important;
  border-color: var(--danger-hover) !important;
  box-shadow: 0 3px 12px rgba(239, 68, 68, .28);
}

.btn-danger {
  color: #fff !important;
  background: var(--danger) !important;
  border-color: var(--danger) !important;
}
.btn-danger:hover {
  background: var(--danger-hover) !important;
  border-color: var(--danger-hover) !important;
}

.btn-warning {
  color: #fff !important;
  background: var(--warning) !important;
  border-color: var(--warning) !important;
}
.btn-warning:hover {
  background: var(--warning-hover) !important;
  border-color: var(--warning-hover) !important;
}

.btn-sm, .button-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 11.5px;
}

.text-button {
  padding: 4px 8px;
  color: var(--primary);
  font-weight: 700;
  background: transparent;
  border: 0;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.text-button:hover {
  color: var(--primary-hover);
  background: var(--primary-soft);
}

/* Segmented Control (Tabs) */
.segmented-control {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
}
.segmented-control button, .segmented-control a {
  min-height: 28px;
  padding: 0 12px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: all var(--motion-fast);
}
.segmented-control button:hover, .segmented-control a:hover { color: var(--text-strong); }
.segmented-control button.active, .segmented-control a.active {
  color: var(--text-strong);
  background: var(--surface-card);
  box-shadow: 0 1px 3px rgba(36, 40, 46, .12);
}

/* ==========================================================================
   BADGES (LUNAR STYLE)
   ========================================================================== */
.badge, .badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  padding: 4px 8px;
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge-blue, .badge-status.badge-disetujui, .badge-dibayarkan {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: rgba(56, 116, 255, .25);
}
.badge-green, .badge-status.badge-open, .badge-status.badge-disetujui {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(28, 154, 108, .22);
}
.badge-orange, .badge-yellow, .badge-status.badge-pending {
  color: #a85b08;
  background: var(--warning-soft);
  border-color: #f2cf8a;
}
.badge-red, .badge-status.badge-ditolak, .badge-status.badge-ditahan, .badge-status.badge-locked {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(209, 63, 76, .25);
}
.badge-purple {
  color: var(--purple);
  background: var(--purple-soft);
  border-color: rgba(114, 87, 217, .22);
}
.badge-draft {
  color: var(--text-secondary);
  background: var(--surface-soft);
  border-color: var(--border-soft);
}
.badge-soft {
  color: var(--text-strong) !important;
  background: var(--surface-soft) !important;
  border-color: var(--border) !important;
}

/* ==========================================================================
   CATEGORY FILTER PILLS
   ========================================================================== */
.category-pill, .filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  letter-spacing: .02em !important;
  border-radius: var(--radius-full) !important;
  border: 1px solid var(--border) !important;
  background: var(--surface-card) !important;
  color: var(--text-strong) !important;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--motion-fast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
  user-select: none;
}

.category-pill:hover, .filter-chip:hover {
  background: var(--primary-soft) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  transform: translateY(-1px);
}

.category-pill.active,
.category-pill.badge-blue,
.filter-chip.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(56, 116, 255, .32) !important;
}

.category-pill.badge-soft,
.filter-chip:not(.active) {
  background: var(--surface-card) !important;
  border-color: var(--border) !important;
  color: var(--text-strong) !important;
}

/* ==========================================================================
   TABLES (LUNAR PHOENIX STYLE)
   ========================================================================== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

table, .table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  color: var(--text-primary);
  margin-bottom: 0;
  background: transparent;
}

th, .table th {
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
th:first-child, td:first-child, .table th:first-child, .table td:first-child { padding-left: 22px; }
th:last-child, td:last-child, .table th:last-child, .table td:last-child { padding-right: 22px; }

td, .table td {
  height: 58px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  font-size: 12.8px;
  color: var(--text-primary);
  background: transparent;
}

tbody tr {
  transition: background var(--motion-fast);
}
tbody tr:hover, .table-hover tbody tr:hover {
  background: var(--surface-hover) !important;
}

.customer-cell, .pegawai-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.customer-cell .avatar, .pegawai-cell .avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
}
.customer-cell > div, .pegawai-cell > div {
  display: grid;
  line-height: 1.25;
}
.customer-cell strong, .pegawai-cell strong {
  color: var(--text-strong);
  font-size: 12.8px;
  font-weight: 700;
}
.customer-cell small, .pegawai-cell small {
  color: var(--text-muted);
  font-size: 10px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 12px 22px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 12px;
}
.table-footer span {
  white-space: nowrap;
}

/* ==========================================================================
   LUNAR PAGINATION
   ========================================================================== */
.lunar-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
}
.lunar-pagination ul {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.lunar-pagination li {
  display: flex;
  align-items: center;
  justify-content: center;
}
.lunar-pagination li span,
.lunar-pagination li a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--radius-md, 8px);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  cursor: pointer;
  line-height: 1;
  user-select: none;
}
.lunar-pagination li a:hover {
  color: var(--primary);
  background: var(--primary-soft, hsl(var(--primary-h, 230) 70% 96%));
  border-color: var(--primary-soft, hsl(var(--primary-h, 230) 70% 92%));
}
.lunar-pagination li a:active {
  transform: scale(0.95);
}
.lunar-pagination li.active span {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 8px hsla(var(--primary-h, 230), 70%, 50%, 0.25);
  font-weight: 700;
}
.lunar-pagination li.disabled span {
  color: var(--text-muted);
  opacity: 0.4;
  cursor: not-allowed;
}
.lunar-pagination li.dots span {
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 2px;
  cursor: default;
  border: none;
  min-width: 24px;
}
.lunar-pagination li span svg,
.lunar-pagination li a svg {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Hide pagination on very small screens, show only prev/next */
@media (max-width: 576px) {
  .lunar-pagination li:not(:first-child):not(:last-child) {
    display: none;
  }
  .lunar-pagination li.active {
    display: flex;
  }
  .table-footer {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
}

.row-action {
  width: 32px;
  height: 32px;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: color var(--motion-fast), background var(--motion-fast);
}
.row-action:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

/* ==========================================================================
   FORMS & INPUTS (LUNAR STYLE)
   ========================================================================== */
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-strong);
  text-transform: uppercase;
  letter-spacing: .02em;
}

.form-control, .form-select, input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  color: var(--text-primary);
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.8px;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background var(--motion-fast);
}

.form-control:focus, .form-select:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 116, 255, .15);
  background: var(--surface-card);
  color: var(--text-primary);
  outline: 0;
}

.input-group {
  display: flex;
  align-items: stretch;
  width: 100%;
}
.input-group-text {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.input-group .form-control {
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.form-text {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   POPOVERS, DROPDOWNS & NOTIFICATIONS (LUNAR STYLE)
   ========================================================================== */
.notification-popover {
  position: fixed;
  z-index: 1050;
  top: calc(var(--topbar-height) - 4px);
  right: 100px;
  width: min(380px, calc(100vw - 24px));
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
  animation: popoverIn var(--motion-fast);
}
@keyframes popoverIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.popover-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
}

.popover-list {
  max-height: 340px;
  overflow-y: auto;
}
.popover-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-soft);
  text-decoration: none;
  color: inherit;
  transition: background var(--motion-fast);
}
.popover-item:last-child { border-bottom: 0; }
.popover-item:hover { background: var(--surface-hover); }
.popover-item.unread { background: var(--primary-soft); }

.popover-icon {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  margin-top: 2px;
}
.popover-icon.blue { color: var(--primary); background: rgba(56, 116, 255, .15); }
.popover-icon.orange { color: var(--warning); background: rgba(217, 125, 16, .15); }
.popover-icon.green { color: var(--success); background: rgba(28, 154, 108, .15); }

.popover-copy {
  flex: 1;
  min-width: 0;
}
.popover-title {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text-strong);
  margin-bottom: 2px;
}
.popover-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.35;
}
.popover-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.popover-footer {
  padding: 10px;
  text-align: center;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-soft);
}
.popover-footer a {
  font-size: 12px;
  font-weight: 700;
}

/* User Profile Dropdown */
.dropdown-menu {
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  padding: 6px;
  min-width: 220px;
  animation: popoverIn var(--motion-fast);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12.8px;
  font-weight: 600;
  color: var(--text-primary);
  border-radius: var(--radius-xs);
  transition: background var(--motion-fast), color var(--motion-fast);
}
.dropdown-item:hover {
  background: var(--surface-hover);
  color: var(--primary);
}
.dropdown-item.text-danger:hover {
  background: var(--danger-soft);
  color: var(--danger) !important;
}
.dropdown-divider {
  border-top: 1px solid var(--border-soft);
  margin: 6px 0;
}
.dropdown-item-text {
  padding: 6px 12px;
  font-size: 11px;
}

/* ==========================================================================
   TOAST NOTIFICATIONS (LUNAR STYLE)
   ========================================================================== */
.toast-lunar {
  position: fixed;
  z-index: 1080;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  padding: 12px 18px;
  color: #fff;
  background: #263043;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  animation: toastIn var(--motion-fast);
}
[data-theme="dark"] .toast-lunar {
  background: #1e2638;
  border: 1px solid var(--border);
}
.toast-lunar svg { width: 18px; height: 18px; color: #64deb2; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   ALERTS (LUNAR STYLE)
   ========================================================================== */
.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 12.8px;
  font-weight: 500;
  border: 1px solid transparent;
  margin-bottom: 20px;
}
.alert svg, .alert i { font-size: 18px; width: 18px; height: 18px; flex-shrink: 0; }
.alert-success {
  color: #0f6244;
  background: var(--success-soft);
  border-color: rgba(28, 154, 108, .25);
}
.alert-danger {
  color: #9b202c;
  background: var(--danger-soft);
  border-color: rgba(209, 63, 76, .25);
}
.alert-warning {
  color: #8c4c06;
  background: var(--warning-soft);
  border-color: rgba(217, 125, 16, .25);
}
.alert-info {
  color: #1e52c8;
  background: var(--primary-soft);
  border-color: rgba(56, 116, 255, .25);
}
[data-theme="dark"] .alert-success { color: #64deb2; }
[data-theme="dark"] .alert-danger { color: #ff858f; }
[data-theme="dark"] .alert-warning { color: #ffbe6b; }
[data-theme="dark"] .alert-info { color: #8cb4ff; }

/* ==========================================================================
   FOOTER (LUNAR STYLE)
   ========================================================================== */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 32px;
  color: var(--text-muted);
  font-size: 11px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-card);
  margin-top: auto;
}
.footer p { margin: 0; }
.footer div { display: flex; gap: 18px; }
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--primary); }

/* ==========================================================================
   RESPONSIVE DESIGN (MATCHING LUNAR MEDIA QUERIES)
   ========================================================================== */
@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { grid-template-columns: var(--sidebar-width) 1fr auto; }
}

@media (max-width: 920px) {
  :root { --sidebar-width: 0px; }
  .mobile-only { display: inline-grid; }
  .brand-name span { display: none; }
  .topbar { grid-template-columns: auto 1fr auto; padding-inline: 16px; gap: 12px; }
  .main-content { margin-left: 0 !important; }

  .sidebar {
    width: 252px;
    transform: translateX(-102%);
    box-shadow: var(--shadow-popover);
  }
  .sidebar-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-open .sidebar-backdrop {
    position: fixed;
    z-index: 1015;
    inset: var(--topbar-height) 0 0 0;
    display: block;
    width: 100%;
    height: auto;
    background: rgba(20, 24, 36, .45);
    backdrop-filter: blur(2px);
    border: 0;
    cursor: pointer;
  }
  .sidebar-collapse { display: none; }
  .promo-card { grid-template-columns: 1fr; }
  .promo-art { display: none; }
  .profile-copy { display: none; }
}

@media (max-width: 680px) {
  .topbar { height: 58px; --topbar-height: 58px; padding-inline: 12px; }
  .sidebar { top: 58px; }
  .sidebar-open .sidebar-backdrop { top: 58px; }
  .main-content { padding-top: 58px; }
  .content-body { padding: 18px 16px 32px; }
  .page-heading { flex-direction: column; align-items: flex-start; gap: 14px; }
  .heading-actions { width: 100%; }
  .metric-grid { grid-template-columns: 1fr; gap: 12px; }
  .global-search { display: none; }
  .global-search.is-open {
    display: flex;
    position: absolute;
    top: 60px;
    left: 12px;
    right: 12px;
    z-index: 1040;
    box-shadow: var(--shadow-popover);
  }
  .footer { flex-direction: column; align-items: flex-start; gap: 10px; padding: 20px 16px; }
}

/* ==========================================================================
   KEGIATAN DINAS (RAPAT & DINAS LUAR)
   ========================================================================== */
.kd-jenis {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.kd-jenis i { font-size: 12px; }
.kd-jenis-rapat { color: var(--purple); background: var(--purple-soft); }
.kd-jenis-dinas_luar { color: var(--primary); background: var(--primary-soft); }

.kd-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 46px;
  min-width: 46px;
  height: 50px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  line-height: 1;
}
.kd-date strong { font-size: 17px; color: var(--text-strong); }
.kd-date small { font-size: 9.5px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-top: 3px; }

.kd-title { font-weight: 700; color: var(--text-strong); font-size: 13.5px; line-height: 1.35; }
.kd-meta { font-size: 11.5px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; }
.kd-meta i { margin-right: 3px; }

.kd-file {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 210px;
  padding: 5px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color var(--motion-fast), background var(--motion-fast), color var(--motion-fast);
}
.kd-file:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.kd-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kd-file .bi-file-earmark-pdf { color: var(--danger); }
.kd-file .bi-file-earmark-image { color: var(--success); }

.kd-note {
  margin-top: 6px;
  padding: 6px 10px;
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-xs);
  background: var(--danger-soft);
  color: var(--text-primary);
  font-size: 11.5px;
}

.kd-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 26px 18px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--motion-fast), background var(--motion-fast);
}
.kd-dropzone:hover, .kd-dropzone.is-dragover { border-color: var(--primary); background: var(--primary-soft); }
.kd-dropzone.has-file { border-style: solid; border-color: var(--success); background: var(--success-soft); }
.kd-dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.kd-dropzone .kd-dropzone-icon { font-size: 30px; color: var(--primary); line-height: 1; }
.kd-dropzone.has-file .kd-dropzone-icon { color: var(--success); }
.kd-dropzone strong { color: var(--text-strong); font-size: 13.5px; }
.kd-dropzone small { color: var(--text-muted); font-size: 11.5px; }

.kd-jenis-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kd-jenis-option { position: relative; margin: 0; }
.kd-jenis-option input { position: absolute; opacity: 0; pointer-events: none; }
.kd-jenis-option label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  cursor: pointer;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast);
}
.kd-jenis-option label:hover { border-color: var(--primary); transform: translateY(-1px); }
.kd-jenis-option input:checked + label { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.kd-jenis-option input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }
.kd-jenis-option .kd-jenis-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: 18px;
}
.kd-jenis-option strong { display: block; color: var(--text-strong); font-size: 13.5px; }
.kd-jenis-option small { color: var(--text-muted); font-size: 11.5px; }

.kd-preview {
  width: 100%;
  height: 620px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}
.kd-preview-img { display: block; max-width: 100%; max-height: 620px; margin: 0 auto; border-radius: var(--radius-md); border: 1px solid var(--border-soft); }

.kd-detail-list { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; margin: 0; font-size: 13px; }
.kd-detail-list dt { color: var(--text-muted); font-weight: 600; }
.kd-detail-list dd { margin: 0; color: var(--text-strong); font-weight: 600; word-break: break-word; }

.kd-mini-bar { display: flex; height: 6px; border-radius: var(--radius-full); overflow: hidden; background: var(--surface-soft); min-width: 80px; }
.kd-mini-bar span:first-child { background: var(--purple); }
.kd-mini-bar span:last-child { background: var(--primary); }

@media (max-width: 575.98px) {
  .kd-jenis-picker { grid-template-columns: 1fr; }
  .kd-detail-list { grid-template-columns: 1fr; gap: 2px; }
  .kd-detail-list dd { margin-bottom: 8px; }
  .kd-preview { height: 420px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
