:root {
  --bg: #081522;
  --bg-alt: #12243a;
  --panel: rgba(14, 30, 49, 0.9);
  --panel-strong: rgba(18, 36, 58, 0.95);
  --text: #eaf4ff;
  --muted: #a7bed8;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #61d4a8;
  --accent-2: #7dbdff;
  --danger: #ff8f9c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

body.lightbox-open {
  overflow: hidden;
}

.page-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(97, 212, 168, 0.22), transparent 36%),
    radial-gradient(circle at 85% 15%, rgba(125, 189, 255, 0.22), transparent 36%),
    linear-gradient(160deg, var(--bg), var(--bg-alt));
  z-index: -1;
}

.topbar {
  width: min(1200px, calc(100% - 32px));
  margin: 24px auto 16px;
}

.topbar h1 {
  margin: 10px 0 4px;
  font-size: 34px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.home-link {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}

.home-link:hover {
  text-decoration: underline;
}

.layout {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto 28px;
  display: grid;
  gap: 16px;
  grid-template-columns: 1.1fr 1fr;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  backdrop-filter: blur(6px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.card-header h2 {
  margin: 0;
  font-size: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid rgba(125, 189, 255, 0.4);
  border-radius: 999px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 600;
}

.grid {
  display: grid;
  gap: 12px;
}

.two-col {
  grid-template-columns: 1fr 1fr;
}

.three-col {
  grid-template-columns: repeat(3, 1fr);
}

label,
.nails-block,
.dental-block,
.notes-block {
  display: block;
  margin-bottom: 12px;
}

label > span,
.block-title {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(7, 21, 36, 0.8);
}

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

select:focus,
input:focus,
textarea:focus,
button:focus {
  outline: 2px solid rgba(125, 189, 255, 0.45);
  outline-offset: 1px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(7, 21, 36, 0.65);
}

.checkbox-item input {
  width: 16px;
  height: 16px;
}

.notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dental-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(7, 21, 36, 0.42);
}

.dental-block-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.dental-block-copy {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.notes-container {
  display: grid;
  gap: 8px;
}

.note-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

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

.selected-cat-photo {
  margin: 2px 0 14px;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(7, 21, 36, 0.55);
}

.selected-cat-photo-frame {
  width: 96px;
  height: 96px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(7, 21, 36, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

.selected-cat-photo-frame.has-photo {
  cursor: zoom-in;
}

.selected-cat-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selected-cat-photo-empty {
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.selected-cat-photo-meta {
  font-size: 13px;
  color: var(--muted);
}

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(4, 8, 18, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
}

.photo-lightbox img,
.photo-lightbox-image {
  max-width: min(94vw, 1280px);
  max-height: 82vh;
  object-fit: contain;
  border-radius: 10px;
  transition: filter 0.25s ease, transform 0.25s ease;
  filter: blur(0);
}

.photo-lightbox img.is-loading {
  filter: blur(12px);
  transform: scale(1.01);
}

.photo-lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: 1px solid rgba(125, 189, 255, 0.45);
  border-radius: 8px;
  background: rgba(12, 20, 45, 0.9);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 10px;
}

.photo-lightbox-caption {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  max-width: min(94vw, 900px);
  min-height: 20px;
}

.loading-dots {
  display: inline-flex;
  margin-left: 2px;
}

.loading-dots .dot {
  opacity: 0;
  animation: lightbox-dot-pulse 1.3s infinite;
}

.loading-dots .dot:nth-child(1) {
  animation-delay: 0s;
}

.loading-dots .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes lightbox-dot-pulse {
  0% {
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  40% {
    opacity: 1;
  }
  60% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}

.primary {
  background: rgba(97, 212, 168, 0.2);
  border-color: rgba(97, 212, 168, 0.5);
  color: var(--accent);
  font-weight: 600;
}

.secondary {
  background: rgba(125, 189, 255, 0.16);
  border-color: rgba(125, 189, 255, 0.45);
  color: var(--accent-2);
}

.danger {
  background: rgba(255, 143, 156, 0.16);
  border-color: rgba(255, 143, 156, 0.45);
  color: var(--danger);
}

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

.hidden {
  display: none;
}

.message {
  margin-top: 10px;
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

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

.message.success {
  color: var(--accent);
}

.history-meta {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel-strong);
}

.history-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.history-time {
  font-size: 14px;
  color: var(--accent-2);
}

.history-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 10px 0;
  font-size: 14px;
}

.history-values strong {
  color: var(--muted);
  font-weight: 500;
}

.history-notes {
  margin: 10px 0;
  padding-left: 18px;
  color: var(--text);
}

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

.all-checks {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 10px;
}

.all-checks-title {
  font-size: 14px;
  color: var(--muted);
}

.cat-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 21, 36, 0.45);
  overflow: hidden;
}

.cat-group-header {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  padding: 10px 12px;
}

.cat-group-body {
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

.cat-group-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--panel-strong);
  font-size: 13px;
}

.cat-group-empty,
.cat-group-error {
  color: var(--muted);
  font-size: 13px;
}

.cat-group-error {
  color: var(--danger);
}

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

  .three-col {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .two-col,
  .three-col,
  .checkbox-grid,
  .history-values {
    grid-template-columns: 1fr;
  }

  .selected-cat-photo {
    grid-template-columns: 1fr;
  }

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