/*
 * Same palette as the app, so the owner recognises one product in both places.
 * The panel is a different medium though: denser, built for a keyboard and for
 * reading a lot at once, not for a wet hand in a hurry.
 */
:root {
  --bg: #F6F7F5;
  --surface: #FFFFFF;
  --surface-muted: #EFF3F0;
  --ink: #101613;
  --ink-muted: #5C6661;
  --ink-inverse: #FFFFFF;
  --border: #D7DCD8;
  --accent: #0B6B3A;
  --accent-soft: #E4F0E8;
  --alert: #B42318;
  --alert-soft: #FDECEA;
  --pending: #B45309;
  --radius: 10px;
  --gap: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex; align-items: center; gap: var(--gap);
  padding: 12px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.nav { display: flex; gap: 18px; flex: 1; }
.nav a { color: var(--ink-muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.nav a.on { color: var(--accent); }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.who .user { font-weight: 600; }
.who .farm { color: var(--ink-muted); }
.farm-picker { display: flex; align-items: center; gap: 8px; }
.farm-picker [hidden] { display: none; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.page { max-width: 1120px; margin: 0 auto; padding: 24px; }

/* Console sections. Sits under the top bar only inside /console. */
.subnav {
  display: flex; gap: 6px; padding: 8px 24px;
  background: var(--surface-muted); border-bottom: 1px solid var(--border);
}
.subnav a {
  padding: 5px 12px; border-radius: 20px; font-size: 14px; font-weight: 600;
  color: var(--ink-muted); text-decoration: none;
}
.subnav a.on { background: var(--surface); color: var(--accent); }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-head h2 { margin-top: 0; }
.danger-zone { border-left: 4px solid var(--alert); }
.credentials dd strong { font-size: 18px; letter-spacing: 0.5px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

.flash { padding: 12px 24px; font-size: 14px; font-weight: 600; }
.flash.alert { background: var(--alert-soft); color: var(--alert); }
.flash.notice { background: var(--accent-soft); color: var(--accent); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: var(--gap);
}

h1 { font-size: 22px; margin: 0 0 4px; }
.muted { color: var(--ink-muted); font-size: 14px; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], select {
  width: 100%; height: 44px; padding: 0 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
.field { margin-bottom: 14px; }
.field :where(input[type=number], input[type=date], textarea) {
  width: 100%; height: 44px; padding: 0 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
.field :where(textarea) { height: auto; padding: 10px 12px; }

/* :where keeps these at zero specificity, so .quiet-button, .danger-button and
   .small still win. Submit inputs and the number and date fields looked like
   bare browser controls next to the styled ones (Card 051). */
button, .button, :where(input[type=submit]) {
  height: 44px; padding: 0 20px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--ink-inverse);
  font-size: 15px; font-weight: 700; cursor: pointer;
}
button.link, .link button {
  background: none; color: var(--ink-muted); font-weight: 600; padding: 0; height: auto;
}

.signin { max-width: 380px; margin: 8vh auto; }

/* Card 026: login, second factor and account. */
.quiet { color: var(--ink-muted); font-size: 14px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.steps { color: var(--ink-muted); font-size: 14px; padding-left: 20px; margin: 14px 0; }
.steps li { margin-bottom: 6px; }
.qr { display: flex; justify-content: center; margin: 8px 0 16px; }
.qr svg { width: 200px; height: 200px; }
.secret {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 15px;
  letter-spacing: 1px; word-break: break-all;
  background: var(--surface-muted); padding: 10px; border-radius: var(--radius);
}
details summary { font-size: 14px; color: var(--ink-muted); cursor: pointer; margin-bottom: 8px; }
.codes {
  list-style: none; padding: 0; margin: 16px 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.codes li {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 16px;
  background: var(--surface-muted); padding: 10px; border-radius: var(--radius);
  text-align: center; letter-spacing: 1px;
}
.pairs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
.pairs dt { color: var(--ink-muted); font-weight: 600; }
.pairs dd { margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.button {
  display: inline-flex; align-items: center; text-decoration: none;
  height: 44px; padding: 0 20px; border-radius: var(--radius);
  background: var(--accent); color: var(--ink-inverse); font-weight: 700; font-size: 15px;
}
/* Standalone, not only `.button.quiet-button`: these classes also land on real
   <button> elements, which otherwise keep the solid primary style. */
.quiet-button { background: var(--surface-muted); color: var(--ink); }
.danger, .button.danger { background: var(--alert); color: var(--ink-inverse); }
.narrow { max-width: 380px; }

/* Cards 027-029: dashboard, herd table and cow page. */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--gap); margin-bottom: var(--gap); }
.page-head h1 { margin: 0; }
.page-head .muted { margin: 4px 0 0; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

.period { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; }
.presets a { padding: 7px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--ink-muted); text-decoration: none; }
.presets a.on { background: var(--accent-soft); color: var(--accent); }
.period .custom { display: flex; align-items: center; gap: 8px; }
.period .custom label { margin: 0; font-size: 13px; }
.period .custom input[type=date] { height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 14px; color: var(--ink); }
input[type=submit].small, .small { height: 38px; padding: 0 14px; font-size: 14px; }

.sync-note { font-size: 13px; color: var(--ink-muted); margin: 0 0 var(--gap); }
.sync-note .warn { color: var(--pending); font-weight: 600; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.metric-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-muted); }
.metric strong { font-size: 24px; }
.metric-extra { font-size: 13px; color: var(--ink-muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge.up { background: var(--accent-soft); color: var(--accent); }
.badge.down { background: var(--alert-soft); color: var(--alert); }
.badge.flat { background: var(--surface-muted); color: var(--ink-muted); }

.pending { border-left: 4px solid var(--pending); }
.pending-row { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--border); }
.pending-row:first-of-type { border-top: 0; }
.pending-row > div { flex: 1; }
.pending-row p { margin: 4px 0 0; }
.tag { min-width: 30px; text-align: center; padding: 4px 8px; border-radius: var(--radius); font-weight: 700; font-size: 14px; }
.tag.alert { background: var(--alert-soft); color: var(--alert); }
.tag.pending-tag { background: #FEF3C7; color: var(--pending); }
.drops, .missing { list-style: none; padding: 0; margin: 10px 0 0; font-size: 14px; }
.drops li, .missing li { padding: 4px 0; border-bottom: 1px solid var(--border); }

/* The chart is an SVG scaled to the card's width; the bars carry their own
   geometry, so no inline style is needed and the strict CSP stays intact. */
.chart { display: block; width: 100%; height: 180px; border-bottom: 1px solid var(--border); }
.chart .bar { fill: var(--accent); }
.chart .bar.empty { fill: var(--border); }
.axis { display: flex; justify-content: space-between; margin-top: 6px; }
.tick { font-size: 11px; color: var(--ink-muted); white-space: nowrap; }

.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: start; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
@media (max-width: 900px) { .two-up { grid-template-columns: 1fr; } }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table th a { color: inherit; text-decoration: none; }
.table th a.sorted { color: var(--accent); }
.table tr.zero td { color: var(--ink-muted); }
.table tr.inactive td { opacity: .55; }
.table.compact { margin-top: 16px; }
.scroll { overflow-x: auto; }
.scroll.tall { max-height: 460px; overflow-y: auto; }
.table-card { padding: 0; }
.table-card .scroll { padding: 6px 6px 0; }

.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filter { display: flex; flex-direction: column; gap: 4px; }
.filter label { margin: 0; }
.filter input, .filter select { height: 38px; min-width: 150px; }
.filter.check { flex-direction: row; align-items: center; gap: 6px; }
.filter.check input { height: auto; min-width: 0; width: auto; }
.filter.check label { font-weight: 600; color: var(--ink); }

.bulk { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-muted); border-radius: 0 0 var(--radius) var(--radius); font-size: 14px; }
.bulk select { height: 38px; width: auto; min-width: 160px; }
.pick { width: 34px; }
.strong-link { font-weight: 700; color: var(--accent); text-decoration: none; }
.pager { display: flex; gap: 6px; margin-top: var(--gap); }
.pager a { padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink-muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.pager a.on { background: var(--accent); color: var(--ink-inverse); border-color: var(--accent); }

.empty-state { text-align: center; padding: 40px 20px; }
.narrow-form { max-width: 560px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }
.hint { display: block; font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.form-errors { background: var(--alert-soft); color: var(--alert); border-radius: var(--radius); padding: 12px 14px; margin-bottom: var(--gap); font-size: 14px; }
.form-errors p { margin: 0 0 6px; }
.warn-card { border-left: 4px solid var(--pending); }
textarea { width: 100%; padding: 10px 12px; font-size: 15px; font-family: inherit; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.inline-form input[type=text], .inline-form input[type=date] { height: 38px; width: auto; flex: 1; min-width: 120px; }
.danger-button { background: var(--alert); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.timeline li { padding: 7px 0; border-bottom: 1px solid var(--border); color: var(--ink-muted); }
.timeline li:last-child { border-bottom: 0; }
.timeline strong { color: var(--ink); }

/* Card 031: corrections and conflicts. */
.table tr.conflict td { background: #FFFBEB; }
.table tr.loser td { opacity: .6; }
.entry-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.entry-actions form { margin: 0; }
.inline-form.tight { margin: 0; gap: 4px; }
.inline-form.tight input[type=number] { height: 34px; width: 80px; padding: 0 8px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; }
.inline-form.tight input[type=text] { height: 34px; min-width: 110px; flex: 0 1 130px; font-size: 13px; }
.entry-actions .small { height: 34px; padding: 0 10px; font-size: 13px; }

.inline-form input[type=email] { height: 38px; flex: 1; min-width: 160px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

.spaced { margin-top: 20px; }
.spaced-sm { margin-top: 14px; }
.flush { margin: 0; }

/* Links in the panel are chrome, not content: the browser's blue underline
   fights the palette and made the signed-in name look like a warning. */
a { color: var(--accent); }
.who .user {
  color: var(--ink); font-weight: 600; text-decoration: none;
  padding: 4px 8px; border-radius: 7px;
}
.who .user:hover { background: var(--surface-muted); }
.quiet { text-decoration: none; }
.quiet:hover { text-decoration: underline; }
.table td a, .timeline a { text-decoration: none; }
.table td a:hover, .timeline a:hover { text-decoration: underline; }
.pager a, .presets a, .button { text-decoration: none; }
.is-disabled { opacity: 0.5; cursor: not-allowed; }
.sub-row td { border-top: 0; padding-top: 0; }

/* Phone width (Card 051): at 390px the top bar was 668px wide, with the farm
   picker and "Sair" off screen. The menu takes its own scrollable row. */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; white-space: nowrap; gap: 16px; padding-bottom: 2px; }
  .who { margin-left: auto; gap: 8px; min-width: 0; }
  .who .farm-picker select { max-width: 150px; height: 36px; font-size: 14px; }
  .card { overflow-x: auto; }
  .page-head { flex-wrap: wrap; gap: 12px; }
  .period .custom { flex-wrap: wrap; width: 100%; }
  .period .custom input[type=date] { flex: 1 1 130px; min-width: 0; }
  .presets { flex-wrap: wrap; }
}
