: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;
}

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 {
  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: 24px auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-card {
  width: min(460px, 100%);
  margin: 9vh auto;
  padding: 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: 80px;
  height: 80px;
  max-width: 80px;
  max-height: 80px;
  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;
}

.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);
}

[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;
}

.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: 100;
}

[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: 48px;
  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;
  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 {
  transform: translateY(-1px);
  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);
}

.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: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.global-overview-actions .btn-primary,
.global-overview-actions .btn-secondary {
  width: auto;
  min-width: 180px;
  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(2, 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: 270px;
}

.global-overview-chart-wrap-ops {
  min-height: 220px;
}

.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: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.side-menu-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* Species Side Menu */
.species-side-menu {
  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: 999;
  transition: right 0.3s ease;
  overflow-y: auto;
}

[data-theme=\"light\"] .species-side-menu {
  background: var(--bg);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
}

.species-side-menu.open {
  right: 0;
}

.side-menu-content {
  padding: 20px;
}

.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;
}

#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);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.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;
}

.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;
}

.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;
}

[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 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 18px 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;
}

.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;
}

.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;
}

.agri-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: stretch;
}

.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: var(--input-bg);
  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.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.35);
}

.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-map-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 280px;
  background: rgba(255, 255, 255, 0.02);
}

.agri-osm-frame {
  border: 0;
  width: 100%;
  height: 320px;
  display: block;
}

@media (max-width: 900px) {
  .agri-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .agri-map-layout {
    grid-template-columns: 1fr;
  }

  .agri-terrain-pill-list {
    max-height: 220px;
  }
}

@media (max-width: 720px) {
  .agri-osm-frame {
    height: 260px;
  }
}

/* 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;
}

/* ── Collapsible tabs nav wrapper ── */
.tabs-nav-wrapper {
  position: relative;
}

.tabs-nav-handle {
  display: flex;
  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: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0 8px;
  transition: max-height 0.3s ease, opacity 0.22s ease, padding 0.3s ease;
  pointer-events: none;
}

.tabs-nav-wrapper.open .tabs,
.tabs-nav-wrapper:hover .tabs {
  max-height: 300px;
  opacity: 1;
  padding: 0 8px 10px;
  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 8px 10px;
  pointer-events: auto;
}

.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;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0;
  padding: 8px;
  background: var(--tabs-container-bg);
  border-radius: 12px;
}

.tab-btn {
  width: auto;
  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;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: var(--tab-hover-bg);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.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;
}

.tab-panel {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.table-wrap {
  overflow-x: auto;
}

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 {
    justify-content: flex-start;
  }

  .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: 1fr;
  }

  .app-header .logo h2 {
    font-size: 1.1rem;
  }

  .app-header .logo img {
    height: 42px;
  }

  .tabs {
    gap: 6px;
    padding: 6px;
  }

  .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 14px;
  }

  .header-brand-group {
    gap: 8px;
  }

  .header-shortcuts {
    gap: 6px;
  }

  .header-shortcut-btn {
    min-width: 92px;
    padding: 6px 8px;
    font-size: 0.72rem;
  }

  .global-overview-hero h2 {
    font-size: 1.45rem;
  }

  .global-overview-stats {
    grid-template-columns: 1fr;
  }

  .global-overview-stat-card {
    min-height: 124px;
    padding: 16px;
  }

  .global-overview-actions .btn-primary,
  .global-overview-actions .btn-secondary {
    min-width: 0;
    width: 100%;
  }

  .app-header .logo img {
    height: 32px;
  }

  .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);
}

/* Milk filter bar */
.milk-filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  align-items: stretch;
  align-items: end;
.global-overview-stats > * {
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)),
    var(--tab-bg);
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.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::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 {
  gap: 14px;
}

.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;
}

.sales-section-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.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: 96px;
  padding: 9px 14px;
  margin-top: 0;
  border-radius: 12px;
}

.milk-sales-filter-panel {
  position: relative;
  z-index: 1;
}

.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;
}

.milk-sales-clear-btn {
  align-self: stretch;
}

.cheese-records-filter-panel .btn-clear-filter {
  width: auto;
  align-self: center;
  padding: 8px 16px;
  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: 8px;
  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;
}

.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: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.table-actions .btn-small {
  width: auto;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: none;
}

.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));
}

.btn-small-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.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);
}

[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;
  }

  .milk-filter-bar {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .milk-records-filter-panel,
  .cheese-records-filter-panel {
    grid-template-columns: 1fr;
  }

    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-column: span 1;
  }

  .sales-export-btn {
    width: 100%;
  }

  .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: 1000;
  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);
}

.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);
}

/* 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);
}

.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;
  }
  
  .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: flex !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;
  }
  
  /* 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;
  }

  .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;
}

.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);
}

/* ===== 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: 360px;
  height: 480px;
  background: var(--card-bg, #1a2e1a);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow, 0 8px 32px rgba(0,0,0,0.22));
  margin-bottom: 12px;
  overflow: hidden;
}

#chatHeader {
  background: var(--primary-strong, #22c55e);
  color: #fff;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#chatHeader button {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.8;
  padding: 0 4px;
}

#chatHeader button:hover {
  opacity: 1;
}

#chatMessages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.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: 8px 12px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#chatInputRow {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

#chatInput {
  flex: 1;
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.88rem;
  resize: none;
  outline: none;
  background: rgba(255, 255, 255, 0.06);
  color: #e8f5f0;
  caret-color: #e8f5f0;
  -webkit-text-fill-color: #e8f5f0;
  font-family: inherit;
  max-height: 120px;
  overflow-y: auto;
}

#chatInput::placeholder {
  color: rgba(232, 245, 240, 0.45);
  -webkit-text-fill-color: rgba(232, 245, 240, 0.45);
}

#chatInput:focus {
  border-color: #22c55e;
  background: rgba(255, 255, 255, 0.10);
}

/* Botões mic e foto */
#chatMicBtn,
#chatImgBtn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  color: var(--text);
}

#chatMicBtn:hover,
#chatImgBtn:hover {
  background: var(--input-bg-focus);
}

#chatMicBtn.mic-active {
  background: #ef5350;
  color: #fff;
  border-color: #ef5350;
  animation: chatMicPulse 1s infinite;
}

@keyframes chatMicPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* 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: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-strong, #22c55e);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

#chatSendBtn:hover:not(:disabled) {
  background: #1a9e45;
}

#chatSendBtn:disabled {
  background: #aaa;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  #chatPanel {
    width: calc(100vw - 32px);
    height: 400px;
  }
  #chatWidget {
    bottom: 16px;
    right: 16px;
  }
}

/* ─── 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"] #chatMicBtn,
[data-theme="light"] #chatImgBtn {
  background: #edf5ed;
  border-color: rgba(45,122,63,0.3);
  color: #1a2e1a;
}

[data-theme="light"] #chatMicBtn:hover,
[data-theme="light"] #chatImgBtn:hover {
  background: #d8ecd8;
}

/* ═══════════════════════════════════════════════════════════════
   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 (lado esquerdo)
   ═══════════════════════════════════════════════════════════════ */

#teamChatWidget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

#teamChatWidget.hidden {
  display: none !important;
}

/* ── Toggle button ────────────────────────────────────────────── */
#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;
}
#teamChatToggleBtn:hover {
  background: #1a9e45;
  transform: scale(1.08);
}
#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-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; }

#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;
}

/* ── 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 {
    bottom: 12px;
    left: 12px;
  }
  #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);
}

/* 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;
}
