:root {
  /* Dark Mode (default) */
  color-scheme: dark;
  --bg: #0a1f1a;
  --bg-alt: #112d26;
  --text: #e8f5f0;
  --text-dim: rgba(232, 245, 240, 0.6);
  --primary: #4ade80;
  --primary-strong: #22c55e;
  --accent: #fbbf24;
  --danger: #ef4444;
  --success: #22c55e;
  --card: rgba(17, 45, 38, 0.85);
  --card-bg: rgba(17, 45, 38, 0.9);
  --border: rgba(74, 222, 128, 0.2);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --bg-gradient-1: rgba(34, 197, 94, 0.15);
  --bg-gradient-2: rgba(251, 191, 36, 0.1);
  --bg-shape-1: #22c55e;
  --bg-shape-2: #fbbf24;
  --stat-bg: rgba(74, 222, 128, 0.08);
  --table-bg: rgba(17, 45, 38, 0.4);
  --table-header-bg: rgba(74, 222, 128, 0.15);
  --input-bg: rgba(255, 255, 255, 0.05);
  --input-bg-focus: rgba(255, 255, 255, 0.08);
  --tab-bg: rgba(17, 45, 38, 0.6);
  --tab-hover-bg: rgba(74, 222, 128, 0.15);
  --tabs-container-bg: rgba(74, 222, 128, 0.05);
}

[data-theme="light"] {
  /* Light Mode - Agricultural Theme */
  color-scheme: light;
  --bg: #f5f3e8;
  --bg-alt: #fdfcf7;
  --text: #2d3a2e;
  --text-dim: rgba(45, 58, 46, 0.65);
  --primary: #2d7a3f;
  --primary-strong: #1f5c2f;
  --accent: #d68c00;
  --danger: #c53030;
  --success: #1f8b4c;
  --card: rgba(253, 252, 247, 0.95);
  --card-bg: rgba(253, 252, 247, 0.98);
  --border: rgba(45, 122, 63, 0.2);
  --shadow: 0 8px 32px rgba(45, 58, 46, 0.12);
  --bg-gradient-1: rgba(139, 195, 74, 0.25);
  --bg-gradient-2: rgba(255, 193, 7, 0.2);
  --bg-shape-1: #8bc34a;
  --bg-shape-2: #ffc107;
  --stat-bg: rgba(139, 195, 74, 0.15);
  --table-bg: rgba(255, 255, 255, 0.7);
  --table-header-bg: rgba(139, 195, 74, 0.2);
  --input-bg: rgba(255, 255, 255, 0.9);
  --input-bg-focus: rgba(255, 255, 255, 1);
  --tab-bg: rgba(253, 252, 247, 0.8);
  --tab-hover-bg: rgba(139, 195, 74, 0.2);
  --tabs-container-bg: rgba(139, 195, 74, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(10, 31, 26, 0.95) 0%, rgba(17, 45, 38, 0.9) 100%),
    repeating-linear-gradient(90deg, transparent 0px, transparent 2px, rgba(74, 222, 128, 0.03) 2px, rgba(74, 222, 128, 0.03) 4px),
    repeating-linear-gradient(0deg, transparent 0px, transparent 2px, rgba(74, 222, 128, 0.03) 2px, rgba(74, 222, 128, 0.03) 4px),
    radial-gradient(circle at 20% 30%, var(--bg-gradient-1) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, var(--bg-gradient-2) 0%, transparent 50%),
    var(--bg);
  overflow-x: hidden;
  position: relative;
  transition: background 0.3s ease, color 0.3s ease;
}

[data-theme="light"] body {
  background:
    linear-gradient(135deg, rgba(245, 243, 232, 0.98) 0%, rgba(253, 252, 247, 0.95) 100%),
    repeating-linear-gradient(90deg, transparent 0px, transparent 2px, rgba(139, 195, 74, 0.04) 2px, rgba(139, 195, 74, 0.04) 4px),
    repeating-linear-gradient(0deg, transparent 0px, transparent 2px, rgba(139, 195, 74, 0.04) 2px, rgba(139, 195, 74, 0.04) 4px),
    radial-gradient(circle at 20% 30%, var(--bg-gradient-1) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, var(--bg-gradient-2) 0%, transparent 50%),
    var(--bg);
}

body::before {

  html.modal-scroll-lock,
  body.modal-scroll-lock {
    overflow: hidden !important;
  }
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(74, 222, 128, 0.1) 0%, transparent 25%),
    radial-gradient(circle at 85% 80%, rgba(251, 191, 36, 0.08) 0%, transparent 25%);
  animation: pulse 8s ease-in-out infinite;
  z-index: -1;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.2;
}

.bg-shape-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--bg-shape-1) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  animation: float 20s ease-in-out infinite;
}

.bg-shape-2 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, var(--bg-shape-2) 0%, transparent 70%);
  left: -100px;
  bottom: -100px;
  animation: float 15s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.9); }
}

.container {
  width: min(1160px, 94vw);
  margin: 0 auto 24px;
}

body:not(.auth-screen) .container {
  width: 100vw;
  max-width: 100vw;
  margin: 0;
  padding: 0;
}

body:not(.auth-screen) #app {
  margin: 0;
  padding: 0;
}

body:not(.auth-screen) .app-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100vw;
  max-width: 100vw;
  margin: 0;
  border-radius: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-card {
  width: min(460px, 100%);
  margin: clamp(16px, 9vh, 64px) auto;
  padding: clamp(22px, 4vw, 36px);
  animation: rise 450ms ease;
  background: var(--card);
  box-shadow: 0 12px 40px rgba(45, 58, 46, 0.15);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-icon {
  display: block;
  width: min(180px, 48vw);
  height: auto;
  max-width: 100%;
  max-height: 110px;
  margin: 0 auto 16px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(45, 122, 63, 0.3));
  animation: bounce 2s ease-in-out infinite;
}

.login-card:hover .login-icon {
  animation: bounce 0.6s ease-in-out;
}

[data-theme="light"] .login-icon {
  filter: drop-shadow(0 6px 12px rgba(139, 195, 74, 0.4));
}

.login-header h1 {
  margin: 8px 0;
  font-size: 2.2rem;
  color: var(--primary);
  font-weight: 800;
}

.login-subtitle {
  margin: 8px 0 0;
  color: var(--text);
  opacity: 0.7;
  font-size: 1rem;
}

@media (max-width: 640px) {
  .login-card {
    width: 100%;
    margin: 12px auto;
    border-radius: 14px;
  }

  .login-header {
    margin-bottom: 20px;
  }

  .login-icon {
    width: min(160px, 58vw);
    max-height: 96px;
    margin-bottom: 12px;
  }

  .sso-buttons-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--text);
  font-size: 0.95rem;
}

.form-group input,
.form-group select {
  margin-top: 0;
}

.form-group input:focus,
.form-group select:focus {
  transform: translateY(-1px);
}

input::placeholder {
  font-size: 0.93rem;
}

.checkbox-group {
  margin: 8px 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  font-weight: 400;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.checkbox-label span {
  font-size: 0.95rem;
  color: var(--text-dim);
}

.btn-primary {
  width: 100%;
  margin-top: 8px;
  padding: 14px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(45, 122, 63, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(45, 122, 63, 0.5);
}

.login-footer {
  margin-top: 24px;
  text-align: center;
}

.login-footer .hint {
  margin: 12px 0;
  padding: 12px;
  background: rgba(139, 195, 74, 0.1);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}

.login-footer .auth-links {
  margin-top: 16px;
}

h1,
h2,
h3 {
  margin-top: 0;
  color: var(--primary);
}

h1 {
  text-align: center;
  font-size: 2rem;
  line-height: 1.2;
}

label {
  display: block;
  margin-top: 14px;
  font-weight: 700;
  color: var(--text);
}

hr {
  margin: 24px 0;
  border: none;
  border-top: 1px solid var(--border);
  opacity: 0.5;
}

input,
select,
textarea,
button {
  width: 100%;
  margin-top: 6px;
  padding: 13px 16px;
  border-radius: 10px;
  border: 2px solid rgba(74, 222, 128, 0.3);
  font-size: 0.98rem;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  transition: background 0.2s ease, border-color 0.2s ease;
}

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  border: 2px solid rgba(45, 122, 63, 0.35);
  background: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] button {
  border: none;
}

select option {
  color: #000;
  background: #fff;
}

input::placeholder,
select::placeholder,
textarea::placeholder {
  color: var(--text);
  opacity: 0.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--input-bg-focus);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 122, 63, 0.12);
}

textarea {
  min-height: 90px;
}

button {
  border: 0;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

button:hover {
  background: var(--primary-strong);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 222, 128, 0.4);
}

/* Setas de navegação dos menus: sem deslocação no hover. */
button.agri-theme-arrow:hover,
button[aria-label*="anterior"]:not(.tabs-scroll-btn):hover,
button[aria-label*="seguinte"]:not(.tabs-scroll-btn):hover,
button[aria-label*="Anterior"]:not(.tabs-scroll-btn):hover,
button[aria-label*="Seguinte"]:not(.tabs-scroll-btn):hover {
  transform: none;
  box-shadow: none;
}

[data-theme="light"] button:hover {
  box-shadow: 0 6px 20px rgba(45, 122, 63, 0.4);
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #dc2626;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.hint {
  margin-top: 14px;
  font-size: 0.9rem;
  opacity: 0.75;
  text-align: center;
  color: var(--text);
}

.auth-links {
  margin-top: 12px;
  font-size: 0.95rem;
  text-align: center;
}

.auth-links a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
  transition: color 0.2s ease;
}

.auth-links a:hover {
  color: var(--primary-strong);
  text-decoration: underline;
}

.hidden {
  display: none;
}

/* React section navigation is used as the desktop sidebar. */

.app-header {
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border-bottom: 2px solid var(--primary);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 4000;
  isolation: isolate;
}

[data-theme="light"] .app-header {
  background: rgba(253, 252, 247, 0.98);
  box-shadow: 0 2px 8px rgba(45, 58, 46, 0.1);
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.app-header .logo:hover {
  transform: scale(1.02);
}

.app-header .logo img {
  height: 88px;
  width: auto;
}

.app-header .logo h2 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
}

.header-shortcuts {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  padding-block: 4px;
  scrollbar-width: none;
}

.header-shortcuts::-webkit-scrollbar {
  display: none;
}

.header-shortcut-btn {
  width: auto;
  min-width: 132px;
  margin-top: 0;
  padding: 8px 14px;
  border: 1px solid rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.12);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-shortcut-btn:hover {
  border-color: rgba(74, 222, 128, 0.7);
  background: rgba(74, 222, 128, 0.24);
}

.header-shortcut-btn.active {
  border-color: rgba(74, 222, 128, 0.9);
  background: rgba(74, 222, 128, 0.32);
  color: #e9ffef;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.25), 0 6px 14px rgba(20, 80, 40, 0.25);
}

.app-content-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-top: 10px;
}

/* Legacy scripts may re-inject this strip; keep module navigation only on the left sidebar. */
.app-header .header-shortcuts {
  display: none !important;
}

.header-page-title {
  margin-left: 10px;
  font-size: 1.02rem;
  line-height: 1.1;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.app-header #headerPageTitle {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  color: #e9ffef !important;
}

.desktop-side-shortcuts {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  z-index: 6;
}

.desktop-side-shortcuts .header-shortcut-btn {
  width: 100%;
  min-width: 0;
  margin-top: 0;
  padding: 12px 14px;
  border-radius: 12px;
  text-align: left;
  justify-content: flex-start;
  font-size: 0.92rem;
}

.app-main-content {
  min-width: 0;
}

.global-overview-stack {
  gap: 16px;
}

.global-overview-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 20px;
  background:
    radial-gradient(circle at top left, rgba(82, 224, 137, 0.18), transparent 42%),
    linear-gradient(135deg, rgba(9, 48, 34, 0.96), rgba(15, 63, 45, 0.96));
}

.global-overview-kicker {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.global-overview-hero h2 {
  margin: 0;
  font-size: 1.9rem;
}

.global-overview-hero p {
  margin: 8px 0 0;
  max-width: 720px;
  color: var(--text-dim);
}

.global-overview-actions {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.global-overview-actions .btn-primary,
.global-overview-actions .btn-secondary {
  width: 100%;
  min-width: 0;
  margin-top: 0;
}

.global-overview-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  align-items: stretch;
}

.global-overview-stats > * {
  min-width: 0;
}

.global-overview-stat-card {
  position: relative;
  overflow: hidden;
  min-height: 140px;
  padding: 18px;
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, rgba(82, 224, 137, 0.14), transparent 38%),
    linear-gradient(180deg, rgba(20, 67, 49, 0.92), rgba(14, 56, 41, 0.96));
  border: 1px solid rgba(82, 224, 137, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 10px 24px rgba(0, 0, 0, 0.18);
}

.global-overview-stat-card::before {
  content: "";
  position: absolute;
  inset: auto -20px -20px auto;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(82, 224, 137, 0.08);
}

.global-overview-stat-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.global-overview-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.global-overview-stat-label {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: rgba(237, 251, 242, 0.86);
}

.global-overview-stat-card strong {
  position: relative;
  z-index: 1;
  font-size: clamp(1.65rem, 2vw, 2.2rem);
  line-height: 1.05;
  margin-top: 0;
  color: #f4fff7;
}

.global-overview-stat-card small {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 10px;
  color: rgba(220, 239, 227, 0.7);
  font-size: 0.8rem;
}

.global-overview-stat-card-balance strong,
.global-overview-stat-card-milk strong,
.global-overview-stat-card-cheese strong {
  color: #9ff7be;
}

.global-overview-stat-card-orders strong,
.global-overview-stat-card-eggs strong {
  color: #ffe49a;
}

.global-overview-stat-card-clients strong,
.global-overview-stat-card-land strong,
.global-overview-stat-card-crops strong {
  color: #b8e7ff;
}

.global-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.global-overview-grid-secondary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.global-overview-panel {
  padding: 16px;
}

.global-overview-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.global-overview-panel-head h3 {
  margin: 0;
}

.global-overview-panel-head span {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.global-overview-chart-wrap {
  position: relative;
  min-height: 300px;
}

.global-overview-chart-wrap-finance {
  min-height: 260px;
}

.global-overview-chart-wrap-ops {
  min-height: 260px;
}

.global-overview-mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.global-overview-mini-stats div {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(82, 224, 137, 0.12);
  border-radius: 14px;
  padding: 14px;
}

.global-overview-mini-stats strong {
  display: block;
  font-size: 1.3rem;
  color: var(--primary);
}

.global-overview-mini-stats span {
  display: block;
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 0.82rem;
}

[data-theme="light"] .global-overview-hero {
  background:
    radial-gradient(circle at top left, rgba(45, 122, 63, 0.14), transparent 42%),
    linear-gradient(135deg, rgba(244, 252, 246, 0.98), rgba(233, 247, 238, 0.98));
}

[data-theme="light"] .global-overview-mini-stats div {
  background: rgba(255, 255, 255, 0.84);
  border-color: rgba(45, 122, 63, 0.12);
}

[data-theme="light"] .global-overview-stat-card {
  background:
    radial-gradient(circle at top right, rgba(45, 122, 63, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(248, 252, 249, 0.98), rgba(237, 247, 241, 0.98));
  border-color: rgba(45, 122, 63, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 10px 24px rgba(45, 122, 63, 0.08);
}

[data-theme="light"] .global-overview-stat-label {
  color: rgba(22, 54, 33, 0.76);
}

[data-theme="light"] .global-overview-stat-card strong {
  color: #14552b;
}

[data-theme="light"] .global-overview-stat-card small {
  color: rgba(22, 54, 33, 0.6);
}

[data-theme="light"] .global-overview-stat-icon {
  background: rgba(45, 122, 63, 0.1);
}

[data-theme="light"] .header-shortcut-btn {
  border-color: rgba(45, 122, 63, 0.35);
  background: rgba(45, 122, 63, 0.12);
}

[data-theme="light"] .header-shortcut-btn:hover {
  border-color: rgba(45, 122, 63, 0.65);
  background: rgba(45, 122, 63, 0.2);
}

[data-theme="light"] .header-shortcut-btn.active {
  border-color: rgba(45, 122, 63, 0.8);
  background: rgba(45, 122, 63, 0.28);
  color: #12311a;
  box-shadow: 0 0 0 1px rgba(45, 122, 63, 0.2), 0 6px 14px rgba(45, 122, 63, 0.18);
}

/* Species Menu Button (Hamburger in Header) */
.species-menu-btn {
  display: none; /* Hidden on desktop */
  flex-direction: column;
  justify-content: space-around;
  width: 40px;
  height: 40px;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 8px;
  transition: all 0.3s ease;
}

.species-menu-btn span {
  width: 100%;
  height: 3px;
  background: #000;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.species-menu-btn.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.species-menu-btn.active span:nth-child(2) {
  opacity: 0;
}

.species-menu-btn.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Side Menu Overlay */
.side-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 5000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.side-menu-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* Species Side Menu */
.species-side-menu {
  --side-menu-dead-zone: 28px;
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: var(--card);
  border-left: 2px solid var(--primary);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.3);
  z-index: 5001;
  transition: right 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.species-side-menu::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--side-menu-dead-zone);
  background: var(--card);
  border-right: 1px solid rgba(74, 222, 128, 0.25);
  z-index: 3;
  pointer-events: auto;
}

body.side-menu-open {
  overflow: hidden;
}

body.side-menu-open #app {
  touch-action: none;
}

[data-theme=\"light\"] .species-side-menu {
  background: var(--bg);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
}

[data-theme=\"light\"] .species-side-menu::before {
  background: var(--bg);
  border-right: 1px solid rgba(45, 122, 63, 0.22);
}

.species-side-menu.open {
  right: 0;
}

.side-menu-content {
  position: relative;
  z-index: 2;
  padding: 20px 20px 20px calc(20px + var(--side-menu-dead-zone));
}

.side-menu-content h3 {
  margin: 0 0 20px 0;
  color: var(--primary);
  font-size: 1.3rem;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
}

#sideMenuTabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  border-radius: 10px;
}

  /* Side menu: main section navigation buttons */
  .side-menu-sections {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(74, 222, 128, 0.25);
    overflow: hidden;
    border-radius: 10px;
  }

  .side-section-btn {
    width: 100% !important;
    min-width: unset !important;
    padding: 14px 16px !important;
    text-align: left !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(74, 222, 128, 0.2) !important;
    color: var(--text) !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    margin-top: 0 !important;
  }

  [data-theme="light"] .side-section-btn {
    background: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid rgba(45, 122, 63, 0.3) !important;
  }

  .side-section-btn:hover {
    background: rgba(74, 222, 128, 0.15) !important;
    border-color: var(--primary) !important;
    transform: translateX(4px) !important;
  }

  .side-section-btn.active {
    background: var(--primary) !important;
    color: #000 !important;
    font-weight: 700 !important;
    border-color: var(--primary) !important;
    box-shadow: none !important;
  }

  .side-menu-tabs-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin: 0 0 8px 0;
    padding: 0;
  }

  .side-menu-tabs-title.hidden {
    display: none;
  }

