/* ==========================================================================
   KEHIDUPAN APP - STYLESHEET
   Design Theme: Modern Glassmorphism & High Contrast Dual Themes (Dark & Light)
   ========================================================================== */

:root {
  /* Color Palette - Dark Theme Default */
  --bg-main: #0b0f19;
  --bg-card: rgba(23, 31, 50, 0.75);
  --bg-card-hover: rgba(30, 41, 66, 0.85);
  --bg-input: #172033;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.35);

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-sky: #06b6d4;
  --accent-rose: #f43f5e;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --ext-banner-bg: linear-gradient(135deg, rgba(30, 41, 66, 0.85), rgba(15, 23, 42, 0.95));
  --ext-banner-text: #f8fafc;
  --ext-banner-sub: #94a3b8;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);

  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables Override */
body.light-mode {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f1f5f9;
  --border-color: rgba(0, 0, 0, 0.1);
  --border-highlight: rgba(99, 102, 241, 0.3);

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: rgba(79, 70, 229, 0.1);
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-sky: #0284c7;
  --accent-rose: #e11d48;

  --text-main: #0f172a;
  --text-muted: #334155;
  --text-subtle: #64748b;

  --ext-banner-bg: linear-gradient(135deg, #e0e7ff, #e0f2fe);
  --ext-banner-text: #1e1b4b;
  --ext-banner-sub: #3730a3;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 25px rgba(79, 70, 229, 0.12);
}

/* Reset & Basic Setup */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: clip;
}

/* Layout Architecture */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-main);
  position: relative;
}

/* Left Sidebar Navigation */
.app-sidebar {
  width: 270px;
  min-width: 270px;
  max-width: 270px;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  box-sizing: border-box;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  min-height: 70px;
  max-height: 70px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  box-sizing: border-box;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent-emerald));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--text-main);
}

.brand-text h1 .dot {
  color: var(--accent-emerald);
}

.brand-text p {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sidebar-close-btn:hover {
  color: var(--text-main);
  background: var(--bg-input);
}

/* Sidebar Navigation Menu */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-sizing: border-box;
}

.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.4);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: transparent;
  padding: 0;
  border: none;
}

.group-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-subtle);
  letter-spacing: 0.5px;
  padding: 4px 8px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.group-label i {
  font-size: 0.72rem;
  color: var(--primary);
  opacity: 0.85;
}

.group-btns {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  white-space: nowrap;
  box-sizing: border-box;
}

.nav-btn i {
  width: 18px;
  text-align: center;
  font-size: 0.86rem;
  opacity: 0.8;
  transition: transform 0.18s ease;
}

.nav-btn:hover {
  color: var(--text-main);
  background: var(--bg-input);
  transform: translateX(2px);
}

.nav-btn:hover i {
  transform: scale(1.1);
  opacity: 1;
}

body.dark-mode .nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-btn.active {
  background: var(--primary);
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
  font-weight: 700;
  transform: translateX(2px);
}

.nav-btn.active i {
  opacity: 1;
  color: #ffffff;
}

/* Dashboard Group Special Style (Paling Atas) */
.nav-group.dashboard-group {
  margin-top: 0;
  margin-bottom: 6px;
  padding-top: 0;
  padding-bottom: 12px;
  border-top: none;
  border-bottom: 2px solid var(--border-color);
}

.nav-btn.dashboard-btn {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.22);
  color: var(--accent-emerald);
  font-weight: 700;
}

.nav-btn.dashboard-btn:hover {
  background: rgba(16, 185, 129, 0.16);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.35);
}

.nav-btn.dashboard-btn.active {
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  color: #ffffff !important;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  flex-shrink: 0;
}

.app-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-subtle);
  font-weight: 600;
}

.status-pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  display: inline-block;
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

/* Right Main App Wrapper */
.app-main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
  position: relative;
}

/* App Topbar - Sticky / Fixed at Top */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 70px;
  min-height: 70px;
  max-height: 70px;
  padding: 0 32px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 90;
  box-sizing: border-box;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sidebar-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-toggle-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--border-highlight);
}

.topbar-breadcrumb .topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Sheets Popover & Sync Status */
.sync-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--text-subtle);
  margin-left: 6px;
  transition: var(--transition);
}

