:root {
  --bg: #121715;
  --bg-2: #1a211d;
  --card: #1c2420;
  --ink: #e6ebe7;
  --muted: #94a19a;
  --line: #2b3630;
  --field: #141b18;
  --field-border: #3a4740;
  --green: #3f8f69;
  --green-ink: #7fd0a6;
  --green-soft: #1f3a2e;
  --amber: #e2a44a;
  --amber-soft: #3a2d16;
  --red: #e07a7a;
  --red-soft: #3d2222;
  --blue: #9db3e6;
  --blue-soft: #222b3f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.3);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); line-height: 1.45; font-size: 15px; }
a { color: var(--green-ink); }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Layout */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.5rem; background: #0f1512; color: #e6ebe7; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.topbar .brand { color: #f2f6f3; text-decoration: none; font-family: Georgia, serif; font-size: 1.25rem; display: flex; align-items: center; gap: .5rem; }
.topbar .brand small { font-family: inherit; font-size: .8rem; opacity: .75; font-style: italic; }
.paw { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f6efe3 0 18%, transparent 19%), radial-gradient(circle at 65% 35%, #f6efe3 0 18%, transparent 19%), radial-gradient(circle at 22% 55%, #f6efe3 0 14%, transparent 15%), radial-gradient(circle at 78% 55%, #f6efe3 0 14%, transparent 15%), radial-gradient(ellipse at 50% 68%, #f6efe3 0 28%, transparent 29%), var(--green); display: inline-block; }
.topbar nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #b9c6bf; text-decoration: none; padding: .35rem .7rem; border-radius: 6px; font-size: .95rem; }
.topbar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.topbar nav a.active { background: var(--green-soft); color: var(--green-ink); }
.topbar .who { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.topbar .who a { color: #e6ebe7; text-decoration: none; }
.topbar form { margin: 0; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.role { display: inline-block; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; padding: .1rem .4rem; border-radius: 4px; background: rgba(255,255,255,.12); margin-left: .25rem; }
.page { max-width: 1120px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; }
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; }
.stat .n { font-size: 1.8rem; font-family: Georgia, serif; color: var(--green-ink); line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .85rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Badges */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--green-soft); color: var(--green-ink); }
.badge-due_soon { background: var(--amber-soft); color: var(--amber); }
.badge-overdue { background: var(--red-soft); color: var(--red); }
.badge-as_needed, .badge-neutral { background: #2a3430; color: var(--muted); }
.badge-type { background: var(--blue-soft); color: var(--blue); }
.chip { display: inline-block; background: #2a3430; border-radius: 6px; padding: .1rem .5rem; font-size: .8rem; margin: 0 .25rem .25rem 0; }

/* Forms */
form.stack { display: grid; gap: .9rem; }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .25rem; }
label .opt { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--field-border); border-radius: 7px; font: inherit; background: var(--field); color: var(--ink); color-scheme: dark;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(63,143,105,.45); border-color: var(--green); }
textarea { min-height: 90px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) { .row, .row-3 { grid-template-columns: 1fr; } }
.btn { display: inline-block; padding: .5rem .95rem; border-radius: 7px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; background: var(--green); color: #fff; }
.btn:hover { background: #4aa47a; }
.btn-secondary { background: var(--bg-2); color: var(--green-ink); border-color: var(--field-border); }
.btn-secondary:hover { background: #26302b; }
.btn-danger { background: var(--bg-2); color: var(--red); border-color: #5a3434; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
form.inline { display: inline; }
.errors { background: var(--red-soft); color: var(--red); border-radius: 7px; padding: .7rem 1rem; margin-bottom: 1rem; }
.errors ul { margin: 0; padding-left: 1.2rem; }
.flash { padding: .7rem 1rem; border-radius: 7px; margin-bottom: 1.25rem; }
.flash-success { background: var(--green-soft); color: var(--green-ink); }
.flash-error { background: var(--red-soft); color: var(--red); }
.help { color: var(--muted); font-size: .82rem; margin-top: .25rem; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); align-items: center; }
.list li:last-child { border-bottom: 0; }

/* Definition grid */
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 0; }
dl.props dt { color: var(--muted); font-size: .85rem; }
dl.props dd { margin: 0; white-space: pre-wrap; }

/* Login */
.auth { max-width: 400px; margin: 8vh auto 0; }
.auth .brand-big { text-align: center; margin-bottom: 1.5rem; }
.auth .brand-big .paw { width: 56px; height: 56px; }
.auth h1 { text-align: center; }

/* Bars */
.bar { height: 8px; background: #2a3430; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green); }

details summary { cursor: pointer; color: var(--green-ink); font-size: .85rem; }
pre.json { background: #0f1512; color: #c9d3cd; padding: .6rem; border-radius: 6px; font-size: .75rem; overflow-x: auto; max-height: 220px; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: 1rem; }

html { color-scheme: dark; }
::placeholder { color: #6c7a73; }

/* Card header with controls */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }

/* Checkbox dropdown */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .6rem .75rem; }
.dropdown-actions { display: flex; gap: .5rem; margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--line); }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; font-size: .92rem; padding: .25rem 0; cursor: pointer; margin: 0; }
label.check input { accent-color: var(--green); width: 16px; height: 16px; margin: 0; }

/* Multi-animal picker on the activity form */
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .25rem .75rem; max-height: 260px; overflow: auto; border: 1px solid var(--field-border); border-radius: 7px; padding: .5rem .75rem; background: var(--field); }
.picker-tools { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; flex-wrap: wrap; }
.mode { display: flex; gap: .25rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: .2rem; width: max-content; }
.mode label { margin: 0; font-weight: 500; font-size: .9rem; padding: .35rem .8rem; border-radius: 6px; cursor: pointer; color: var(--muted); }
.mode input { display: none; }
.mode input:checked + span { color: #fff; }
.mode label:has(input:checked) { background: var(--green); color: #fff; }

/* Reports */
.day-head { display: flex; justify-content: space-between; align-items: baseline; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: .4rem .7rem; margin: .9rem 0 .25rem; }
table.compact th, table.compact td { padding: .4rem .5rem; }
.card-head h2 a { text-decoration: none; }

/* Photo gallery */
.gallery-card { margin-bottom: 1rem; }
.gallery-stage { position: relative; background: #0b0f0d; border-radius: 8px; overflow: hidden; min-height: 200px; }
.gallery-slide { margin: 0; }
.gallery-slide a { display: block; }
.gallery-slide a { display: flex; justify-content: center; align-items: center; min-height: 200px; padding: .75rem; }
.gallery-slide img { display: block; width: auto; height: auto; max-width: min(400px, 100%); max-height: 400px; border-radius: 4px; }
.gallery-slide figcaption { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .75rem; font-size: .9rem; background: var(--bg-2); border-top: 1px solid var(--line); }
.gallery-nav { position: absolute; top: 0; bottom: 38px; width: 56px; border: 0; background: linear-gradient(90deg, rgba(0,0,0,.45), transparent); color: #fff; font-size: 2.4rem; cursor: pointer; opacity: .75; }
.gallery-nav:hover { opacity: 1; }
.gallery-nav.prev { left: 0; }
.gallery-nav.next { right: 0; background: linear-gradient(270deg, rgba(0,0,0,.45), transparent); }
.gallery-thumbs { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.thumb { position: relative; }
.thumb-btn { display: flex; align-items: center; justify-content: center; padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; background: #0b0f0d; cursor: pointer; width: 84px; height: 84px; }
.thumb-btn img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; }
.thumb.active .thumb-btn { border-color: var(--green-ink); }
.thumb-menu { position: absolute; top: 4px; right: 4px; }
.thumb-menu > summary { list-style: none; cursor: pointer; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1rem; line-height: 1; }
.thumb-menu > summary::-webkit-details-marker { display: none; }
.thumb-menu .dropdown-panel { left: 0; right: auto; min-width: 200px; }
.upload-form label { cursor: pointer; }

/* Avatar on lists */
/* Avatars are locked to a 75px box; the image keeps its aspect ratio inside it. */
.avatar-box { width: 75px; height: 75px; border-radius: 8px; background: var(--bg-2); display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; }
.avatar-box img { display: block; width: auto; height: auto; max-width: 75px; max-height: 75px; }
.avatar-placeholder { width: 75px; height: 75px; border-radius: 8px; background: var(--bg-2); border: 1px dashed var(--line); flex: none; }
.with-avatar { display: flex; align-items: center; gap: .6rem; }

.avatar-link { display: block; flex: none; border-radius: 8px; transition: transform .12s ease, box-shadow .12s ease; }
.avatar-link:hover, .avatar-link:focus-visible { transform: translateY(-1px); box-shadow: 0 0 0 2px var(--green); outline: none; }