#sideMenuTabs .tab-btn {
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(74, 222, 128, 0.2);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

[data-theme=\"light\"] #sideMenuTabs .tab-btn {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(45, 122, 63, 0.3);
}

#sideMenuTabs .tab-btn:hover {
  background: rgba(74, 222, 128, 0.15);
  border-color: var(--primary);
  transform: translateX(4px);
}

[data-theme=\"light\"] #sideMenuTabs .tab-btn:hover {
  background: rgba(139, 195, 74, 0.2);
}

#sideMenuTabs .tab-btn.active {
  background: var(--primary);
  color: #000;
  font-weight: 700;
  border-color: var(--primary);
  box-shadow: none;
}

/* Permanent Cortex-like left sidebar */
:root {
  --rf-perm-sidebar-width: 248px;
}

.species-menu-btn,
#sideMenuOverlay {
  display: none !important;
}

.app-header .logo {
  display: none !important;
}

.species-side-menu {
  right: auto !important;
  left: 0 !important;
  top: 0 !important;
  width: var(--rf-perm-sidebar-width) !important;
  height: 100vh !important;
  border-left: 0 !important;
  border-right: 1px solid rgba(74, 222, 128, 0.24) !important;
  box-shadow: none !important;
  background: rgba(9, 32, 24, 0.98) !important;
  z-index: 12000 !important;
  isolation: isolate;
  transition: none !important;
  overflow: visible !important;
}

.species-side-menu::before {
  display: none !important;
}

.species-side-menu.open {
  right: auto !important;
  left: 0 !important;
}

.side-menu-content {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 10px 10px 10px !important;
  overflow: hidden !important;
}

.side-menu-brand {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  cursor: pointer;
}

.side-menu-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.side-menu-brand-text strong {
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: 0.01em;
}

.side-menu-group-label {
  margin: 4px 0 8px;
  color: rgba(234, 247, 239, 0.9);
  font-weight: 800;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.side-menu-main-groups,
.side-menu-footer-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-menu-main-groups {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.side-menu-main-groups::-webkit-scrollbar {
  width: 8px;
}

.side-menu-main-groups::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: rgba(74, 222, 128, 0.28);
}

.side-menu-scroll-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.side-menu-scroll-area::-webkit-scrollbar {
  width: 8px;
}

.side-menu-scroll-area::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: rgba(74, 222, 128, 0.28);
}

.side-group-btn,
.side-footer-btn {
  width: 100%;
  margin-top: 0;
  padding: 6px 8px;
  border-radius: 0;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  background: transparent;
  color: #f2f7f4;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 700;
}

.side-group-btn:hover,
.side-footer-btn:hover {
  background: rgba(74, 222, 128, 0.12);
  border-left-color: #4ade80;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.side-item-icon {
  width: 18px;
  text-align: center;
  flex: 0 0 18px;
  font-size: 0.96rem;
}

.side-item-label {
  white-space: nowrap;
}

.side-item-caret {
  margin-left: auto;
  opacity: 0.9;
  transition: transform 0.2s ease;
}

.side-group-btn.active .side-item-caret {
  transform: rotate(180deg);
}

.side-main-item {
  position: relative;
}

.side-submenu-panel {
  margin: 5px 0 10px 26px;
  padding: 6px;
  border-left: 2px solid rgba(74, 222, 128, 0.35);
  border-radius: 0 8px 8px 0;
  background: rgba(74, 222, 128, 0.06);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-submenu-panel-nested {
  margin: 6px 0 4px 12px;
  border-left-color: rgba(74, 222, 128, 0.25);
  background: rgba(74, 222, 128, 0.03);
}

.side-subitem-with-caret {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.side-nested-caret {
  transition: transform 0.2s ease;
}

.side-subitem-with-caret.active .side-nested-caret {
  transform: rotate(90deg);
}

.side-subitem-btn {
  width: 100%;
  border: 0;
  background: transparent;
  color: #dff3e8;
  text-align: left;
  font-size: 0.84rem;
  font-weight: 700;
  border-radius: 6px;
  padding: 6px 8px;
}

.side-subitem-btn:hover {
  background: rgba(74, 222, 128, 0.14);
}

.side-hover-panel {
  position: absolute;
  left: calc(100% + 8px);
  top: 0;
  min-width: 220px;
  max-height: min(340px, 65vh);
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(3, 6, 4, 0.98);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.52);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 13000;
}

.side-hover-panel.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.side-hover-title {
  margin: 0 0 8px;
  color: #d2d7d3;
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.side-hover-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: #f1f3f2;
  text-align: left;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.95rem;
  font-weight: 600;
  font-style: italic;
}

.side-hover-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.side-menu-divider {
  margin: 10px 0;
  border-top: 1px solid rgba(74, 222, 128, 0.24);
}

.side-collapse-btn {
  width: 44px;
  align-self: center;
  margin-top: 8px;
  padding: 4px 0;
  border-radius: 14px;
  border: 1px solid rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.1);
  color: #d9f6e6;
  font-weight: 700;
  line-height: 1;
}

.side-menu-footer-links {
  flex: 0 0 auto;
  margin-top: 8px;
}

.species-side-menu.collapsed {
  width: 78px !important;
}

.species-side-menu.collapsed .side-menu-brand {
  justify-content: center;
  padding-bottom: 10px;
}

.species-side-menu.collapsed .side-menu-brand-text,
.species-side-menu.collapsed .side-menu-group-label,
.species-side-menu.collapsed .side-item-label,
.species-side-menu.collapsed .side-menu-divider,
.species-side-menu.collapsed .side-menu-tabs-title {
  display: none !important;
}

.species-side-menu.collapsed .side-item-caret,
.species-side-menu.collapsed .side-submenu-panel {
  display: none !important;
}

.species-side-menu.collapsed .side-main-item:hover .side-hover-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.species-side-menu.collapsed .side-menu-content,
.species-side-menu.collapsed .side-menu-main-groups {
  overflow: visible !important;
}

.tab-switch-loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 10, 7, 0.86);
  z-index: 15000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

[data-theme="light"] .tab-switch-loader {
  background: rgba(248, 250, 249, 0.92);
}

.tab-switch-loader.visible {
  opacity: 1;
  pointer-events: auto;
}

.tab-switch-loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.tab-switch-loader-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  animation: rf-loader-pulse 0.8s ease-in-out infinite;
}

.tab-switch-loader-text {
  color: #e8f5f0;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

[data-theme="light"] .tab-switch-loader-text {
  color: #193025;
}

@keyframes rf-loader-pulse {
  0% { transform: scale(0.92); opacity: 0.7; }
  50% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.92); opacity: 0.7; }
}

.species-side-menu.collapsed .side-menu-main-groups,
.species-side-menu.collapsed .side-menu-footer-links {
  gap: 10px;
}

.species-side-menu.collapsed .side-item,
.species-side-menu.collapsed .side-collapse-btn {
  justify-content: center;
}

.species-side-menu.collapsed .side-item-icon {
  width: auto;
  flex: 0 0 auto;
}

body:not(.auth-screen) #app {
  padding-left: calc(var(--rf-perm-sidebar-width) + 10px) !important;
}

body:not(.auth-screen) .app-header {
  left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

@media (max-width: 768px) {
  :root {
    --rf-perm-sidebar-width: min(220px, 70vw);
  }
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 120;
  overflow: visible;
}

.notif-bell-btn {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--stat-bg);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: all 0.3s ease;
}
.notif-bell-btn.hidden { display: none !important; }
.notif-bell-btn:hover {
  background: var(--primary);
  transform: translateY(0) rotate(15deg);
  box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}
.notif-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  background: #e53935;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  pointer-events: none;
}

.team-chat-header-btn {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--stat-bg);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.3s ease;
}

.team-chat-header-btn.hidden {
  display: none !important;
}

.team-chat-header-btn:hover {
  background: var(--primary);
  transform: translateY(0) rotate(10deg);
  box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

.team-chat-header-btn.chat-open {
  background: rgba(255, 255, 255, 0.12);
}

.header-chat-btn {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--stat-bg);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.18rem;
  transition: all 0.3s ease;
}

.header-chat-btn.hidden {
  display: none !important;
}

.header-chat-btn:hover {
  background: var(--primary);
  transform: translateY(0) rotate(10deg);
  box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

.header-chat-btn.chat-open {
  background: rgba(255, 255, 255, 0.12);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--stat-bg);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: var(--primary);
  transform: translateY(0) rotate(20deg);
  box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

[data-theme="light"] .theme-toggle:hover {
  box-shadow: 0 4px 12px rgba(139, 195, 74, 0.4);
}

.theme-icon {
  display: block;
  line-height: 1;
}

.user-menu {
  position: relative;
  z-index: 130;
}

.user-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: var(--bg-alt);
  font-weight: 700;
  font-size: 1.1rem;
  border: 2px solid var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}

[data-theme="light"] .user-icon {
  color: #fff;
  box-shadow: 0 2px 8px rgba(45, 122, 63, 0.3);
}

.user-icon:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(74, 222, 128, 0.5);
}

[data-theme="light"] .user-icon:hover {
  box-shadow: 0 0 20px rgba(139, 195, 74, 0.6);
}

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: rgba(10, 31, 26, 0.96);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  overflow: hidden;
  animation: dropIn 0.2s ease;
  z-index: 1400;
}

[data-theme="light"] .dropdown {
  background: rgba(253, 252, 247, 0.98);
  border: 1px solid rgba(45, 122, 63, 0.25);
  box-shadow: 0 14px 28px rgba(45, 58, 46, 0.18);
}

@keyframes dropIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-info {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text);
}

.user-info strong {
  display: block;
  color: var(--primary);
}

.dropdown-item {
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  color: var(--text);
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  border-radius: 0;
  margin: 0;
  font-weight: 700;
  line-height: 1.3;
}

.dropdown-item:hover {
  background: rgba(74, 222, 128, 0.16);
  transform: none;
}

[data-theme="light"] .dropdown-item:hover {
  background: rgba(45, 122, 63, 0.12);
}

.dropdown-item.danger {
  color: #fff;
  background: rgba(197, 48, 48, 0.86);
}

.dropdown-item.danger:hover {
  background: rgba(197, 48, 48, 1);
}

.grid {
  display: grid;
  gap: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: stretch;
  gap: 14px;
  overflow: visible;
  padding-bottom: 0;
  margin: 18px 0;
}

.stats > .stat-card {
  min-width: 0;
}

.dashboard-central-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  overflow: visible;
  padding-bottom: 0;
}

.dashboard-central-stats > .stat-card {
  min-width: 0;
}

.sim-summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  overflow: visible;
  padding-bottom: 0;
}

.sim-summary-stats > .stat-card {
  min-width: 0;
}

/* In the global overview, cards should wrap to new rows instead of horizontal scrolling. */
.grid.stats.global-overview-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  overflow: visible;
  padding-bottom: 0;
}

.grid.stats.global-overview-stats > .stat-card {
  min-width: 0;
}

.stat-card {
  padding: 16px;
  border-radius: 12px;
  background: var(--stat-bg);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.clickable-card {
  cursor: pointer;
  position: relative;
}

.clickable-card::after {
  content: "📊";
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 1.2rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.clickable-card:hover::after {
  opacity: 0.6;
}

.clickable-card:hover {
  background: var(--primary-dim);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-card span {
  color: var(--text);
  opacity: 0.7;
  font-size: 0.9rem;
}

.stat-card strong {
  display: block;
  font-size: 1.5rem;
  margin-top: 5px;
  color: var(--primary);
}

/* Stats Cards - Desktop/Mobile Toggle */
.stats-card-desktop {
  display: block;
}

.stats-card-mobile {
  display: none;
}

.dashboard-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.dashboard-stack > .card {
  margin: 0;
}

.dashboard-mini-charts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.dashboard-section-card {
  padding: 16px;
}

.dashboard-chart-card,
.weather-dashboard-card {
  position: relative;
  overflow: hidden;
}

.dashboard-chart-card::before,
.weather-dashboard-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top right, rgba(74, 222, 128, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%);
}

.dashboard-comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

@media (max-width: 680px) {
  .dashboard-comparison-grid {
    grid-template-columns: 1fr;
  }
}


/* React dashboard mobile hardening */
@media (max-width: 768px) {
  .container {
    width: 100%;
    margin: 12px auto;
    padding: 0 12px;
  }

  .app-header {
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
  }

  .header-brand-group {
    min-width: 0;
    width: auto;
    flex: 1 1 auto;
    justify-content: flex-start;
  }

  .header-controls {
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .header-shortcuts {
    display: none;
  }

  .header-page-title {
    margin-left: 8px;
    max-width: 52vw;
    font-size: 0.95rem;
  }

  .app-content-layout {
    display: block;
    margin-top: 8px;
  }

  .app-main-content {
    margin-left: 0;
  }

  .react-section-nav {
    display: none;
  }

  .desktop-side-shortcuts {
    display: none;
  }

  .app-header .logo {
    gap: 0;
  }

  .app-header .logo img {
    height: 76px;
  }

  .app-header .logo h2 {
    font-size: 1.05rem;
  }

  .tabs-card {
    margin-top: 8px;
  }

  #tabContent {
    padding: 12px;
  }
}

@media (min-width: 769px) {
  .app-content-layout {
    display: block !important;
    margin-top: 10px;
    position: relative;
  }

  .app-content-layout > .react-section-nav {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed;
    top: 96px;
    left: max(12px, calc((100vw - min(1160px, 94vw)) / 2));
    width: 220px;
    max-width: 220px;
    min-width: 220px;
    height: calc(100vh - 112px);
    overflow-y: auto;
  }

  .app-content-layout > .app-main-content {
    margin-left: 234px;
    min-width: 0;
  }
}

@media (max-width: 600px) {
  .container {
    margin: 8px auto;
    padding: 0 8px;
  }

  .app-header {
    gap: 10px;
    padding: 10px 12px;
  }

  .header-brand-group {
    gap: 6px;
  }

  .header-controls {
    gap: 6px;
  }

  .app-header .logo img {
    height: 68px;
  }

  .app-header .logo h2 {
    font-size: 0.95rem;
  }

  .species-side-menu {
    width: min(92vw, 340px);
    right: -100vw;
  }

  .side-menu-content {
    padding: 16px 16px 16px calc(16px + var(--side-menu-dead-zone));
  }

  #tabContent {
    padding: 10px;
  }

  /* Stats grid: 2 columns on mobile so cards aren't full-width */
  .grid.stats.global-overview-stats,
  .global-overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .global-overview-stat-card {
    min-height: 110px;
    padding: 12px;
    border-radius: 14px;
  }

  .global-overview-stat-card strong {
    font-size: clamp(1.25rem, 5vw, 1.6rem);
  }

  .global-overview-stat-icon {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }

  .global-overview-stat-label {
    font-size: 0.78rem;
  }

  .global-overview-stat-card small {
    font-size: 0.72rem;
    margin-top: 6px;
  }
}
  .dashboard-chart-surface {
    height: 260px;
  }

  .dashboard-mini-charts {
    grid-template-columns: 1fr;
  }
}

.dashboard-chart-head,
.weather-dashboard-header {
  position: relative;
  z-index: 1;
}

.dashboard-chart-subtitle,
.weather-dashboard-subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
  max-width: 64ch;
}

.dashboard-chart-surface {
  position: relative;
  z-index: 1;
  height: 290px;
  padding: 12px 14px 8px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)),
    rgba(8, 25, 20, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.weather-dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.weather-dashboard-copy {
  min-width: 0;
}

.weather-dashboard-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: right;
}

.weather-dashboard-note,
.weather-dashboard-empty {
  margin: 0 0 12px;
  color: var(--text-dim);
  font-size: 0.86rem;
  position: relative;
  z-index: 1;
}

.weather-forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  position: relative;
  z-index: 1;
}

.weather-forecast-card {
  min-height: 124px;
  padding: 14px 14px 12px;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 85% 15%, rgba(74, 222, 128, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid rgba(74, 222, 128, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 6px 16px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.weather-forecast-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.7), rgba(74, 222, 128, 0.75));
  opacity: 0.85;
}

.weather-forecast-card:hover {
  transform: translateY(-2px);
  border-color: rgba(74, 222, 128, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 22px rgba(0, 0, 0, 0.24);
}

.weather-forecast-date {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.weather-forecast-temp {
  display: block;
  font-size: 1.3rem;
  margin-bottom: 10px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.01em;
  line-height: 1.1;
  text-shadow: 0 0 12px rgba(74, 222, 128, 0.22);
}

.weather-forecast-detail {
  font-size: 0.86rem;
  color: var(--text);
  margin-bottom: 5px;
  line-height: 1.35;
  font-weight: 500;
}

.weather-forecast-detail-dim {
  color: var(--text-dim);
  margin-bottom: 0;
}

[data-theme="light"] .weather-forecast-card {
  background:
    radial-gradient(circle at 85% 15%, rgba(45, 122, 63, 0.14), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(240, 247, 242, 0.92));
  border-color: rgba(45, 122, 63, 0.24);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 6px 14px rgba(45, 122, 63, 0.12);
}

[data-theme="light"] .weather-forecast-card:hover {
  border-color: rgba(45, 122, 63, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 10px 20px rgba(45, 122, 63, 0.16);
}

@media (max-width: 900px) {
  .weather-forecast-card {
    min-height: 116px;
    padding: 12px;
  }

  .weather-forecast-temp {
    font-size: 1.2rem;
  }
}

.agri-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.dashboard-agri-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-agri-layout > .agri-block-full {
  grid-column: 1 / -1;
}

.agri-dashboard-panel {
  padding: 14px;
}

.agri-dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.agri-dashboard-head h3 {
  margin: 0;
  color: var(--primary);
  font-size: 1.12rem;
}

.agri-dashboard-head span {
  color: var(--text-dim);
  font-size: 0.82rem;
}

.agri-dashboard-chart-wrap {
  position: relative;
  min-height: 260px;
}

.dashboard-editor-shell {
  position: relative;
}

.dashboard-editor-layout,
.gestao-dashboard-layout {
  transition: padding-right 0.2s ease, transform 0.2s ease;
}

body.dashboard-editor-active .global-overview-stack,
body.dashboard-editor-active .dashboard-stack,
body.dashboard-editor-active .gestao-dashboard-layout {
  padding-left: 0;
  padding-right: 0;
}

body.dashboard-editor-active .dashboard-editor-shell > * {
  max-width: 100%;
}

body.dashboard-editor-active .dashboard-editor-shell,
body.dashboard-editor-active .global-overview-stack,
body.dashboard-editor-active .dashboard-stack,
body.dashboard-editor-active .gestao-dashboard-layout {
  box-sizing: border-box;
}

body.dashboard-editor-active::after {
  content: "";
  position: fixed;
  inset: 10px;
  border: 2px solid rgba(220, 38, 38, 0.72);
  border-radius: 18px;
  pointer-events: none;
  z-index: 999;
  box-shadow:
    inset 0 0 0 1px rgba(254, 202, 202, 0.28),
    0 0 0 1px rgba(220, 38, 38, 0.22);
}

.dashboard-editor-sidebar {
  position: fixed;
  top: 86px;
  left: 14px;
  width: clamp(280px, 22vw, 340px);
  height: calc(100vh - 102px);
  overflow: auto;
  z-index: 120;
  padding: 14px;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--card-bg) 92%, white 8%);
  border: 1px solid rgba(220, 38, 38, 0.45);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.18);
}

