:root {
  --bg: #f3efe6;
  --ink: #1f2a30;
  --muted: #667780;
  --card: rgba(255, 251, 245, 0.82);
  --line: rgba(31, 42, 48, 0.12);
  --accent: #0d6c66;
  --accent-soft: #d9efe9;
  --warm: #c86b3c;
  --shadow: 0 24px 60px rgba(43, 49, 54, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(13, 108, 102, 0.15), transparent 28%),
    radial-gradient(circle at top right, rgba(200, 107, 60, 0.16), transparent 30%),
    linear-gradient(180deg, #f8f4ec 0%, var(--bg) 100%);
  font-family: "Segoe UI Variable Text", "Trebuchet MS", "Gill Sans", sans-serif;
}

body {
  padding: 28px;
}

body.auth-locked {
  overflow: hidden;
}

body.auth-locked .page-shell {
  display: none;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 20% 10%, rgba(13, 108, 102, 0.2), transparent 32%),
    radial-gradient(circle at 80% 20%, rgba(200, 107, 60, 0.18), transparent 30%),
    rgba(243, 239, 230, 0.96);
}

.login-overlay.is-hidden {
  display: none;
}

.login-card {
  width: min(440px, 100%);
  border-radius: calc(var(--radius) + 8px);
  border: 1px solid rgba(255, 255, 255, 0.62);
  padding: 32px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-panel {
  display: grid;
  gap: 12px;
}

.login-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
}

.login-text,
.login-help,
.login-error {
  color: var(--muted);
}

.login-text {
  margin: 12px 0 20px;
}

.login-help {
  margin: 14px 0 0;
  font-size: 0.9rem;
}

.login-error {
  min-height: 1.2rem;
  margin: 12px 0 0;
  color: #9d261b;
  font-weight: 700;
}

.action-btn-secondary {
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  border: 1px solid var(--line);
}

.action-btn-secondary:hover {
  background: rgba(217, 239, 233, 0.95);
}

.login-field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.login-field span {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 600;
}

.login-field input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 13px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}

.page-shell {
  max-width: 1600px;
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.hero-stats,
.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-copy {
  border-radius: calc(var(--radius) + 8px);
  padding: 26px 34px;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  font-weight: 700;
  color: var(--warm);
}

.hero h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 2.15vw, 2.45rem);
  line-height: 0.98;
}

.hero-text {
  max-width: 54rem;
  margin: 12px 0 16px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-pill,
.chip,
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 8px 14px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.62);
}

.hero-stats {
  border-radius: calc(var(--radius) + 8px);
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  border-radius: 18px;
  padding: 13px 16px;
  background: linear-gradient(135deg, rgba(13, 108, 102, 0.08), rgba(255, 255, 255, 0.8));
  min-height: 68px;
  transform: translateY(0);
  animation: rise 0.5s ease both;
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-value {
  margin: 8px 0 0;
  font-size: 1.55rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  gap: 24px;
}

.content-column {
  display: grid;
  gap: 24px;
}

.card {
  border-radius: var(--radius);
  padding: 22px;
}

.toolbar {
  display: grid;
  gap: 18px;
  overflow: visible;
  position: relative;
  z-index: 40;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 600;
}

.field select,
.field input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 13px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.84);
}

.multi-filter {
  position: relative;
  min-width: 0;
}

.multi-filter-button {
  width: 100%;
  min-width: 0;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 36px 12px 13px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.84);
  cursor: pointer;
  text-align: left;
  position: relative;
}

.multi-filter-button::after {
  content: "⌄";
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-55%);
  color: var(--muted);
  font-size: 1rem;
}

.multi-filter-button span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 400;
}

.multi-filter-menu {
  display: none;
  position: absolute;
  z-index: 100;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: none;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
  background: #fffdf8;
  box-shadow: var(--shadow);
}

.multi-filter.is-open .multi-filter-menu {
  display: grid;
  gap: 4px;
}

.multi-filter-option {
  border: 0;
  border-radius: 11px;
  padding: 9px 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.multi-filter-option::before {
  content: "□";
  display: inline-block;
  width: 1.25rem;
  color: var(--muted);
}

.multi-filter-option.is-selected {
  background: rgba(13, 108, 102, 0.12);
  color: var(--accent);
  font-weight: 700;
}

.multi-filter-option.is-selected::before {
  content: "✓";
  color: var(--accent);
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.action-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
}

.action-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.action-status {
  color: var(--muted);
  font-size: 0.92rem;
}

.chip {
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.chip:hover,
.chip-active {
  background: var(--accent-soft);
  border-color: rgba(13, 108, 102, 0.35);
  transform: translateY(-1px);
}

.section-head,
.viewer-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2,
.viewer-topbar h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
}

.section-counter {
  color: var(--muted);
  font-size: 0.95rem;
}

.table-wrap {
  overflow: auto;
}

#newRecordPanel:empty {
  display: none;
}

.floating-record-panel {
  margin: 0 0 20px;
}

.is-hidden {
  display: none;
}