.sync-status-dot.connected {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.sheets-popover-card {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 330px;
  max-width: 90vw;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 200;
  overflow: hidden;
  animation: popoverFadeIn 0.2s ease-out;
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sheets-popover-header {
  padding: 12px 14px;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
}

.sheets-popover-body {
  padding: 14px;
}

.badge-status-connected {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 700;
}

.badge-status-disconnected {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 700;
}

/* History Filter Chips */
.history-filter-chip {
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.history-filter-chip:hover,
.history-filter-chip.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.35);
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 24px 32px 16px;
  max-width: 1840px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

@media (min-width: 1920px) {
  .main-content {
    max-width: 2160px;
    padding: 28px 40px 20px;
  }
}

/* App Footer */
.app-footer {
  margin-top: auto;
  padding: 10px 24px 14px;
  border: none !important;
  box-shadow: none !important;
  text-align: center;
  font-size: 0.76rem;
  color: var(--text-muted);
  background: transparent !important;
}

.app-footer p {
  margin: 0;
  border: none !important;
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

.sheets-btn {
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}

.sheets-btn:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-emerald);
}

.icon-btn, .secondary-btn, .primary-btn, .outline-btn, .danger-btn {
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
}

.icon-btn {
  width: 40px;
  height: 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.icon-btn:hover {
  border-color: var(--border-highlight);
  background: var(--primary-light);
  color: var(--primary);
}

.secondary-btn {
  padding: 8px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.88rem;
}

.secondary-btn:hover {
  border-color: var(--border-highlight);
  background: var(--bg-card-hover);
}

.primary-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: var(--shadow-glow);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.outline-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.outline-btn:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
  background: var(--bg-input);
}

.danger-btn {
  padding: 8px 16px;
  background: var(--accent-rose);
  color: #fff;
  font-size: 0.85rem;
}

.danger-btn:hover {
  background: #e11d48;
}

/* Hero Banner */
.hero-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(16, 185, 129, 0.08));
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.hero-banner .badge {
  margin-bottom: 10px;
}

.data-table .badge {
  margin-bottom: 0;
  vertical-align: middle;
  line-height: 1.2;
}

.badge-vehicle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.3;
  border: 1px solid transparent;
}

.badge-vehicle.badge-mobil {
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.25);
}

.badge-vehicle.badge-motor {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-amber);
  border-color: rgba(245, 158, 11, 0.25);
}

.hero-text {
  flex: 1;
  min-width: 0;
}

.hero-text h2 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text-main);
}

.hero-text p {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: none;
  line-height: 1.5;
}

.hero-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.mini-stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  min-width: 140px;
  display: flex;
  flex-direction: column;
}

.mini-stat-card.primary {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 4px;
}

.mini-stat-card.primary .stat-value {
  color: var(--accent-emerald);
}

/* Calculator Grid - Autofit Architecture */
.calculator-grid {
  display: grid;
  grid-template-columns: minmax(350px, 440px) minmax(0, 1fr);
  gap: 26px;
  margin-bottom: 32px;
  align-items: start;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

@media (min-width: 1536px) {
  .calculator-grid {
    grid-template-columns: 460px minmax(0, 1fr);
    gap: 28px;
  }
}

@media (min-width: 1920px) {
  .calculator-grid {
    grid-template-columns: 480px minmax(0, 1fr);
    gap: 32px;
  }
}

.calculator-grid > * {
  min-width: 0;
  max-width: 100%;
}

.results-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 100%;
  container-type: inline-size;
  container-name: results;
}

.form-card {
  align-self: start;
  height: fit-content;
}

.form-card .card-body {
  padding: 24px 24px 32px;
}

/* Cards Standard */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: border-color 0.3s ease;
}