.dashboard-editor-sidebar-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.dashboard-editor-sidebar-head span,
.dashboard-editor-sidebar-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.4;
}

.dashboard-editor-toolbar-row {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.dashboard-editor-search {
  margin-top: 0;
  padding: 9px 11px;
  border-radius: 10px;
}

.dashboard-editor-counter {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.dashboard-editor-filter-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.dashboard-editor-filter-tab {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.22);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.dashboard-editor-filter-tab.is-active {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.35);
  color: #991b1b;
}

[data-theme="dark"] .dashboard-editor-filter-tab.is-active {
  color: #fecaca;
}

.dashboard-editor-sidebar-actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.dashboard-editor-sidebar-actions .btn-action-secondary {
  width: 100%;
  justify-content: center;
}

.dashboard-editor-library {
  display: grid;
  gap: 12px;
}

.dashboard-editor-library-groups {
  display: grid;
  gap: 10px;
}

.dashboard-editor-library-section {
  display: grid;
  gap: 8px;
}

.dashboard-editor-library-separator {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(220, 38, 38, 0.42),
    transparent
  );
}

.dashboard-editor-library-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dashboard-editor-library-section-head strong {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.dashboard-editor-library-section-head span {
  font-size: 0.76rem;
  font-weight: 700;
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.24);
  border-radius: 999px;
  padding: 2px 8px;
}

.dashboard-editor-library-item {
  text-align: left;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), var(--stat-bg));
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  min-height: 0;
}

.dashboard-editor-library-item[hidden] {
  display: none !important;
}

.dashboard-editor-library-item strong {
  font-size: 0.95rem;
}

.dashboard-editor-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dashboard-editor-item-order {
  min-width: 26px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.dashboard-editor-library-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dashboard-editor-library-item small,
.dashboard-editor-library-kind {
  color: var(--text-dim);
  font-size: 0.78rem;
}

.dashboard-editor-library-item.is-visible {
  opacity: 0.72;
}

.dashboard-editor-library-item.is-hidden {
  border-color: rgba(74, 222, 128, 0.36);
}

.dashboard-editor-library-item.is-active {
  border-color: rgba(220, 38, 38, 0.74);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.35);
}

.dashboard-editor-library-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(45, 58, 46, 0.12);
}

.dashboard-editor-preview {
  border-radius: 14px;
  border: 1px solid rgba(45, 122, 63, 0.14);
  background: rgba(255, 255, 255, 0.5);
  min-height: 88px;
  padding: 10px;
  position: relative;
  overflow: hidden;
}

.dashboard-editor-preview-donut {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  margin: 2px auto 0;
  background:
    conic-gradient(
      rgba(220, 38, 38, 0.82) 0deg 128deg,
      rgba(251, 146, 60, 0.78) 128deg 246deg,
      rgba(56, 189, 248, 0.7) 246deg 360deg
    );
  box-shadow: inset 0 0 0 8px rgba(17, 24, 39, 0.72);
}

.dashboard-editor-preview-titlebar {
  width: 54%;
  height: 10px;
  border-radius: 999px;
  background: rgba(45, 122, 63, 0.18);
  margin-bottom: 10px;
}

.dashboard-editor-preview-cardgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.dashboard-editor-preview-cardgrid span {
  display: block;
  height: 24px;
  border-radius: 10px;
  background: rgba(139, 195, 74, 0.22);
}

.dashboard-editor-preview-surface {
  display: flex;
  align-items: end;
  gap: 8px;
  min-height: 54px;
  position: relative;
}

.dashboard-editor-preview-bar {
  display: block;
  flex: 1;
  border-radius: 999px 999px 6px 6px;
  background: linear-gradient(180deg, rgba(45, 122, 63, 0.55), rgba(139, 195, 74, 0.22));
}

.dashboard-editor-preview-bar-1 {
  height: 36px;
}

.dashboard-editor-preview-bar-2 {
  height: 52px;
}

.dashboard-editor-preview-bar-3 {
  height: 28px;
}

.dashboard-editor-preview-line {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 18px;
  height: 34px;
  border-top: 3px solid rgba(220, 38, 38, 0.48);
  border-radius: 50% 45% 55% 40%;
  transform: skewY(-8deg);
}

.dashboard-editor-block {
  position: relative;
}

.dashboard-editor-block-editable {
  cursor: grab;
  outline: 1px dashed rgba(74, 222, 128, 0.26);
  outline-offset: -1px;
}

.dashboard-editor-block-editable.dragging {
  opacity: 0.72;
  transform: scale(0.995);
}

.dashboard-editor-custom {
  min-height: 120px;
}

.dashboard-editor-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}

.dashboard-editor-remove:hover {
  border-color: rgba(239, 68, 68, 0.5);
  color: var(--danger);
}

.dashboard-editor-fab {
  position: fixed;
  top: 78px;
  right: 18px;
  z-index: 61;
}

.dashboard-editor-toolbar {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
}

@media (max-width: 980px) {
  .dashboard-editor-sidebar {
    width: min(86vw, 360px);
  }
}

.gestao-dashboard-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  align-items: start;
}

.gestao-dashboard-item {
  min-width: 0;
}

.gestao-dashboard-item-full {
  grid-column: 1 / -1;
}

.gestao-dashboard-item-editable {
  outline: 1px dashed rgba(255, 255, 255, 0.14);
  outline-offset: -1px;
}

.gestao-dashboard-drag-handle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px 0;
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
  cursor: grab;
}

.gestao-dashboard-item.dragging {
  opacity: 0.65;
  transform: scale(0.995);
}

.gestao-dashboard-drop-target {
  border-color: rgba(82, 224, 137, 0.65);
  box-shadow: 0 0 0 1px rgba(82, 224, 137, 0.2) inset;
}

.dashboard-gestao-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  overflow: visible;
  padding-bottom: 0;
}

.dashboard-gestao-stats > .stat-card {
  min-width: 0;
}

.dashboard-agri-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  overflow: visible;
  padding-bottom: 0;
  margin-top: 14px;
}

.dashboard-agri-stats > .stat-card {
  min-width: 0;
}

.agri-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: stretch;
}

.agri-command-card {
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(12, 22, 24, 0.92), rgba(10, 18, 20, 0.9)),
    var(--card);
}

.agri-command-layout {
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr);
  gap: 14px;
  min-height: 580px;
}

.agri-command-sidebar {
  border: 1px solid rgba(133, 154, 164, 0.25);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(19, 30, 35, 0.95), rgba(14, 24, 28, 0.92));
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.agri-sidebar-theme-nav {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.agri-sidebar-theme-nav .agri-theme-topbar {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.agri-sidebar-theme-nav .agri-theme-arrow {
  width: 34px;
  height: 34px;
  border-radius: 0;
}

.agri-sidebar-theme-nav .agri-theme-current {
  padding: 3px 8px;
  background: transparent;
  border: none;
  color: #e6ecec;
}

.agri-sidebar-theme-nav .agri-theme-current strong {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.agri-command-sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.agri-command-sidebar-head h4 {
  margin: 0;
  font-size: 1.02rem;
}

.agri-command-sidebar-head span {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.agri-command-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.agri-command-kpis > div {
  border: 1px solid rgba(133, 154, 164, 0.2);
  border-radius: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.agri-command-kpis small {
  display: block;
  color: var(--text-dim);
  font-size: 0.72rem;
  margin-bottom: 2px;
}

.agri-command-kpis strong {
  font-size: 0.95rem;
}

.agri-command-pill-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.agri-command-map-panel {
  border: 1px solid rgba(133, 154, 164, 0.25);
  border-radius: 14px;
  padding: 12px;
  background:
    radial-gradient(circle at top right, rgba(116, 185, 255, 0.12), transparent 35%),
    linear-gradient(180deg, rgba(18, 31, 37, 0.9), rgba(13, 25, 30, 0.88));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agri-theme-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(191, 213, 128, 0.28);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(36, 47, 44, 0.88), rgba(20, 29, 28, 0.82));
}

.agri-theme-arrow {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #d2e77a;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  margin-top: 2px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.agri-theme-arrow:hover {
  color: #dff18e;
  transform: none;
  box-shadow: none;
  background: rgba(210, 231, 122, 0.14);
}

.agri-theme-current {
  flex: 1;
  text-align: center;
  padding: 4px 8px;
}

.agri-theme-current strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.2;
}

.agri-theme-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}

.agri-theme-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(208, 215, 215, 0.55);
}

.agri-theme-dot.active {
  background: #c3db6a;
  box-shadow: 0 0 0 1px rgba(195, 219, 106, 0.34);
}

.agri-theme-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 28px;
}

.agri-theme-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(130, 149, 140, 0.3);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.74rem;
  color: var(--text-dim);
  background: rgba(10, 17, 18, 0.72);
}

.agri-theme-legend-item i {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.agri-theme-legend-empty {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.agri-command-map-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.agri-command-map-toolbar strong {
  display: block;
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.agri-command-map-toolbar small {
  color: var(--text-dim);
}

.agri-command-focus-select {
  margin: 0;
  min-width: min(320px, 100%);
}

.agri-command-focus-select label {
  margin-top: 0;
}

.agri-command-map-wrap {
  flex: 1;
  min-height: 560px;
}

.agri-theme-legend-bottom {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid rgba(130, 149, 140, 0.2);
}

.agri-command-map-footer {
  display: grid;
  gap: 8px;
}

.agri-mobile-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.agri-head-copy {
  flex: 1 1 240px;
  min-width: 0;
}

.agri-header-btn {
  margin: 0;
  padding: 8px 14px;
  font-size: 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: auto;
}

.agri-command-map-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.agri-map-location-pill {
  border: 1px solid rgba(133, 154, 164, 0.25);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--text-dim);
  font-size: 0.82rem;
  background: rgba(0, 0, 0, 0.18);
}

.agri-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

.agri-row-actions .btn-action-secondary {
  margin: 0;
  padding: 6px 10px;
  font-size: 0.78rem;
  width: auto !important;
  min-width: 0;
  flex: 0 0 auto;
  justify-content: center;
}

.agri-management-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
  justify-content: flex-start;
}

.agri-management-tab {
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
  border: 1px solid rgba(143, 188, 164, 0.24);
  background: rgba(14, 38, 33, 0.72);
  color: #d5e7dc;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.agri-management-tab.active {
  border-color: rgba(91, 223, 152, 0.62);
  background: rgba(31, 126, 77, 0.35);
  color: #edfff4;
  box-shadow: 0 0 0 1px rgba(91, 223, 152, 0.3) inset;
}

.agri-terrain-inline-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.agri-management-panel {
  display: none;
  gap: 12px;
}

.agri-management-panel.active {
  display: grid;
}

.agri-management-panel .table-wrap {
  margin-top: 0;
}

.agri-management-table td:last-child,
.agri-management-table th:last-child {
  white-space: nowrap;
}

.agri-management-table .table-actions {
  gap: 8px;
}

.agri-terrain-inline-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 14px;
}

.agri-terrain-inline-copy {
  min-width: 0;
}

.agri-terrain-inline-copy strong {
  display: block;
}

.agri-terrain-inline-copy small {
  color: var(--text-dim);
  display: block;
}

