/* ================================================
   TOMAT CHERRY DASHBOARD — Design System
   Version 1.0
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ---- CSS Custom Properties ---- */
:root {
  /* Brand Palette */
  --red-950: #3d120d;
  --red-900: #6b1f17;
  --red-800: #8c2b21;
  --red-700: #a13826;
  --red-600: #ab4e44;
  --red-500: #b85f56;
  --red-400: #c4756e;
  --red-300: #d4958f;
  --red-200: #e4b5b1;
  --red-100: #f4dbd9;

  --green-950: #071209;
  --green-900: #0f2212;
  --green-800: #1a2e1b;
  --green-700: #253c27;
  --green-600: #3d5c3a;
  --green-500: #547c58;
  --green-400: #619260;
  --green-300: #779c74;
  --green-200: #95b393;
  --green-100: #c0d5bf;
  --green-50:  #e8f0e7;

  /* Theme Tokens — Light Gray (Fixed) */
  --bg-base:      #eef0ee;
  --bg-primary:   #f1f3f1;
  --bg-secondary: #e8ebe8;
  --bg-surface:   #ffffff;
  --bg-surface-2: #f6f8f6;
  --bg-surface-3: #eef1ee;
  --bg-card:      rgba(255, 255, 255, 0.96);
  --bg-glass:     rgba(84, 124, 88, 0.06);
  --bg-glass-2:   rgba(0, 0, 0, 0.03);

  --text-primary:   #1c2e1e;
  --text-secondary: #3d5e3f;
  --text-muted:     #7a9e7c;
  --text-inverse:   #ffffff;

  --border-subtle:  rgba(84, 124, 88, 0.1);
  --border-default: rgba(84, 124, 88, 0.18);
  --border-hover:   rgba(84, 124, 88, 0.32);
  --border-active:  rgba(84, 124, 88, 0.5);

  /* Semantic */
  --primary:        var(--red-600);
  --primary-dark:   var(--red-700);
  --primary-light:  var(--red-500);
  --secondary:      var(--green-400);
  --secondary-dark: var(--green-500);
  --success:        #2e9e5a;
  --warning:        #d4881a;
  --danger:         #cc3333;
  --info:           #2a7fbf;

  /* Dynamic Brand Colors (Set by JS) */
  --color-brand-primary: var(--red-600);
  --color-brand-accent: var(--green-500);

  /* Gradients */
  --grad-primary: linear-gradient(135deg, var(--color-brand-primary) 0%, var(--color-brand-primary) 100%);
  --grad-green:   linear-gradient(135deg, var(--color-brand-accent) 0%, var(--color-brand-accent) 100%);
  --grad-dark:    linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-base) 100%);
  --grad-card:    linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(246,248,246,0.95) 100%);
  --grad-glow:    radial-gradient(ellipse at top, rgba(171,78,68,0.06) 0%, transparent 60%);

  /* Spacing Scale */
  --s-1:  0.25rem;
  --s-2:  0.5rem;
  --s-3:  0.75rem;
  --s-4:  1rem;
  --s-5:  1.25rem;
  --s-6:  1.5rem;
  --s-8:  2rem;
  --s-10: 2.5rem;
  --s-12: 3rem;
  --s-16: 4rem;
  --s-20: 5rem;

  /* Typography */
  --font-sans:    'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  --text-2xs: 0.65rem;
  --text-xs:  0.75rem;
  --text-sm:  0.875rem;
  --text-md:  1rem;
  --text-lg:  1.125rem;
  --text-xl:  1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  /* Border Radius — Subtle & Sleek (Sedikit Round) */
  --r-xs:   2px;
  --r-sm:   4px;
  --r-md:   6px;
  --r-lg:   8px;
  --r-xl:   10px;
  --r-2xl:  12px;
  --r-3xl:  14px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-xs:  0 1px 3px rgba(0,0,0,0.07);
  --shadow-sm:  0 2px 6px rgba(0,0,0,0.09);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.11);
  --shadow-lg:  0 8px 30px rgba(0,0,0,0.13);
  --shadow-xl:  0 16px 50px rgba(0,0,0,0.15);
  --shadow-2xl: 0 24px 64px rgba(0,0,0,0.18);
  --glow-red:   0 0 20px rgba(171,78,68,0.2),  0 0 40px rgba(161,56,38,0.08);
  --glow-green: 0 0 20px rgba(97,146,96,0.18), 0 0 40px rgba(84,124,88,0.08);

  /* Transitions */
  --ease-fast:   150ms cubic-bezier(0.4,0,0.2,1);
  --ease-base:   250ms cubic-bezier(0.4,0,0.2,1);
  --ease-slow:   400ms cubic-bezier(0.4,0,0.2,1);
  --ease-bounce: 300ms cubic-bezier(0.34,1.56,0.64,1);

  /* Layout */
  --sidebar-w:    260px;
  --sidebar-mini: 72px;
  --topbar-h:     64px;
  --content-max:  1400px;
}

