body.admin-page {
  background:
    radial-gradient(circle at top left, rgba(212, 175, 55, 0.2), transparent 28%),
    linear-gradient(180deg, #f8f2de 0%, #f2ead2 100%);
  min-height: 100vh;
}

.admin-shell {
  width: min(1800px, calc(100vw - 32px));
  margin: 0 auto;
  /* prevent children from blowing past the shell */
  min-width: 0;
}

.admin-page .admin-shell:first-of-type {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  padding: 2rem 0 1rem;
}

.admin-kicker,
.admin-subtitle,
.admin-toolbar-copy,
.admin-link-btn,
.admin-save-btn,
.admin-table,
.admin-table input,
.admin-table select,
.admin-table textarea {
  font-family: 'IBM Plex Mono', monospace;
}

.admin-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink3);
}

.admin-title {
  margin: 0;
  font-family: 'Lora', serif;
  font-size: clamp(2rem, 3vw, 3.4rem);
  line-height: 1;
  color: var(--ink);
}

.admin-subtitle {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--ink2);
}

.admin-actions-top {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.admin-link-btn,
.admin-save-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.65rem 1rem;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.66rem;
  text-decoration: none;
  cursor: pointer;
}

.admin-link-btn {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.75);
}

.admin-save-btn {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
  font-weight: 600;
}

.admin-save-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.admin-panel {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(122, 104, 52, 0.2);
  box-shadow: 0 24px 70px rgba(77, 65, 28, 0.12);
  backdrop-filter: blur(10px);
  margin-bottom: 2rem;
  /* clamp panel to its parent — never let it overflow */
  width: 100%;
  overflow: hidden;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(122, 104, 52, 0.16);
}

.admin-toolbar strong,
.is-dirty {
  color: var(--ink);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 75vh;
  /* keeps the scrollbar inside the panel border */
  box-sizing: border-box;
}

.admin-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 0.7rem;
  color: var(--ink);
}

.admin-table th,
.admin-table td {
  border-right: 1px solid rgba(122, 104, 52, 0.15);
  border-bottom: 1px solid rgba(122, 104, 52, 0.15);
  vertical-align: top;
  background: rgba(255, 252, 244, 0.88);
}

.admin-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.65rem 0.55rem;
  background: #f0e3ba;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink2);
  overflow: hidden;
  white-space: nowrap;
  user-select: none;
}

/* ── Column resize handle ───────────────────────────────────────────────── */
.admin-table th .col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
  background: transparent;
  transition: background 0.15s;
}
.admin-table th {
  position: sticky; /* already set, but need relative for the handle */
}
.admin-table th:hover .col-resize-handle {
  background: rgba(196, 164, 68, 0.45);
}
.admin-table.is-resizing {
  cursor: col-resize;
  user-select: none;
}
.admin-table th {
  position: sticky;
}
/* Make th a positioning context for the handle */
.admin-table thead th {
  position: sticky;
  top: 0;
}

.admin-table td:first-child,
.admin-table th:first-child {
  border-left: 1px solid rgba(122, 104, 52, 0.15);
}

/* remove nth-child striping — day grouping replaces it */

/* ── Day group row colours ─────────────────────────────────────────────── */
tr[data-day="01"] td { background: rgba(196, 164,  68, 0.07); }
tr[data-day="02"] td { background: rgba( 26,  48,  96, 0.06); }
tr[data-day="03"] td { background: rgba( 44,  95,  58, 0.06); }
tr[data-day="04"] td { background: rgba(160,  64,   0, 0.07); }
tr[data-day=""]   td { background: rgba(155, 126,  46, 0.05); }

/* Day-header rows (type = day) get a stronger tint + top border */
tr.is-day-header[data-day="01"] td { background: rgba(196, 164,  68, 0.18); border-top: 2px solid rgba(196,164,68,0.5); }
tr.is-day-header[data-day="02"] td { background: rgba( 26,  48,  96, 0.14); border-top: 2px solid rgba(26,48,96,0.3); }
tr.is-day-header[data-day="03"] td { background: rgba( 44,  95,  58, 0.14); border-top: 2px solid rgba(44,95,58,0.3); }
tr.is-day-header[data-day="04"] td { background: rgba(160,  64,   0, 0.14); border-top: 2px solid rgba(160,64,0,0.3); }
tr.is-day-header td { font-weight: 600; }

.admin-table tbody tr:hover td {
  background: rgba(255, 248, 210, 0.98);
}

.admin-table td.meta-cell,
.admin-table td.id-cell,
.admin-table td.type-cell {
  white-space: nowrap;
}

