:root {
  /* Primary: Warm Stone / Cream (60%) */
  --bg-main: #F5F3EC;
  --bg-card: #FBFAF6;
  --bg-secondary: #EBE9DF;
  --bg-inset: #F6F4EC;
  --border-subtle: #E7E3D7;
  --border-soft: #EFECE3;

  /* Secondary: Olive / Graphite / Sage (30%) */
  --bg-sidebar: #303B20;
  --bg-sidebar-hover: #3C4929;
  --text-primary: #252A20;
  --text-secondary: #5C6353;
  --text-muted: #767D6C;
  --olive: #66783E;
  --olive-deep: #465B24;
  --sage: #DDE3C9;
  --sage-soft: #EBF0DF;
  --sage-text: #3A4D22;

  /* Tertiary: Muted Terracotta (10%) */
  --terracotta: #C47A3A;
  --terracotta-hover: #AD672C;
  --terracotta-soft: #F5E8DC;

  /* Elevation & Geometry */
  --radius-card: 20px;
  --radius-subcard: 16px;
  --radius-nav: 12px;
  --shadow-card: 0 4px 20px -2px rgba(37, 42, 32, 0.045), 0 1px 4px rgba(37, 42, 32, 0.025);
  --shadow-popover: 0 14px 36px -6px rgba(37, 42, 32, 0.14), 0 4px 12px rgba(37, 42, 32, 0.06);
  --sidebar-width: clamp(232px, 17.5vw, 272px);
  --transition-fast: 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
select {
  font-family: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.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;
}

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

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 40;
  overflow: hidden;
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-top {
  position: relative;
  z-index: 2;
  padding: 28px 18px 108px;
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar-top::-webkit-scrollbar {
  display: none;
}

.sidebar-brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 28px;
  padding: 0 4px;
}

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

.brand-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background-color: var(--bg-card);
  color: var(--bg-sidebar);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.brand-icon-badge svg {
  width: 21px;
  height: 21px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 1.38rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: #FFFFFF;
}

.brand-tagline {
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.3;
  color: #C9D3B6;
  margin-top: 2px;
}

.sidebar-close-btn {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: #E7ECDD;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-close-btn svg {
  width: 18px;
  height: 18px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-nav);
  font-size: 0.96rem;
  font-weight: 500;
  color: #D7E0C6;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-item:hover {
  background-color: var(--bg-sidebar-hover);
  color: #FFFFFF;
}

.nav-item.is-active {
  background-color: var(--sage);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.92;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
}

.sidebar-divider {
  height: 1px;
  background-color: rgba(255, 255, 255, 0.16);
  margin: 18px 8px;
}

.sidebar-hills {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 98px;
  pointer-events: none;
  z-index: 1;
}

.sidebar-hills svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sidebar-backdrop {
  display: none;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  flex: 1;
  min-width: 0;
  padding: 26px 36px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-card);
  color: var(--text-primary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
}

.greeting-title {
  margin: 0;
  font-size: clamp(1.55rem, 1.85vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--text-primary);
}

.greeting-user {
  font-weight: 800;
}

.greeting-subtitle {
  margin: 4px 0 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
  width: clamp(325px, 28vw, 430px);
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  display: inline-flex;
  pointer-events: none;
}

.search-icon svg {
  width: 17px;
  height: 17px;
}

.search-input {
  width: 100%;
  height: 42px;
  padding: 0 58px 0 42px;
  border-radius: 9999px;
  border: 1px solid transparent;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  outline: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  background-color: var(--bg-card);
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(102, 120, 62, 0.14);
}

.search-kbd {
  position: absolute;
  right: 12px;
  padding: 3px 7px;
  border-radius: 6px;
  background-color: #DFDDD2;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.header-popover-wrap {
  position: relative;
}

.icon-circle-btn,
.profile-circle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.icon-circle-btn {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.icon-circle-btn:hover {
  background-color: #E2DFD3;
}

.profile-circle-btn {
  background-color: var(--olive);
  color: #FFFFFF;
}

.profile-circle-btn:hover {
  background-color: var(--olive-deep);
}

.icon-circle-btn svg,
.profile-circle-btn svg {
  width: 20px;
  height: 20px;
}

.notif-dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--terracotta);
  border: 2px solid var(--bg-secondary);
}