.card:hover {
  border-color: var(--border-highlight);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.card-header h3 i {
  color: var(--primary);
}

.sub-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card-body {
  padding: 24px;
}

/* Form Styling */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.form-group label span.unit {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.8rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.form-control {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Form Helper Options / Chips */
.form-options {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.option-chip {
  padding: 5px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.option-chip:hover, .option-chip.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}


/* Summary Cards Grid - Auto Adaptive Layout (Semua Menu) */
.summary-cards-grid {
  display: grid;
  gap: 16px;
  width: 100%;
  grid-template-columns: repeat(3, 1fr); /* default fallback */
}

/* 1 Card: 1 Kolom Penuh */
.summary-cards-grid.cards-count-1,
.summary-cards-grid[data-cards-count="1"] {
  grid-template-columns: 1fr;
}

/* 2 Cards: 2 Kolom Seimbang (50% - 50%) */
.summary-cards-grid.cards-count-2,
.summary-cards-grid[data-cards-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* 3 Cards: 3 Kolom Seimbang */
.summary-cards-grid.cards-count-3,
.summary-cards-grid[data-cards-count="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* 4 Cards: 4 Kolom di Desktop luas */
.summary-cards-grid.cards-count-4,
.summary-cards-grid[data-cards-count="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* 5 Cards: 5 Kolom Seimbang */
.summary-cards-grid.cards-count-5,
.summary-cards-grid[data-cards-count="5"] {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* 6 Cards: 3 Kolom */
.summary-cards-grid.cards-count-6,
.summary-cards-grid[data-cards-count="6"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Optimasi proporsi kartu jika 4 kolom */
.summary-cards-grid.cards-count-4 .result-card,
.summary-cards-grid[data-cards-count="4"] .result-card {
  padding: 14px 14px;
  gap: 10px;
}

.summary-cards-grid.cards-count-4 .res-icon,
.summary-cards-grid[data-cards-count="4"] .res-icon {
  width: 36px;
  height: 36px;
  font-size: 1rem;
}

.summary-cards-grid.cards-count-4 .res-val,
.summary-cards-grid[data-cards-count="4"] .res-val {
  font-size: 1.22rem;
}

/* Container Queries: Kartu otomatis adaptif terhadap lebar kolom hasil nyata */
@container results (max-width: 980px) {
  .summary-cards-grid.cards-count-4,
  .summary-cards-grid[data-cards-count="4"],
  .summary-cards-grid.cards-count-5,
  .summary-cards-grid[data-cards-count="5"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container results (max-width: 680px) {
  .summary-cards-grid.cards-count-3,
  .summary-cards-grid[data-cards-count="3"],
  .summary-cards-grid.cards-count-6,
  .summary-cards-grid[data-cards-count="6"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container results (max-width: 480px) {
  .summary-cards-grid,
  .summary-cards-grid[class*="cards-count-"],
  .summary-cards-grid[data-cards-count] {
    grid-template-columns: 1fr !important;
  }
}

/* Media Query fallbacks untuk variasi zoom browser */
@media (max-width: 1520px) {
  .summary-cards-grid.cards-count-4,
  .summary-cards-grid[data-cards-count="4"],
  .summary-cards-grid.cards-count-5,
  .summary-cards-grid[data-cards-count="5"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .calculator-grid {
    grid-template-columns: 1fr;
  }
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  min-width: 0;
  box-sizing: border-box;
}

.result-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.result-card.emerald::before { background: var(--accent-emerald); }
.result-card.amber::before { background: var(--accent-amber); }
.result-card.sky::before { background: var(--accent-sky); }

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.res-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  color: var(--primary);
  flex-shrink: 0;
}

.result-card.emerald .res-icon { color: var(--accent-emerald); background: rgba(16, 185, 129, 0.12); }
.result-card.amber .res-icon { color: var(--accent-amber); background: rgba(245, 158, 11, 0.12); }
.result-card.sky .res-icon { color: var(--accent-sky); background: rgba(6, 182, 212, 0.12); }

.res-info {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.res-info .res-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.res-info .res-val {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  margin-top: 2px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.res-info .res-note {
  font-size: 0.72rem;
  color: var(--text-subtle);
  margin-top: 4px;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}

/* Chart Card */
.chart-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
}

.chart-controls {
  display: flex;
  gap: 6px;
}

.sm-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.sm-btn.active {
  background: var(--primary);
  color: #fff !important;
  border-color: var(--primary);
}

.chart-body {
  height: 280px;
  position: relative;
  min-width: 0;
  width: 100%;
}

/* Table Card */
.table-card {
  margin-bottom: 0;
  min-width: 0;
  width: 100%;
}

.table-card .card-body {
  padding: 18px 20px 22px;
}

.table-actions {
  display: flex;
  gap: 10px;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.table-wrapper::-webkit-scrollbar {
  height: 6px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: var(--bg-input);
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.4);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.86rem;
}

.data-table th, .data-table td {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table th {
  background: var(--bg-input);
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.4px;
  white-space: nowrap;
  line-height: 1.35;
}

.data-table td {
  font-size: 0.85rem;
  line-height: 1.45;
}

.data-table td strong.highlight {
  white-space: nowrap;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-input);
}

.data-table tbody tr.current-row,
.data-table tbody tr.current-row td {
  background: var(--bg-input);
  font-weight: 700;
}

.data-table tbody tr.current-row td {
  border-top: 1.5px solid var(--border-color);
  border-bottom: 2px solid var(--border-color);
}

.data-table tbody tr.current-row:hover,
.data-table tbody tr.current-row:hover td {
  background: var(--bg-input);
  filter: brightness(0.97);
}

body.dark-mode .data-table tbody tr.current-row:hover,
body.dark-mode .data-table tbody tr.current-row:hover td {
  filter: brightness(1.12);
}

.data-table td.highlight {
  font-weight: 700;
  color: var(--accent-emerald);
}

/* Extensibility Banner - Theme Aware */
.extensibility-banner {
  background: var(--ext-banner-bg);
  border: 1.5px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  padding: 24px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: var(--shadow-sm);
}

.extensibility-content {
  display: flex;
  align-items: center;
  gap: 18px;
}

.ext-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.ext-text h4 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--ext-banner-text);
}

.ext-text p {
  color: var(--ext-banner-sub);
  font-size: 0.85rem;
  max-width: 680px;
}

/* Footer */
.app-footer {
  text-align: center;
  padding-top: 30px;
  color: var(--text-subtle);
  font-size: 0.82rem;
  border-top: 1px solid var(--border-color);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  color: var(--text-main);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  color: var(--text-main);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.code-preview {
  background: #0f172a;
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: var(--radius-sm);
  margin: 14px 0;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent-emerald);
  overflow-x: auto;
}

/* History List Items */
.history-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-info h5 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.history-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-cost {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-emerald);
}

/* Responsive Styles */
@media (max-width: 1024px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 1000;
    transform: translateX(-100%);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: block;
  }

  .sidebar-toggle-btn {
    display: flex;
  }

  .app-topbar {
    height: 70px;
    padding: 0 18px;
  }

  .main-content {
    padding: 20px 16px 40px;
  }

  .calculator-grid {
    grid-template-columns: 1fr;
  }
  
  .hero-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
  }

  .hero-stats {
    width: 100%;
    justify-content: flex-start;
  }

  .summary-cards-grid.cards-count-3,
  .summary-cards-grid[data-cards-count="3"] {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-cards-grid.cards-count-4,
  .summary-cards-grid[data-cards-count="4"],
  .summary-cards-grid.cards-count-2,
  .summary-cards-grid[data-cards-count="2"] {
    grid-template-columns: repeat(2, 1fr);
  }

  .extensibility-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .topbar-breadcrumb {
    display: none;
  }

  .topbar-actions .secondary-btn span {
    display: none;
  }

  .topbar-actions .secondary-btn {
    padding: 8px 10px;
  }

  .summary-cards-grid,
  .summary-cards-grid[class*="cards-count-"],
  .summary-cards-grid[data-cards-count] {
    grid-template-columns: 1fr !important;
  }

  .hero-stats {
    flex-direction: column;
    width: 100%;
  }

  .mini-stat-card {
    min-width: 100%;
  }
}

/* Print Styling */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .app-header, .header-actions, .nav-tabs, .hero-banner, .extensibility-banner, .table-actions, .sm-btn {
    display: none !important;
  }

  .card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: #fff !important;
    color: #000 !important;
  }

  .data-table th, .data-table td {
    border-bottom: 1px solid #ccc !important;
    color: #000 !important;
  }
}