.admin-table td.type-cell,
.admin-table td.id-cell {
  padding: 0.55rem;
  font-weight: 500;
}

.admin-table td.meta-cell {
  padding: 0.55rem;
  color: var(--ink2);
}

.cell-input,
.cell-select,
.cell-textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.55rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.7rem;
}

.cell-input:focus,
.cell-select:focus,
.cell-textarea:focus {
  outline: none;
  background: #fffaf0;
}

.cell-textarea {
  min-height: 92px;
  resize: vertical;
}

/* ── Image cell (thumbnail + trigger) ───────────────────────────────────── */
.col-image {
  vertical-align: middle;
  padding: 0.4rem;
  text-align: center;
}

.cell-img-thumb {
  display: block;
  width: 100%;
  max-height: 72px;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  margin-bottom: 0.3rem;
}

.cell-img-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: 2px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.cell-img-btn:hover { filter: brightness(1.08); }

/* ── Image upload modal ──────────────────────────────────────────────────── */
.img-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-modal.hidden { display: none; }

.img-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 27, 22, 0.55);
  backdrop-filter: blur(4px);
}

.img-modal-box {
  position: relative;
  z-index: 1;
  background: #fffdf5;
  border: 2px solid var(--gold);
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 80px rgba(28, 27, 22, 0.3);
}

.img-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.2rem 1.2rem 0.8rem;
  border-bottom: 1px solid var(--gold-border);
  flex-shrink: 0;
}

.img-modal-kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink3);
  margin: 0 0 0.2rem;
}

.img-modal-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  letter-spacing: 0.04em;
}

.img-modal-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--ink3);
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  line-height: 1;
}
.img-modal-close:hover { color: var(--ink); }

.img-modal-body {
  padding: 1rem 1.2rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Drop zone */
.img-drop-zone {
  border: 2px dashed var(--gold-border);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  overflow: hidden;
  background: rgba(255, 249, 232, 0.5);
}
.img-drop-zone:hover,
.img-drop-zone.is-over {
  border-color: var(--gold);
  background: rgba(255, 249, 200, 0.7);
}

.img-modal-preview {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
}
.img-modal-preview.hidden { display: none; }
.img-drop-placeholder.hidden { display: none; }

.img-drop-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.5rem;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--ink3);
  font-size: 0.7rem;
  text-align: center;
  pointer-events: none;
}
.img-drop-icon {
  font-size: 2rem;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.img-drop-hint {
  font-size: 0.58rem;
  opacity: 0.7;
}

.img-file-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Alt text field */
.img-field-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
}
.img-alt-input {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  padding: 0.35rem 0.5rem;
  width: 100%;
  box-sizing: border-box;
}
.img-alt-input:focus { outline: none; border-color: var(--gold); background: #fff; }

/* Upload status bar */
.img-upload-status {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  padding: 0.35rem 0.6rem;
  border-radius: 2px;
}
.img-upload-status.hidden    { display: none; }
.img-upload-status.is-uploading { background: rgba(196,164,68,0.15); color: var(--gold); }
.img-upload-status.is-ok        { background: rgba(44, 95, 58, 0.12);  color: #2C5F3A; }
.img-upload-status.is-error     { background: rgba(139,26,26,0.1);     color: #8B1A1A; }

/* Footer */
.img-modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid var(--gold-border);
  flex-shrink: 0;
  gap: 0.5rem;
}
.img-modal-foot-right {
  display: flex;
  gap: 0.5rem;
}

.img-remove-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.4rem 0.8rem;
  background: none;
  color: #8B1A1A;
  border: 1px solid rgba(139,26,26,0.4);
  border-radius: 2px;
  cursor: pointer;
}
.img-remove-btn.hidden { display: none; }
.img-remove-btn:hover  { background: rgba(139,26,26,0.07); }

.img-cancel-btn,
.img-upload-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.4rem 0.9rem;
  border-radius: 2px;
  cursor: pointer;
}
.img-cancel-btn {
  background: none;
  color: var(--ink3);
  border: 1px solid var(--border-strong);
}
.img-upload-btn {
  background: var(--gold);
  color: var(--ink);
  border: none;
  font-weight: 600;
}
.img-upload-btn:disabled { opacity: 0.45; cursor: default; }



@media (max-width: 900px) {
  .admin-page .admin-shell:first-of-type {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-actions-top {
    justify-content: space-between;
  }

  .admin-shell {
    width: min(100vw - 16px, 1800px);
  }
}