:root {
  --bg: #eaf3f2;
  --bg-soft: #dbeae7;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-alt: #f5fbfa;
  --line: #cce0dc;
  --ink: #112427;
  --ink-soft: #4a656a;
  --brand: #0f8f78;
  --brand-strong: #0a6f5e;
  --accent: #ff7d4d;
  --danger: #c23a3a;
  --shadow-xl: 0 24px 54px rgba(17, 36, 39, 0.14);
  --shadow-lg: 0 14px 34px rgba(17, 36, 39, 0.11);
  --shadow-sm: 0 8px 18px rgba(17, 36, 39, 0.07);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: "Work Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% -12%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0) 46%),
    radial-gradient(circle at 92% 8%, rgba(15, 143, 120, 0.18) 0%, rgba(15, 143, 120, 0) 42%),
    radial-gradient(circle at 74% 112%, rgba(255, 125, 77, 0.16) 0%, rgba(255, 125, 77, 0) 42%),
    linear-gradient(155deg, var(--bg) 0%, #edf6f4 50%, var(--bg-soft) 100%);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: "Sora", "Work Sans", sans-serif;
  letter-spacing: -0.022em;
}

p {
  margin: 0;
}

.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 18px 50px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
}

.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 24px;
  border-color: rgba(15, 143, 120, 0.24);
  box-shadow: var(--shadow-xl);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.hero::before {
  width: 320px;
  height: 320px;
  right: -120px;
  top: -150px;
  background: radial-gradient(circle, rgba(15, 143, 120, 0.2) 0%, rgba(15, 143, 120, 0) 70%);
}

.hero::after {
  width: 280px;
  height: 280px;
  right: 120px;
  bottom: -180px;
  background: radial-gradient(circle, rgba(255, 125, 77, 0.2) 0%, rgba(255, 125, 77, 0) 68%);
}

.hero > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-strong);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.hero h1 {
  font-size: clamp(1.7rem, 3.3vw, 2.35rem);
  margin-bottom: 8px;
}

.hero-copy {
  color: var(--ink-soft);
  max-width: 660px;
  line-height: 1.5;
  font-size: 1rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.auth-card {
  margin-top: 14px;
  padding: 22px;
}

.auth-card p {
  margin-top: 8px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.auth-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 14px;
}

.side {
  padding: 18px;
  position: sticky;
  top: 14px;
  align-self: start;
  background:
    linear-gradient(155deg, rgba(13, 119, 101, 0.96) 0%, rgba(10, 97, 82, 0.96) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0));
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-xl);
}

.side h2 {
  margin-bottom: 10px;
  color: #ffffff;
}

.side .muted {
  color: rgba(234, 255, 250, 0.86);
}

.muted {
  color: var(--ink-soft);
}

.sync-state {
  margin-top: 8px;
  min-height: 1.25rem;
  font-weight: 600;
}

.locale-control {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.locale-control label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: rgba(236, 255, 251, 0.9);
}

.locale-control select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.94);
  color: #14383d;
  padding: 8px 10px;
  font-size: 0.86rem;
}

.active-pet-scope {
  margin-top: 14px;
  padding: 13px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background:
    linear-gradient(170deg, rgba(255, 255, 255, 0.18) 0%, rgba(203, 236, 228, 0.08) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(3px);
}

.active-pet-scope label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: rgba(236, 255, 251, 0.9);
}

.active-pet-picker {
  margin-top: 8px;
  position: relative;
}

.active-pet-trigger {
  width: 100%;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.98) 0%, rgba(240, 251, 248, 0.94) 100%);
  color: #123337;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  text-align: left;
  box-shadow: 0 9px 18px rgba(5, 40, 34, 0.16);
}

.active-pet-trigger:hover {
  filter: none;
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 10px 20px rgba(5, 40, 34, 0.18);
}

.active-pet-trigger[aria-expanded="true"] {
  border-color: rgba(15, 143, 120, 0.55);
  box-shadow:
    0 0 0 2px rgba(15, 143, 120, 0.2),
    0 14px 24px rgba(5, 40, 34, 0.22);
}

.active-pet-trigger:disabled {
  opacity: 0.68;
  cursor: not-allowed;
}

.active-pet-avatar-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.active-pet-avatar-wrap .pet-avatar {
  --avatar-size: 36px;
}