.agri-type-chip {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.agri-type-chip.property {
  color: #d4e7db;
  background: rgba(62, 111, 90, 0.28);
  border-color: rgba(100, 164, 135, 0.45);
}

.agri-type-chip.asset {
  color: #d5e7ff;
  background: rgba(56, 95, 142, 0.28);
  border-color: rgba(101, 148, 202, 0.46);
}

.agri-management-empty {
  margin: 0;
  color: var(--text-dim);
}

.agri-schedule-day-card {
  padding: 12px;
}

.agri-schedule-item-list {
  display: grid;
  gap: 8px;
}

.agri-schedule-item {
  border: 1px solid rgba(137, 185, 160, 0.2);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(5, 30, 24, 0.35);
}

.agri-schedule-item strong {
  display: block;
  font-size: 0.88rem;
}

.agri-schedule-item small {
  display: block;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.agri-btn-danger {
  border-color: rgba(255, 99, 99, 0.45) !important;
  color: #ffb0b0 !important;
  background: rgba(255, 60, 60, 0.12) !important;
}

.agri-btn-danger:hover {
  background: rgba(255, 70, 70, 0.2) !important;
  border-color: rgba(255, 120, 120, 0.68) !important;
}

.agri-calendar-card {
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(13, 23, 26, 0.98), rgba(8, 16, 18, 0.96)),
    var(--card);
  border: 1px solid rgba(178, 207, 84, 0.22);
}

.agri-calendar-cat-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.agri-calendar-cat-btn {
  width: auto;
  margin-top: 0;
  padding: 5px 14px;
  border: 1px solid rgba(178, 207, 84, 0.3);
  background: rgba(178, 207, 84, 0.07);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  white-space: nowrap;
  line-height: 1.5;
}

.agri-calendar-cat-btn:hover {
  border-color: rgba(178, 207, 84, 0.6);
  background: rgba(178, 207, 84, 0.15);
}

.agri-calendar-cat-btn.active {
  border-color: rgba(178, 207, 84, 0.85);
  background: rgba(178, 207, 84, 0.22);
  color: #d9f08a;
}

[data-theme="light"] .agri-calendar-cat-btn {
  background: rgba(80, 120, 20, 0.08);
  border-color: rgba(80, 120, 20, 0.3);
  color: var(--text);
}

[data-theme="light"] .agri-calendar-cat-btn.active {
  background: rgba(80, 120, 20, 0.18);
  border-color: rgba(80, 120, 20, 0.7);
  color: #2d5a0f;
}

.agri-meteo-card {
  padding: 14px;
  border: 1px solid rgba(181, 220, 69, 0.2);
  background:
    radial-gradient(circle at 85% 10%, rgba(181, 220, 69, 0.1), transparent 40%),
    linear-gradient(180deg, rgba(12, 22, 24, 0.95), rgba(7, 16, 18, 0.96));
}

.agri-meteo-card-under-calendar {
  border-color: rgba(137, 179, 163, 0.24);
  background:
    radial-gradient(circle at 88% 14%, rgba(78, 144, 205, 0.08), transparent 38%),
    linear-gradient(180deg, rgba(10, 19, 22, 0.95), rgba(6, 14, 16, 0.96));
}

.agri-meteo-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.agri-meteo-meta {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.agri-meteo-top {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.agri-meteo-current {
  border: 1px solid rgba(181, 220, 69, 0.28);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
}

.agri-meteo-current-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.agri-meteo-current-copy h4 {
  margin: 0 0 8px;
  font-size: 1.18rem;
  color: var(--primary);
  letter-spacing: 0.03em;
}

.agri-meteo-current-copy p {
  margin: 0 0 4px;
  color: var(--text-dim);
  font-size: 0.86rem;
}

.agri-meteo-current-copy strong {
  color: #f1f8f3;
  font-size: 1.2rem;
}

.agri-meteo-hours {
  display: grid;
  grid-template-columns: repeat(6, minmax(88px, 1fr));
  gap: 8px;
}

.agri-meteo-hour-slot {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 4px;
}

.agri-meteo-card-under-calendar .agri-meteo-hour-slot {
  background: rgba(255, 255, 255, 0.015);
}

.agri-meteo-hour-slot strong {
  font-size: 0.92rem;
  color: #f4faf6;
}

.agri-meteo-hour-slot small {
  color: var(--text-dim);
  font-size: 0.72rem;
}

.agri-meteo-hour {
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.agri-meteo-icon {
  font-size: 1.05rem;
  line-height: 1;
  color: #f3f7f4;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.08);
}

.agri-meteo-months {
  display: grid;
  grid-template-columns: repeat(6, minmax(86px, 1fr));
  gap: 8px;
}

.agri-meteo-month-card {
  border: 1px solid rgba(181, 220, 69, 0.2);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  background: rgba(181, 220, 69, 0.06);
  display: grid;
  gap: 4px;
}

.agri-meteo-card-under-calendar .agri-meteo-month-card {
  border-color: rgba(126, 174, 205, 0.22);
  background: rgba(88, 140, 175, 0.08);
}

.agri-meteo-month-card span {
  color: #e7efe8;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.agri-meteo-month-card strong {
  color: var(--primary);
  font-size: 0.9rem;
}

.agri-meteo-month-card small {
  color: var(--text-dim);
  font-size: 0.74rem;
}

.agri-meteo-month-icon {
  font-size: 1.12rem;
  line-height: 1;
  color: #f2f6f3;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .agri-meteo-card {
  background:
    radial-gradient(circle at 85% 10%, rgba(45, 122, 63, 0.1), transparent 42%),
    linear-gradient(180deg, rgba(252, 254, 252, 0.98), rgba(241, 248, 243, 0.98));
}

[data-theme="light"] .agri-meteo-hour-slot,
[data-theme="light"] .agri-meteo-current {
  background: rgba(255, 255, 255, 0.74);
}

.agri-calendar-legend {
  display: inline-flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.agri-calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.agri-calendar-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.agri-calendar-dot-plant {
  background: #b5dc45;
}

.agri-calendar-dot-harvest {
  background: #d47c42;
}

.agri-calendar-head-row {
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  border-bottom: 1px solid rgba(181, 220, 69, 0.28);
  padding-bottom: 8px;
}

.agri-calendar-head-timeline {
  display: grid;
  gap: 6px;
}

.agri-calendar-seasons {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0;
}

.agri-calendar-seasons span {
  font-size: 0.68rem;
  color: #dfe7de;
  text-align: center;
  padding: 3px 4px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.agri-calendar-head-title {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.agri-calendar-head-months {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0;
}

.agri-calendar-head-months span {
  font-size: 0.72rem;
  color: #d5dcd6;
  text-align: center;
  border-left: 1px solid rgba(255, 255, 255, 0.09);
  padding: 0 2px;
}

.agri-calendar-head-months span.current {
  color: #ffffff;
  font-weight: 700;
}

.agri-calendar-body {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.agri-calendar-body .agri-calendar-row:nth-child(odd) .agri-calendar-track {
  background: rgba(255, 255, 255, 0.01);
}

.agri-calendar-row {
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.agri-calendar-crop-name {
  color: #e6ece8;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.agri-calendar-crop-icon {
  width: 16px;
  text-align: center;
}

.agri-calendar-track {
  position: relative;
  min-height: 28px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: center;
}

.agri-calendar-month-marker {
  align-self: stretch;
  justify-self: center;
  width: 0;
  border-left: 2px dashed rgba(255, 255, 255, 0.8);
  z-index: 4;
  pointer-events: none;
  opacity: 0.9;
}

.agri-calendar-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  position: absolute;
  inset: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.agri-calendar-grid span {
  border-left: 1px solid rgba(255, 255, 255, 0.09);
}

.agri-calendar-bar {
  height: 10px;
  border-radius: 4px;
  z-index: 1;
  margin: 0 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18) inset;
}

.agri-calendar-bar-plant {
  background: linear-gradient(90deg, #a9d13f, #c5ea56);
}

.agri-calendar-bar-harvest {
  background: linear-gradient(90deg, #ce7238, #e19155);
}

.agri-calendar-empty {
  color: var(--text-dim);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.9rem;
}

.agri-terrain-sidepanel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
}

.agri-terrain-sidepanel-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.agri-terrain-sidepanel-head span {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.agri-terrain-pill-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  max-height: 330px;
  padding-right: 2px;
}

.agri-terrain-pill {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.agri-terrain-pill small {
  color: var(--text-dim);
  font-size: 0.78rem;
}

.agri-terrain-pill-crop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--text);
}

.agri-terrain-pill-crop i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.agri-terrain-pill.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.35);
  background: linear-gradient(90deg, rgba(74, 222, 128, 0.2), rgba(74, 222, 128, 0.06));
}

.agri-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.agri-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.agri-form-grid label {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
}

.agri-terrain-modal-box {
  max-width: 760px;
  max-height: 88vh;
}

.agri-terrain-modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
}

.agri-boundary-tools {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.agri-boundary-tools small {
  color: var(--text-dim);
  line-height: 1.35;
}

.agri-boundary-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.agri-boundary-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px 12px;
}

.agri-boundary-metrics label {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.agri-boundary-metrics input {
  margin: 0;
}

.agri-boundary-actions .btn-action-secondary {
  width: auto;
  margin-top: 0;
  padding: 8px 12px;
  flex: 0 0 auto;
}

.agri-boundary-msg {
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
}

.agri-map-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 280px;
  background: rgba(255, 255, 255, 0.02);
}

.agri-osm-live-map {
  width: 100%;
  height: 100%;
  min-height: 360px;
}

.agri-osm-live-map.agri-map-drawing {
  cursor: crosshair;
  outline: 2px dashed rgba(255, 77, 79, 0.55);
  outline-offset: -4px;
}

.agri-property-marker {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.agri-property-marker:hover {
  transform: scale(1.1);
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.3));
}

.agri-map-status {
  margin: 8px 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.agri-osm-frame {
  border: 0;
  width: 100%;
  height: 320px;
  display: block;
}

.pos-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── POS Quick Action Buttons ───────────────────────────────────────────── */
.pos-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.pos-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 90px;
  text-align: center;
  touch-action: manipulation;
}

.pos-quick-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.pos-quick-btn:active {
  transform: translateY(0);
}

.pos-quick-btn .pqb-icon {
  font-size: 2rem;
  line-height: 1;
}

.pos-quick-btn .pqb-label {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Invoice upload zone */
.pos-invoice-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px dashed rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  margin-top: 4px;
}
.piz-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.pos-invoice-btn {
  font-size: 0.82rem;
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s;
  white-space: nowrap;
}
.pos-invoice-btn:hover {
  background: rgba(255, 255, 255, 0.13);
}
.pos-invoice-btn.piz-clear {
  color: #ffb0b0;
  border-color: rgba(255, 99, 99, 0.4);
  padding: 6px 9px;
}
.piz-filename {
  font-size: 0.8rem;
  color: var(--text-dim);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Venda tint */
.pos-quick-btn.venda {
  border-color: rgba(74, 222, 128, 0.2);
  background: rgba(74, 222, 128, 0.06);
}
.pos-quick-btn.venda:hover {
  background: rgba(74, 222, 128, 0.14);
  border-color: #4ade80;
  box-shadow: 0 4px 16px rgba(74, 222, 128, 0.18);
}

/* Compra tint */
.pos-quick-btn.compra {
  border-color: rgba(251, 191, 36, 0.2);
  background: rgba(251, 191, 36, 0.05);
}
.pos-quick-btn.compra:hover {
  background: rgba(251, 191, 36, 0.12);
  border-color: #fbbf24;
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.18);
}

[data-theme="light"] .pos-quick-btn {
  background: #ffffff;
  border-color: rgba(45, 106, 79, 0.18);
  color: #1a3a2a;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
[data-theme="light"] .pos-quick-btn:hover {
  background: #f6faf7;
  box-shadow: 0 4px 16px rgba(45, 106, 79, 0.12);
}
[data-theme="light"] .pos-quick-btn.venda {
  background: #f0fdf4;
  border-color: rgba(34, 197, 94, 0.3);
}
[data-theme="light"] .pos-quick-btn.venda:hover {
  background: #dcfce7;
  border-color: #22c55e;
}
[data-theme="light"] .pos-quick-btn.compra {
  background: #fffbeb;
  border-color: rgba(245, 158, 11, 0.3);
}
[data-theme="light"] .pos-quick-btn.compra:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}

.pos-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
}

.pos-section-subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.pos-catalog-card,
.pos-cart-card {
  padding: 14px;
}

.pos-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.pos-section-head h3 {
  margin: 0;
  color: var(--primary);
}

.pos-section-head span {
  color: var(--text-dim);
  font-size: 0.84rem;
}

.pos-filter-row {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 220px);
  gap: 10px;
  margin-bottom: 10px;
}

.pos-segment {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.05);
}

.pos-segment-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

.pos-segment-btn.is-active {
  background: var(--primary);
  color: #072212;
}

.pos-search {
  width: 100%;
}

.pos-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.pos-item-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--stat-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pos-item-type {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pos-item-card h4 {
  margin: 5px 0;
}

.pos-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pos-add-btn {
  min-height: 44px;
  padding: 10px 14px;
}

.pos-qty-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.pos-qty-btn {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.pos-qty-btn:active {
  background: rgba(74, 222, 128, 0.2);
}

.pos-qty-input {
  width: 70px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  font-weight: 700;
  padding: 0 6px;
}

.pos-remove-btn {
  min-width: 40px;
  min-height: 40px;
  touch-action: manipulation;
}

.pos-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.pos-divider {
  height: 1px;
  margin: 14px 0;
  background: var(--border);
}

.pos-total-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.pos-actions-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.pos-actions-row .btn-action,
.pos-actions-row .btn-action-secondary,
.pos-actions-row .btn-secondary {
  min-height: 46px;
  padding: 10px 14px;
  touch-action: manipulation;
}

.pos-badges {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .agri-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .agri-meteo-top {
    grid-template-columns: 1fr;
  }

  .agri-meteo-hours,
  .agri-meteo-months {
    grid-template-columns: repeat(4, minmax(82px, 1fr));
  }

  .dashboard-agri-layout {
    grid-template-columns: 1fr;
  }

  .agri-map-layout {
    grid-template-columns: 1fr;
  }

  .agri-terrain-pill-list {
    max-height: 220px;
  }

  .pos-layout {
    grid-template-columns: 1fr;
  }

  .pos-filter-row {
    grid-template-columns: 1fr;
  }

  .pos-catalog-grid {
    grid-template-columns: 1fr;
  }

  .pos-item-card {
    padding: 14px;
  }

  .pos-actions-row {
    position: sticky;
    bottom: 0;
    background: color-mix(in srgb, var(--card-bg) 92%, black 8%);
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-bottom: -4px;
    z-index: 3;
  }
}

@media (max-width: 720px) {
  .agri-command-layout {
    grid-template-columns: 1fr;
  }

  .agri-meteo-hours,
  .agri-meteo-months {
    grid-template-columns: repeat(3, minmax(82px, 1fr));
  }

  .agri-meteo-card-under-calendar {
    padding: 12px;
  }

  .agri-calendar-head-row,
  .agri-calendar-row {
    grid-template-columns: 1fr;
  }

  .agri-calendar-head-timeline,
  .agri-calendar-seasons,
  .agri-calendar-head-months,
  .agri-calendar-track {
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .agri-calendar-seasons span {
    min-width: 100px;
  }

  .agri-command-pill-list {
    max-height: 220px;
  }

  .agri-command-map-wrap,
  .agri-osm-frame {
    height: 260px;
  }

  .agri-header-btn {
    min-width: auto;
    width: auto;
  }
}

/* Stats Redirect Button (Mobile) */
.stats-redirect-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, rgba(74, 222, 128, 0.8) 100%);
  border: 2px solid var(--primary);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

[data-theme="light"] .stats-redirect-btn {
  background: linear-gradient(135deg, var(--primary) 0%, rgba(139, 195, 74, 0.9) 100%);
  box-shadow: 0 4px 12px rgba(45, 122, 63, 0.2);
}

.stats-redirect-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 222, 128, 0.4);
}

[data-theme="light"] .stats-redirect-btn:hover {
  box-shadow: 0 6px 20px rgba(45, 122, 63, 0.3);
}

.stats-redirect-btn:active {
  transform: translateY(0);
}

.stats-redirect-btn .btn-icon {
  font-size: 2.5rem;
  flex-shrink: 0;
}

.stats-redirect-btn .btn-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #000;
}

.stats-redirect-btn .btn-content strong {
  font-size: 1.1rem;
  font-weight: 700;
  color: #000;
}

.stats-redirect-btn .btn-content small {
  font-size: 0.85rem;
  opacity: 0.8;
  color: #000;
  font-weight: 500;
}

.stats-redirect-btn .btn-arrow {
  font-size: 1.8rem;
  font-weight: bold;
  flex-shrink: 0;
  color: #000;
  opacity: 0.8;
}

.tabs-card {
  padding: 0;
  overflow: visible;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* ── Collapsible tabs nav wrapper ── */
.tabs-nav-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  --tabs-rail-bg: #0f2f27;
  --tabs-left-dead-zone: 88px;
  --tabs-right-dead-zone: 88px;
  --tabs-inline-start-gutter: 96px;
  --tabs-inline-end-gutter: 96px;
  overflow: hidden;
  border-radius: 12px;
}

[data-theme="light"] .tabs-nav-wrapper {
  --tabs-rail-bg: #edf6ee;
}

.tabs-nav-wrapper.tabs-has-overflow {
  --tabs-left-dead-zone: 88px;
  --tabs-right-dead-zone: 88px;
  --tabs-inline-start-gutter: 96px;
  --tabs-inline-end-gutter: 96px;
}

.tabs-nav-wrapper::before,
.tabs-nav-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--tabs-rail-bg);
  pointer-events: none;
  z-index: 23;
  opacity: 1;
}

.tabs-nav-wrapper.tabs-has-overflow::after {
  opacity: 1;
}

.tabs-nav-wrapper::before {
  left: 0;
  width: var(--tabs-left-dead-zone);
  pointer-events: auto;
  z-index: 26;
}

.tabs-nav-wrapper::after {
  right: 0;
  width: var(--tabs-right-dead-zone);
  opacity: 1;
  pointer-events: auto;
  z-index: 26;
}

.tabs-scroll-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  background: #102d26;
  color: var(--text);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

[data-theme="light"] .tabs-scroll-btn {
  background: #ffffff;
}

.tabs-scroll-btn:hover:not([disabled]) {
  transform: translateY(-50%);
  border-color: rgba(74, 222, 128, 0.58);
  background: #164337;
  box-shadow: none;
}

[data-theme="light"] .tabs-scroll-btn:hover:not([disabled]) {
  background: #eef8f0;
}

.tabs-scroll-btn:active:not([disabled]) {
  transform: translateY(-50%);
  background: #0e2a23;
}

[data-theme="light"] .tabs-scroll-btn:active:not([disabled]) {
  background: #e4f4e7;
}

.tabs-scroll-btn:focus,
.tabs-scroll-btn:focus-visible {
  transform: translateY(-50%);
}

.tabs-scroll-btn-left {
  left: 22px;
  pointer-events: auto;
}

.tabs-scroll-btn-right {
  right: 22px;
}

.tabs-nav-wrapper.tabs-has-overflow .tabs-scroll-btn {
  display: inline-flex !important;
}

.tabs-scroll-btn[disabled] {
  opacity: 1;
  background: #102d26;
  border-color: #2d4d44;
  color: #6f8f86;
  cursor: default;
}

[data-theme="light"] .tabs-scroll-btn[disabled] {
  background: #ffffff;
  border-color: #c9d8cb;
  color: #8aa08e;
}

.tabs-nav-handle {
  display: none !important;
  align-items: center;
  justify-content: center;
  padding: 10px 16px 8px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s;
}

.tabs-nav-wrapper.open .tabs-nav-handle,
.tabs-nav-wrapper:hover .tabs-nav-handle {
  border-color: var(--primary);
}

.tabs-nav-hint {
  font-size: 1.1rem;
  color: var(--text-dim);
  transition: transform 0.25s;
}

.tabs-nav-wrapper.open .tabs-nav-hint,
.tabs-nav-wrapper:hover .tabs-nav-hint {
  transform: rotate(180deg);
}

.tabs-nav-wrapper .tabs {
  max-height: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 50px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-padding-inline-start: var(--tabs-inline-start-gutter);
  scroll-padding-inline-end: var(--tabs-inline-end-gutter);
  opacity: 1;
  padding: 8px var(--tabs-inline-end-gutter) 8px var(--tabs-inline-start-gutter);
  pointer-events: auto !important;
}

.tabs-nav-wrapper.open .tabs,
.tabs-nav-wrapper:hover .tabs {
  max-height: none;
  opacity: 1;
  padding: 8px var(--tabs-inline-end-gutter) 8px var(--tabs-inline-start-gutter);
  pointer-events: auto;
}
.tabs-nav-wrapper.tabs-nav-static .tabs-nav-handle {
  display: none;
}
.tabs-nav-wrapper.tabs-nav-static .tabs {
  max-height: none;
  opacity: 1;
  padding: 8px var(--tabs-inline-end-gutter) 10px var(--tabs-inline-start-gutter);
  pointer-events: auto !important;
}

.tabs-nav-wrapper.open .tabs,
.tabs-nav-wrapper:hover .tabs {
  pointer-events: auto !important;
}

.tabs-nav-wrapper.tabs-nav-empty {
  display: none;
}

body.principal-page .tabs-card {
  background: transparent;
  border: none;
  box-shadow: none;
}

body.principal-page #tabContent.principal-tab-content {
  padding-top: 0;
}

#tabContent {
  padding: 16px;
}

