/* ===== ROOT & RESET ===== */
:root {
  --md-primary: #6750A4;
  --md-on-primary: #ffffff;
  --md-surface: #ffffff;
  --md-bg: #f4f4f9;
  --md-error: #B00020;
  --md-success: #0F9D58;
  --card-radius: 16px;
  --gap: 12px;
  --font: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--md-bg);
  color: #1e1e1e;
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}

/* ===== MATERIAL ICONS GLOBAL ===== */
.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  line-height: 1;
  font-size: 24px;
}
.md-btn .material-symbols-rounded { font-size: 20px; margin-right: 4px; }
.icon-btn .material-symbols-rounded { font-size: 28px; }
.app-bar .back .material-symbols-rounded { font-size: 28px; color: white; }

/* ===== APP BAR ===== */
.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--md-primary), #4a2f9e);
  color: var(--md-on-primary);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.app-bar.small { padding: 8px 14px; }
.app-bar .back { text-decoration: none; display: flex; align-items: center; }
.app-bar-left { display: flex; align-items: center; gap: 8px; }
.brand img, #logoFrame { height: 40px; width: 40px; object-fit: contain; border-radius: 8px; background: white; padding: 2px; }
.greeting { font-weight: 500; font-size: 0.95rem; opacity: 0.9; }

/* ===== CONTAINER & CARD ===== */
.container { padding: 12px; max-width: 900px; margin: 0 auto; }
.card {
  background: var(--md-surface);
  padding: 14px 16px;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
  margin-bottom: var(--gap);
  transition: all 0.2s ease;
}

/* ===== SEARCH ===== */
.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--gap);
  background: white;
  border-radius: 40px;
  padding: 4px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.search-row .search-icon { color: #777; }
.search-row input[type="search"] {
  flex: 1;
  padding: 12px 0;
  border: none;
  font-size: 1rem;
  background: transparent;
  outline: none;
}
.search-row .icon-btn { padding: 6px; }

/* ===== KPI GRID (BARU) ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: var(--gap);
}
.kpi-card {
  text-align: center;
  padding: 12px 4px;
  background: white;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.kpi-card .kpi-icon { font-size: 32px; color: var(--md-primary); }
.kpi-card.warning .kpi-icon { color: #F44336; }
.kpi-value { display: block; font-size: 24px; font-weight: 700; margin: 4px 0; }
.kpi-label { font-size: 11px; color: #777; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== BUTTONS ===== */
.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: 0.15s;
}
.icon-btn:active { background: rgba(0,0,0,0.08); }

.md-btn {
  background: var(--md-primary);
  color: var(--md-on-primary);
  border: none;
  padding: 10px 18px;
  border-radius: 40px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(103,80,164,0.3);
  cursor: pointer;
  transition: 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.md-btn:active { transform: scale(0.96); }

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: var(--gap);
}
.quick-actions .md-btn { white-space: nowrap; font-size: 0.85rem; padding: 8px 14px; }

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--md-primary);
  color: white;
  border: none;
  box-shadow: 0 4px 16px rgba(103,80,164,0.4);
  cursor: pointer;
  z-index: 30;
  transition: 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab .material-symbols-rounded { font-size: 32px; }
.fab:active { transform: scale(0.9); }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #eee;
  padding: 6px 0 10px;
  display: flex;
  justify-content: space-around;
  z-index: 40;
}
.bottom-nav a {
  text-decoration: none;
  color: #777;
  font-weight: 500;
  font-size: 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.bottom-nav a .material-symbols-rounded { font-size: 28px; }
.bottom-nav a.active { color: var(--md-primary); }
.bottom-nav a.active .material-symbols-rounded { font-variation-settings: 'FILL' 1; }

/* ===== INSIGHTS & RECENT ===== */
.insights h2, .mini-chart h2, .recent h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 6px;
}
#aiInsights { font-size: 0.95rem; line-height: 1.5; }
.recent-item {
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.recent-item .material-symbols-rounded { font-size: 18px; }

/* ===== CHART FILTER ===== */
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.filter-btn {
  background: #f0f0f0;
  border: none;
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: 0.15s;
}
.filter-btn.active { background: var(--md-primary); color: white; }
.filter-btn .material-symbols-rounded { font-size: 18px; }
.chart-type-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
.chart-type-selector select {
  padding: 8px 14px;
  border-radius: 30px;
  border: 1px solid #ddd;
  background: white;
  font-size: 0.9rem;
}

/* ===== COVER MODE ===== */
.cover-only { display: none; }
.cover-mode .cover-only { display: block; }
.cover-mode .main-only { display: none; }
.cover-mode .app-bar { padding: 6px 10px; }
.cover-mode .greeting { font-size: 0.7rem; }
.cover-mode .container { padding: 6px; }
.cover-mode .cover-summary { text-align: center; font-size: 0.9rem; }
.cover-mode .cover-summary #coverGreeting { font-size: 1.2rem; font-weight: 600; margin-bottom: 12px; }

/* ===== FLEX MODE ===== */
.flex-mode .container {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 12px;
  padding: 16px;
}
.flex-mode .bottom-nav { display: none; }
.flex-mode .fab { bottom: 30px; }

/* ===== SETTING ITEMS ===== */
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}
.setting-item .material-symbols-rounded { font-size: 22px; color: var(--md-primary); }
.setting-item label { font-weight: 500; font-size: 0.85rem; }
.setting-item input, .setting-item textarea, .setting-item select {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 12px;
  font-size: 1rem;
  width: 100%;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ===== DESKTOP ===== */
@media (min-width: 900px) {
  .container { max-width: 960px; }
  .bottom-nav { display: none; }
  .fab { bottom: 30px; }
}