.active-pet-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.active-pet-name {
  font-weight: 700;
  color: #13363a;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-pet-meta {
  margin-top: 2px;
  font-size: 0.76rem;
  color: #547178;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-pet-chevron {
  font-size: 0.86rem;
  color: #32686c;
  flex-shrink: 0;
}

.active-pet-menu {
  position: absolute;
  z-index: 32;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.98) 0%, rgba(241, 251, 248, 0.95) 100%);
  box-shadow: 0 16px 30px rgba(5, 40, 34, 0.24);
  backdrop-filter: blur(8px);
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
}

.active-pet-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #15383d;
  text-align: left;
  padding: 7px 8px;
}

.active-pet-option:hover {
  filter: none;
  background: rgba(15, 143, 120, 0.1);
  border-color: rgba(15, 143, 120, 0.18);
}

.active-pet-option.active {
  background: rgba(15, 143, 120, 0.18);
  border-color: rgba(15, 143, 120, 0.3);
  box-shadow: inset 0 0 0 1px rgba(15, 143, 120, 0.16);
}

.active-pet-option-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.active-pet-option-name {
  display: block;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.active-pet-option-meta {
  margin-top: 1px;
  display: block;
  font-size: 0.74rem;
  color: #5c7a80;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.active-pet-scope .muted {
  margin-top: 8px;
  font-size: 0.78rem;
  color: rgba(236, 255, 251, 0.82);
  line-height: 1.35;
}

.tab-nav {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.tab {
  justify-content: flex-start;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.11);
  color: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.18);
}

.tab:hover {
  filter: brightness(1.03);
}

.tab.active {
  background: #ffffff;
  color: var(--brand-strong);
  border-color: rgba(255, 255, 255, 0.45);
}

.main-column {
  display: grid;
  gap: 14px;
}

.tab-panel {
  padding: 18px;
}