.nav-context-bar {
  margin: 2px 8px 0;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(74, 222, 128, 0.18);
  background: rgba(8, 33, 27, 0.55);
  color: var(--text-dim);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-context-bar strong {
  color: var(--text);
  font-weight: 700;
}

.nav-context-link {
  width: auto;
  margin: 0;
  padding: 2px 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.92rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.nav-context-link:hover {
  color: var(--primary);
  transform: none;
  box-shadow: none;
}

.nav-context-link-active {
  color: var(--text);
  font-weight: 700;
}

.nav-context-separator {
  color: var(--text-dim);
}

.tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  padding: 8px;
  background: var(--tabs-container-bg);
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  width: auto;
  flex: 0 0 auto;
  height: 38px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--tab-bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  font-weight: 600;
  transform: none !important;
  transition: background-color 0.16s ease, border-color 0.16s ease,
    color 0.16s ease, box-shadow 0.16s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:active,
.tab-btn:focus,
.tab-btn:focus-visible,
.tab-btn:hover {
  transform: none !important;
}

.tab-btn .menu-icon {
  font-size: 0.98rem;
  line-height: 1;
}

.tab-btn .menu-label {
  line-height: 1;
}

.tab-btn:hover {
  background: var(--tab-hover-bg);
  border-color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: var(--bg-alt);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

[data-theme="light"] .tab-btn.active {
  color: #fff;
  box-shadow: 0 4px 12px rgba(139, 195, 74, 0.4);
}

.tab-content {
  min-height: 300px;
  width: 100%;
  display: block;
  visibility: visible;
  opacity: 1;
}

.settings-hero-card {
  padding: 16px;
  margin-bottom: 16px;
}

.settings-hero-card h2 {
  margin: 0;
}

.settings-hero-card p {
  margin: 8px 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.settings-panel {
  padding: 16px;
  margin-top: 16px;
  padding-bottom: 22px;
  background:
    radial-gradient(circle at top right, rgba(74, 222, 128, 0.12), transparent 42%),
    linear-gradient(165deg, rgba(10, 43, 36, 0.9), rgba(7, 30, 25, 0.88));
}

.settings-tabbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.settings-tabbar button {
  width: 100%;
  margin-top: 0;
  border-radius: 12px;
}

.settings-tabbar button[aria-selected="true"] {
  box-shadow: 0 0 0 1px rgba(91, 223, 152, 0.32) inset;
}

.settings-pane[hidden] {
  display: none !important;
}

.settings-pane-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.settings-subcard {
  padding: 14px;
  margin: 0 0 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(98, 173, 147, 0.22);
  border-radius: 14px;
}

.settings-subcard h4 {
  margin: 0 0 10px;
}

.settings-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.settings-fields .form-group,
.settings-kids-grid .form-group {
  margin: 0;
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.settings-kids-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  align-items: end;
}

.settings-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.settings-switch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.settings-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.settings-species-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.settings-species-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(98, 173, 147, 0.22);
  background:
    linear-gradient(180deg, rgba(98, 173, 147, 0.12), rgba(7, 30, 25, 0.18));
}

.settings-species-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-species-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(98, 173, 147, 0.28);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
}

.settings-checkbox {
  align-items: center;
  gap: 10px;
}

.settings-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.settings-actions-sticky {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding-top: 10px;
  margin-top: 8px;
  background: linear-gradient(180deg, rgba(7, 30, 25, 0), rgba(7, 30, 25, 0.9) 28%);
}

.settings-actions .btn-primary {
  width: auto;
  min-width: 260px;
  margin-top: 0;
}

.settings-backup-card {
  border: 1px solid rgba(98, 173, 147, 0.24);
  background: linear-gradient(160deg, rgba(10, 43, 36, 0.86), rgba(7, 30, 25, 0.82));
}

#settingsMsg {
  font-size: 0.85rem;
  color: var(--text-dim);
}

@media (max-width: 720px) {
  .settings-actions-sticky {
    position: static;
    background: transparent;
    padding-top: 0;
  }

  .settings-actions .btn-primary,
  .settings-actions .btn-action-secondary {
    min-width: 0;
    width: 100%;
  }

  .settings-tabbar {
    grid-template-columns: 1fr;
  }
}

.tab-panel {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.table-wrap {
  overflow-x: auto;
}

#tabContent .table-wrap {
  padding: 10px;
  border-radius: 18px;
  background: rgba(7, 24, 20, 0.18);
  border: 1px solid rgba(74, 222, 128, 0.08);
}

#tabContent .table-wrap > table,
#tabContent .table-wrap > div > table {
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(74, 222, 128, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

#tabContent .table-wrap > table th,
#tabContent .table-wrap > div > table th {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(74, 222, 128, 0.2), rgba(74, 222, 128, 0.14));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

#tabContent .table-wrap > table tbody tr,
#tabContent .table-wrap > div > table tbody tr {
  transition: background 0.18s ease, transform 0.18s ease;
  border-bottom: 1px solid rgba(74, 222, 128, 0.12);
}

#tabContent .table-wrap > table tbody tr:last-child,
#tabContent .table-wrap > div > table tbody tr:last-child {
  border-bottom: none;
}

#tabContent .table-wrap > table tbody td,
#tabContent .table-wrap > div > table tbody td {
  border-bottom: 1px solid rgba(74, 222, 128, 0.1);
  padding: 12px 12px;
  line-height: 1.35;
}

#tabContent .table-wrap > table tbody tr:hover,
#tabContent .table-wrap > div > table tbody tr:hover {
  background: rgba(74, 222, 128, 0.06);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--table-bg);
}

th {
  background: var(--table-header-bg);
  color: var(--primary);
  font-weight: 700;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  vertical-align: top;
}

td .btn-small {
  padding: 6px 10px;
  margin: 0 2px;
  font-size: 1rem;
  min-width: auto;
}

td .btn-small:hover {
  transform: translateY(-1px);
}

.message {
  margin: 8px 0 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--primary);
}

@keyframes rise {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@media (max-width: 920px) {
  .tab-panel {
    grid-template-columns: 1fr;
  }

  .header-brand-group {
    gap: 10px;
  }

  .header-shortcuts {
    gap: 8px;
  }

  .header-shortcut-btn {
    min-width: 110px;
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .global-overview-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .global-overview-actions {
    grid-template-columns: 1fr 1fr;
  }

  .global-overview-grid,
  .global-overview-grid-secondary {
    grid-template-columns: 1fr;
  }

  .global-overview-stats {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .global-overview-mini-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .app-header .logo h2 {
    font-size: 1.1rem;
  }

  .app-header .logo img {
    height: 52px;
  }

  .tabs {
    gap: 6px;
    padding: 6px;
    flex-wrap: nowrap;
  }

  .tab-btn {
    padding: 8px 12px;
    font-size: 0.88rem;
  }

  .stats {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-card strong {
    font-size: 1.3rem;
  }
}

/* Light Mode Enhanced Styles for Login/Signup Pages */
[data-theme="light"] .login-card {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(139, 195, 74, 0.3);
  box-shadow: 0 16px 48px rgba(45, 122, 63, 0.12);
}

[data-theme="light"] .btn-primary {
  background: linear-gradient(135deg, #2d7a3f 0%, #1f5c2f 100%);
  box-shadow: 0 6px 16px rgba(45, 122, 63, 0.35);
}

[data-theme="light"] .btn-primary:hover {
  box-shadow: 0 10px 24px rgba(45, 122, 63, 0.5);
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 195, 74, 0.2);
}

@media (max-width: 600px) {
  .container {
    width: 100%;
    margin: 0;
  }

  .app-header {
    padding: 10px 12px;
  }

  .header-brand-group {
    gap: 6px;
  }

  .header-controls {
    gap: 6px;
  }

  .global-overview-hero h2 {
    font-size: 1.45rem;
  }

  .global-overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .global-overview-stat-card {
    min-height: 110px;
    padding: 12px;
  }

  .global-overview-stat-icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }

  .global-overview-stat-label {
    font-size: 0.8rem;
  }

  .global-overview-mini-stats div {
    padding: 10px 8px;
  }

  .global-overview-actions .btn-primary,
  .global-overview-actions .btn-secondary {
    min-width: 0;
    width: 100%;
  }

  .app-header .logo img {
    height: 64px;
  }

  .app-header .logo h2 {
    font-size: 1rem;
  }
  
  .species-menu-btn {
    width: 36px;
    height: 36px;
    padding: 6px;
  }

  .user-icon {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .tabs-card {
    padding: 12px;
    border-radius: 0;
  }

  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }

  .tab-btn {
    white-space: nowrap;
  }

  .login-icon {
    width: 60px;
    height: 60px;
    max-width: 60px;
    max-height: 60px;
  }

  .login-card {
    padding: 24px;
    width: 95%;
    max-width: 380px;
  }
}

/* Sub-tabs (section navigation inside a species) */
.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  background: var(--tabs-container-bg);
  border-bottom: 1px solid var(--border);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.sub-tab-btn {
  width: auto;
  margin-top: 0;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--tab-bg);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.sub-tab-btn:hover {
  background: var(--tab-hover-bg);
  border-color: var(--primary);
}

.sub-tab-btn.active {
  background: var(--primary);
  color: var(--bg-alt);
  border-color: var(--primary);
}

.react-section-nav {
  margin: 0;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(7, 18, 15, 0.94);
  min-height: calc(100vh - 130px);
  position: sticky;
  top: 90px;
  z-index: 5;
}

.react-section-nav-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(222, 240, 231, 0.7);
  margin-bottom: 10px;
  padding: 0 2px 10px;
  border-bottom: 1px solid rgba(74, 222, 128, 0.28);
}

.react-section-nav-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.react-section-group {
  border: 1px solid rgba(74, 222, 128, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.react-section-group.open {
  border-color: rgba(74, 222, 128, 0.4);
  box-shadow: inset 0 0 0 1px rgba(74, 222, 128, 0.12);
}

.react-section-nav-tabs-wrap {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.react-section-nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.react-section-btn,
.react-subtab-btn {
  width: 100% !important;
  margin-top: 0 !important;
  min-width: 0;
  white-space: normal;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(74, 222, 128, 0.25);
  background: rgba(74, 222, 128, 0.07);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.react-section-btn:hover {
  border-color: rgba(74, 222, 128, 0.6);
  background: rgba(74, 222, 128, 0.16);
}

.react-section-btn.active {
  border-color: rgba(74, 222, 128, 0.8);
  background: rgba(74, 222, 128, 0.22);
}

.react-section-chevron {
  flex: 0 0 auto;
  transition: transform 0.2s ease;
}

.react-section-group.open .react-section-chevron {
  transform: rotate(180deg);
}

.react-subtab-btn {
  justify-content: flex-start;
  border: 0;
  border-left: 2px solid rgba(74, 222, 128, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  font-size: 0.88rem;
  font-weight: 600;
}

.react-subtab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-left-color: rgba(74, 222, 128, 0.8);
}

.react-subtab-btn.active {
  background: linear-gradient(90deg, rgba(253, 188, 74, 0.28), rgba(74, 222, 128, 0.1));
  border-left-color: rgba(253, 188, 74, 0.95);
  color: #fef4d9;
}

.react-section-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 8px;
  border-top: 1px dashed rgba(74, 222, 128, 0.26);
}

[data-theme="light"] .react-section-nav {
  background: rgba(252, 251, 245, 0.96);
}

[data-theme="light"] .react-section-btn {
  background: rgba(45, 122, 63, 0.1);
  border-color: rgba(45, 122, 63, 0.3);
}

[data-theme="light"] .react-section-btn.active {
  background: rgba(45, 122, 63, 0.2);
}

[data-theme="light"] .react-subtab-btn.active {
  color: #3b2a00;
}

@media (max-width: 600px) {
  .react-section-nav {
    display: none;
  }
}

/* Milk filter bar */
.milk-filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  align-items: end;
}

.milk-filter-bar select,
.milk-filter-bar input,
.milk-filter-bar input[type="date"] {
  width: 100%;
  min-width: 0;
  max-width: none;
  margin-top: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.9rem;
}

.milk-filter-bar .btn-clear-filter {
  width: 100%;
  margin-top: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--danger);
  color: #fff;
  border: none;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.sales-section-card {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
}

.sales-section-card + .sales-section-card {
  margin-top: 18px;
}

.sales-section-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 110px;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.12), rgba(251, 191, 36, 0.05));
  pointer-events: none;
}

.production-summary-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 55%),
    var(--card);
  border-radius: 20px;
}

.production-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  overflow: visible;
  padding-bottom: 0;
}

.production-stat-grid > .stat-card {
  min-width: 0;
}

.production-summary-card .stat-card {
  min-height: 104px;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(74, 222, 128, 0.06);
  border: 1px solid rgba(74, 222, 128, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.production-summary-card .stat-card strong {
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}

.production-summary-card .stat-card span {
  font-size: 0.95rem;
  font-weight: 700;
}

.production-chart-card {
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid rgba(74, 222, 128, 0.14);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(8, 40, 32, 0.94), rgba(7, 33, 27, 0.92));
}

.production-chart-title {
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}

.production-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.production-chart-head .production-chart-title {
  margin: 0;
}

.production-chart-toggle-btn {
  width: auto;
  min-width: 118px;
  margin-top: 0;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.12);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.production-chart-toggle-btn:hover {
  border-color: rgba(74, 222, 128, 0.65);
  background: rgba(74, 222, 128, 0.2);
  transform: none;
  box-shadow: none;
}

[data-theme="light"] .production-chart-toggle-btn {
  border-color: rgba(45, 122, 63, 0.35);
  background: rgba(45, 122, 63, 0.14);
}

[data-theme="light"] .production-chart-toggle-btn:hover {
  border-color: rgba(45, 122, 63, 0.6);
  background: rgba(45, 122, 63, 0.22);
}

.production-chart-wrap {
  position: relative;
  height: 180px;
  min-height: 180px;
}

.sales-section-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.sales-section-head h3 {
  font-size: 1.95rem;
  letter-spacing: -0.03em;
}

.sales-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.18);
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sales-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 6px 12px;
  margin-left: 8px;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.16);
  border: 1px solid rgba(74, 222, 128, 0.22);
  color: var(--primary);
  font-size: 0.95rem;
  font-weight: 800;
  vertical-align: middle;
}

.sales-export-btn {
  width: auto;
  min-width: 136px;
  min-height: 42px;
  padding: 9px 14px;
  margin-top: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.milk-sales-filter-panel {
  position: relative;
  z-index: 1;
}

.milk-filter-bar {
  margin-bottom: 18px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(74, 222, 128, 0.12);
}

.milk-sales-filter-panel .filter-field {
  min-width: 0;
}

.milk-records-filter-panel {
  grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(150px, 1fr)) minmax(170px, 1fr) minmax(160px, 0.9fr);
}

.cheese-records-filter-panel {
  grid-template-columns: repeat(2, minmax(170px, 1fr)) minmax(180px, 1fr) minmax(160px, 0.9fr);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-label {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-left: 2px;
}

.filter-field-buyer {
  grid-column: span 2;
}

.filter-field-page-size {
  max-width: 150px;
}

.milk-sales-clear-btn {
  width: auto !important;
  min-width: 136px;
  min-height: 42px;
  justify-self: start;
  align-self: end;
  padding: 9px 14px !important;
  font-size: 0.8rem !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.milk-row-actions {
  display: inline-flex !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 6px;
}

.milk-row-actions .btn-small {
  min-width: 76px;
  max-width: none;
}

.milk-row-actions .btn-small.btn-small-danger {
  min-width: 84px;
}

.cheese-records-filter-panel .btn-clear-filter {
  width: auto;
  align-self: end;
  min-width: 136px;
  min-height: 42px;
  padding: 9px 14px;
  font-size: 0.82rem;
}

.milk-sales-table {
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(74, 222, 128, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.milk-sales-table th {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(74, 222, 128, 0.2), rgba(74, 222, 128, 0.14));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.sales-section-card .table-wrap {
  position: relative;
  z-index: 1;
  padding: 10px;
  border-radius: 18px;
  background: rgba(7, 24, 20, 0.18);
  border: 1px solid rgba(74, 222, 128, 0.08);
}

.milk-sales-table tbody tr {
  transition: background 0.18s ease, transform 0.18s ease;
  border-bottom: 1px solid rgba(74, 222, 128, 0.12);
}

.milk-sales-table tbody tr:last-child {
  border-bottom: none;
}

.milk-sales-table tbody td {
  border-bottom: 1px solid rgba(74, 222, 128, 0.10);
  padding: 12px 12px;
  line-height: 1.35;
}

.milk-sales-table tbody tr:hover {
  background: rgba(74, 222, 128, 0.06);
}

.milk-sales-pagination {
  margin-top: 14px;
}

.pager-shell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 6px;
}

.pager-info {
  color: var(--text-dim);
  font-size: 0.83rem;
  font-weight: 600;
}

.pager-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.pager-page-btn,
.pager-nav-btn {
  width: auto;
  min-width: 42px;
  margin-top: 0;
  border-radius: 10px;
}

.pager-page-btn.is-active {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #062015;
  box-shadow: 0 10px 18px rgba(34, 197, 94, 0.25);
}

.pager-nav-btn[disabled],
.pager-page-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.milk-filter-summary {
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 0 4px;
  align-self: center;
}

/* Feed stock alert banners */
.alert-banner {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.alert-banner.alert-warning {
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.5);
  color: #fbbf24;
}
.alert-banner.alert-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: #ef4444;
}

/* Table action buttons side by side */
.table-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  width: auto;
  white-space: nowrap;
  flex-wrap: nowrap;
}

.filter-select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--text-primary, #e2e8f0);
  font-size: 0.82rem;
  padding: 5px 10px;
  height: 32px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.filter-select:focus {
  border-color: rgba(74, 222, 128, 0.5);
}

.filter-select option {
  background: #1a2a1a;
  color: #e2e8f0;
}

.table-actions-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: auto;
  justify-content: flex-start;
  flex-wrap: nowrap;
}

.table-actions button,
.table-actions .btn-small,
.table-actions .btn-action,
.table-actions .btn-action-secondary {
  width: auto !important;
  min-width: 0;
  max-width: fit-content;
  flex: 0 0 auto;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.table-actions .btn-small {
  min-width: 112px;
  max-width: none;
  min-height: 36px;
  padding: 7px 10px;
  line-height: 1;
}

.table-actions .btn-small.btn-small-danger {
  min-width: 112px;
  max-width: none;
}

.milk-sales-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

.racao-purchases-card {
  padding: 16px;
}

.racao-head {
  margin-bottom: 14px;
}

.racao-title {
  font-size: clamp(1.35rem, 2.5vw, 2rem);
}

.racao-filter-bar {
  grid-template-columns: minmax(180px, 1.2fr) repeat(2, minmax(130px, 1fr)) minmax(130px, 1fr) minmax(140px, 0.9fr);
  align-items: end;
}

.racao-filter-bar .filter-field {
  min-width: 0;
}

.racao-filter-bar .filter-field > input,
.racao-filter-bar .filter-field > select,
.racao-filter-bar .filter-field > .filter-select {
  width: 100%;
  min-width: 0;
}

.racao-table {
  min-width: 980px;
  table-layout: auto;
}

.racao-table th,
.racao-table td {
  white-space: nowrap;
}

.racao-purchases-card .table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

.racao-summary-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 0.83rem;
}

@media (max-width: 900px) {
  .racao-filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .racao-filter-bar .milk-sales-clear-btn {
    grid-column: span 2;
  }
}

@media (max-width: 600px) {
  .racao-filter-bar {
    grid-template-columns: 1fr;
  }

  .racao-table {
    min-width: 760px;
  }

  .racao-filter-bar .milk-sales-clear-btn {
    grid-column: auto;
    width: 100% !important;
    justify-self: stretch;
  }

  .racao-table td:last-child {
    white-space: normal;
  }

  .racao-table .table-actions,
  .racao-table .table-actions-inline {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 6px;
  }

  .racao-table .table-actions .btn-small {
    width: 100% !important;
    min-width: 0;
    justify-content: center;
  }
}

.table-actions .btn-small {
  width: auto;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 0.78rem;
  line-height: 1;
  box-shadow: none;
  flex: 0 0 auto;
}

.table-actions .btn-small:not(.btn-small-danger) {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.95), rgba(34, 197, 94, 0.92));
  color: #082116;
}

.table-actions .btn-small:not(.btn-small-danger):hover {
  background: linear-gradient(135deg, rgba(95, 233, 144, 1), rgba(45, 212, 113, 1));
}

.table-actions .btn-small.btn-small-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.table-actions .btn-small.btn-small-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ffd4d4;
  box-shadow: none;
}

/* Egg table action buttons — dedicated classes, no generic conflicts */
.egg-actions {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 6px;
  width: auto;
}

