/* UniHaras — estilos com dois temas: Claro (areia e verde) e Escuro (verde-noite e dourado) */

:root, [data-theme="claro"] {
  --bg: #F3EEE4;
  --surface: #FFFDF9;
  --surface-2: #F8F4EC;
  --surface-3: #EFE8DB;
  --text: #1C2620;
  --text-2: #4E5A53;
  --muted: #6B746E;
  --border: #E2D9C8;
  --border-strong: #CFC3AE;
  --primary: #1F3A2E;
  --primary-hover: #15291F;
  --on-primary: #F6F1E8;
  --accent: #A9792C;
  --accent-soft: #F4E7CF;
  --gold: #B8893B;
  --sidebar: #1F3A2E;
  --sidebar-text: #DCE5DF;
  --sidebar-muted: #9DB3A6;
  --sidebar-active: #2C4F3F;
  --sidebar-accent: #D9AE5F;
  --ok: #2E7D4F; --ok-soft: #E2F1E7;
  --warn: #9A6A00; --warn-soft: #FBEFCF;
  --danger: #B3362B; --danger-soft: #F9E1DE;
  --info: #2B5F8A; --info-soft: #E1ECF5;
  --chart-1: #1F3A2E; --chart-2: #C08A35; --chart-3: #6E9B7F; --chart-4: #B3362B; --chart-5: #2B5F8A;
  --shadow: 0 1px 2px rgba(31, 41, 35, .06), 0 4px 16px rgba(31, 41, 35, .06);
  --shadow-lg: 0 10px 40px rgba(20, 30, 25, .22);
  color-scheme: light;
}

[data-theme="escuro"] {
  --bg: #0D1612;
  --surface: #14211B;
  --surface-2: #192920;
  --surface-3: #213428;
  --text: #ECE6DA;
  --text-2: #C3CCC6;
  --muted: #94A49A;
  --border: #26392F;
  --border-strong: #35503F;
  --primary: #D9AE5F;
  --primary-hover: #E6C07A;
  --on-primary: #1A1408;
  --accent: #E1BA72;
  --accent-soft: #2E2716;
  --gold: #D9AE5F;
  --sidebar: #0A120E;
  --sidebar-text: #D7DED9;
  --sidebar-muted: #8C9C92;
  --sidebar-active: #1B2C23;
  --sidebar-accent: #D9AE5F;
  --ok: #6CCB92; --ok-soft: #173326;
  --warn: #E7BE5A; --warn-soft: #33290F;
  --danger: #F08A7E; --danger-soft: #3A1A16;
  --info: #7DB4E0; --info-soft: #16283A;
  --chart-1: #D9AE5F; --chart-2: #6CCB92; --chart-3: #7DB4E0; --chart-4: #F08A7E; --chart-5: #B9A6E8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Manrope', system-ui, sans-serif; font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: 'Urbanist', 'Manrope', sans-serif; margin: 0; letter-spacing: -.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hidden { display: none !important; }

/* ===== Layout ===== */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 14px; color: var(--sidebar-text); }
.brand:hover { text-decoration: none; }
.brand svg { width: 36px; height: 36px; flex-shrink: 0; }
.brand-name { font-family: 'Urbanist', sans-serif; font-size: 24px; letter-spacing: -.5px; line-height: 1; color: #F6F1E8; }
.brand-name b { font-weight: 800; } .brand-name span { font-weight: 300; }
.brand-sub { font-size: 11px; color: var(--sidebar-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.nav { padding: 6px 10px 20px; display: flex; flex-direction: column; gap: 1px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 14px 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--sidebar-text); font-weight: 500; min-height: 36px;
}
.nav a:hover { background: var(--sidebar-active); text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--sidebar-accent); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 22px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }
.btn.menu-btn { display: none; }

/* ===== Botões ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-icon { width: 38px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== Cartões e grade ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-head h3 { font-size: 17px; font-weight: 700; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-family: 'Urbanist', sans-serif; font-size: 28px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.kpi-sub { color: var(--text-2); font-size: 12.5px; }
.pos { color: var(--ok); } .neg { color: var(--danger); }

/* ===== Barra de ferramentas e filtros ===== */
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  padding: 10px 14px; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--gold); }

/* ===== Formulários ===== */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.req { color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-family: 'Urbanist'; font-weight: 700; font-size: 15px; padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 14px; }