/* (Dark/light mode removed — single light theme) */

/* ================================================
   RESET & BASE
   ================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Global Professional Text Wrapping */
h1, h2, h3, h4, p, span, div {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-base);
  background-image: var(--grad-glow);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(171,78,68,0.35);
  color: var(--text-primary);
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ================================================
   UTILITY CLASSES
   ================================================ */
.hidden   { display: none !important; }
.sr-only  { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.relative { position: relative; }
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-2   { gap: var(--s-2); }
.gap-3   { gap: var(--s-3); }
.gap-4   { gap: var(--s-4); }
.gap-6   { gap: var(--s-6); }
.gap-8   { gap: var(--s-8); }
.w-full  { width: 100%; }
.h-full  { height: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-bold   { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-display { font-family: var(--font-display); }

/* Color utilities */
.text-primary-color { color: var(--primary); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.text-danger   { color: var(--danger); }
.text-muted    { color: var(--text-muted); }
.text-secondary-color { color: var(--text-secondary); }

/* ================================================
   LAYOUT — APP SHELL
   ================================================ */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(161,56,38,0.1) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 20% 100%, rgba(84,124,88,0.08) 0%, transparent 50%);
}

#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--ease-slow), transform var(--ease-slow);
  overflow: hidden;
}

#sidebar.collapsed {
  width: var(--sidebar-mini);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
  height: var(--topbar-h);
  flex-shrink: 0;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-lg);
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: var(--glow-red);
}

.logo-text {
  overflow: hidden;
  transition: opacity var(--ease-slow), width var(--ease-slow);
}

.logo-text h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-sm);
  color: var(--text-primary);
  white-space: nowrap;
  line-height: 1.2;
}

.logo-text p {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

#sidebar.collapsed .logo-text {
  opacity: 0;
  width: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s-3) 0;
}

.nav-section-label {
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--s-4) var(--s-5) var(--s-2);
  white-space: nowrap;
  transition: opacity var(--ease-slow);
}

#sidebar.collapsed .nav-section-label {
  opacity: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0.6rem var(--s-4);
  margin: 2px var(--s-3);
  border-radius: var(--r-lg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--ease-base);
  white-space: nowrap;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(161,56,38,0.1);
  color: var(--red-700);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -var(--s-3);
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: var(--r-full);
  left: 0;
}

.nav-item .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 1.25rem !important; /* Force a harmonious size */
  flex-shrink: 0;
  opacity: 0.8;
  color: var(--green-400);
}

.nav-item.active .nav-icon { opacity: 1; color: inherit; }

.nav-label {
  font-size: var(--text-sm);
  font-weight: 500;
  overflow: hidden;
  transition: opacity var(--ease-slow), width var(--ease-slow);
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: var(--text-2xs);
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-full);
  flex-shrink: 0;
  transition: opacity var(--ease-slow);
}

#sidebar.collapsed .nav-label,
#sidebar.collapsed .nav-badge,
#sidebar.collapsed .nav-section-label {
  display: none;
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--s-4);
}

.user-card {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2);
  border-radius: var(--r-lg);
  transition: background var(--ease-base);
  cursor: pointer;
}

.user-card:hover { background: var(--bg-glass); }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info { overflow: hidden; transition: opacity var(--ease-slow); }
.user-name  { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.user-role  { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }

#sidebar.collapsed .user-info { opacity: 0; width: 0; display: none; }

/* ---- Main Content ---- */
#main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--ease-slow);
}

#main-content.sidebar-collapsed { margin-left: var(--sidebar-mini); }