.egg-action-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  padding: 5px 14px;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  min-height: 36px;
  min-width: 112px !important;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.95), rgba(34, 197, 94, 0.92));
  color: #082116;
  white-space: nowrap;
  margin: 0 !important;
}

.egg-action-btn:hover {
  background: linear-gradient(135deg, rgba(95, 233, 144, 1), rgba(45, 212, 113, 1));
}

.egg-action-btn-danger {
  background: rgba(239, 68, 68, 0.15) !important;
  color: var(--danger) !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
  width: auto !important;
  min-width: 112px !important;
  padding: 7px 10px !important;
}

.egg-action-btn-danger:hover {
  background: rgba(239, 68, 68, 0.25) !important;
  color: #ffd4d4 !important;
}

.encomendas-actions {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.encomendas-actions .encomendas-action-btn {
  width: auto !important;
  min-width: 0;
  margin: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.encomendas-actions .encomendas-action-btn.btn-small-danger {
  width: 34px !important;
  min-width: 34px;
  padding: 0 !important;
}

.clientes-actions {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 6px;
  width: auto !important;
  white-space: nowrap;
}

.clientes-actions .clientes-action-btn {
  width: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto !important;
  font-size: 0.76rem;
  padding: 5px 9px;
}

.clientes-actions .clientes-action-btn.btn-small-danger {
  width: 34px !important;
  min-width: 34px;
  padding: 0 !important;
}

.sortable-th {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}
.sortable-th:hover {
  background: var(--tab-hover-bg);
}
.sort-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  font-size: 0.78rem;
  opacity: 0.7;
  margin-left: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .sub-tab-btn.active {
  color: #fff;
}

[data-theme="light"] .sales-section-card::before {
  background: linear-gradient(135deg, rgba(45, 122, 63, 0.09), rgba(214, 140, 0, 0.05));
}

[data-theme="light"] .production-summary-card .stat-card {
  background: rgba(45, 122, 63, 0.06);
  border-color: rgba(45, 122, 63, 0.12);
}

[data-theme="light"] .sales-kicker,
[data-theme="light"] .sales-count-pill {
  background: rgba(45, 122, 63, 0.08);
  border-color: rgba(45, 122, 63, 0.16);
}

/* Force consistent layout for React milk rectification modal, even with stale JS bundles */
.milk-weekly-react-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
}

.milk-weekly-react-header h3 {
  order: 1 !important;
  margin: 0 !important;
}

.milk-weekly-react-close {
  order: 2 !important;
  margin-left: auto !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.milk-weekly-react-actions {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
}

.milk-weekly-react-actions > button {
  width: 100% !important;
  min-height: 48px !important;
}

@media (max-width: 760px) {
  .milk-weekly-react-actions {
    grid-template-columns: 1fr !important;
  }
}

[data-theme="light"] .sort-arrow {
  background: rgba(45, 122, 63, 0.08);
}

@media (max-width: 600px) {
  .sub-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 8px 12px;
  }

  .production-chart-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .production-chart-toggle-btn {
    width: 100%;
  }

  .milk-filter-bar {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .milk-records-filter-panel,
  .cheese-records-filter-panel {
    grid-template-columns: 1fr;
  }

  .milk-sales-clear-btn {
    width: 100% !important;
    justify-self: stretch;
  }

  .sales-export-btn {
    width: 100%;
  }

  .sales-section-head {
    align-items: stretch;
  }

  .sales-section-head h3 {
    font-size: 1.5rem;
  }

  .production-summary-card .stat-card strong {
    font-size: 1.65rem;
  }

  .pager-shell {
    align-items: stretch;
  }
}

/* Modal Styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 6000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.draft-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  color: var(--text);
}

.draft-clear-btn {
  background: none;
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: inherit;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: auto;
  white-space: nowrap;
}

.draft-clear-btn:hover {
  background: rgba(251, 191, 36, 0.2);
}

.modal-content {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 28px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
  border: 2px solid rgba(74, 222, 128, 0.4);
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .modal-content input,
[data-theme="light"] .modal-content select,
[data-theme="light"] .modal-content textarea {
  border: 2px solid rgba(45, 122, 63, 0.4);
  background: rgba(255, 255, 255, 1);
}

.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}

[data-theme="light"] .modal-content input:focus,
[data-theme="light"] .modal-content select:focus,
[data-theme="light"] .modal-content textarea:focus {
  box-shadow: 0 0 0 3px rgba(45, 122, 63, 0.15);
}

.close-modal {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  margin: 0;
  background: var(--tab-hover-bg, rgba(0,0,0,0.08));
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.close-modal:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

/* Animal Cards */
.animals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.animal-card {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.animal-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(74, 222, 128, 0.2);
  border-color: var(--primary);
}

.animal-card-image {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.animal-card-placeholder {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.1), rgba(34, 197, 94, 0.05));
  border-radius: 8px;
  margin-bottom: 12px;
}

.animal-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: var(--text);
}

.animal-card-tag {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0 0 8px 0;
}

.animal-card-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 4px;
}

.badge-for-sale {
  background: var(--primary);
  color: #000;
}

.animal-tooltip {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translate(-50%, -100%);
  background: rgba(0, 0, 0, 0.95);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.animal-card:hover .animal-tooltip {
  opacity: 1;
}

/* Animal Detail View */
.animal-detail-container {
  max-width: 1000px;
  margin: 0 auto;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-header h2 {
  margin: 0;
  font-size: 1.8rem;
}

.detail-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 28px;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 32px;
  margin-bottom: 24px;
}

.detail-image-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.animal-detail-image {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.animal-placeholder-image {
  width: 100%;
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 96px;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.1), rgba(34, 197, 94, 0.05));
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.image-upload-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.image-upload-buttons .btn-small {
  flex: 1;
  min-width: 120px;
  white-space: nowrap;
}

.detail-info-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-row {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 12px;
  align-items: center;
}

.detail-row label {
  font-weight: 600;
  color: var(--text-dim);
}

.edit-field {
  padding: 8px 12px;
  border: 2px solid rgba(74, 222, 128, 0.35);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

[data-theme="light"] .edit-field {
  border: 2px solid rgba(45, 122, 63, 0.4);
  background: rgba(255, 255, 255, 0.95);
}

.edit-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}

[data-theme="light"] .edit-field:focus {
  box-shadow: 0 0 0 3px rgba(45, 122, 63, 0.15);
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
  background: var(--primary);
  color: #000;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-small:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

.btn-secondary {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--primary);
}

.btn-provider {
  flex: 1;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.18s ease;
}

.btn-provider:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: var(--primary);
}

.btn-provider.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.history-section {
  margin-top: 32px;
}

.history-section h3 {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.history-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.history-card h4 {
  margin-top: 0;
  margin-bottom: 16px;
  color: var(--primary);
}

.animal-react-detail {
  width: 100%;
}

.animal-react-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.animal-react-detail-head h2 {
  margin: 0;
}

.animal-react-detail-actions {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

/* Header-specific button sizing: keep buttons side-by-side and make the delete button smaller */
.animal-react-detail-actions > button {
  width: auto; /* override global button:100% */
  min-width: 0;
}

.animal-react-detail-actions .btn-secondary {
  padding: 8px 12px;
}

.animal-react-detail-actions .btn-small {
  padding: 6px 10px;
  font-size: 0.9rem;
}

.animal-react-detail-actions .btn-small.btn-small-danger.btn-delete {
  padding: 6px 10px;
  min-width: 48px;
  white-space: nowrap;
}

.animal-react-detail-menu {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: 14px;
  background: rgba(8, 33, 27, 0.55);
}

.animal-react-detail-tab {
  width: 100%;
  margin: 0;
  border-radius: 12px;
  border: 1px solid rgba(74, 222, 128, 0.25);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  padding: 10px 12px;
}

.animal-react-detail-tab.active {
  background: var(--primary);
  color: #052014;
  border-color: var(--primary);
}

.animal-react-panel {
  margin-bottom: 14px;
}

.animal-react-panel-single {
  grid-template-columns: 1fr;
}

.animal-react-actions-row {
  display: flex;
  justify-content: flex-end;
}

.animal-react-actions-row .btn-action {
  min-width: 200px;
}

.animal-react-form-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.animal-react-form-grid label {
  display: block;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 6px;
}

.animal-react-form-action {
  display: flex;
  align-items: end;
}

@media (max-width: 920px) {
  .animal-react-detail-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .animal-react-detail-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .animal-react-form-grid {
    grid-template-columns: 1fr;
  }

  .animal-react-form-action .btn-action,
  .animal-react-actions-row .btn-action {
    min-width: 100%;
  }
}

/* Action Buttons */
.action-buttons-container {
  margin-bottom: 20px;
}

.action-buttons {
  display: flex;
  flex-direction: row;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
}

.quick-actions-card {
  position: relative;
  overflow: hidden;
}

.quick-actions-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.08), rgba(74, 222, 128, 0));
  pointer-events: none;
}

.quick-actions-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.quick-actions-head h3 {
  margin: 0;
}

.quick-actions-hint {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  position: relative;
  z-index: 1;
}

.quick-actions-group {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
}

.quick-actions-group h4 {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 1rem;
}

.quick-actions-row {
  gap: 10px;
}

.quick-action-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border-color: rgba(74, 222, 128, 0.25);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08));
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.quick-action-btn .qa-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.quick-action-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(74, 222, 128, 0.55);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .quick-actions-group {
  background: rgba(45, 106, 79, 0.05);
  border-color: rgba(45, 106, 79, 0.15);
}

[data-theme="light"] .quick-action-btn {
  background: linear-gradient(180deg, #ffffff, #f6fbf8);
  border-color: rgba(45, 106, 79, 0.25);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.btn-action {
  padding: 6px 8px;
  background: var(--primary);
  color: #000;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.75rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: fit-content;
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(74, 222, 128, 0.3);
}

/* Mercado sidebar product buttons */
.market-series-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  border-left: 3px solid transparent;
  font-family: inherit;
  font-size: 0.82rem;
}

.market-series-btn:hover {
  background: rgba(82, 224, 137, 0.08);
  border-color: rgba(82, 224, 137, 0.3);
  border-left-color: var(--primary);
}

.market-series-btn.active {
  background: rgba(82, 224, 137, 0.12);
  border-color: rgba(82, 224, 137, 0.35);
  border-left-color: var(--primary);
  box-shadow: 0 2px 8px rgba(82, 224, 137, 0.12);
}

.market-series-btn .msb-name {
  font-weight: 600;
  font-size: 0.83rem;
  display: block;
  margin-bottom: 2px;
}

.market-series-btn .msb-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.market-series-btn .msb-price {
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  color: var(--primary);
  background: rgba(82, 224, 137, 0.1);
  padding: 3px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.market-series-btn .msb-price.msb-price-dim {
  color: var(--text-dim);
  background: transparent;
}

[data-theme="light"] .market-series-btn {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(45, 106, 79, 0.15);
  border-left-color: transparent;
}

[data-theme="light"] .market-series-btn:hover {
  background: rgba(45, 106, 79, 0.06);
  border-color: rgba(45, 106, 79, 0.3);
  border-left-color: var(--primary);
}

[data-theme="light"] .market-series-btn.active {
  background: rgba(45, 106, 79, 0.1);
  border-color: rgba(45, 106, 79, 0.4);
  border-left-color: var(--primary);
}

[data-theme="light"] .market-series-btn .msb-price {
  background: rgba(45, 106, 79, 0.12);
}

.btn-action-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 8px;
  font-size: 0.7rem;
  flex-shrink: 0;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: fit-content;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-action-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--primary);
}

[data-theme="light"] .btn-action-secondary {
  background: #ffffff;
  color: #1a3a2a;
  border-color: rgba(45, 106, 79, 0.3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .btn-action-secondary:hover {
  background: rgba(45, 106, 79, 0.08);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.15);
  color: var(--primary);
}

/* Species List Header */
.species-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: nowrap;
}

.view-toggle {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.view-toggle-btn {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.view-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text);
}

.view-toggle-btn.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
  font-weight: 600;
}

.view-container {
  display: none;
}

.view-container.active {
  display: block;
}

/* Category Filters */
.category-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  margin-top: 16px;
  margin-bottom: 20px;
}

.category-filter-btn {
  width: 100%;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 2px solid rgba(74, 222, 128, 0.25);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-align: center;
}

.cfb-short { display: none; }

[data-theme="light"] .category-filter-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(45, 122, 63, 0.35);
  color: #1a1a1a;
}

.category-filter-btn:hover {
  background: rgba(74, 222, 128, 0.2);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(74, 222, 128, 0.2);
}

[data-theme="light"] .category-filter-btn:hover {
  background: rgba(139, 195, 74, 0.25);
  box-shadow: 0 2px 8px rgba(45, 122, 63, 0.15);
}

.category-filter-btn.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(74, 222, 128, 0.4);
  transform: translateY(-1px);
}

[data-theme="light"] .category-filter-btn.active {
  background: var(--primary);
  box-shadow: 0 4px 16px rgba(45, 122, 63, 0.3);
}

