/* ============================================================
   JUNCO AGRO 360 — Design System (Light default / Dark optional)
   ============================================================ */

/* ── Light theme (padrão) ───────────────────────────────────── */
:root {
  --bg-darkest: #f0f4f8;
  --bg-dark: #f8fafc;
  --bg-card: #ffffff;
  --bg-card2: #f1f5f9;
  --bg-hover: #e2e8f0;
  --border: rgba(0, 0, 0, 0.08);
  --border-light: rgba(0, 0, 0, 0.14);

  --green: #16a34a;
  --green-dark: #15803d;
  --green-glow: rgba(22, 163, 74, 0.12);
  --blue: #2563eb;
  --yellow: #d97706;
  --red: #dc2626;
  --purple: #7c3aed;
  --cyan: #0891b2;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --sidebar-w: 240px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  --transition: 0.2s ease;
}

/* ── Dark theme ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-darkest: #080c14;
  --bg-dark: #0d1117;
  --bg-card: #161b27;
  --bg-card2: #1c2333;
  --bg-hover: #212840;
  --border: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.12);

  --green: #4ade80;
  --green-dark: #16a34a;
  --green-glow: rgba(74, 222, 128, 0.15);
  --blue: #60a5fa;
  --yellow: #fbbf24;
  --red: #f87171;
  --purple: #a78bfa;
  --cyan: #22d3ee;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

html {
  font-size: 14px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
html {
  scrollbar-width: thin;
  scrollbar-color: #758e5e var(--bg-dark);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: #758e5e;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #5d724a;
}

/* Sidebar scrollbar override (keeps standard style) */
.sidebar {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-card2) var(--bg-darkest);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: var(--bg-darkest);
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--bg-card2);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--bg-hover);
}

/* ── Utilities ─────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.flex-1 {
  flex: 1;
}

.gap-1 {
  gap: 6px;
}

.gap-2 {
  gap: 12px;
}

.gap-3 {
  gap: 18px;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.w-full {
  width: 100%;
}

.mt-1 {
  margin-top: 6px;
}

.mt-2 {
  margin-top: 12px;
}

.mt-3 {
  margin-top: 20px;
}

.mb-1 {
  margin-bottom: 6px;
}

.mb-2 {
  margin-bottom: 12px;
}

.font-bold {
  font-weight: 700;
}

.text-sm {
  font-size: 0.85rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-green {
  color: var(--green);
}

.text-red {
  color: var(--red);
}

.text-yellow {
  color: var(--yellow);
}

.text-blue {
  color: var(--blue);
}

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

/* ── Login ─────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 20%, rgba(74, 222, 128, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 10% 80%, rgba(96, 165, 250, 0.06) 0%, transparent 50%),
    var(--bg-darkest);
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow), 0 0 60px rgba(74, 222, 128, 0.05);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--green-glow);
  border-radius: 16px;
  color: var(--green);
  margin: 0 auto 12px;
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 4px;
}

.login-error {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

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

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-darkest);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.mobile-header {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--green-glow);
  border-radius: 8px;
  color: var(--green);
  flex-shrink: 0;
}

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

.sidebar-header .logo-text {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.accent {
  color: var(--green);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

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

.nav-item.active {
  background: var(--green-glow);
  color: var(--green);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

[data-theme="dark"] .nav-item.active {
  border-color: rgba(74, 222, 128, 0.2);
}

/* Lucide icons inside nav */
.nav-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-icon svg,
i[data-lucide].nav-icon {
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

.icon-sm {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  vertical-align: text-bottom;
}

.icon-md {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  vertical-align: text-bottom;
}

.icon-lg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
  vertical-align: text-bottom;
}