/* ---- Topbar ---- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-6);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--s-4);
}

.btn-collapse {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--ease-base);
  flex-shrink: 0;
}

.btn-collapse:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--ease-base);
  position: relative;
}

.topbar-btn:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: var(--r-full);
  border: 1.5px solid var(--bg-primary);
}

.weather-chip {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--ease-base);
}

.weather-chip:hover {
  background: var(--bg-surface-2);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ---- Page Content ---- */
#page-content {
  flex: 1;
  min-width: 0;
  padding: var(--s-6);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ================================================
   CARD COMPONENTS
   ================================================ */
.card { min-width: 0; max-width: 100%; box-sizing: border-box;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--s-6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--ease-base), box-shadow var(--ease-base), transform var(--ease-base);
}

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

.card-hover:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-5);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

/* KPI Cards */
.kpi-card {
  border: none;
  border-radius: var(--r-xl);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  height: 110px !important;
  position: relative;
  overflow: hidden;
  transition: all var(--ease-base);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  color: #ffffff;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: #ffffff;
  opacity: 0.1;
  transform: translate(20%, -30%);
}

/* Elegant Gradient Backgrounds */
.kpi-card.red     { background: linear-gradient(135deg, var(--red-500), var(--red-700)); }
.kpi-card.green   { background: linear-gradient(135deg, var(--green-400), var(--green-600)); }
.kpi-card.warning { background: linear-gradient(135deg, #f2a635, #c77b10); }
.kpi-card.info    { background: linear-gradient(135deg, #4da4e0, #226da8); }

.kpi-card:hover {
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  transform: translateY(-3px);
}

.kpi-icon {
  width: 32px; height: 32px; border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.kpi-card .kpi-icon { 
  background: rgba(255, 255, 255, 0.25) !important; 
  color: #ffffff !important; 
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
}

/* Override text color inside the card */
.kpi-card .kpi-value { color: #ffffff; }
.kpi-card .kpi-label { color: rgba(255, 255, 255, 0.9); }
.kpi-card .kpi-change { 
  background: rgba(255, 255, 255, 0.22) !important; 
  color: #ffffff !important; 
}

.kpi-change {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
}

.kpi-change.up   { background: rgba(76,175,116,0.15); color: var(--success); }
.kpi-change.down { background: rgba(224,85,85,0.15);  color: var(--danger);  }
.kpi-change.flat { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ================================================
   GRID SYSTEM
   ================================================ */
.grid { display: grid; gap: var(--s-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* ================================================
   BUTTONS
   ================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0.55rem var(--s-4);
  border-radius: var(--r-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  transition: all var(--ease-base);
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.08);
  opacity: 0;
  transition: opacity var(--ease-fast);
  border-radius: inherit;
}

.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(161,56,38,0.35);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(161,56,38,0.5); }

.btn-green {
  background: var(--grad-green);
  color: #fff;
  box-shadow: 0 2px 8px rgba(84,124,88,0.35);
}
.btn-green:hover { box-shadow: 0 4px 16px rgba(84,124,88,0.5); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-default);
}
.btn-outline:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-glass);
}

.btn-ghost {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-surface-2); }

.btn-danger {
  background: rgba(224,85,85,0.15);
  color: var(--danger);
  border-color: rgba(224,85,85,0.25);
}
.btn-danger:hover { background: rgba(224,85,85,0.25); }

.btn-sm { padding: 0.35rem var(--s-3); font-size: var(--text-xs); border-radius: var(--r-md); }
.btn-lg { padding: 0.75rem var(--s-6); font-size: var(--text-md); border-radius: var(--r-xl); }
.btn-icon { width: 36px; height: 36px; padding: 0 !important; border-radius: var(--r-md); font-size: 20px; }
.btn-icon-sm { width: 26px; height: 26px; padding: 0 !important; border-radius: var(--r-sm); font-size: 16px; flex-shrink: 0; }

/* ================================================
   FORMS
   ================================================ */
.form-group { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 0.55rem var(--s-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: all var(--ease-base);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

@media (max-width: 1024px) {
  .form-control {
    /* Mencegah iOS Safari auto-zoom saat fokus input */
    font-size: 16px !important;
  }
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus {
  border-color: var(--border-active);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(97,146,96,0.12);
}

.form-control:hover:not(:focus) { border-color: var(--border-hover); }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236a8a6a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-grid { display: grid; gap: var(--s-4); }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); align-items: start; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); align-items: start; }

/* ================================================
   TABLES
   ================================================ */
.table-wrapper { width: 100%; max-width: 100%; box-sizing: border-box;
  overflow-x: auto;
  border-radius: var(--r-xl);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table thead tr {
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-default);
}

.data-table th {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: var(--s-3) var(--s-4);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

.data-table tbody tr:hover { background: var(--bg-glass); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ================================================
   BADGES & STATUS
   ================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: rgba(76,175,116,0.15); color: var(--success);  border: 1px solid rgba(76,175,116,0.25); }
.badge-danger  { background: rgba(224,85,85,0.15);  color: var(--danger);   border: 1px solid rgba(224,85,85,0.25); }
.badge-warning { background: rgba(232,168,56,0.15); color: var(--warning);  border: 1px solid rgba(232,168,56,0.25); }
.badge-info    { background: rgba(74,159,212,0.15); color: var(--info);     border: 1px solid rgba(74,159,212,0.25); }
.badge-red     { background: rgba(171,78,68,0.15);  color: var(--red-300);  border: 1px solid rgba(171,78,68,0.25); }
.badge-green   { background: rgba(97,146,96,0.15);  color: var(--green-200); border: 1px solid rgba(97,146,96,0.25); }
.badge-muted   { background: var(--bg-glass);       color: var(--text-muted); border: 1px solid var(--border-subtle); }

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}
.status-dot.success { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.danger  { background: var(--danger);  box-shadow: 0 0 6px var(--danger);  }
.status-dot.warning { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.status-dot.muted   { background: var(--text-muted); }

/* ================================================
   MODAL
   ================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-2xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-2xl);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.modal-body    { padding: var(--s-6); }
.modal-footer  { padding: var(--s-4) var(--s-6); border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: var(--s-3); }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: var(--bg-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--ease-fast);
}

.modal-close:hover { background: var(--bg-surface-2); color: var(--text-primary); }

/* ================================================
   PROGRESS BARS
   ================================================ */
.progress-bar {
  height: 6px;
  background: var(--bg-surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--grad-green);
  transition: width 800ms cubic-bezier(0.4,0,0.2,1);
}

.progress-fill.red     { background: var(--grad-primary); }
.progress-fill.warning { background: linear-gradient(90deg, #e8a838, #f0c050); }

/* ================================================
   TABS
   ================================================ */
.tabs {
  display: flex;
  gap: var(--s-1);
  background: var(--bg-surface-2);
  border-radius: var(--r-xl);
  padding: var(--s-1);
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  flex: 1;
  padding: 0.4rem 0.85rem;
  border-radius: var(--r-lg);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--ease-base);
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-btn:hover { color: var(--text-secondary); }

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ================================================
   PAGE HEADER
   ================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--s-6);
  gap: var(--s-4);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--s-1);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-shrink: 0;
}

/* ================================================
   SEARCH & FILTER BAR
   ================================================ */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: var(--s-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.search-input {
  width: 100%;
  padding: 0.55rem var(--s-4) 0.55rem 2.25rem;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: all var(--ease-base);
  outline: none;
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--border-active); background: var(--bg-surface); box-shadow: 0 0 0 3px rgba(97,146,96,0.12); }

/* ================================================
   MOBILE BOTTOM NAV
   ================================================ */
#mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: var(--s-2) var(--s-2) calc(var(--s-2) + env(safe-area-inset-bottom));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.mobile-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-secondary);
  padding: 0;
  width: 64px;
  height: 64px;
  border-radius: var(--r-md);
  transition: all var(--ease-base);
}

.mobile-nav-item i {
  color: var(--green-400);
}

.mobile-nav-item.active i {
  color: inherit;
}

.mobile-nav-item.active {
  color: var(--red-400);
  background: rgba(171,78,68,0.12);
}

.mobile-nav-item span {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ================================================
   TOAST NOTIFICATIONS
   ================================================ */
#toast-container {
  position: fixed;
  bottom: var(--s-6);
  right: var(--s-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  max-width: 360px;
  min-width: 260px;
  pointer-events: auto;
  font-size: var(--text-sm);
}

.toast-success { background: rgba(76,175,116,0.1); border-color: rgba(76,175,116,0.3); }
.toast-success .toast-icon { color: var(--success); }

.toast-error { background: rgba(224,85,85,0.1); border-color: rgba(224,85,85,0.3); }
.toast-error .toast-icon { color: var(--danger); }

.toast-warning { background: rgba(232,168,56,0.1); border-color: rgba(232,168,56,0.3); }
.toast-warning .toast-icon { color: var(--warning); }

.toast-info { background: rgba(46,158,90,0.05); border-color: rgba(46,158,90,0.2); }
.toast-info .toast-icon { color: var(--primary); }

.toast-icon { flex-shrink: 0; font-size: 1.25rem; display: flex; align-items: center; justify-content: center; }
.toast-msg  { flex: 1; color: var(--text-primary); font-weight: 600; font-size: 13px; line-height: 1.4; }

/* ================================================
   CHART CONTAINER
   ================================================ */
.chart-container {
  position: relative;
  width: 100%;
}

/* ================================================
   EMPTY STATES
   ================================================ */
.empty-state {
  text-align: center;
  padding: var(--s-16) var(--s-8);
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: var(--s-4); opacity: 0.5; }
.empty-state h3 { font-size: var(--text-lg); font-weight: 600; color: var(--text-secondary); margin-bottom: var(--s-2); }
.empty-state p  { font-size: var(--text-sm); max-width: 320px; margin: 0 auto; }

/* ================================================
   SKELETON LOADING
   ================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-surface-3) 50%, var(--bg-surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--r-md);
}

/* ================================================
   SWITCH TOGGLE
   ================================================ */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-surface-3);
  border-radius: var(--r-full);
  transition: all var(--ease-base);
  border: 1px solid var(--border-default);
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--ease-bounce);
}

.switch input:checked + .switch-slider { background: rgba(97,146,96,0.3); border-color: var(--green-400); }
.switch input:checked + .switch-slider::before { transform: translate(20px, -50%); background: var(--green-300); }

/* ================================================
   RESPONSIVE BREAKPOINTS & MOBILE OPTIMIZATIONS
   ================================================ */
@media (max-width: 1280px) {
  :root { --sidebar-w: 220px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Universal override for all inline grid-template-columns */
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 1024px) {
  .form-control, .btn {
    /* Touch Target & iOS Zoom Fix */
    font-size: 16px !important;
    min-height: 42px;
  }

  #sidebar {
    transform: translateX(-100%);
    width: 260px !important;
    z-index: 9999 !important;
  }

  #sidebar.collapsed {
    width: 260px !important;
  }

  #sidebar.collapsed .logo-text,
  #sidebar.collapsed .nav-label,
  #sidebar.collapsed .nav-badge,
  #sidebar.collapsed .nav-section-label,
  #sidebar.collapsed .user-info {
    opacity: 1 !important;
    width: auto !important;
    display: flex !important;
  }

  #sidebar.mobile-open {
    transform: translateX(0) !important;
    box-shadow: 0 0 50px rgba(0,0,0,0.4);
  }

  #topbar {
    padding: 0 var(--s-3);
  }

  #main-content {
    margin-left: 0 !important;
    padding-bottom: 84px;
    width: 100% !important;
    overflow-x: hidden;
  }

  #mobile-nav { display: block; }

  #page-content {
    padding: var(--s-3);
    width: 100% !important;
    box-sizing: border-box;
  }

  .grid,
  .grid-2,
  .grid-3,
  .grid-4,
  .grid-auto {
    grid-template-columns: 1fr !important;
  }

  .form-grid,
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr !important;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-3);
  }

  .page-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
  }

  .page-actions .btn,
  .page-actions select {
    flex: 1 1 auto;
    justify-content: center;
  }

  .card { min-width: 0; max-width: 100%; box-sizing: border-box;
    padding: var(--s-4);
    box-sizing: border-box;
    max-width: 100%;
  }

  /* Table touch scroll with min-width guard */
  .table-wrapper { width: 100%; max-width: 100%; box-sizing: border-box;
    width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--s-2);
  }

  .data-table {
    min-width: 600px;
    font-size: var(--text-xs) !important;
  }

  .data-table th,
  .data-table td {
    padding: var(--s-2) var(--s-3);
    white-space: nowrap;
  }

  .chart-container {
    height: 200px !important;
  }

  .modal-overlay {
    padding: var(--s-2);
    align-items: flex-end;
    z-index: 10000 !important;
  }

  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  }

  .modal-body {
    padding: var(--s-4);
  }

  .modal-footer {
    padding: var(--s-3) var(--s-4);
  }

  #toast-container {
    bottom: 80px;
    right: var(--s-3);
    left: var(--s-3);
  }

  .toast { max-width: 100%; min-width: 0; }

  .topbar-btn.hide-mobile { display: none; }
  .weather-chip .weather-temp { display: none; }

  .tabs {
    flex-wrap: wrap;
    gap: 2px;
  }

  .tab-btn {
    padding: 0.4rem var(--s-2);
    font-size: var(--text-xs);
  }

  #leaflet-map {
    height: 340px !important;
  }
}