/* Responsive adjustments for detail view */
@media (max-width: 920px) {
  .detail-card {
    grid-template-columns: 1fr;
  }

  .header-shortcuts {
    display: none;
  }

  .global-overview-actions {
    display: grid;
  }

  .side-menu-sections {
    display: flex;
  }
  
  .detail-row {
    grid-template-columns: 140px 1fr auto;
  }
  
  .animals-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  
  /* Show species menu button in mobile */
  .species-menu-btn {
    display: none !important;
    pointer-events: none !important;
  }
  
  /* Hide desktop tabs nav in mobile (use side menu instead) */
  .tabs-card .tabs,
  .tabs-nav-wrapper .tabs,
  .tabs-nav-wrapper.open .tabs,
  .tabs-nav-wrapper:hover .tabs {
    display: none !important;
    max-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .tabs-nav-handle {
    display: none;
  }

  .tabs-scroll-btn {
    display: none !important;
  }
  
  /* Adjust action buttons for mobile */
  .action-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .btn-action {
    flex: 1 1 100%;
    min-width: 100%;
    justify-content: center;
    font-size: 0.9rem;
    padding: 12px;
  }
  
  .btn-action-secondary {
    flex: 1 1 calc(50% - 4px);
    min-width: calc(50% - 4px);
    justify-content: center;
    font-size: 0.85rem;
    padding: 10px 8px;
    text-align: center;
  }

  .egg-actions {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .egg-action-btn {
    font-size: 0.76rem !important;
    padding: 5px 10px !important;
  }

  .egg-action-btn-danger {
    width: 34px !important;
    padding: 0 !important;
  }

  .milk-sales-table tr[data-egg-row] td:last-child {
    white-space: nowrap;
  }

  .quick-actions-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .quick-actions-hint {
    width: 100%;
  }

  .quick-actions-group {
    padding: 10px;
  }

  .quick-action-btn {
    border-radius: 9px;
    font-size: 0.78rem;
    padding: 9px 8px;
  }
  
  .species-list-header h3 {
    font-size: 1.1rem;
  }
  
  .species-list-header {
    flex-wrap: wrap;
  }

  .category-filters {
    gap: 5px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  
  .category-filter-btn {
    padding: 6px 4px;
    font-size: 0.72rem;
  }
  .cfb-full { display: none; }
  .cfb-short { display: inline; }
}

@media (max-width: 700px) {
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .detail-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  
  .detail-row label {
    font-size: 0.85rem;
  }
  
  .animals-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }
  
  .animal-card-image,
  .animal-card-placeholder {
    height: 120px;
  }
  
  /* Toggle stats cards for mobile */
  .stats-card-desktop {
    display: none !important;
  }
  
  .stats-card-mobile {
    display: block !important;
  }
  
  .species-list-header {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  
  .species-list-header h3 {
    font-size: 0.9rem;
    flex: 1;
    min-width: 0;
  }

  .view-toggle {
    flex-shrink: 0;
    width: auto;
  }
  
  .view-toggle-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
  }
  
  .category-filters {
    gap: 4px;
    grid-template-columns: 1fr;
  }
  
  .category-filter-btn {
    padding: 6px 4px;
    font-size: 0.7rem;
  }
  .cfb-full { display: none; }
  .cfb-short { display: inline; }
}

@media (max-width: 480px) {
  .species-list-header h3 {
    font-size: 0.95rem;
  }
  
  .view-toggle-btn {
    padding: 8px;
    font-size: 0.8rem;
  }
  
  .category-filter-btn {
    width: 100%;
    padding: 8px 6px;
    font-size: 0.78rem;
  }
  
  .stat-card {
    padding: 12px;
  }
  
  .stat-card span {
    font-size: 0.8rem;
  }
  
  .stat-card strong {
    font-size: 1.1rem;
  }
  
  /* Compact stats redirect buttons for very small screens */
  .stats-redirect-btn {
    padding: 16px;
    gap: 12px;
  }
  
  .stats-redirect-btn .btn-icon {
    font-size: 2rem;
  }
  
  .stats-redirect-btn .btn-content strong {
    font-size: 1rem;
  }
  
  .stats-redirect-btn .btn-content small {
    font-size: 0.8rem;
  }
  
  .stats-redirect-btn .btn-arrow {
    font-size: 1.5rem;
  }
  
  /* Side menu adjustments for very small screens */
  .species-side-menu {
    width: 85%;
    right: -85%;
  }
  
  .side-menu-content h3 {
    font-size: 1.1rem;
  }
  
  #sideMenuTabs .tab-btn {
    padding: 12px 14px;
    font-size: 0.95rem;
  }
}

/* ===== Modais: Perfil e Histórico de Notificações ===== */
/* Usa .active — igual aos outros modais existentes */

.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: dropIn 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
  width: auto;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* Histórico de Notificações */
.notif-history-list {
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notif-item {
  background: rgba(74, 222, 128, 0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.notif-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 4px;
}

.notif-item-body {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.notif-item-date {
  font-size: 0.78rem;
  color: var(--primary);
  opacity: 0.8;
}

.notif-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 24px 0;
  font-size: 0.92rem;
}

/* Perfil */
.profile-info {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px 20px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: #000;
  flex-shrink: 0;
}

.profile-details p {
  margin: 6px 0;
  font-size: 0.95rem;
  color: var(--text);
}

.profile-details strong {
  color: var(--text-dim);
}

/* ===== Redesigned Profile Page ===== */
.profile-page-wrap {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 0;
}

/* Hero header */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 24px 28px;
}

.profile-avatar-lg {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: #000;
  flex-shrink: 0;
}

.profile-hero-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.profile-hero-name {
  margin: 0;
  font-size: 1.4rem;
  color: var(--text);
}

.profile-role-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: fit-content;
}

.profile-role-administrador {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.profile-role-gestor {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.profile-role-pastor {
  background: rgba(74, 222, 128, 0.15);
  color: var(--primary);
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.profile-hero-email,
.profile-hero-since {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-dim);
}

/* Sections grid */
.profile-sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.profile-section {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-section-full {
  grid-column: 1 / -1;
}

.profile-section-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

/* Field rows */
.profile-field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.profile-field-row:last-of-type {
  border-bottom: none;
}

.profile-field-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.profile-field-value {
  font-size: 0.92rem;
  color: var(--text);
  text-align: right;
}

/* Language select */
.profile-lang-select {
  background: var(--input-bg, var(--card));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
}

.profile-pref-note {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 2px 0 0;
  line-height: 1.5;
}

/* Password form */
.profile-pw-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-pw-label {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: -4px;
}

.profile-pw-input {
  background: var(--input-bg, var(--card));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
}

.profile-pw-input:focus {
  outline: none;
  border-color: var(--primary);
}

.profile-pw-save-btn {
  margin-top: 4px;
  background: var(--primary);
  color: #000;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: opacity 0.2s;
}

.profile-pw-save-btn:hover {
  opacity: 0.85;
}

.profile-pw-save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.profile-pw-msg {
  font-size: 0.88rem;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 2px;
}

.profile-pw-msg.hidden {
  display: none;
}

.profile-pw-msg-ok {
  background: rgba(74, 222, 128, 0.12);
  color: var(--primary);
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.profile-pw-msg-error {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* 2FA section */
.profile-2fa-status {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
}

.profile-2fa-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.profile-2fa-off {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.profile-2fa-on {
  background: rgba(74, 222, 128, 0.12);
  color: var(--primary);
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.profile-2fa-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.88rem;
  cursor: not-allowed;
  width: fit-content;
}

/* Activity table */
.profile-activity-table {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.profile-activity-row {
  display: grid;
  grid-template-columns: 1.8fr 2fr 1.4fr;
  gap: 12px;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.profile-activity-row:last-child {
  border-bottom: none;
}

.profile-activity-header {
  background: rgba(74, 222, 128, 0.06);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 680px) {
  .profile-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .profile-sections-grid {
    grid-template-columns: 1fr;
  }
  .profile-activity-row {
    grid-template-columns: 1fr 1fr;
    font-size: 0.82rem;
  }
  .profile-activity-row span:last-child {
    grid-column: 1 / -1;
    color: var(--text-dim);
    font-size: 0.78rem;
  }
}

/* ===== Rotina Diária ===== */
.rotina-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0;
}

/* Rotina inline layout currently rendered by client.js (rsi-*/
.species-rotina-wrapper {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rotina-armazem {
  padding: 16px;
}

.rsi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.rsi-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
  padding: 12px;
}

.rsi-item.rsi-empty {
  border-color: rgba(239, 68, 68, 0.45);
}

.rsi-item.rsi-low {
  border-color: rgba(239, 68, 68, 0.7);
  background: rgba(239, 68, 68, 0.06);
}

.rsi-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rsi-label {
  flex: 1;
  font-weight: 700;
}

.rsi-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.rsi-kg-val {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.rsi-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  opacity: 0.55;
  transition: opacity 0.15s;
  line-height: 1;
}
.rsi-edit-btn:hover {
  opacity: 1;
}

.rsi-sub {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 0.86rem;
}

.rsi-days-low {
  color: #ef4444;
  font-weight: 700;
}

.rsi-controls {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rsi-btn,
.species-rsi-btn {
  width: auto;
  margin-top: 0;
  min-width: 40px;
  padding: 8px 12px;
  border-radius: 9px;
}

.rsi-saca-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  font-weight: 600;
  color: var(--text-dim);
}

.species-rsi-saca-input {
  width: 84px;
  min-width: 84px;
  margin-top: 0;
  padding: 6px 8px;
  border-radius: 8px;
  text-align: right;
}

.rotina-table {
  overflow: hidden;
  position: relative;
}

.rotina-table-header,
.rotina-table-row {
  display: grid;
  grid-template-columns: var(--rt-cols, 88px 1fr 1fr);
  gap: 0;
}

.rotina-table-header {
  border-bottom: 1px solid var(--border);
  background: rgba(74, 222, 128, 0.08);
}

.rt-cell {
  min-width: 0;
  padding: 12px;
}

.rt-col-header {
  font-weight: 700;
  color: var(--primary);
}

.rt-hora-cell {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.rt-cabras-cell,
.rt-cabritos-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rt-cabritos-cell {
  border-left: 1px solid var(--border);
}

.rotina-table-general .rotina-table-header .rt-cell + .rt-cell,
.rotina-table-general .rotina-table-row .rt-cell + .rt-cell {
  border-left: 1px solid var(--border);
}

.rotina-table-general .rt-hora-cell {
  border-right: none;
}

.rotina-table-general .rt-animal-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rotina-table-general .rt-col-header {
  text-align: center;
}

.rotina-table-general-desktop {
  display: block;
}

.rotina-table-general-mobile {
  display: none;
}

.rt-evento {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
}

.rt-evento-done {
  opacity: 0.74;
  filter: saturate(0.7) blur(0.2px);
}

.rotina-now-line {
  position: absolute;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    rgba(34, 197, 94, 0.85),
    rgba(34, 197, 94, 0.25)
  );
  pointer-events: none;
  z-index: 2;
  box-shadow:
    0 0 0 1px rgba(34, 197, 94, 0.2),
    0 0 10px rgba(34, 197, 94, 0.35);
}

.rotina-now-dot {
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow:
    0 0 0 2px rgba(253, 252, 247, 0.9),
    0 0 10px rgba(34, 197, 94, 0.55);
}

.rt-ev-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.1;
}

.rt-ev-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rt-ev-detalhe {
  color: var(--text-dim);
  font-size: 0.82rem;
}

.rt-empty {
  color: var(--text-dim);
  font-style: italic;
}

@media (max-width: 860px) {
  .rotina-table:not(.rotina-table-general) .rotina-table-header,
  .rotina-table:not(.rotina-table-general) .rotina-table-row {
    grid-template-columns: 72px 1fr;
  }

  .rotina-table:not(.rotina-table-general) .rotina-table-header .rt-cell:last-child,
  .rotina-table:not(.rotina-table-general) .rotina-table-row .rt-cell:last-child {
    display: none;
  }

  .rotina-table-general-desktop {
    display: none;
  }

  .rotina-table-general-mobile {
    display: block;
  }

  .rotina-table-general-mobile .rotina-table-header,
  .rotina-table-general-mobile .rotina-table-row {
    grid-template-columns: 72px 1fr;
  }

  .rotina-table-general-mobile .rt-hora-cell {
    border-right: 1px solid var(--border);
  }

  .rotina-table-general-mobile .rotina-table-header .rt-cell:last-child,
  .rotina-table-general-mobile .rotina-table-row .rt-cell:last-child {
    display: block;
  }

  .rt-hora-cell {
    padding: 10px 8px;
  }
}

@media (max-width: 600px) {
  .rsi-grid {
    grid-template-columns: 1fr;
  }

  .rsi-header {
    grid-template-columns: auto 1fr;
  }

  .rsi-kg-val {
    grid-column: 1 / -1;
    justify-self: end;
  }
}

.species-header-wrap {
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.35s ease;
  max-height: 120px;
  opacity: 1;
  margin-bottom: 0;
}

.species-header-wrap.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.species-header-wrap.collapsed:hover,
.species-header-wrap.collapsed:focus-within {
  max-height: 120px;
  opacity: 1;
  pointer-events: auto;
}

.species-header-peek {
  display: none;
  padding: 3px 16px;
  font-size: 0.72rem;
  color: var(--text-dim);
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: none;
  letter-spacing: 0.02em;
}

.species-header-wrap.collapsed + .sub-tabs {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.species-page-header {
  padding: 14px 20px;
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.species-page-header h2 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--primary);
}

.species-header-hint {
  display: none;
}


.rotina-header-card {
  padding: 28px 32px;
}

.rotina-header-card h2 {
  margin: 0 0 8px;
  font-size: 2rem;
  color: var(--primary);
}

.rotina-subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 1rem;
}

.rotina-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
  align-items: center;
}

.rotina-legend-item {
  display: flex;
  align-items: center;
}

.rotina-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
}

.badge-leite {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-racao-cabras {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-racao-cabritos {
  background: rgba(249, 115, 22, 0.15);
  color: #ea580c;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

[data-theme="dark"] .badge-leite { color: #93c5fd; }
[data-theme="dark"] .badge-racao-cabras { color: #86efac; }
[data-theme="dark"] .badge-racao-cabritos { color: #fdba74; }

.rotina-summary {
  padding: 16px 20px;
}

.rotina-summary h3 {
  margin: 0 0 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
}

.rotina-summary-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rotina-summary-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.rotina-summary-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1.2;
}

.rotina-summary-item div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rotina-summary-item strong {
  font-size: 0.95rem;
}

.rotina-summary-item span {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.rotina-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rotina-slot {
  display: flex;
  gap: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  transition: opacity 0.2s;
}

.rotina-slot-past {
  opacity: 0.5;
}

.rotina-slot-next {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(45, 106, 79, 0.2);
}

.rotina-hora {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  gap: 4px;
}

.rotina-hora-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.rotina-hora-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rotina-eventos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.rotina-evento {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
}

.rotina-evento-leite {
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid #3b82f6;
}

.rotina-evento-cabras {
  background: rgba(34, 197, 94, 0.08);
  border-left: 3px solid #16a34a;
}

.rotina-evento-cabritos {
  background: rgba(249, 115, 22, 0.08);
  border-left: 3px solid #ea580c;
}

.rotina-evento-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
  line-height: 1.3;
}

.rotina-evento div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rotina-evento strong {
  font-size: 0.9rem;
  line-height: 1.3;
}

.rotina-evento-detalhe {
  font-size: 0.78rem;
  color: var(--text-dim);
}

@media (max-width: 480px) {
  .rotina-hora-label {
    font-size: 0.95rem;
  }

  .rotina-hora {
    min-width: 48px;
  }

  .rotina-slot {
    gap: 10px;
    padding: 12px;
  }
}

/* ===== Rotina — Armazém & Confirmação ===== */
.rotina-stock {
  padding: 16px 20px;
}

.rotina-stock-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rotina-stock.rotina-stock-warning {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.rotina-stock.rotina-stock-empty {
  border-color: var(--danger, #ef4444);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.rotina-stock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.rotina-stock-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rotina-stock-count {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.rotina-stock-unit {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.rotina-stock-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.rotina-stock-btn {
  flex-shrink: 0;
  width: auto;
  margin-top: 0;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  transform: none;
  box-shadow: none;
}

.rotina-stock-btn-add {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.rotina-stock-btn-remove {
  font-size: 1.2rem;
  padding: 6px 14px;
}

.rotina-stock-btn:hover {
  opacity: 0.85;
}

.rotina-stock-days {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
}

.rotina-stock-days-low {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}

.rotina-stock-size-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.rotina-stock-size-row input {
  width: 64px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.85rem;
}

/* Event confirm button */
.rotina-evento-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.rotina-evento-done {
  opacity: 0.65;
}

.rotina-confirm-btn {
  flex-shrink: 0;
  width: auto;
  margin-top: 0;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  align-self: center;
  transition: background 0.15s, color 0.15s;
  transform: none;
  box-shadow: none;
}

.rotina-confirm-btn:hover:not([disabled]) {
  background: var(--primary);
  color: #fff;
  transform: none;
  box-shadow: none;
}

.rotina-confirm-btn-done,
.rotina-confirm-btn[disabled] {
  border-color: #22c55e;
  color: #22c55e;
  cursor: default;
  opacity: 0.8;
}

/* Confirmation modal internals */
.rotina-conf-check-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  line-height: 1.4;
}

.rotina-conf-check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Ordenha goat selection rows */
.rotina-goat-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #d1d5db);
  transition: background 0.15s;
}
.rotina-goat-row.rotina-goat-checked {
  background: rgba(45, 122, 63, 0.08);
}
.rotina-goat-row.rotina-goat-saved {
  border-color: var(--primary) !important;
  background: rgba(var(--primary-rgb, 22 163 74), 0.10) !important;
}
.rotina-goat-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.rotina-goat-label {
  display: flex;
  align-items: center;
  cursor: pointer;
}
.rotina-goat-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.rotina-goat-name {
  font-size: 1.05rem;
  font-weight: 500;
  flex: 1;
  min-width: 0;
}
.rotina-goat-row .rotina-goat-cb {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  max-width: 20px !important;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0 !important;
  padding: 0 !important;
}
.rotina-goat-row .rotina-goat-liters {
  width: 64px !important;
  min-width: 64px !important;
  max-width: 64px !important;
  flex-shrink: 0;
  padding: 4px 8px !important;
  margin-top: 0 !important;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--input-bg, #fff);
  color: var(--text);
  text-align: right;
}

.rotina-goat-row .rotina-goat-liters[hidden] {
  display: none !important;
}



.rotina-conf-deduct {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(249, 115, 22, 0.1);
  color: #ea580c;
  font-size: 0.82rem;
  border-left: 3px solid #ea580c;
}

.rotina-conf-egg label {
  display: block;
  font-weight: 700;
  color: var(--text);
}

.rotina-conf-egg input {
  margin-top: 0;
}

[data-theme="dark"] .rotina-conf-deduct {
  color: #fdba74;
}

.rotina-conf-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

@media (max-width: 480px) {
  .rotina-stock-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .rotina-confirm-btn {
    font-size: 0.7rem;
    padding: 4px 8px;
  }
}

/* ─── Chat IA Flutuante ────────────────────────────────────────────────────── */

#chatWidget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#chatWidget.hidden {
  display: none !important;
}

#chatToggleBtn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-strong, #22c55e);
  color: #fff;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.28);
  transition: background 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chatToggleBtn:hover {
  background: #1a9e45;
  transform: scale(1.08);
}

#chatToggleBtn.chat-open {
  background: #555;
}

#chatPanel {
  display: flex;
  flex-direction: column;
  width: min(540px, calc(100vw - 24px));
  height: min(760px, calc(100vh - 96px));
  background: linear-gradient(180deg, rgba(5, 34, 24, 0.98), rgba(3, 25, 18, 0.98));
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: 22px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.34);
  margin-bottom: 12px;
  overflow: hidden;
}

#chatHeader {
  background: rgba(6, 45, 31, 0.94);
  color: #fff;
  padding: 12px 18px;
  font-weight: 600;
  font-size: 0.94rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(74, 222, 128, 0.2);
}

.chat-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: rgba(74, 222, 128, 0.18);
  border: 1px solid rgba(74, 222, 128, 0.28);
}

.chat-header-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.chat-header-copy small {
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  opacity: 0.72;
}

.chat-header-copy strong {
  font-size: 1.06rem;
  font-weight: 800;
}

#chatHeader button {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(74, 222, 128, 0.18);
  color: #d1fae5;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
}

#chatHeader button:hover {
  background: rgba(74, 222, 128, 0.18);
}

.assistant-hub-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(74, 222, 128, 0.18);
  background: rgba(5, 36, 25, 0.88);
}

.assistant-hub-tab {
  border: 1px solid rgba(74, 222, 128, 0.24);
  background: rgba(255, 255, 255, 0.03);
  color: #d1fae5;
  border-radius: 12px;
  padding: 9px 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.assistant-hub-tab.active {
  background: rgba(34, 197, 94, 0.26);
  border-color: rgba(74, 222, 128, 0.52);
}

.assistant-hub-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.assistant-hub-view.hidden {
  display: none !important;
}

#chatPanel #teamChatPanel {
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#chatPanel #teamChatBody {
  min-height: 0;
}

#chatPanel .assistant-hub-tab .team-chat-badge {
  position: static;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  font-size: 0.62rem;
  padding: 0 4px;
}

#chatMessages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.chat-welcome-card {
  border-radius: 18px;
  border: 1px solid rgba(74, 222, 128, 0.24);
  background: rgba(8, 52, 35, 0.52);
  color: #d8fbe8;
  padding: 16px 18px;
  font-size: 1.05rem;
  line-height: 1.38;
}

.chat-prompt-list {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.chat-prompt-chip {
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid rgba(74, 222, 128, 0.2);
  background: rgba(4, 40, 28, 0.56);
  color: #9cc3ad;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-prompt-chip:hover {
  border-color: rgba(74, 222, 128, 0.44);
  color: #d7fbe7;
  background: rgba(8, 60, 40, 0.5);
  transform: none;
  box-shadow: none;
}

.chat-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
  word-break: break-word;
}

.chat-user {
  background: var(--primary-strong, #22c55e);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-assistant {
  background: var(--table-bg, rgba(17,45,38,0.4));
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-error {
  background: #fdecea;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

/* Indicador "a escrever..." com três pontos animados */
.chat-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted, #888);
  animation: chatBounce 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

#chatInputArea {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(74, 222, 128, 0.18);
  flex-shrink: 0;
  background: rgba(4, 32, 23, 0.88);
}

#chatInputRow {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(74, 222, 128, 0.32);
  border-radius: 20px;
  padding: 8px 10px;
}

#chatInput {
  flex: 1;
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 14px;
  padding: 8px 10px;
  font-size: 1rem;
  resize: none;
  outline: none;
  background: transparent;
  color: #e8f5f0;
  caret-color: #e8f5f0;
  -webkit-text-fill-color: #e8f5f0;
  font-family: inherit;
  max-height: 120px;
  overflow-y: auto;
}

#chatInput::placeholder {
  color: rgba(214, 241, 226, 0.6);
  -webkit-text-fill-color: rgba(214, 241, 226, 0.6);
}

#chatInput:focus {
  border-color: #22c55e;
  background: rgba(255, 255, 255, 0.10);
}

/* Botões mic e foto */
#chatImgBtn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: #f97316;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  color: #fff;
}

#chatImgBtn:hover {
  background: #ea580c;
}

/* Pré-visualização de imagens pendentes */
#chatImagePreviews {
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 4px;
}

.chat-img-preview {
  position: relative;
  width: 58px;
  height: 58px;
  flex-shrink: 0;
}

.chat-img-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border, #ddd);
}