/* ===== Tabelas ===== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700;
  padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tr.clickable { cursor: pointer; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .actions { text-align: right; white-space: nowrap; width: 1%; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); }
.tbl .sub td { color: var(--text-2); }
.tbl .grp td { font-weight: 700; background: var(--surface-3); }
.tbl .tot td { font-weight: 800; background: var(--accent-soft); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .5; display: block; margin: 0 auto 8px; }

/* ===== Etiquetas ===== */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-info { background: var(--info-soft); color: var(--info); }
.tag-gold { background: var(--accent-soft); color: var(--accent); }

/* ===== Alertas ===== */
.alert-list { display: flex; flex-direction: column; }
.alert-item { display: flex; gap: 12px; align-items: center; padding: 11px 20px; border-top: 1px solid var(--border); color: var(--text); }
.alert-item:hover { background: var(--surface-2); text-decoration: none; }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.alert-dot.vencido { background: var(--danger); } .alert-dot.urgente { background: var(--warn); } .alert-dot.atencao { background: var(--info); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 700; }
.alert-detail { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bell { position: relative; }
.bell .badge { position: absolute; top: 3px; right: 3px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; border-radius: 999px; min-width: 17px; height: 17px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* ===== Animais ===== */
.animal-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.animal-card { overflow: hidden; display: flex; flex-direction: column; color: var(--text); transition: transform .12s, box-shadow .12s; }
.animal-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.animal-photo { aspect-ratio: 4 / 3; background: var(--surface-3); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.animal-photo img { width: 100%; height: 100%; object-fit: cover; }
.animal-photo svg { width: 64px; height: 64px; opacity: .35; }
.animal-info { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.animal-name { font-family: 'Urbanist'; font-size: 18px; font-weight: 700; }
.animal-meta { color: var(--text-2); font-size: 13px; }
.ficha-head { display: flex; gap: 20px; align-items: flex-start; padding: 20px; flex-wrap: wrap; }
.ficha-foto { width: 180px; height: 180px; border-radius: 14px; overflow: hidden; background: var(--surface-3); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.ficha-foto img { width: 100%; height: 100%; object-fit: cover; }
.ficha-foto svg { width: 72px; height: 72px; opacity: .35; }
.ficha-dados { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 10px; }
.ficha-nome { font-size: 30px; font-weight: 800; }
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 18px; }
.dl div span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.dl div b { font-weight: 600; }

/* Árvore genealógica */
.tree { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 0 18px; min-width: 720px; }
.tree-col { display: flex; flex-direction: column; justify-content: space-around; gap: 8px; }
.tree-node { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface); position: relative; min-height: 44px; }
.tree-node.macho { border-left: 4px solid var(--info); }
.tree-node.femea { border-left: 4px solid var(--accent); }
.tree-node.raiz { border: 2px solid var(--gold); background: var(--accent-soft); }
.tree-node .n { font-weight: 700; } .tree-node .r { font-size: 12px; color: var(--muted); }
.tree-node.vazio { color: var(--muted); font-style: italic; background: var(--surface-2); }
.tree-node .pos { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }

.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.foto { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1; background: var(--surface-3); border: 1px solid var(--border); }
.foto img { width: 100%; height: 100%; object-fit: cover; }
.foto .acoes { position: absolute; inset: auto 6px 6px 6px; display: flex; gap: 6px; justify-content: flex-end; }
.foto.principal { outline: 3px solid var(--gold); }

/* Cartão de vacina */
.vac-card { border: 2px solid var(--primary); border-radius: 14px; overflow: hidden; }
.vac-card-head { background: var(--primary); color: var(--on-primary); padding: 14px 18px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.vac-card-head h3 { font-size: 20px; }

/* ===== Gráficos ===== */
.chart { width: 100%; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: 'Manrope', sans-serif; }
.chart .gridline { stroke: var(--border); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar-track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--chart-2); border-radius: 999px; }

/* ===== Modal ===== */
.modal-back { position: fixed; inset: 0; background: rgba(8, 14, 11, .55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 720px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal.wide { max-width: 1040px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); gap: 12px; }
.modal-head h2 { font-size: 20px; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }

/* ===== Toast ===== */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 380px; font-weight: 600; animation: in .2s ease-out; }
.toast.erro { background: var(--danger); color: #fff; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.login { width: 100%; max-width: 420px; padding: 32px; }
.login .brand { padding: 0 0 22px; justify-content: center; color: var(--text); }
.login .brand-name { color: var(--text); font-size: 34px; }
.login .brand svg { width: 52px; height: 52px; }

.items-table .input { min-height: 34px; padding: 5px 8px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-pill { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ===== Responsivo ===== */
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 90; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .g-2, .g-3, .g-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar h1 { font-size: 18px; }
  .hide-sm { display: none !important; }
}

/* ===== Impressão ===== */
@media print {
  .sidebar, .topbar, .tabs, .toolbar, .no-print, .btn { display: none !important; }
  body, .content { background: #fff; color: #000; padding: 0; }
  .card { box-shadow: none; border: 1px solid #999; }
}

.ic-lg { width: 28px; height: 28px; flex-shrink: 0; color: var(--gold); }
.tbl td svg, .card-pad > div svg { max-width: 100%; }

/* Versão do sistema no rodapé do menu */
.versao-badge { margin: auto 16px 16px; padding: 8px 10px; border-radius: 8px; font-size: 12px; color: var(--sidebar-muted); border: 1px solid rgba(255,255,255,.12); text-align: center; }
.instalar-app { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 16px 10px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--gold); background: transparent; color: var(--gold); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.instalar-app svg { width: 16px; height: 16px; }
.instalar-app:hover { background: var(--sidebar-active); }
.instalar-app.hidden { display: none; }
.versao-badge:hover { color: var(--sidebar-text); text-decoration: none; background: var(--sidebar-active); }
.versao-atual { border-left: 4px solid var(--gold); }

/* ===== Documento para impressão (ficha do animal) ===== */
.doc { background: #fff; color: #1a1a1a; border: 1px solid var(--border); border-radius: 12px; padding: 28px 32px; max-width: 1000px; margin: 0 auto; font-size: 12.5px; }
.doc .muted { color: #666; }
.doc h2, .doc h3, .doc h4 { color: #1F3A2E; }
.doc-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 2px solid #1F3A2E; padding-bottom: 12px; margin-bottom: 16px; }
.doc-marca { display: flex; gap: 10px; align-items: center; }
.doc-marca svg { width: 42px; height: 42px; --primary: #1F3A2E; --gold: #B8893B; }
.doc-titulo { text-align: right; }
.doc-titulo h2 { font-size: 20px; }
.doc-animal { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 8px; }
.doc-animal img { width: 150px; height: 150px; object-fit: cover; border-radius: 8px; border: 1px solid #ccc; }
.doc-nome { font-size: 24px; margin-bottom: 8px !important; }
.doc .dl div span { color: #666; }
.doc-sec { margin-top: 18px; break-inside: avoid-page; }
.doc-sec h3 { font-size: 15px; border-bottom: 1px solid #ccc; padding-bottom: 4px; margin-bottom: 8px; }
.doc-sec h4 { font-size: 13px; margin: 12px 0 6px; }
.doc-tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.doc-tbl th { text-align: left; background: #f1ede4; color: #333; font-weight: 700; padding: 5px 7px; border: 1px solid #d8d0c0; }
.doc-tbl td { padding: 5px 7px; border: 1px solid #e2dccf; vertical-align: top; }
.doc-tbl .num { text-align: right; }
.doc-tbl tr { break-inside: avoid; }
.doc-gen td { width: 33%; }
.doc-vazio { color: #888; font-style: italic; margin: 0; }
.doc-assina { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 48px; text-align: center; font-size: 12px; break-inside: avoid; }
.doc-assina .linha { border-top: 1px solid #333; margin-bottom: 6px; }
.doc-rodape { margin-top: 18px; text-align: center; color: #888; font-size: 10.5px; }
@media print {
  @page { margin: 12mm; }
  .doc { border: 0; padding: 0; max-width: none; border-radius: 0; }
  .content { max-width: none; }
  .main, .shell { display: block; }
}

@media print {
  html, body, .shell, .main, .content { background: #fff !important; color: #000; }
  html { color-scheme: light; }
}
@media print {
  html[data-theme], html[data-theme] body { background: #fff !important; color-scheme: light !important; }
}

.print-only { display: none; }
@media print { .print-only { display: block; } .kpi-value { font-size: 20px; } }

.tbl-rel td, .tbl-rel th { padding: 7px 10px; font-size: 13px; }
@media print { .tbl-rel td, .tbl-rel th { padding: 3px 5px; font-size: 9.5pt; border: 1px solid #ccc; } .tbl-rel tr { break-inside: avoid; } }

/* Consumo e rateio: tabela compacta para o botão Excluir caber sem rolar */
.tbl-consumo th, .tbl-consumo td { padding-left: 8px; padding-right: 8px; }
.tbl-consumo td.actions { white-space: nowrap; }
.tbl-consumo td:nth-child(2) { white-space: nowrap; }

/* Avisos em destaque */
.alert { padding: 10px 14px; border-radius: 9px; border: 1px solid var(--border); font-size: 14px; }
.alert-danger { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.tbl-aportes td.clickable:hover { background: var(--gold-soft, rgba(201,162,39,.12)); }

/* Barra de progresso (pagamento da compra) */
.barra { height: 10px; border-radius: 99px; background: var(--border); overflow: hidden; }
.barra > span { display: block; height: 100%; background: var(--ok, #2f7d4f); border-radius: 99px; }

/* Campo numérico com valor inválido */
.input.input-erro { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
input[data-num] { text-align: right; font-variant-numeric: tabular-nums; }

/* ===== Galeria ===== */
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.g-item { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); cursor: pointer; display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s; }
.g-item:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.g-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.g-thumb { position: relative; aspect-ratio: 4 / 3; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.g-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-thumb .g-play { position: absolute; width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; color: #fff; }
.g-thumb .g-play svg { width: 20px; height: 20px; fill: #fff; stroke: none; margin-left: 3px; }
.g-thumb .g-ext { font-weight: 700; letter-spacing: .05em; font-size: 13px; text-transform: uppercase; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.g-thumb .g-ext svg { width: 34px; height: 34px; }
.g-info { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.g-info b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-info span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: inherit; }
.chip[aria-pressed="true"] { background: var(--primary); color: var(--surface); border-color: transparent; }
.chip small { opacity: .7; margin-left: 4px; }
.drop { border: 2px dashed var(--border); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); transition: background .15s, border-color .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.up-lista { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-height: 260px; overflow: auto; }
.up-item { display: grid; grid-template-columns: 1fr 90px; gap: 8px; align-items: center; font-size: 13px; }
.up-item .barra { height: 8px; }
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.viewer-media { background: #111; border-radius: 10px; display: grid; place-items: center; min-height: 320px; max-height: 70vh; overflow: hidden; position: relative; }
.viewer-media img, .viewer-media video { max-width: 100%; max-height: 70vh; display: block; }
.viewer-media iframe { width: 100%; height: 70vh; border: 0; background: #fff; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.45); color: #fff; border: 0; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 20px; }
.viewer-nav.prev { left: 8px; } .viewer-nav.next { right: 8px; }
@media (max-width: 760px) { .viewer { grid-template-columns: 1fr; } .galeria { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }
.g-info .g-animal svg { width: 13px; height: 13px; vertical-align: -2px; }

/* ===== Marca nas impressões: logomarca do haras + By UniHaras ===== */
.marca-imp { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; flex-shrink: 0; }
.marca-imp .marca-logo { max-height: 64px; max-width: 200px; width: auto; height: auto; object-fit: contain; display: block; }
.marca-imp svg { width: 42px; height: 42px; --primary: #1F3A2E; --gold: #B8893B; }
/* marca do UniHaras (logo + nome) — à esquerda sem logo do haras, à direita quando o haras tem logomarca */
.marca-sis { display: flex; align-items: center; gap: 6px; color: #1F3A2E; }
.marca-sis svg { width: 38px; height: 38px; --primary: #1F3A2E; --gold: #B8893B; flex-shrink: 0; }
.marca-sis-nome { font-family: 'Urbanist', 'Manrope', sans-serif; font-size: 17px; letter-spacing: -.3px; line-height: 1; white-space: nowrap; }
.marca-sis-nome b { font-weight: 800; }
.marca-dir { margin-left: auto; flex-shrink: 0; }
.marca-dir .marca-sis { flex-direction: column; gap: 2px; }  /* à direita: símbolo em cima da palavra */
.marca-dir .marca-sis svg { width: 30px; height: 30px; }
.marca-dir .marca-sis-nome { font-size: 12px; }
.doc-dir { display: flex; align-items: center; gap: 16px; }
.ct-head.com-dir { grid-template-columns: auto 1fr auto auto; }
.marca-by { font-size: 8px; letter-spacing: .04em; color: #9a9a9a; line-height: 1.2; }
.print-marca { display: none; }
@media print {
  .print-marca { display: flex !important; align-items: center; gap: 14px; padding: 0 0 8px; margin-bottom: 12px; border-bottom: 1.5px solid #1F3A2E; color: #1a1a1a; break-inside: avoid; }
  .print-marca .pm-haras { font-size: 11pt; line-height: 1.3; }
  .print-marca .pm-haras div { font-size: 9pt; color: #555; }
  .main:has(.doc-head) .print-marca { display: none !important; }  /* a ficha já tem cabeçalho próprio com a marca */
  .marca-by { font-size: 6.5pt; }
}
.logo-config { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 220px; height: 110px; border: 1px dashed var(--border); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#f3f0ea 0% 25%, #fff 0% 50%) 50% / 16px 16px; padding: 8px; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ===== Contrato de venda ===== */
.contrato { font-size: 11.5px; line-height: 1.45; }
.contrato p { margin: 0 0 6px; text-align: justify; }
.ct-pagina { margin-bottom: 28px; }
.ct-head { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; border-bottom: 2px solid #1F3A2E; padding-bottom: 10px; margin-bottom: 12px; }
.ct-centro { text-align: center; }
.ct-titulo { font-weight: 800; font-size: 14px; letter-spacing: .02em; color: #1F3A2E; }
.ct-haras { font-size: 10.5px; color: #444; margin-top: 3px; }
.ct-num { text-align: right; font-size: 11px; }
.ct-valor { font-size: 16px; font-weight: 800; }
.ct-box { border: 1px solid #cfc6b4; border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; break-inside: avoid; }
.ct-box h4 { margin: 0 0 6px; text-align: center; font-size: 11.5px; letter-spacing: .04em; background: #f1ede4; padding: 3px; border-radius: 3px; color: #1F3A2E; }
.ct-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 2px 14px; }
.ct-grid span, .ct-especiais b { color: #555; }
.ct-tbl { width: 100%; border-collapse: collapse; }
.ct-tbl th { font-size: 10.5px; text-align: left; border-bottom: 1px solid #cfc6b4; padding: 3px 5px; }
.ct-tbl td { padding: 4px 5px; vertical-align: top; }
.ct-tbl .c { text-align: center; } .ct-tbl .num { text-align: right; white-space: nowrap; }
.ct-especiais { margin-top: 8px; border-top: 1px dashed #cfc6b4; padding-top: 6px; }
.ct-crono { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px 10px; font-size: 10.5px; }
.ct-aviso { font-weight: 700; font-size: 10.5px; text-align: center !important; margin: 10px 0 !important; }
.ct-assinaturas { display: grid; grid-template-columns: 1fr 1fr; gap: 34px 40px; margin-top: 34px; break-inside: avoid; }
.ct-ass { text-align: center; font-size: 10.5px; }
.ct-ass .linha { border-top: 1px solid #333; margin-bottom: 4px; }
.ct-nota p { font-size: 12.5px; line-height: 1.6; }
.ct-local { text-align: right !important; font-weight: 600; margin: 12px 0 !important; }
.ct-emitente { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: end; margin-top: 18px; font-size: 11px; }
.ct-tit { text-align: center; font-size: 13px; margin: 6px 0 10px; color: #1F3A2E; }
.ct-cl { break-inside: auto; }
.ct-rodape { text-align: center !important; color: #999; font-size: 9px; margin-top: 18px !important; }
@media screen and (max-width: 720px) { .ct-head { grid-template-columns: 1fr; text-align: center; } .ct-num { text-align: center; } .ct-crono { grid-template-columns: 1fr 1fr; } .ct-grid, .ct-emitente { grid-template-columns: 1fr; } }
@media print {
  .contrato { font-size: 9pt; line-height: 1.35; }
  .contrato p { margin-bottom: 4px; }
  .ct-box { padding: 5px 8px; margin-bottom: 7px; }
  .ct-assinaturas { margin-top: 26px; gap: 26px 36px; }
  .ct-head { margin-bottom: 8px; padding-bottom: 6px; }
  .ct-pagina { page-break-after: always; margin: 0; }
  .ct-pagina:last-child { page-break-after: auto; }
  .ct-crono { font-size: 7.4pt; gap: 1px 6px; }
  .ct-crono span { white-space: nowrap; }
}

.ct-sep { text-align: center; font-size: 12px; color: var(--muted, #777); border-top: 2px dashed #cfc6b4; padding-top: 8px; margin: 10px 0 18px; }
@media print { .ct-unica { page-break-before: auto; page-break-after: auto; } }

@media print { #toast-root, #modal-root { display: none !important; } }
.field label.btn { font-size: 14px; }
.field label.btn-primary { color: var(--on-primary); }