@media (max-width: 480px) {
  :root { --topbar-h: 56px; }
  .breadcrumb { display: none; }
  
  /* Typography & Layout Scaling for Mobile */
  body { font-size: 13px; }
  .page-title { font-size: 1.25rem !important; }
  
  /* Cards */
  .card { min-width: 0; max-width: 100%; box-sizing: border-box; padding: 16px !important; border-radius: var(--r-lg); }
  
  /* KPI Cards Compact Mobile */
  [style*="grid-template-columns"]:has(> .kpi-card) { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .kpi-card { padding: 12px 14px !important; height: 90px !important; gap: 6px !important; }
  .kpi-card::after { width: 80px; height: 80px; }
  .kpi-value { font-size: 1.15rem !important; margin-top: 2px !important; }
  .kpi-label { font-size: 11px !important; white-space: normal !important; line-height: 1.3 !important; }
  .kpi-change { display: none !important; }
  .kpi-icon { width: 28px !important; height: 28px !important; font-size: 1.1rem !important; }
  
  /* Tables & Buttons */
  .data-table th, .data-table td { padding: 10px 12px !important; font-size: 12px !important; }
  .btn { font-size: 13px !important; }

  #leaflet-map { height: 300px !important; }
  .search-input-wrap { width: 100%; }
}

/* ================================================
   SIDEBAR OVERLAY (mobile)
   ================================================ */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9998;
  backdrop-filter: blur(3px);
}