.chat-img-preview button {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #555;
  color: #fff;
  border: none;
  font-size: 0.55rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Miniaturas de imagem dentro das bolhas de chat */
.chat-img-thumb {
  max-width: 190px;
  max-height: 190px;
  border-radius: 8px;
  margin-bottom: 4px;
  display: block;
}

/* Resultado de tool call (registo na BD) */
.chat-tool-result {
  align-self: center;
  text-align: center;
  max-width: 96%;
  font-size: 0.83rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 7px 14px;
}

.chat-tool-success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

#chatSendBtn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(21, 128, 61, 0.88);
  color: #fff;
  border: 1px solid rgba(74, 222, 128, 0.35);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

#chatSendBtn:hover:not(:disabled) {
  background: #15803d;
}

#chatSendBtn:disabled {
  background: #aaa;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  #chatPanel {
    width: calc(100vw - 16px);
    height: min(760px, calc(100vh - 24px));
    border-radius: 16px;
  }
  #chatWidget {
    bottom: 8px;
    right: 8px;
  }
}

/* ─── Chat: modo claro explícito ─────────────────────────────── */
[data-theme="light"] #chatPanel {
  background: #fff;
  border-color: rgba(45,122,63,0.25);
}

[data-theme="light"] #chatMessages {
  background: #fff;
}

[data-theme="light"] .chat-assistant {
  background: #f0f4f0;
  color: #2d3a2e;
}

[data-theme="light"] #chatInputArea {
  border-top-color: rgba(45,122,63,0.2);
  background: #fff;
}

[data-theme="light"] #chatInput {
  background: #f5f8f5;
  color: #1a2e1a;
  caret-color: #1a2e1a;
  -webkit-text-fill-color: #1a2e1a;
  border-color: rgba(45,122,63,0.35);
}

[data-theme="light"] #chatInput::placeholder {
  color: rgba(45,58,46,0.5);
  -webkit-text-fill-color: rgba(45,58,46,0.5);
}

[data-theme="light"] #chatInput:focus {
  background: #fff;
  border-color: #1f5c2f;
}

[data-theme="light"] #chatImgBtn {
  background: #ea580c;
  color: #fff;
}

[data-theme="light"] #chatImgBtn:hover {
  background: #c2410c;
}

/* ═══════════════════════════════════════════════════════════════
   BADGES DE STATUS
   ═══════════════════════════════════════════════════════════════ */

.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
  text-transform: capitalize;
}

.badge-success {
  background: rgba(82, 224, 137, 0.2);
  color: rgba(82, 224, 137, 1);
}

.badge-warning {
  background: rgba(246, 200, 95, 0.2);
  color: rgba(246, 200, 95, 1);
}

.badge-danger {
  background: rgba(255, 138, 91, 0.2);
  color: rgba(255, 138, 91, 1);
}

.badge-secondary {
  background: rgba(150, 150, 150, 0.2);
  color: rgba(200, 200, 200, 1);
}

[data-theme="light"] .badge-success {
  background: rgba(82, 224, 137, 0.15);
  color: rgba(16, 130, 60, 1);
}

[data-theme="light"] .badge-warning {
  background: rgba(246, 200, 95, 0.15);
  color: rgba(150, 100, 10, 1);
}

[data-theme="light"] .badge-danger {
  background: rgba(255, 138, 91, 0.15);
  color: rgba(180, 40, 20, 1);
}

[data-theme="light"] .badge-secondary {
  background: rgba(150, 150, 150, 0.15);
  color: rgba(80, 80, 80, 1);
}

[data-theme="light"] #chatToggleBtn {
  background: #1f5c2f;
  box-shadow: 0 4px 16px rgba(45,58,46,0.3);
}

[data-theme="light"] #chatToggleBtn:hover {
  background: #174a25;
}

/* ═══════════════════════════════════════════════════════════════
   CHAT INTERNO DA EQUIPA (junto ao cabeçalho)
   ═══════════════════════════════════════════════════════════════ */

#teamChatWidget {
  position: fixed;
  top: 78px;
  right: 18px;
  bottom: auto;
  left: auto;
  z-index: 9998;
  display: block;
}

#teamChatWidget.hidden {
  display: none !important;
}

/* ── Toggle button ────────────────────────────────────────────── */
#teamChatWidget #teamChatToggleBtn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-strong, #22c55e);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.28);
  transition: background 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  order: 2;
}
#teamChatWidget #teamChatToggleBtn:hover {
  background: #1a9e45;
  transform: scale(1.08);
}
#teamChatWidget #teamChatToggleBtn.chat-open { background: #555; }

.team-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
}
.team-chat-badge.hidden { display: none; }

/* ── Panel ────────────────────────────────────────────────────── */
#teamChatPanel {
  display: flex;
  flex-direction: column;
  width: 380px;
  height: 560px;
  background: linear-gradient(180deg, rgba(8, 31, 24, 0.98), rgba(11, 42, 31, 0.98));
  border: 1px solid rgba(74, 222, 128, 0.18);
  border-radius: 22px;
  box-shadow: 0 20px 48px rgba(0,0,0,0.34);
  margin-bottom: 12px;
  overflow: hidden;
  order: 1;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* ── Header ───────────────────────────────────────────────────── */
#teamChatHeader {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.team-chat-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.team-chat-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
}
.team-chat-header-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.team-chat-header-title {
  font-size: 1rem;
  font-weight: 800;
}
.team-chat-header-subtitle {
  font-size: 0.72rem;
  opacity: 0.78;
}
#teamChatHeader button {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.8;
  padding: 2px 6px;
}
#teamChatHeader button:hover { opacity: 1; }

.team-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-chat-new-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  font-size: 1.2rem;
  padding: 0;
}

.team-chat-new-btn:hover {
  background: rgba(74, 222, 128, 0.3);
}

#teamChatBody {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

#teamChatPanel.team-chat-mode-list #teamChatChannelList {
  max-height: none;
  flex: 1;
  border-bottom: none;
}

#teamChatPanel.team-chat-mode-list #teamChatConversation {
  display: none;
}

#teamChatPanel.team-chat-mode-conversation #teamChatChannelList {
  display: none;
}

#teamChatPanel.team-chat-mode-conversation #teamChatConversation {
  display: flex;
}

#teamChatPanel.team-chat-mode-new #teamChatChannelList,
#teamChatPanel.team-chat-mode-new #teamChatConversation {
  display: none;
}

#teamChatPanel.team-chat-mode-new #teamChatNewConversation {
  display: flex;
}

#teamChatNewConversation {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.team-chat-new-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(74, 222, 128, 0.18);
}

.team-chat-new-back-btn,
.team-chat-new-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(74, 222, 128, 0.24);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0;
}

.team-chat-new-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.team-chat-new-title {
  font-size: 1.05rem;
  font-weight: 800;
}

.team-chat-new-subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.team-chat-search-wrap {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(74, 222, 128, 0.12);
}

#teamChatUserSearch {
  border-radius: 999px;
  border: 1px solid rgba(74, 222, 128, 0.22);
  background: rgba(8, 34, 25, 0.68);
}

#teamChatUserPickerList {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 14px;
}

.team-chat-picker-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  margin-bottom: 8px;
  border-radius: 14px;
  border: 1px solid rgba(74, 222, 128, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
}

.team-chat-picker-item:hover {
  background: rgba(74, 222, 128, 0.12);
  transform: none;
}

.team-chat-picker-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.84rem;
  font-weight: 800;
  background: rgba(74, 222, 128, 0.18);
}

.team-chat-picker-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-chat-picker-empty {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
}

.team-chat-picker-empty-icon {
  font-size: 1.9rem;
  opacity: 0.7;
}

.team-chat-empty-list {
  padding: 26px 10px;
  text-align: center;
  color: var(--text-dim);
  margin: 0;
}

/* ── Channel list ─────────────────────────────────────────────── */
#teamChatChannelList {
  flex-shrink: 0;
  border-bottom: 1px solid rgba(74, 222, 128, 0.12);
  max-height: 150px;
  overflow-y: auto;
  background: rgba(8, 28, 22, 0.72);
  padding: 8px 8px 10px;
}

.tcl-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim, rgba(232,245,240,0.55));
  padding: 8px 8px 5px;
  pointer-events: none;
}

.team-channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.87rem;
  color: var(--text);
  text-align: left;
  transition: background 0.13s, transform 0.13s, color 0.13s;
}
.team-channel-item:hover {
  background: var(--tab-hover-bg, rgba(74,222,128,0.12));
  transform: translateY(-1px);
}
.team-channel-item.active {
  background: linear-gradient(135deg, rgba(74,222,128,0.16), rgba(74,222,128,0.1));
  font-weight: 600;
  color: var(--primary, #4ade80);
  box-shadow: inset 0 0 0 1px rgba(74,222,128,0.18);
}
.team-channel-item .tcl-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-strong, #22c55e);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.team-channel-item .tcl-avatar.global {
  background: var(--accent, #fbbf24);
}
.team-channel-item .tcl-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-channel-unread {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 0.63rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-shrink: 0;
}

#teamChatConversation {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

#teamChatChannelMeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid rgba(74, 222, 128, 0.08);
  background: rgba(255,255,255,0.02);
}

.team-chat-back-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(74, 222, 128, 0.2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 8px;
}

.team-chat-back-btn:hover {
  background: rgba(74, 222, 128, 0.14);
  border-color: rgba(74, 222, 128, 0.32);
}

.team-chat-channel-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.team-chat-channel-badge {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(74,222,128,0.14);
  border: 1px solid rgba(74,222,128,0.18);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.team-chat-channel-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.team-chat-channel-hint {
  font-size: 0.72rem;
  color: var(--text-dim, rgba(232,245,240,0.55));
}

/* ── Messages area ────────────────────────────────────────────── */
#teamChatMessages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.86rem;
  line-height: 1.5;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.015), rgba(255,255,255,0)),
    rgba(5, 24, 18, 0.36);
}

.tm-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.tm-row-self {
  justify-content: flex-end;
}

.tm-row-other {
  justify-content: flex-start;
}

.tm-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  font-weight: 800;
  flex-shrink: 0;
}

.tm-avatar-self {
  background: rgba(74,222,128,0.18);
  color: #d1fae5;
}

.tm-avatar-other {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

.tm-bubble {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 16px;
  word-break: break-word;
  box-shadow: 0 8px 18px rgba(0,0,0,0.14);
}
.tm-bubble-self {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}
.tm-bubble-other {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
  border: 1px solid rgba(255,255,255,0.04);
}
.tm-sender {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary, #4ade80);
  margin-bottom: 3px;
}
.tm-time {
  font-size: 0.66rem;
  opacity: 0.62;
  margin-top: 4px;
  text-align: right;
}
.tm-empty {
  text-align: center;
  color: var(--text-dim, rgba(232,245,240,0.55));
  font-size: 0.82rem;
  padding: 24px 0;
}

.tm-error {
  color: #f87171 !important;
  font-size: 0.8rem;
}

.tm-channel-name {
  text-align: center;
  color: var(--text-dim, rgba(232,245,240,0.55));
  font-size: 0.75rem;
  padding: 2px 0 8px;
  letter-spacing: 0.04em;
}

/* ── Input area ───────────────────────────────────────────────── */
#teamChatInputArea {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 12px 14px;
  border-top: 1px solid rgba(74, 222, 128, 0.08);
  flex-shrink: 0;
  background: rgba(8, 24, 20, 0.72);
}

.team-chat-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-chat-composer-shell {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(74, 222, 128, 0.16);
}

.team-chat-voice-timer {
  display: none;
  font-size: 0.75rem;
  color: #fb7185;
  font-weight: 700;
  min-width: 40px;
}

#teamChatInput {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.86rem;
  resize: none;
  outline: none;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  caret-color: var(--text);
  -webkit-text-fill-color: var(--text);
  font-family: inherit;
  min-height: 44px;
  max-height: 120px;
  overflow-y: auto;
}
#teamChatInput::placeholder {
  color: var(--text-dim, rgba(232,245,240,0.45));
  -webkit-text-fill-color: var(--text-dim, rgba(232,245,240,0.45));
}
#teamChatInput:focus {
  background: rgba(255,255,255,0.07);
}

#teamChatSendBtn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
#teamChatSendBtn:hover:not(:disabled) { background: #1a9e45; }
#teamChatSendBtn:disabled { background: #aaa; cursor: not-allowed; }

/* ── File & Voice buttons ─────────────────────────────────────── */
#teamChatFileBtn,
#teamChatVoiceBtn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid rgba(74,222,128,0.2);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
  padding: 0;
}
#teamChatFileBtn:hover,
#teamChatVoiceBtn:hover { border-color: var(--primary, #4ade80); background: rgba(74,222,128,0.12); }
#teamChatVoiceBtn.recording { background: rgba(244,68,68,0.2); border-color: #f44; animation: pulse-rec 1s infinite; }
@keyframes pulse-rec { 0%,100%{box-shadow:0 0 0 0 rgba(244,68,68,0.4)} 50%{box-shadow:0 0 0 6px rgba(244,68,68,0)} }

/* ── Multimedia messages ──────────────────────────────────────── */
.tm-media { margin-bottom: 3px; }
.tm-img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
  cursor: zoom-in;
  object-fit: cover;
}
.tm-video {
  max-width: 220px;
  max-height: 160px;
  border-radius: 8px;
  display: block;
}
.tm-audio-wrap { display: flex; align-items: center; gap: 6px; }
.tm-audio-icon { font-size: 1.1rem; }
.tm-audio { height: 32px; min-width: 140px; max-width: 180px; }
.tm-audio-dur { font-size: 0.7rem; opacity: 0.65; white-space: nowrap; }
.tm-file-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(74,222,128,0.12);
  color: var(--primary, #4ade80);
  font-size: 0.82rem;
  text-decoration: none;
  word-break: break-all;
}
.tm-file-link:hover { background: rgba(74,222,128,0.22); }


@media (max-width: 480px) {
  #teamChatPanel {
    width: calc(100vw - 24px);
    height: min(76vh, 560px);
    border-radius: 18px;
  }
  #teamChatWidget {
    top: 70px;
    right: 8px;
    left: auto;
  }
  #teamChatChannelList {
    max-height: 138px;
  }
  .team-chat-back-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
  #teamChatInputArea {
    padding: 10px;
  }
  .team-chat-composer-shell {
    padding: 6px;
  }
  #teamChatSendBtn {
    width: 40px;
    height: 40px;
  }
}

/* ── Light mode overrides ─────────────────────────────────────── */
[data-theme="light"] #teamChatPanel {
  background: var(--card-bg);
  border-color: rgba(45,122,63,0.18);
}
[data-theme="light"] #teamChatHeader {
  background: var(--primary-strong, #1f5c2f);
}
[data-theme="light"] #teamChatChannelList {
  background: var(--tab-bg);
}
[data-theme="light"] #teamChatChannelMeta {
  background: rgba(0,0,0,0.015);
}
[data-theme="light"] .team-chat-back-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(45, 122, 63, 0.24);
}
[data-theme="light"] .tcl-section-label {
  color: var(--text-dim);
}
[data-theme="light"] .team-channel-item { color: var(--text); }
[data-theme="light"] .team-channel-item:hover,
[data-theme="light"] .team-channel-item.active {
  background: var(--tab-hover-bg);
}
[data-theme="light"] .team-channel-item.active { color: var(--primary-strong); }
[data-theme="light"] .tm-bubble-other {
  background: var(--table-bg);
  color: var(--text);
}
[data-theme="light"] .tm-avatar-other {
  background: rgba(0,0,0,0.06);
}
[data-theme="light"] .tm-sender { color: var(--primary-strong); }
[data-theme="light"] .tm-empty,
[data-theme="light"] .tm-channel-name { color: var(--text-dim); }
[data-theme="light"] #teamChatFileBtn,
[data-theme="light"] #teamChatVoiceBtn { background: var(--table-bg); color: var(--text); }
[data-theme="light"] .tm-file-link { color: var(--primary-strong); }
[data-theme="light"] #teamChatInput {
  background: var(--input-bg);
  color: var(--text);
  caret-color: var(--text);
  -webkit-text-fill-color: var(--text);
}
[data-theme="light"] #teamChatInput::placeholder {
  color: var(--text-dim);
  -webkit-text-fill-color: var(--text-dim);
}
[data-theme="light"] .team-chat-composer-shell {
  background: rgba(0,0,0,0.02);
  border-color: rgba(45,122,63,0.14);
}
[data-theme="light"] #teamChatSendBtn {
  background: var(--primary-strong, #1f5c2f);
}
[data-theme="light"] #teamChatSendBtn:hover:not(:disabled) {
  background: var(--primary, #2d7a3f);
}
[data-theme="light"] #teamChatToggleBtn {
  background: var(--primary-strong, #1f5c2f);
}
[data-theme="light"] #teamChatToggleBtn:hover {
  background: var(--primary, #2d7a3f);
}

[data-theme="light"] .team-chat-header-btn:hover {
  box-shadow: 0 4px 12px rgba(45, 122, 63, 0.4);
}

/* Genealogia: garantir botões compactos e área de visualização ampla */
[data-sub-section="genealogia"] button[onclick*="genealogy"] {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
}

[data-sub-section="genealogia"] input[id^="genealogy_zoom_"] {
  width: 220px;
  max-width: 48vw;
}

[data-sub-section="genealogia"] [id^="genealogy_wrap_"] {
  min-height: 62vh;
  max-height: 86vh;
  overflow: auto;
}

/* ===== GENEALOGY TREE ===== */
.genealogy-tree {
  overflow-x: auto;
  padding: 8px 0 8px 4px;
}
.genealogy-node {
  position: relative;
  margin-bottom: 6px;
}
.genealogy-connector {
  display: inline-block;
  position: absolute;
  left: -20px;
  top: 50%;
  width: 16px;
  height: 2px;
  background: var(--border-color, #3a3a3a);
}
.genealogy-connector::before {
  content: '';
  position: absolute;
  left: 0;
  top: calc(-50% + 1px);
  width: 2px;
  height: 100%;
  background: var(--border-color, #3a3a3a);
}
.genealogy-card {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background: var(--card-bg, #1e2a1e);
  border: 1px solid var(--border-color, #3a3a3a);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  max-width: 520px;
}
.genealogy-card:hover {
  border-color: var(--primary, #2d7a3f);
  box-shadow: 0 0 0 2px rgba(45,122,63,0.18);
}
.genealogy-children {
  padding-left: 28px;
  margin-top: 4px;
  border-left: 2px solid var(--border-color, #3a3a3a);
  margin-left: 20px;
}