.annual-calendar-section {
  display: grid;
  gap: 18px;
}

.annual-calendar-section.is-hidden {
  display: none;
}

.annual-calendar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.annual-month-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
  overflow: hidden;
}

.annual-month-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(90deg, rgba(13, 108, 102, 0.12), transparent);
}

.annual-month-head h3 {
  margin: 0;
  font-size: 1rem;
}

.annual-month-count {
  color: var(--muted);
  font-size: 0.86rem;
}

.annual-month-body {
  display: grid;
}

.annual-empty {
  padding: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.annual-entry {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  cursor: pointer;
}

.annual-entry:hover {
  background: rgba(13, 108, 102, 0.08);
}

.annual-date {
  font-weight: 700;
}

.annual-summary strong {
  display: block;
  margin-bottom: 4px;
}

.annual-summary span {
  color: var(--muted);
  font-size: 0.88rem;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.records-table th,
.records-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.records-table th {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.records-row {
  cursor: pointer;
  transition: background 0.2s ease;
}

.records-row:hover,
.records-row.is-active {
  background: rgba(13, 108, 102, 0.08);
}

.records-row.is-active td {
  border-bottom-color: transparent;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.status-active {
  background: #dff3e8;
  color: #16623a;
}

.status-pending {
  background: #fff0c7;
  color: #8a5a00;
}

.status-baja {
  background: #ffe0dc;
  color: #9d261b;
}

.cell-title {
  display: grid;
  gap: 4px;
}

.cell-title strong {
  font-size: 0.96rem;
}

.cell-title span {
  color: var(--muted);
  font-size: 0.86rem;
}

.expand-cell {
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.expand-panel {
  margin: 0 10px 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.62);
  overflow: hidden;
}

.expand-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(380px, 1.05fr);
  gap: 0;
  align-items: stretch;
}

.expand-side {
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.expand-side + .expand-side {
  border-left: 1px solid var(--line);
}

.expand-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.expand-top h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.expand-meta {
  display: grid;
  gap: 12px;
}

.calendar-list {
  display: grid;
  gap: 14px;
}

.calendar-group {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.54);
}

.calendar-group h3 {
  margin: 0;
  padding: 14px 16px;
  font-size: 1rem;
  background: linear-gradient(90deg, rgba(13, 108, 102, 0.12), transparent);
}

.calendar-entry {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.calendar-entry:hover {
  background: rgba(13, 108, 102, 0.08);
}

.calendar-date {
  font-weight: 700;
}

.calendar-summary strong {
  display: block;
  margin-bottom: 4px;
}

.calendar-summary span,
.calendar-amount {
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-card,
.viewer-card {
  min-height: 320px;
}

.detail-meta {
  display: grid;
  gap: 14px;
}

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

.meta-item {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.meta-item label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.edit-item {
  display: grid;
  gap: 8px;
}

.edit-item.full {
  grid-column: 1 / -1;
}

.edit-item label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.edit-item input,
.edit-item select,
.edit-item textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 13px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
}

.edit-item textarea {
  min-height: 92px;
  resize: vertical;
}

.edit-help {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-actions a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.detail-actions a:hover {
  text-decoration: underline;
}

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

.inline-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
}

.inline-btn.danger {
  border-color: rgba(200, 107, 60, 0.35);
  background: rgba(200, 107, 60, 0.12);
}

.pdf-manage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.pdf-manage input[type="file"] {
  max-width: 100%;
}

.pdf-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pdf-tab {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
}

.pdf-tab.is-active {
  background: var(--accent-soft);
  border-color: rgba(13, 108, 102, 0.4);
}

.viewer-frame {
  position: relative;
  min-height: 760px;
  height: 100%;
  flex: 1;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fbfaf7;
}

.pdf-frame {
  width: 100%;
  height: 100%;
  min-height: 760px;
  border: 0;
}

.viewer-fallback,
.empty-state {
  color: var(--muted);
  line-height: 1.6;
}

.viewer-fallback {
  display: grid;
  place-items: center;
  min-height: 760px;
  height: 100%;
  padding: 24px;
  text-align: center;
}

.empty-table {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.tag {
  width: fit-content;
  font-size: 0.78rem;
  padding: 7px 12px;
}

.tag.good {
  background: rgba(13, 108, 102, 0.14);
  border-color: rgba(13, 108, 102, 0.25);
}

.tag.warn {
  background: rgba(200, 107, 60, 0.16);
  border-color: rgba(200, 107, 60, 0.28);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

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

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

  .expand-side + .expand-side {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  body {
    padding: 14px;
  }

  .hero-copy,
  .hero-stats,
  .card {
    padding: 18px;
  }

  .filters,
  .meta-grid,
  .edit-grid,
  .annual-calendar-grid {
    grid-template-columns: 1fr;
  }

  .calendar-entry {
    grid-template-columns: 1fr;
  }

  .annual-entry {
    grid-template-columns: 1fr;
  }

  .viewer-frame,
  .pdf-frame {
    min-height: 420px;
    height: 420px;
  }
}