.sidebar-category {
  padding: 12px 14px 4px 14px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

body.sidebar-collapsed .sidebar-category {
  display: none !important;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.user-info strong {
  display: block;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-logout {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.18);
  color: var(--red);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-logout svg {
  width: 14px;
  height: 14px;
}

.btn-logout:hover {
  background: rgba(220, 38, 38, 0.16);
}

.btn-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--bg-card2);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-theme-toggle svg {
  width: 16px;
  height: 16px;
}

.btn-theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 24px;
  min-width: 0;
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-title span {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 400;
  margin-left: 8px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: #0d1117;
}

.btn-primary:hover {
  background: #6ee7a0;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

.btn-secondary {
  background: var(--bg-card2);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.25);
}

.btn-warning {
  background: rgba(251, 191, 36, 0.15);
  color: var(--yellow);
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.btn-warning:hover {
  background: rgba(251, 191, 36, 0.25);
}

.btn-blue {
  background: rgba(96, 165, 250, 0.15);
  color: var(--blue);
  border: 1px solid rgba(96, 165, 250, 0.2);
}

.btn-blue:hover {
  background: rgba(96, 165, 250, 0.25);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 8px;
}

.card-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -1px;
}

.card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.kpi-card.green::before {
  background: var(--green);
}

.kpi-card.blue::before {
  background: var(--blue);
}

.kpi-card.yellow::before {
  background: var(--yellow);
}

.kpi-card.red::before {
  background: var(--red);
}

.kpi-card.purple::before {
  background: var(--purple);
}

.kpi-card.cyan::before {
  background: var(--cyan);
}

/* ── Grid layouts ──────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {

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

/* ── Table ─────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  line-height: 1.15;
}

thead th {
  background: var(--bg-card2);
  color: var(--text-primary);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 4px;
  text-align: left;
  border: 1px solid var(--border-light);
  white-space: nowrap;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:nth-child(even) {
  background: var(--bg-dark);
}

tbody tr:nth-child(odd) {
  background: var(--bg-card);
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody td {
  padding: 2px 4px;
  color: var(--text-primary);
  vertical-align: middle;
  border: 1px solid var(--border-light);
  white-space: nowrap;
}

/* Botões pequenos dentro da tabela para não esticar a altura da linha */
table .btn {
  padding: 1px 3px !important;
  font-size: 0.65rem !important;
  gap: 2px !important;
  border-radius: 3px !important;
  height: auto !important;
  line-height: 1 !important;
}

table .btn svg,
table .btn i,
table .btn [data-lucide] {
  width: 10px !important;
  height: 10px !important;
}

/* Badges compactos dentro da tabela */
table .badge {
  padding: 1px 5px !important;
  font-size: 0.65rem !important;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green {
  background: rgba(74, 222, 128, 0.12);
  color: var(--green);
}

.badge-red {
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
}

.badge-yellow {
  background: rgba(251, 191, 36, 0.12);
  color: var(--yellow);
}

.badge-blue {
  background: rgba(96, 165, 250, 0.12);
  color: var(--blue);
}

.badge-purple {
  background: rgba(167, 139, 250, 0.12);
  color: var(--purple);
}

.badge-gray {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-secondary);
}

/* ── Filtros ───────────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Form Fields ───────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

input,
select,
textarea {
  background: var(--bg-card2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 0.87rem;
  font-family: 'Inter', sans-serif;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

select option {
  background: var(--bg-card2);
  color: var(--text-primary);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.form-grid .span-2 {
  grid-column: span 2;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2 {
    grid-column: span 1;
  }
}

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none !important;
}

.tab {
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  border-radius: var(--radius) var(--radius) 0 0;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
}

/* ── Section divider ───────────────────────────────────────── */
.section-divider {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 18px 0 14px;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
}

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

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 360px;
}

.toast.success {
  border-left: 3px solid var(--green);
}

.toast.error {
  border-left: 3px solid var(--red);
}

.toast.warning {
  border-left: 3px solid var(--yellow);
}

.toast-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.toast.success .toast-icon {
  color: var(--green);
}

.toast.error .toast-icon {
  color: var(--red);
}

.toast.warning .toast-icon {
  color: var(--yellow);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Smooth theme transition ───────────────────────────────── */
html {
  transition: background-color 0.25s ease, color 0.25s ease;
}

body,
.sidebar,
.card,
.modal,
.kpi-card,
.produto-card {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}


/* ── Loading ───────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state h4 {
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ── Chart containers ──────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 260px;
}

/* ── Actions column ────────────────────────────────────────── */
.actions {
  display: flex;
  gap: 6px;
}

/* ── Progress / mini bar ───────────────────────────────────── */
.mini-bar {
  height: 4px;
  background: var(--bg-card2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}



/* ── Dashboard — page header sub ──────────────────────────── */
.page-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.mt-20 {
  margin-top: 20px;
}

/* ── Dashboard — KPI cards repaginados ─────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 0;
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

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

.kpi-card.kpi-warn {
  border-color: rgba(251, 191, 36, 0.25);
}

.kpi-card.kpi-danger {
  border-color: rgba(248, 113, 113, 0.25);
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.kpi-icon-blue {
  background: rgba(96, 165, 250, 0.12);
}

.kpi-icon-yellow {
  background: rgba(251, 191, 36, 0.12);
}

.kpi-icon-green {
  background: rgba(74, 222, 128, 0.12);
}

.kpi-icon-red {
  background: rgba(248, 113, 113, 0.12);
}

.kpi-body {
  min-width: 0;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-value.kpi-yellow {
  color: var(--yellow);
}

.kpi-value.kpi-blue {
  color: var(--blue);
}

.kpi-value.kpi-red {
  color: var(--red);
}

.kpi-value.kpi-green {
  color: var(--green);
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.kpi-skeleton {
  height: 20px;
  background: var(--bg-card2);
  border-radius: 6px;
  animation: pulse 1.2s ease infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: .6
  }

  50% {
    opacity: 1
  }
}

/* ── Dashboard — Card header com legenda ───────────────────── */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-header-row .card-title {
  margin-bottom: 0;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-txt {
  margin-right: 6px;
}

/* ── Dashboard — Dots de status ────────────────────────────── */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-green {
  background: var(--green);
}

.dot-yellow {
  background: var(--yellow);
}

.dot-red {
  background: var(--red);
}

/* ── Dashboard — Grid de produtos ──────────────────────────── */
.produto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}

.produto-card {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: all var(--transition);
  cursor: default;
}

.produto-card:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.produto-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.produto-cat {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.produto-nome {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--green);
  line-height: 1.3;
  margin-bottom: 6px;
  min-height: 2.2em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.produto-qty {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.produto-qty.qty-zero {
  color: var(--red);
}

.produto-unit {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.produto-consumo {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Dashboard — Movimentações row ─────────────────────────── */
.mov-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.mov-row:last-child {
  border-bottom: none;
}

.mov-nome {
  margin-left: 6px;
  font-size: 0.83rem;
}

/* ── Dashboard — Estoque baixo row ─────────────────────────── */
.baixo-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.baixo-row:last-child {
  border-bottom: none;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%) !important;
    transition: transform 0.3s ease;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
    height: 100% !important;
    min-height: 100% !important;
    bottom: 0 !important;
  }

  .sidebar.active {
    transform: translateX(0) !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 16px;
    padding-top: 10px;
  }

  .page-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .header-actions {
    width: 100% !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .header-actions .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  .mobile-header {
    display: flex !important;
    align-items: center;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 6px 12px;
    position: sticky;
    top: 0;
    z-index: 90;
    height: 50px;
  }

  .btn-mobile-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    transition: background 0.2s;
  }

  .btn-mobile-toggle:hover {
    background: var(--bg-hover);
  }

  .btn-mobile-toggle svg {
    width: 24px;
    height: 24px;
  }

  .mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-logo .logo-text {
    font-size: 1.1rem;
    font-weight: 800;
  }
}

/* ── Sidebar Overlay ───────────────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 95;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.hidden {
  display: none !important;
  opacity: 0;
}

/* ── Toggle Switch ─────────────────────────────────────────── */
.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-hover);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--green);
}

input:focus+.slider {
  box-shadow: 0 0 1px var(--green);
}

input:checked+.slider:before {
  transform: translateX(16px);
}

input:disabled+.slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Import Instructions ───────────────────────────────────── */
.import-instructions .table-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.import-instructions table {
  width: 100%;
  border-collapse: collapse;
}

.import-instructions th {
  background: var(--bg-card2);
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.import-instructions td {
  padding: 8px 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.import-instructions th:last-child,
.import-instructions td:last-child {
  border-right: none;
}

.import-instructions .text-red {
  color: var(--red);
  font-weight: bold;
}

.import-instructions .table-sm th,
.import-instructions .table-sm td {
  padding: 6px 10px;
}

/* ── Compra de Leite — Single Line ─────────────────────────── */
#table-compra-leite th,
#table-compra-leite td {
  white-space: nowrap;
}

/* ── Permissões de Ação (Criar, Editar, Excluir) ────────────── */
body.no-create button[onclick*="new" i],
body.no-create button[onclick*="novo" i],
body.no-create button[onclick*="add" i],
body.no-create button[onclick*="import" i],
body.no-create button[id*="new" i],
body.no-create button[class*="new" i],
body.no-create [id*="btn-new" i],
body.no-create [class*="btn-new" i] {
  display: none !important;
}

body.no-edit button[onclick*="edit" i],
body.no-edit button[onclick*="update" i],
body.no-edit button[onclick*="openForm" i],
body.no-edit button[onclick*="pagar" i],
body.no-edit button[onclick*="pago" i],
body.no-edit button[onclick*="receber" i],
body.no-edit button[onclick*="recebido" i],
body.no-edit button[onclick*="pay" i] {
  display: none !important;
}

body.no-delete button[onclick*="del" i],
body.no-delete button[onclick*="delete" i],
body.no-delete button[onclick*="destroy" i] {
  display: none !important;
}

/* ── Sidebar Collapsed / Retracted state ─────────────────── */
body.sidebar-collapsed {
  --sidebar-w: 70px;
}

body.sidebar-collapsed .sidebar-logo-custom,
body.sidebar-collapsed .logo-text {
  display: none !important;
}

body.sidebar-collapsed .sidebar-hamburger-icon {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: var(--text-primary);
}

body.sidebar-collapsed .sidebar-hamburger-icon svg {
  width: 20px;
  height: 20px;
}

body.sidebar-collapsed .nav-item span {
  display: none !important;
}

body.sidebar-collapsed .nav-item {
  justify-content: center !important;
  padding: 12px !important;
}

body.sidebar-collapsed .user-info {
  display: none !important;
}

body.sidebar-collapsed .sidebar-footer-actions {
  flex-direction: column !important;
  gap: 8px !important;
}

body.sidebar-collapsed .btn-logout span {
  display: none !important;
}

body.sidebar-collapsed .btn-logout {
  width: 34px !important;
  height: 34px !important;
  padding: 0 !important;
  justify-content: center !important;
}

/* Override collapsed sidebar styles on mobile to keep it full width drawer */
@media (max-width: 768px) {
  body.sidebar-collapsed .sidebar {
    width: 240px !important;
  }

  body.sidebar-collapsed .sidebar-logo-custom,
  body.sidebar-collapsed .logo-text {
    display: flex !important;
  }

  body.sidebar-collapsed .sidebar-hamburger-icon {
    display: none !important;
  }

  body.sidebar-collapsed .nav-item span {
    display: inline !important;
  }

  body.sidebar-collapsed .nav-item {
    justify-content: flex-start !important;
    padding: 9px 12px !important;
  }

  body.sidebar-collapsed .user-info {
    display: block !important;
  }

  body.sidebar-collapsed .sidebar-footer-actions {
    flex-direction: row !important;
  }

  body.sidebar-collapsed .btn-logout span {
    display: inline !important;
  }

  body.sidebar-collapsed .btn-logout {
    width: auto !important;
    height: auto !important;
    padding: 7px 10px !important;
  }
}

/* ── Sobrescritas de Layout Mobile & Responsividade (<= 768px) ── */
@media (max-width: 768px) {

  /* Estruturas de Layout */
  .treinamentos-layout {
    grid-template-columns: 1fr !important;
  }

  /* Sobrescritas de Grids Inline */
  div[style*="grid-template-columns: 1fr 240px"],
  div[style*="grid-template-columns: 1fr 1.2fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Grids de KPIs */
  #fazenda-kpis {
    grid-template-columns: 1fr !important;
  }

  #fat-kpis-container {
    min-width: auto !important;
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Filtros e Controles */
  .filters {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .filters .filter-group {
    width: 100% !important;
    margin: 0 !important;
  }

  .filters .filter-group select,
  .filters .filter-group input {
    width: 100% !important;
    min-width: 0 !important;
  }

  .filters .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Filtros inline do Rebanho */
  #reb-filters-inline {
    width: 100% !important;
    margin-left: 0 !important;
    margin-top: 8px !important;
    flex-wrap: wrap !important;
  }

  #reb-filters-inline input,
  #reb-filters-inline select {
    flex: 1 1 80px !important;
    width: auto !important;
    height: 32px !important;
  }

  #reb-filters-inline button {
    width: 100% !important;
    height: 32px !important;
    justify-content: center !important;
  }


  /* Cabeçalhos de Página */
  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .page-header>div[style*="display:flex"],
  .page-header>div[style*="display: flex"] {
    width: 100% !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .page-header .btn {
    flex: 1 !important;
    min-width: 120px !important;
    justify-content: center !important;
  }

  /* Proteção para tabelas */
  .table-wrapper {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }

  .table-wrapper table:not(.fat-table) th,
  .table-wrapper table:not(.fat-table) td {
    padding: 8px 10px !important;
  }

  /* Modais Responsivos */
  .modal-overlay .card {
    width: 95% !important;
    max-width: 95% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }
}

@media (max-width: 480px) {
  #fat-kpis-container {
    grid-template-columns: 1fr !important;
  }
}

/* ── Estilos de Captura de Screenshot (Oculta sidebar e expande conteúdo) ── */
html.is-screenshot,
body.is-screenshot {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

.is-screenshot .app-shell {
  display: block !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

.is-screenshot .main-content,
.is-screenshot main,
.is-screenshot #page-container,
.is-screenshot #fin-content,
.is-screenshot #faturamento-container,
.is-screenshot .table-wrapper {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  overflow-y: visible !important;
  overflow-x: visible !important;
}

.is-screenshot .sidebar,
.is-screenshot #sidebar,
.is-screenshot aside,
.is-screenshot .mobile-header,
.is-screenshot .filters,
.is-screenshot .page-header button,
.is-screenshot .draft-alert,
.is-screenshot .wizard-footer,
.is-screenshot .modo-selection,
.is-screenshot #coleta-actions {
  display: none !important;
  width: 0 !important;
}

.is-screenshot .main-content,
.is-screenshot main {
  margin-left: 0 !important;
  padding: 10px !important;
  width: 100% !important;
}