.notif-dot[hidden] {
  display: none;
}

/* Popovers */
.popover-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: var(--shadow-popover);
  z-index: 60;
  overflow: hidden;
}

.popover-panel[hidden] {
  display: none;
}

.search-dropdown {
  left: 0;
  right: auto;
  width: 100%;
  min-width: 320px;
}

.notif-dropdown {
  width: 336px;
}

.profile-dropdown {
  width: 274px;
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.popover-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
}

.popover-meta {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.text-action-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--terracotta);
  cursor: pointer;
}

.text-action-btn:hover {
  color: var(--terracotta-hover);
}

.search-results-list {
  max-height: 290px;
  overflow-y: auto;
  padding: 6px;
}

.search-result-btn {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.search-result-btn:hover {
  background-color: var(--bg-main);
}

.search-result-title {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
}

.search-result-meta {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.search-result-cat {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 9999px;
  background-color: var(--sage);
  color: var(--sage-text);
  white-space: nowrap;
}

.search-empty {
  padding: 18px 14px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.notif-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.notif-item {
  padding: 10px 12px;
  border-radius: 10px;
  transition: background-color var(--transition-fast);
}

.notif-item.is-unread {
  background-color: #F4F5ED;
}

.notif-item + .notif-item {
  margin-top: 4px;
}

.notif-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.notif-item-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.notif-item-time {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.notif-item-body {
  margin: 4px 0 0;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.profile-avatar-lg {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--olive);
  color: #FFFFFF;
  font-size: 0.875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-full-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-role {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--olive);
}

.profile-site {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.popover-divider {
  height: 1px;
  background-color: var(--border-soft);
}

.profile-menu-actions {
  padding: 6px;
}

.profile-menu-btn {
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.profile-menu-btn:hover {
  background-color: var(--bg-main);
}

/* Shared Dashboard Container & Stretching Grid */
.dashboard-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.dashboard-view[hidden],
.placeholder-view[hidden] {
  display: none;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header-icon {
  width: 22px;
  height: 22px;
  color: var(--bg-sidebar);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-header-icon svg {
  width: 22px;
  height: 22px;
}

.card-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.card-subtitle-pill {
  padding: 2px 9px;
  border-radius: 9999px;
  background-color: var(--bg-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Row 1: Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 22px 24px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 142px;
}

.stat-main {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon-well {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background-color: var(--sage-soft);
  color: var(--olive-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-well--terracotta {
  background-color: var(--terracotta-soft);
  color: var(--terracotta);
}

.stat-icon-well svg {
  width: 25px;
  height: 25px;
}

.stat-copy {
  min-width: 0;
}

.stat-label {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.3;
}

.stat-value {
  font-size: clamp(1.75rem, 2.05vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-top: 4px;
}

.stat-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 16px;
  font-size: 0.84rem;
}

.trend-pill {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background-color: #E3EAD3;
  color: var(--olive-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.trend-pill--terracotta {
  background-color: var(--terracotta-soft);
  color: var(--terracotta);
}

.trend-pill svg {
  width: 12px;
  height: 12px;
}

.trend-highlight {
  font-weight: 700;
  color: var(--olive-deep);
}

.trend-highlight--terracotta {
  color: var(--terracotta);
}

.trend-context {
  font-weight: 500;
  color: var(--text-muted);
}

.clock-badge {
  width: 17px;
  height: 17px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.clock-badge svg {
  width: 16px;
  height: 16px;
}

/* Row 2: Middle Grid (Stretches vertically to fill viewport) */
.middle-grid {
  flex: 1.25 1 280px;
  display: grid;
  grid-template-columns: 1.36fr 1fr;
  gap: 22px;
}

.activity-card,
.iot-card {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
}

/* Pill Select */
.pill-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.pill-select {
  appearance: none;
  background-color: var(--bg-card);
  border: 1px solid #E1DDD0;
  border-radius: 9999px;
  padding: 7px 34px 7px 15px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.pill-select:hover,
.pill-select:focus {
  border-color: var(--olive);
  background-color: #FFFFFF;
}

.pill-select-chevron {
  position: absolute;
  right: 12px;
  pointer-events: none;
  color: var(--text-secondary);
  display: inline-flex;
}

.pill-select-chevron svg {
  width: 14px;
  height: 14px;
}

/* Bar Chart */
.chart-wrapper {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 14px;
  padding: 8px 0 26px;
  min-height: 205px;
}

.chart-y-axis {
  height: 100%;
  min-height: 175px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 30px;
  flex-shrink: 0;
  line-height: 1;
}

.chart-plot-region {
  position: relative;
  flex: 1;
  height: 100%;
  min-height: 175px;
}

.chart-gridlines {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.gridline {
  width: 100%;
  border-top: 1px solid var(--border-soft);
}

.gridline--base {
  border-top-color: #E2DFD4;
}

.chart-bars {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(10px, 1.4vw, 22px);
  padding: 0 12px;
  align-items: end;
}

.chart-bar-col {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  position: relative;
}

.chart-bar-btn {
  width: 100%;
  max-width: 68px;
  min-height: 8px;
  border: none;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  position: relative;
  transition: height 280ms cubic-bezier(0.22, 1, 0.36, 1), filter var(--transition-fast), transform var(--transition-fast);
}

.chart-bar-btn:hover,
.chart-bar-btn:focus-visible {
  filter: brightness(0.94);
  outline: none;
}

.bar-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background-color: var(--text-primary);
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.chart-bar-btn:hover .bar-tooltip,
.chart-bar-btn:focus-visible .bar-tooltip,
.chart-bar-btn.is-selected .bar-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.bar-tone--sage-1 { background-color: #DCE3CC; }
.bar-tone--sage-2 { background-color: #CBD6B6; }
.bar-tone--sage-3 { background-color: #BCCBA4; }
.bar-tone--sage-4 { background-color: #A4B988; }
.bar-tone--sage-5 { background-color: #95AB75; }
.bar-tone--sage-6 { background-color: #76904D; }
.bar-tone--olive-peak { background-color: #466126; }

.chart-x-label {
  position: absolute;
  top: calc(100% + 10px);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* IoT Compost Health Card */
.iot-card {
  position: relative;
  overflow: hidden;
  padding-bottom: 84px;
}

.iot-header {
  position: relative;
  z-index: 2;
  margin-bottom: 12px;
}

.iot-title-stack {
  align-items: flex-start;
}

.iot-title-stack .card-header-icon {
  margin-top: 2px;
}

.iot-demo-caption {
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.iot-metrics-grid {
  position: relative;
  z-index: 2;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: center;
  gap: 16px;
}

.iot-metric-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 20px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: 0 2px 10px rgba(37, 42, 32, 0.03);
}

.iot-metric-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: var(--sage-soft);
  color: var(--olive-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.iot-metric-icon svg {
  width: 22px;
  height: 22px;
}

.iot-metric-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.iot-metric-value {
  font-size: clamp(1.45rem, 1.75vw, 1.7rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 4px 0 9px;
  line-height: 1.1;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
}

.status-badge--optimal {
  background-color: var(--sage);
  color: var(--sage-text);
}

.status-badge--attention {
  background-color: var(--terracotta-soft);
  color: #9A4E1A;
}

.iot-landscape {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 84px;
  pointer-events: none;
  z-index: 1;
}

.iot-hills-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.iot-sprout-svg {
  position: absolute;
  right: 26px;
  bottom: 14px;
  width: 82px;
  height: 48px;
}

/* Row 3: Bottom Grid (Stretches vertically to fill viewport) */
.bottom-grid {
  flex: 1 1 225px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.batches-card,
.recent-card {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
}

.view-all-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--terracotta);
  transition: color var(--transition-fast);
}

.view-all-link:hover {
  color: var(--terracotta-hover);
}

.view-all-link svg {
  width: 15px;
  height: 15px;
  transition: transform var(--transition-fast);
}

.view-all-link:hover svg {
  transform: translateX(2px);
}

/* Active Batches Card Body (Spacious, clean layout matching reference) */
.featured-batch-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(190px, 45%) 1fr;
  gap: 22px;
  align-items: center;
}

.batch-photo-frame {
  border-radius: var(--radius-subcard);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-secondary);
  height: 100%;
  min-height: 162px;
  max-height: 224px;
}

.batch-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.batch-summary-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 4px 0;
}

.batch-panel-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.batch-id-heading {
  margin: 0;
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.batch-meta-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.batch-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 5px;
}

.batch-meta-row--material {
  margin-top: 0;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.batch-meta-row svg {
  width: 16px;
  height: 16px;
  color: var(--olive);
  flex-shrink: 0;
}

.batch-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
}

.batch-status-label {
  font-weight: 600;
  color: var(--text-muted);
}

.terracotta-arrow-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background-color: var(--terracotta);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(196, 122, 58, 0.28);
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.terracotta-arrow-btn:hover {
  background-color: var(--terracotta-hover);
  transform: translateX(2px);
}

.terracotta-arrow-btn svg {
  width: 17px;
  height: 17px;
}

/* Recent Activities List */
.activity-list {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}

.activity-list-item + .activity-list-item {
  border-top: 1px solid var(--border-soft);
}

.activity-row-btn {
  width: 100%;
  border: none;
  background: transparent;
  padding: 12px 8px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  transition: background-color var(--transition-fast);
}

.activity-row-btn:hover {
  background-color: var(--bg-inset);
}

.activity-row-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.activity-icon-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--sage-soft);
  color: var(--olive-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon-circle svg {
  width: 19px;
  height: 19px;
}

.activity-text-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.activity-row-title {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-primary);
}

.activity-row-subtitle {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-row-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.activity-time {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.activity-row-right svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-fast);
}

.activity-row-btn:hover .activity-row-right svg {
  transform: translateX(2px);
}

/* Placeholder Section View */
.placeholder-card {
  padding: 28px 32px;
}

.placeholder-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.placeholder-eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--olive);
}

.placeholder-title {
  margin: 4px 0 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
}

.placeholder-subtitle {
  margin: 6px 0 0;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.placeholder-summary {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background-color: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.terracotta-pill-btn {
  border: none;
  border-radius: 9999px;
  background-color: var(--terracotta);
  color: #FFFFFF;
  padding: 10px 18px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.terracotta-pill-btn:hover {
  background-color: var(--terracotta-hover);
}

.placeholder-preview-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.preview-mini-card {
  background-color: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 16px;
}

.preview-mini-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-primary);
}

.preview-mini-meta {
  margin: 6px 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(37, 42, 32, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 80;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  width: 100%;
  max-width: 480px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--terracotta);
}

.modal-title {
  margin: 3px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-inset);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-close-btn svg {
  width: 17px;
  height: 17px;
}

.modal-body {
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background-color: var(--bg-inset);
  font-size: 0.84rem;
}

.modal-detail-key {
  font-weight: 600;
  color: var(--text-muted);
}

.modal-detail-val {
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

.modal-detail-note {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Tablet Breakpoint */
@media (max-width: 1120px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .middle-grid,
  .bottom-grid {
    flex: none;
    grid-template-columns: 1fr;
  }

  .iot-card {
    padding-bottom: 100px;
  }
}

@media (max-width: 1023px) {
  .sidebar {
    width: 268px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-popover);
  }

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

  .sidebar-close-btn {
    display: inline-flex;
  }

  .sidebar-backdrop.is-visible {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(37, 42, 32, 0.45);
    z-index: 35;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 20px 22px 26px;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .search-container {
    width: 290px;
  }
}

/* Mobile Breakpoint */
@media (max-width: 680px) {
  .main-content {
    padding: 16px 14px 24px;
    gap: 16px;
  }

  .top-header {
    align-items: stretch;
    gap: 14px;
  }

  .header-actions {
    width: 100%;
    margin-left: 0;
  }

  .search-container {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .search-kbd {
    display: none;
  }

  .greeting-title {
    font-size: 1.4rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    min-height: 120px;
    padding: 18px 20px;
  }

  .activity-card,
  .iot-card,
  .batches-card,
  .recent-card {
    padding: 18px 16px;
  }

  .iot-card {
    padding-bottom: 92px;
  }

  .iot-metrics-grid {
    grid-template-columns: 1fr;
  }

  .featured-batch-layout {
    grid-template-columns: 1fr;
  }

  .batch-photo-frame {
    height: 175px;
  }

  .chart-bars {
    gap: 8px;
    padding: 0 4px;
  }

  .notif-dropdown {
    width: min(310px, calc(100vw - 28px));
  }
}
