:root {
  --bg: #FBF6EC;
  --bg-2: #F4ECDB;
  --card: #FFFFFF;
  --ink: #2A1A0E;
  --ink-2: #5C4636;
  --ink-3: #8A7563;
  --line: #E8DCC4;
  --line-2: #D9C9A8;
  --brown: #4A2C1A;
  --brown-deep: #2E1A0E;
  --green: #3A6B33;
  --green-deep: #2A5024;
  --purple: #6B3FA0;
  --purple-deep: #4F2C7A;
  --heart: #D94545;
  --amber: #E8A33D;
  --shadow-sm: 0 1px 2px rgba(74,44,26,0.06), 0 1px 1px rgba(74,44,26,0.04);
  --shadow-md: 0 4px 14px -4px rgba(74,44,26,0.12), 0 2px 4px rgba(74,44,26,0.06);
  --shadow-lg: 0 18px 40px -16px rgba(74,44,26,0.22), 0 4px 10px rgba(74,44,26,0.06);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

.script { font-family: 'Caveat', cursive; font-weight: 700; }
.serif  { font-family: 'Lora', Georgia, serif; }
.mono   { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }

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

/* Top nav */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topnav .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topnav .brand img { height: 44px; width: auto; display: block; }
.topnav .brand-text { display: flex; flex-direction: column; line-height: 1; }
.topnav .brand-text .a { font-family: 'Caveat', cursive; font-weight: 700; font-size: 22px; color: var(--brown); }
.topnav .brand-text .b { font-size: 10px; letter-spacing: 0.18em; color: var(--green); font-weight: 700; margin-top: 2px; }
.topnav .nav-tabs { display: flex; gap: 4px; }
.topnav .nav-tabs button {
  background: transparent;
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}
.topnav .nav-tabs button.active { background: var(--brown); color: #fff; }
.topnav .user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}
.topnav .user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--purple); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.topnav .user-chip .meta { display: flex; flex-direction: column; line-height: 1.1; color: var(--ink); }
.topnav .user-chip .meta .name { font-weight: 700; font-size: 13px; color: var(--ink); }
.topnav .user-chip .meta .role { font-size: 11px; color: var(--ink-3); }
.topnav .icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brown); color: #fff; box-shadow: var(--shadow-md); }
.btn-primary:hover { background: var(--brown-deep); }
.btn-green { background: var(--green); color: #fff; box-shadow: var(--shadow-md); }
.btn-green:hover { background: var(--green-deep); }
.btn-purple { background: var(--purple); color: #fff; box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn-outline:hover { background: var(--bg-2); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 14px 22px; font-size: 15px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-danger { background: #fff; color: var(--heart); border-color: #F2C7C7; }
.btn-danger:hover { background: #FDF0F0; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 700; color: var(--ink-2); letter-spacing: 0.02em; }
.input, .textarea, .select {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s ease, box-shadow .15s ease;
}
/* datetime-local has UA-imposed min-width that breaks two-column grids */
input[type="datetime-local"].input,
input[type="date"].input,
input[type="time"].input {
  min-width: 0;
  max-width: 100%;
}
.field { min-width: 0; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brown);
  box-shadow: 0 0 0 4px rgba(74,44,26,0.08);
}
.textarea { min-height: 90px; resize: vertical; line-height: 1.45; }

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--bg);
}
.login-art {
  position: relative;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.login-art .logo {
  width: 92%;
  max-width: 720px;
  filter: drop-shadow(0 14px 28px rgba(74,44,26,0.10));
  position: relative;
  z-index: 1;
}
.login-art .paws {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
}
.login-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.login-card {
  width: 100%;
  max-width: 420px;
}
.login-card h1 {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 44px;
  color: var(--brown);
  margin: 0 0 4px;
  line-height: 1;
}
.login-card .sub {
  color: var(--ink-3);
  font-size: 14px;
  margin-bottom: 24px;
}
.role-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-2);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 22px;
  position: relative;
}
.role-toggle button {
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-3);
  border-radius: 10px;
  z-index: 1;
  transition: color .2s ease;
}
.role-toggle button.active { color: #fff; }
.role-toggle .slider {
  position: absolute;
  top: 4px; bottom: 4px;
  width: calc(50% - 4px);
  border-radius: 10px;
  background: var(--brown);
  transition: transform .25s cubic-bezier(.5,0,.2,1), background .25s ease;
  box-shadow: var(--shadow-sm);
}
.role-toggle[data-role="admin"] .slider { transform: translateX(calc(100% + 0px)); background: var(--purple); }
.tiny-hint { font-size: 12px; color: var(--ink-3); margin-top: 12px; }
.divider-or { display:flex; align-items:center; gap:10px; margin: 18px 0; color: var(--ink-3); font-size: 12px;}
.divider-or::before, .divider-or::after { content:""; flex:1; height:1px; background: var(--line); }

/* Page layout */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px;
  width: 100%;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 20px;
}
.page-head h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.page-head .hello {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 28px;
  color: var(--green);
  margin-bottom: 4px;
  line-height: 1.15;
}
.page-head .sub { color: var(--ink-3); font-size: 14px; margin-top: 4px; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat.stat-clickable {
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.stat.stat-clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-2);
}
.stat .icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.stat .num { font-size: 22px; font-weight: 800; line-height: 1; }
.stat .lbl { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* Pet cards grid */
.pet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.pet-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.pet-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.pet-card .photo {
  aspect-ratio: 4/3;
  background: var(--bg-2);
  position: relative;
  overflow: hidden;
}
.pet-card .photo .placeholder-pet {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(135deg, #F4ECDB, #F4ECDB 10px, #ECE0C6 10px, #ECE0C6 20px);
  color: var(--ink-3);
  font-size: 36px;
}
.pet-card .photo img { width: 100%; height: 100%; object-fit: cover; }
.pet-card .badge-tl {
  position: absolute; top: 10px; left: 10px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}
.pet-card .badge-tr {
  position: absolute; top: 10px; right: 10px;
  background: var(--heart);
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px;
}
.pet-card .body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; }
.pet-card .name { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.pet-card .meta { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.pet-card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink-2);
}
.tag.green { background: #E6F0E1; color: var(--green-deep); }
.tag.purple { background: #EDE3F7; color: var(--purple-deep); }
.tag.amber { background: #FCEFD3; color: #7A5615; }
.tag.red { background: #FBE0E0; color: #8B2929; }

/* Add pet card (dashed) */
.add-pet {
  border: 2px dashed var(--line-2);
  border-radius: 20px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-3);
  font-weight: 700;
  font-size: 14px;
  min-height: 320px;
  transition: background .15s ease, border-color .15s ease;
}
.add-pet:hover { background: var(--bg-2); border-color: var(--brown); color: var(--brown); }
.add-pet .plus {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  color: var(--brown);
}

/* Pet detail */
.detail-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 22px;
}
.detail-hero {
  position: relative;
  aspect-ratio: 16/10;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-2);
}
.detail-hero .placeholder-pet {
  width: 100%; height: 100%;
  background: repeating-linear-gradient(135deg, #F4ECDB, #F4ECDB 14px, #ECE0C6 14px, #ECE0C6 28px);
  display: flex; align-items: center; justify-content: center;
  font-size: 80px;
}
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero .upload-cta {
  position: absolute;
  bottom: 14px; right: 14px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  display: inline-flex; gap: 6px; align-items: center;
}
.gallery {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.gallery .thumb {
  aspect-ratio: 1/1;
  border-radius: 10px;
  background: repeating-linear-gradient(45deg, #F4ECDB, #F4ECDB 8px, #ECE0C6 8px, #ECE0C6 16px);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid transparent;
}
.gallery .thumb.active { border-color: var(--brown); }
.gallery .thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery .thumb.add {
  background: #fff;
  border: 1.5px dashed var(--line-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3);
  font-size: 22px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.tabs button {
  flex: 1;
  background: transparent;
  border: none;
  padding: 9px 12px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-3);
}
.tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.tabs button .tab-count {
  margin-left: 4px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--brown);
  color: #fff;
  font-weight: 800;
}
.tabs button.active .tab-count { background: var(--brown); }

/* Medication / Care list */
.med-list { display: flex; flex-direction: column; gap: 10px; }
.med-item {
  display: flex;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  align-items: flex-start;
}
.med-item .pill-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: #FCEFD3;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #7A5615;
}
.med-item .pill-icon.green { background: #E6F0E1; color: var(--green-deep); }
.med-item .pill-icon.purple { background: #EDE3F7; color: var(--purple-deep); }
.med-item .pill-icon.red { background: #FBE0E0; color: #8B2929; }
.med-item .info { flex: 1; }
.med-item .info .t { font-weight: 700; font-size: 14px; }
.med-item .info .d { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.med-item .info .when { font-size: 11px; font-weight: 600; color: var(--green-deep); margin-top: 6px; display: inline-block; padding: 2px 8px; background: #E6F0E1; border-radius: 999px; }
.med-item .more { color: var(--ink-3); padding: 4px; }

/* Notes feed */
.note {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.note + .note { margin-top: 10px; }
.note .head {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--ink-3);
  margin-bottom: 8px;
}
.note .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.note .body { font-size: 14px; line-height: 1.55; }

/* Homes list (admin) */
.home-row {
  display: grid;
  grid-template-columns: 2fr 1.4fr 1fr 1fr 0.6fr;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.home-row:hover { background: var(--bg-2); }
.home-row .h-name { display: flex; gap: 12px; align-items: center; }
.home-row .h-name .icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--brown); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.home-row .h-name .name { font-weight: 700; }
.home-row .h-name .addr { font-size: 12px; color: var(--ink-3); }
.home-row .pets-mini { display: flex; gap: -8px; }
.pet-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--bg-2);
  margin-left: -8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--brown);
}
.pet-avatar:first-child { margin-left: 0; }
.pet-avatar.dog { background: #F4D6A3; }
.pet-avatar.cat { background: #D9C9E8; }
.pet-avatar.other { background: #C7DDC1; }
.status-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
}
.status-dot::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
}
.status-dot.idle::before { background: var(--ink-3); }
.status-dot.urgent::before { background: var(--heart); }

/* Section */
.section { margin-top: 26px; }
.section h2 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px;
}
.section h2 .count { font-size: 12px; color: var(--ink-3); font-weight: 600; background: var(--bg-2); padding: 2px 8px; border-radius: 999px; }

.between { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }

/* Two-col detail right column */
.kv {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; color: var(--ink); }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  background: #FBE0E0;
  color: #6B1F1F;
  font-size: 13px;
  border: 1px solid #F2C7C7;
}
.alert .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--heart); flex-shrink: 0; margin-top: 1px; }
.alert .dot::before { content: "!"; color: white; font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }

/* Admin settings */
.settings-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 22px;
}
.settings-nav { display: flex; flex-direction: column; gap: 4px; }
.settings-nav button {
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-2);
}
.settings-nav button.active { background: var(--brown); color: #fff; }
.settings-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  gap: 18px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row .label { font-weight: 700; font-size: 14px; }
.settings-row .desc { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* Switch */
.switch { position: relative; width: 42px; height: 24px; background: var(--line); border-radius: 999px; cursor: pointer; transition: background .2s; flex-shrink: 0; border: none; padding: 0; }
.switch.on { background: var(--green); }
.switch::after {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch.on::after { transform: translateX(18px); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(46,26,14,0.4);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade .15s ease;
}
.modal {
  background: #fff;
  border-radius: 20px;
  max-width: 480px;
  width: 100%;
  max-height: calc(100vh - 40px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: pop .2s ease;
}
.modal.modal-lg { max-width: 640px; }
.modal .head { padding: 20px 22px 4px; flex-shrink: 0; }
.modal .head h3 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.modal .head p { margin: 4px 0 0; color: var(--ink-3); font-size: 13px; }
.modal .body {
  padding: 16px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
}
.modal .foot { padding: 14px 22px; background: var(--bg-2); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; border-top: 1px solid var(--line); }

/* Section heading inside long modals */
.form-section {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 6px 0 2px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}
.form-section:first-child { border-top: none; margin-top: -4px; padding-top: 0; }

/* Input-with-unit suffix */
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }
.input-row .select { width: 90px; flex-shrink: 0; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brown-deep);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: toast-in .25s cubic-bezier(.5,0,.2,1);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Empty placeholder for photos */
.placeholder-pet svg { width: 60%; height: 60%; opacity: 0.4; }

/* Highlight flash for scrolled-to section */
.flash-highlight {
  animation: flash-highlight 1.4s ease;
}
@keyframes flash-highlight {
  0%, 100% { background: transparent; }
  20%      { background: color-mix(in oklab, var(--green) 8%, transparent); }
}

/* ====================================================
   SETTINGS GRIDS — Fixed counts at desktop, responsive
   Theme: 3×3 (9 themes)
   Panels: 4×2 (8 panels)
   Typography: 4×1 (4 fonts)
   ==================================================== */
.theme-grid       { grid-template-columns: repeat(3, 1fr); }
.panels-grid      { grid-template-columns: repeat(4, 1fr); }
.typography-grid  { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 720px) {
  .theme-grid      { grid-template-columns: repeat(2, 1fr); }
  .panels-grid     { grid-template-columns: repeat(2, 1fr); }
  .typography-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .theme-grid      { grid-template-columns: 1fr; }
  .panels-grid     { grid-template-columns: repeat(2, 1fr); }
  .typography-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ====================================================
   MOBILE RESPONSIVENESS
   ==================================================== */
@media (max-width: 720px) {
  /* Compact top nav */
  .topnav { padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  .topnav .brand img { height: 36px; }
  .topnav .brand-text { display: none; }
  .topnav .nav-tabs { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 6px 0; flex-wrap: nowrap; }
  .topnav .nav-tabs::-webkit-scrollbar { display: none; }
  .topnav .nav-tabs button { padding: 7px 12px; font-size: 13px; flex-shrink: 0; }
  .topnav .user-chip { padding: 4px 8px 4px 4px; }
  .topnav .user-chip .avatar { width: 26px; height: 26px; font-size: 11px; }
  .topnav .user-chip .meta .name { font-size: 12px; }
  .topnav .user-chip .meta .role { font-size: 10px; }
  .topnav .icon-btn { width: 32px; height: 32px; }

  /* Pages */
  .page { padding: 18px 14px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
  .page-head h1 { font-size: 24px; }
  .page-head .hello { font-size: 20px; }
  .page-head .row { flex-wrap: wrap; }

  /* Stats stack 2x2 */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat .icon { width: 36px; height: 36px; }
  .stat .num { font-size: 18px; }
  .stat .lbl { font-size: 11px; }

  /* Card spacing */
  .card-pad { padding: 16px; }

  /* Pet grid single column on phones */
  .pet-grid { grid-template-columns: 1fr; gap: 12px; }
  .pet-card .photo { aspect-ratio: 16/10; }

  /* Detail page stacks */
  .detail-grid { grid-template-columns: 1fr; gap: 14px; }

  /* Home rows stack */
  .home-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px;
  }
  .home-row > * { width: 100%; }
  .home-row .col-hide { display: none; }

  /* Settings grid stacks */
  .settings-grid { grid-template-columns: 1fr; gap: 14px; }
  .settings-nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 6px; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav button { white-space: nowrap; flex-shrink: 0; }

  /* Section heads */
  .section h2 { font-size: 16px; }

  /* Login stacks */
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { min-height: 180px; padding: 20px 0; }
  .login-art .logo { width: 60%; max-width: 280px; }
  .login-form { padding: 24px 18px; }
  .login-card h1 { font-size: 32px; }

  /* Modals */
  .modal { max-width: 100%; margin: 0; max-height: 100vh; border-radius: 16px 16px 0 0; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal .head { padding: 16px 18px 4px; }
  .modal .body { padding: 14px 18px 18px; }
  .modal .foot { padding: 12px 18px; flex-wrap: wrap; }
  .modal .foot .btn { flex: 1; min-width: 0; }

  /* Tweaks panel scoots in */
  .tabs { padding: 3px; }
  .tabs button { padding: 8px 8px; font-size: 12px; }

  /* Tables — invoice */
  .invoice-print table { font-size: 11px; }

  /* Toast */
  .toast { bottom: 12px; left: 12px; right: 12px; transform: none; width: auto; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .page-head h1 { font-size: 22px; }
  .gallery { grid-template-columns: repeat(4, 1fr); }
}

/* ====================================================
   CREDITS — tiny footer link
   ==================================================== */
.app-credits {
  position: fixed;
  right: 16px;
  bottom: 12px;
  font-size: 10px;
  color: var(--ink-3);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.04em;
  opacity: 0.55;
  z-index: 50;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--card) 60%, transparent);
  backdrop-filter: blur(4px);
  transition: opacity .2s ease;
}
.app-credits:hover { opacity: 1; }
@media (max-width: 720px) {
  .app-credits { right: 8px; bottom: 8px; font-size: 9px; padding: 3px 8px; }
}
@media print {
  .app-credits { display: none !important; }
}

/* ====================================================
   INBOX / NOTIFICATIONS
   ==================================================== */
.inbox-popover {
  position: fixed;
  top: 64px;
  right: 12px;
  width: 380px;
  max-width: calc(100vw - 24px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px -16px rgba(0,0,0,0.22), 0 4px 10px rgba(0,0,0,0.06);
  z-index: 200;
  overflow: hidden;
  animation: pop .2s ease;
}
.inbox-popover-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.inbox-unread-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--heart);
  color: #fff;
  letter-spacing: 0.04em;
}
.inbox-popover-list { max-height: 380px; overflow-y: auto; }
.inbox-popover-foot {
  border-top: 1px solid var(--line);
  padding: 4px 8px;
}

.inbox-row {
  width: 100%;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  position: relative;
  transition: background .12s ease;
}
.inbox-row:last-child { border-bottom: none; }
.inbox-row:hover { background: var(--bg-2); }
.inbox-row-unread { background: color-mix(in oklab, var(--brown) 4%, transparent); }
.inbox-row-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.inbox-row-body { flex: 1; min-width: 0; }
.inbox-row-title { font-weight: 700; font-size: 14px; line-height: 1.3; }
.inbox-row-summary {
  font-size: 12px; color: var(--ink-2);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.inbox-row-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-3);
  margin-top: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.inbox-row-dot {
  position: absolute;
  top: 18px; right: 14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brown);
}
.inbox-row-compact { padding: 10px 14px; }
.inbox-row-compact .inbox-row-icon { width: 30px; height: 30px; border-radius: 8px; }
.inbox-row-compact .inbox-row-title { font-size: 13px; }

/* Email modal letterhead */
.email-letterhead { padding: 4px; }
.email-from {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.email-from-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--brown);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

/* Bell needs to position the unread dot reliably */
.bell-wrapper { position: relative; }
.bell-wrapper .bell-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--heart);
  border: 2px solid var(--card);
}

/* Tweak-driven body classes (restored — keep last) */
body.hide-logo-nav .topnav .brand img { display: none; }
body.hide-hello .hello { display: none; }
body.hide-hello .hello-line { display: none; }