#sidebar-overlay.visible { display: block !important; }



/* ================================================
   TOM SELECT OVERRIDES (Dark/Light Theme)
   ================================================ */
.ts-control {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--r-lg) !important;
  padding: 0.55rem var(--s-3) !important;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02) !important;
  font-family: inherit !important;
  font-size: var(--text-sm) !important;
  transition: all var(--ease-base) !important;
}
.ts-control.focus {
  border-color: var(--border-active) !important;
  box-shadow: 0 0 0 3px rgba(171,78,68,0.12) !important; /* using primary red shadow */
}
.ts-dropdown {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-lg) !important;
  margin-top: 4px !important;
  font-family: inherit !important;
  font-size: var(--text-sm) !important;
 z-index: 9999 !important; }
.ts-dropdown .option {
  padding: 0.6rem 0.8rem !important;
  transition: background 0.15s ease;
  color: var(--text-primary) !important; z-index: 9999 !important; }
/* Match app hover theme */
.ts-dropdown .option.active, .ts-dropdown .option:hover {
  background: rgba(171,78,68,0.08) !important;
  color: var(--primary) !important;
}
.ts-wrapper.single .ts-control:after {
  border-color: var(--text-muted) transparent transparent transparent !important;
}
.ts-wrapper.single.dropdown-active .ts-control:after {
  border-color: transparent transparent var(--text-muted) transparent !important;
}
.ts-control input {
  color: var(--text-primary) !important;
  font-size: var(--text-sm) !important;
}
.item {
  color: var(--text-primary) !important;
}


.ts-wrapper.form-control {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: stretch !important;
  height: 100% !important;
}
.ts-wrapper.form-control .ts-control {
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  overflow: hidden !important;
  min-height: 0 !important;
}
.ts-wrapper.form-control .item {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}




/* Phosphor Icons alignment fix */
.ph-duotone {
  vertical-align: text-bottom;
  margin-right: 0.15rem;
}
.nav-item .ph-duotone, .mobile-nav-item .ph-duotone {
  margin-right: 0;
  vertical-align: middle;
}


/* Compact KPI Grid for all devices */
[class*='grid']:has(> .kpi-card) {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
  gap: var(--s-3) !important;
}

/* Custom map cursor for drawing */
.crosshair-cursor-enabled,
.crosshair-cursor-enabled .leaflet-interactive {
  cursor: crosshair !important;
}