.stats-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.stat {
  border-radius: 16px;
  padding: 14px;
  background:
    linear-gradient(148deg, #ffffff 0%, #eef9f6 62%, #e5f4f0 100%);
  border: 1px solid #cfe5df;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 1.42rem;
  font-weight: 700;
  font-family: "Sora", "Work Sans", sans-serif;
}

.stat-label {
  margin-top: 4px;
  color: #2b5056;
  font-size: 0.84rem;
  font-weight: 600;
}

.stat-hint {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.dashboard-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.chart-block {
  min-height: 320px;
}

.chart-wrap {
  margin-top: 10px;
  position: relative;
  height: 235px;
  border-radius: 14px;
  border: 1px solid #d8e8e4;
  background: linear-gradient(180deg, #ffffff 0%, #f2faf8 100%);
  padding: 10px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 18px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.split {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(300px, 0.92fr) minmax(0, 1.08fr);
  gap: 12px;
}

.block {
  position: relative;
  overflow: hidden;
  border: 1px solid #d6e5e2;
  border-radius: 16px;
  padding: 12px;
  background:
    linear-gradient(165deg, #fcfefd 0%, var(--surface-alt) 100%);
  box-shadow: 0 10px 24px rgba(17, 36, 39, 0.06);
}

.block::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(15, 143, 120, 0.34) 0%, rgba(15, 143, 120, 0) 60%);
  pointer-events: none;
}

.block h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.overview-insights {
  margin-top: 14px;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.constrained-list {
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.constrained-list > * {
  min-width: 0;
}

.item {
  position: relative;
  overflow: hidden;
  --accent-strip: linear-gradient(180deg, #12a188 0%, #0f8f78 100%);
  color: var(--ink);
  width: 100%;
  text-align: left;
  border: 1px solid #d5e4e1;
  background: #ffffff;
  border-radius: 13px;
  padding: 12px;
  min-height: 72px;
  box-shadow: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent-strip);
  transition: width 0.18s ease, opacity 0.18s ease;
  opacity: 0.82;
}

.item:hover {
  transform: translateY(-1px);
  border-color: #9fcfc3;
  box-shadow: 0 6px 14px rgba(17, 36, 39, 0.06);
}

.item.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(15, 143, 120, 0.18);
}

.item.active::before {
  width: 5px;
  opacity: 1;
}

button.item {
  display: block;
  color: var(--ink);
  background: #ffffff;
  padding: 12px;
  border-color: #d5e4e1;
  box-shadow: none;
  filter: none;
}

button.item:hover {
  filter: none;
}

.item-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.item-body {
  flex: 1 1 auto;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.item[data-accent="pet-dog"] { --accent-strip: linear-gradient(180deg, #0fa37f 0%, #0d8769 100%); }
.item[data-accent="pet-cat"] { --accent-strip: linear-gradient(180deg, #f59e3f 0%, #ec6d2d 100%); }
.item[data-accent="pet-bird"] { --accent-strip: linear-gradient(180deg, #4a9df8 0%, #2d7dd2 100%); }
.item[data-accent="pet-small"] { --accent-strip: linear-gradient(180deg, #9d7bff 0%, #6b59d3 100%); }
.item[data-accent="pet-other"] { --accent-strip: linear-gradient(180deg, #5fa8a7 0%, #3b7f86 100%); }

.item[data-accent="reminder-vaccine"] { --accent-strip: linear-gradient(180deg, #0ba38b 0%, #0a8574 100%); }
.item[data-accent="reminder-medication"] { --accent-strip: linear-gradient(180deg, #46a6ff 0%, #277dcf 100%); }
.item[data-accent="reminder-feeding"] { --accent-strip: linear-gradient(180deg, #ffa455 0%, #ec7434 100%); }
.item[data-accent="reminder-visit"] { --accent-strip: linear-gradient(180deg, #8d84ff 0%, #655cd6 100%); }
.item[data-accent="reminder-grooming"] { --accent-strip: linear-gradient(180deg, #f07ca8 0%, #cf4f84 100%); }
.item[data-accent="reminder-other"] { --accent-strip: linear-gradient(180deg, #5a9ea3 0%, #447e82 100%); }

.item[data-accent="document-vet"] { --accent-strip: linear-gradient(180deg, #0f9f88 0%, #0d826f 100%); }
.item[data-accent="document-vaccine"] { --accent-strip: linear-gradient(180deg, #4aa8ff 0%, #2d7fd3 100%); }
.item[data-accent="document-lab"] { --accent-strip: linear-gradient(180deg, #8e85ff 0%, #665cd7 100%); }
.item[data-accent="document-rx"] { --accent-strip: linear-gradient(180deg, #ff9f55 0%, #e9702b 100%); }
.item[data-accent="document-insurance"] { --accent-strip: linear-gradient(180deg, #f689b3 0%, #d6608f 100%); }
.item[data-accent="document-other"] { --accent-strip: linear-gradient(180deg, #5fa8a7 0%, #3b7f86 100%); }

.item[data-accent="weight"] { --accent-strip: linear-gradient(180deg, #52b7ff 0%, #2d88d9 100%); }
.item[data-accent="diet"] { --accent-strip: linear-gradient(180deg, #ffa965 0%, #ea7b37 100%); }
.item[data-accent="vet-note"] { --accent-strip: linear-gradient(180deg, #5aa4ff 0%, #2f7fd3 100%); }
.item[data-accent="vaccination"] { --accent-strip: linear-gradient(180deg, #0ea68c 0%, #0a8572 100%); }
.item[data-accent="caregiver"] { --accent-strip: linear-gradient(180deg, #a080ff 0%, #7359d9 100%); }
.item[data-accent="supply"] { --accent-strip: linear-gradient(180deg, #f6a04a 0%, #e7772e 100%); }
.item[data-accent="travel"] { --accent-strip: linear-gradient(180deg, #4cc1b5 0%, #2f8f89 100%); }

.item-title {
  font-weight: 600;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.34;
  white-space: normal;
}

.item-meta {
  font-size: 0.84rem;
  color: var(--ink-soft);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.32;
  white-space: normal;
}

.item-meta:empty {
  display: none;
}

.item-details {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
}

.item-detail {
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.35;
}

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

.compact-head {
  margin-top: 4px;
}

.list-toolbar {
  margin: 8px 0 10px;
}

.filter-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 10px;
}

.filter-row select {
  width: 100%;
  min-width: 0;
  font-size: 0.84rem;
  padding: 9px 10px;
}

.search-input {
  width: 100%;
  border-radius: 999px;
  padding: 10px 14px;
  border-color: #c8ddd8;
  background:
    linear-gradient(180deg, #ffffff 0%, #f4fbf9 100%);
}

.search-input::placeholder {
  color: #708a8f;
}

.detail-view {
  margin-top: 8px;
  border: 1px solid #d8e8e4;
  border-radius: 14px;
  background:
    linear-gradient(170deg, #ffffff 0%, #f3faf8 100%);
  padding: 10px;
  min-height: 112px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.detail-row {
  border: 1px solid #d6e5e2;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.detail-row:hover {
  transform: translateY(-1px);
  border-color: #9fcfc3;
  box-shadow: 0 8px 16px rgba(17, 36, 39, 0.08);
}

.detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 700;
}

.detail-value {
  margin-top: 4px;
  font-size: 0.92rem;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.pet-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid #d5e5e2;
  border-radius: 12px;
  background: #ffffff;
  margin-bottom: 10px;
}

.pet-hero-copy h4 {
  margin: 0;
  font-size: 1rem;
}

.pet-avatar {
  --avatar-size: 34px;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(17, 36, 39, 0.14);
  background: linear-gradient(145deg, #f7fcfb 0%, #eef6f4 100%);
  flex-shrink: 0;
}

.pet-avatar.hero-avatar {
  --avatar-size: 64px;
}

.pet-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pet-avatar-fallback {
  font-size: calc(var(--avatar-size) * 0.46);
  line-height: 1;
}

.pet-avatar[data-color="orange"] { background: linear-gradient(145deg, #fff4e8 0%, #ffe0c3 100%); }
.pet-avatar[data-color="teal"] { background: linear-gradient(145deg, #e8fbf7 0%, #c6f0e7 100%); }
.pet-avatar[data-color="blue"] { background: linear-gradient(145deg, #eaf3ff 0%, #cadeff 100%); }
.pet-avatar[data-color="purple"] { background: linear-gradient(145deg, #f1ecff 0%, #ddd0ff 100%); }
.pet-avatar[data-color="pink"] { background: linear-gradient(145deg, #ffeef5 0%, #ffd5e7 100%); }
.pet-avatar[data-color="green"] { background: linear-gradient(145deg, #eaf8ee 0%, #cdeecd 100%); }

.doc-thumb {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  border: 1px solid #d1e3df;
  overflow: hidden;
  flex-shrink: 0;
  background: #f3faf8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.78);
}

.doc-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-media {
  margin: 0 0 10px;
  border: 1px solid #d5e5e2;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}

.detail-media img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  cursor: zoom-in;
}

.doc-image-shell {
  display: grid;
  gap: 8px;
}

.doc-image-preview {
  border: 1px dashed #c7ddd8;
  border-radius: 12px;
  min-height: 132px;
  background: #f6fbfa;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #628188;
  overflow: hidden;
  padding: 8px;
}

.doc-image-preview.empty {
  font-size: 0.86rem;
}

.doc-image-preview img {
  width: 100%;
  max-height: 230px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
}

.doc-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.doc-image-actions .ghost {
  padding: 8px 10px;
  font-size: 0.82rem;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  grid-template-rows: auto 1fr;
  background: rgba(5, 10, 12, 0.92);
  backdrop-filter: blur(2px);
}

.image-lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.image-lightbox-title {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.92rem;
  max-width: 54vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-lightbox-actions {
  display: flex;
  gap: 8px;
}

.image-lightbox-actions .ghost {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.26);
  padding: 8px 10px;
  box-shadow: none;
}

.image-lightbox-viewport {
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: zoom-in;
}

.image-lightbox-viewport img {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.14s ease;
}

.image-lightbox[hidden] {
  display: none;
}

.editor-shell {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #cfe2de;
  border-radius: 14px;
  background:
    linear-gradient(165deg, #ffffff 0%, #eef9f6 100%);
}

.editor-shell::before {
  content: "Edit mode";
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
  border: 1px solid #caded9;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #3e646a;
  background: rgba(255, 255, 255, 0.86);
}

.editor-shell[data-mode="create"] {
  border-color: rgba(15, 143, 120, 0.45);
  box-shadow: inset 0 0 0 1px rgba(15, 143, 120, 0.08);
}

.editor-shell[data-mode="create"]::before {
  content: "Create mode";
  border-color: rgba(15, 143, 120, 0.32);
  color: #0a6f5e;
  background: rgba(15, 143, 120, 0.08);
}

.editor-shell[data-mode="edit"] {
  border-color: #d4e5e1;
}

.records-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.records-grid > .block {
  display: grid;
  align-content: start;
  gap: 8px;
}

#tab-records .records-grid {
  grid-template-columns: 1fr;
}

.record-panel {
  min-height: 620px;
}

.record-panel[hidden] {
  display: none !important;
}

.record-panel .constrained-list {
  max-height: 320px;
  padding-right: 6px;
}

.record-panel .item {
  padding: 12px 12px 12px 14px;
  min-height: 78px;
}

.record-nav {
  margin-top: 12px;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid #cfdfdb;
  background:
    linear-gradient(160deg, #ffffff 0%, #eff8f6 100%);
}

.record-switch {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  background: transparent;
  color: #2f565c;
  box-shadow: none;
  font-weight: 600;
}

.record-switch:hover {
  filter: none;
  background: rgba(15, 143, 120, 0.1);
}

.record-switch.active {
  background: linear-gradient(132deg, var(--brand) 0%, #11a085 100%);
  color: #ffffff;
  box-shadow: 0 8px 14px rgba(15, 143, 120, 0.22);
}

.sync-summary-shell {
  margin-top: 12px;
}

.sync-summary {
  border: 1px solid #d6e5e2;
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(160deg, #ffffff 0%, #f3faf8 100%);
  color: #2b5960;
  font-weight: 600;
}

.sync-summary.is-warning {
  border-color: #f2bcae;
  color: #973924;
  background: linear-gradient(160deg, #fff9f8 0%, #fff2ee 100%);
}

.timeline-list {
  position: relative;
  padding-left: 14px;
}

.timeline-list::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(15, 143, 120, 0.35) 0%, rgba(15, 143, 120, 0.08) 100%);
}

.timeline-list .log-item {
  position: relative;
}

.timeline-list .log-item::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #0f8f78;
  box-shadow: 0 0 0 3px rgba(15, 143, 120, 0.14);
}

.timeline-list .log-item[data-kind="error"]::before {
  background: #d65235;
  box-shadow: 0 0 0 3px rgba(214, 82, 53, 0.16);
}

.timeline-list .log-item[data-kind="conflict"]::before {
  background: #e57254;
  box-shadow: 0 0 0 3px rgba(229, 114, 84, 0.16);
}

.timeline-list .log-item[data-kind="success"]::before {
  background: #0f9f88;
}

.all-data-kpis {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.all-data-kpi {
  position: relative;
  overflow: hidden;
  border: 1px solid #d5e4e1;
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(165deg, #ffffff 0%, #f1faf8 100%);
}

.all-data-kpi::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #0f8f78 0%, rgba(15, 143, 120, 0) 78%);
}

.all-data-kpi[data-accent="coverage"]::before { background: linear-gradient(90deg, #0f8f78 0%, rgba(15, 143, 120, 0) 78%); }
.all-data-kpi[data-accent="medical"]::before { background: linear-gradient(90deg, #4b96ff 0%, rgba(75, 150, 255, 0) 78%); }
.all-data-kpi[data-accent="alert"]::before { background: linear-gradient(90deg, #ea6a4b 0%, rgba(234, 106, 75, 0) 78%); }
.all-data-kpi[data-accent="stable"]::before { background: linear-gradient(90deg, #14a689 0%, rgba(20, 166, 137, 0) 78%); }
.all-data-kpi[data-accent="travel"]::before { background: linear-gradient(90deg, #6c86ff 0%, rgba(108, 134, 255, 0) 78%); }

.all-data-kpi-value {
  font-family: "Sora", "Work Sans", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #183237;
}

.all-data-kpi-label {
  margin-top: 3px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: #42666d;
}

.all-data-kpi-hint {
  margin-top: 7px;
  font-size: 0.8rem;
  color: #53757b;
}

.all-data-grid {
  margin-top: 12px;
}

.data-block {
  min-height: 260px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-head h3 {
  margin-bottom: 0;
}

.section-hint {
  margin-top: 6px;
  margin-bottom: 4px;
  color: #5a7a81;
  font-size: 0.84rem;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #cde0dc;
  background: #ffffff;
  color: #376067;
  font-size: 0.78rem;
  font-weight: 700;
}

.count-pill.is-empty {
  color: #6e888d;
  border-color: #dbe7e4;
  background: #f7fbfa;
}

.editor-form {
  display: grid;
  gap: 10px;
}

.field-label {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.weekday-shell {
  display: grid;
  gap: 8px;
}

.weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.weekday-chip {
  border: 1px solid #cde0dc;
  border-radius: 10px;
  background: #ffffff;
  color: #315b62;
  box-shadow: none;
  padding: 8px 0;
  font-size: 0.82rem;
  font-weight: 600;
}

.weekday-chip:hover {
  filter: none;
  border-color: #9ccdc1;
}

.weekday-chip.active {
  border-color: #0f8f78;
  background: rgba(15, 143, 120, 0.14);
  color: #0d6858;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border-radius: 11px;
  border: 1px solid #cde0dc;
  background: #ffffff;
  padding: 10px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 0;
  border-color: rgba(15, 143, 120, 0.65);
  box-shadow: 0 0 0 3px rgba(15, 143, 120, 0.17);
}

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

button {
  border: 1px solid transparent;
  border-radius: 11px;
  background: linear-gradient(132deg, var(--brand) 0%, #11a085 100%);
  color: #ffffff;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(15, 143, 120, 0.24);
}

button:hover {
  filter: brightness(0.98);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  box-shadow: none;
}

button.secondary {
  background: linear-gradient(132deg, #ff8c62 0%, var(--accent) 100%);
  box-shadow: 0 10px 18px rgba(255, 125, 77, 0.26);
}

button.ghost {
  background: #ffffff;
  color: var(--ink);
  border-color: #d4e1de;
  box-shadow: none;
}

button.apple {
  background: #171717;
}

.status-bar {
  min-height: 30px;
  margin-top: 12px;
  padding: 8px 4px;
  color: var(--ink-soft);
  font-weight: 500;
}

.status-bar.error {
  color: var(--danger);
}

.status-bar.success {
  color: var(--brand-strong);
}

.empty-state {
  color: var(--ink-soft);
  font-size: 0.9rem;
  border: 1px dashed #cfdedb;
  border-radius: 10px;
  padding: 10px;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.9) 0%, rgba(244, 251, 249, 0.95) 100%);
}

.log-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.log-item {
  border: 1px solid #d6e4e1;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
}

.log-item.conflict {
  border-color: #f0c2b8;
  background: #fff6f4;
}

.log-item[data-kind="error"] {
  border-color: #f0c2b8;
  background: #fff5f2;
}

.log-item[data-kind="success"] {
  border-color: #b9dfd5;
  background: #f3fbf8;
}

.log-title {
  font-weight: 600;
}

.log-meta {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.log-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d6e4e1;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  margin-right: 8px;
}

.log-pill.kind-conflict,
.log-pill.kind-error {
  border-color: #eb9e8d;
  color: #a83d26;
  background: #fff2ee;
}

.log-pill.kind-success {
  border-color: #9ad3c5;
  color: #0d755f;
  background: #ecf9f4;
}

.log-pill.kind-info {
  border-color: #c4dce5;
  color: #35677c;
  background: #edf7fb;
}

.kv-item {
  position: relative;
  overflow: hidden;
  --accent-strip: linear-gradient(180deg, #0f8f78 0%, #0d7865 100%);
  border: 1px solid #d8e6e2;
  border-radius: 10px;
  background: #ffffff;
  padding: 10px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.kv-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent-strip);
}

.kv-item[data-accent="emergency"] {
  --accent-strip: linear-gradient(180deg, #ec7a57 0%, #d4572f 100%);
}

.kv-item[data-accent="settings"] {
  --accent-strip: linear-gradient(180deg, #5f8eff 0%, #3b6fd6 100%);
}

.kv-item:hover {
  transform: translateY(-1px);
  border-color: #a7cfca;
  box-shadow: 0 8px 16px rgba(17, 36, 39, 0.07);
}

.kv-label {
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.kv-value {
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--ink);
  word-break: break-word;
}

@media (prefers-reduced-motion: no-preference) {
  .hero,
  .side,
  .tab-panel {
    animation: panel-enter 0.46s cubic-bezier(0.2, 0.7, 0, 1) both;
  }

  .item,
  .stat,
  .detail-row,
  .all-data-kpi,
  .log-item,
  .kv-item {
    animation: item-enter 0.34s cubic-bezier(0.2, 0.7, 0, 1) both;
    animation-delay: calc(var(--stagger-index, 0) * 28ms);
  }
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes item-enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .all-data-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .side {
    position: static;
  }

  .tab-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #tab-all-data .records-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 14px 12px 28px;
  }

  .hero {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .tab-nav {
    grid-template-columns: 1fr;
  }

  .record-nav {
    width: 100%;
    justify-content: stretch;
  }

  .record-switch {
    flex: 1 1 0;
    text-align: center;
  }

  .record-panel {
    min-height: auto;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .all-data-kpis {
    grid-template-columns: 1fr;
  }

  .doc-image-actions .ghost {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }

  .image-lightbox-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .image-lightbox-title {
    max-width: 100%;
  }
}
