:root {
  --maroon: #7b1a1a;
  --maroon-dark: #5d1313;
  --gold: #e8c14a;
  --border: #ddd;
  --bg: #f4f2ef;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }

/* ---------- custom scrollbars (theme) ---------- */

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--maroon) transparent;
}

/* WebKit / Chromium */
::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
::-webkit-scrollbar-track {
  background: #ece8e3;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb {
  background: var(--maroon);
  border-radius: 8px;
  border: 2px solid #ece8e3;
}
::-webkit-scrollbar-thumb:hover {
  background: #5d1313;
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* Dark sidebar: lighter thumb on the maroon background */
#sidebar { scrollbar-color: var(--gold) rgba(255, 255, 255, 0.08); }
#sidebar ::-webkit-scrollbar-track,
#nav::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
}
#sidebar ::-webkit-scrollbar-thumb,
#nav::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-color: transparent;
}
#sidebar ::-webkit-scrollbar-thumb:hover,
#nav::-webkit-scrollbar-thumb:hover {
  background: #d4ae3f;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  margin: 0;
  background: var(--bg);
  color: #222;
}

/* ---------- sidebar ---------- */

#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--maroon-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.brand strong { display: block; font-size: 17px; letter-spacing: 1px; }
.brand span { font-size: 12px; color: var(--gold); }

#nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

#nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 18px;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
#nav button:hover { background: rgba(255, 255, 255, 0.06); }
#nav button.active {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: var(--gold);
  color: #fff;
  font-weight: 600;
}
#nav button .ico {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke-width: 1.75;
}
#nav .nav-divider {
  margin: 10px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  padding: 12px 20px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

#logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 8px 12px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
#logout:hover { background: rgba(255, 255, 255, 0.12); }
#logout svg { width: 15px; height: 15px; }

/* ---------- login page ---------- */

.login-page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--maroon-dark) 0%, #2c0a0a 100%);
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 36px 32px;
  width: 360px;
  max-width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand strong {
  display: block;
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--maroon);
}
.login-brand span {
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #999;
}
.login-field { margin-bottom: 16px; }
.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}
.login-field input {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-sizing: border-box;
}
.login-field input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.login-error {
  background: #fdecea;
  color: #b71c1c;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 6px;
  margin: 0 0 14px;
}
.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--gold);
  border: none;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 13px;
  cursor: pointer;
}
.login-btn:hover { filter: brightness(0.96); }
.login-btn:disabled { opacity: 0.6; cursor: default; }

/* ---------- content ---------- */

#content { margin-left: var(--sidebar-w); min-height: 100vh; }

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
}
#topbar h1 { font-size: 18px; margin: 0; }
#topbar p { margin: 2px 0 0; font-size: 13px; color: #777; max-width: 640px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

#dirty-badge {
  font-size: 12px;
  color: #b26a00;
  background: #fff4e0;
  border: 1px solid #f0d9a8;
  padding: 4px 10px;
  border-radius: 99px;
}

button {
  font: inherit;
  padding: 9px 18px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  border-radius: 6px;
}
.topbar-actions button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.topbar-actions button svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}
button.primary {
  background: var(--gold);
  border-color: var(--gold);
  font-weight: 600;
}
button:hover { filter: brightness(0.96); }

#status {
  position: sticky;
  top: 65px;
  z-index: 9;
  padding: 10px 28px;
  font-size: 14px;
}
#status.ok { background: #e6f4e6; color: #1b5e20; }
#status.err { background: #fdecea; color: #b71c1c; }

main { max-width: 860px; margin: 24px auto 64px; padding: 0 28px; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 16px;
}

/* ---------- fields ---------- */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 5px;
}
.field input[type='text'],
.field textarea,
.field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  background: #fff;
}
.field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--gold);
  border-color: var(--gold);
}

.img-preview {
  margin-top: 8px;
  max-width: 140px;
  max-height: 140px;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: cover;
  display: block;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--maroon);
  background: #fff;
  border: 1px solid var(--maroon);
  border-radius: 6px;
  cursor: pointer;
}
.upload-btn:hover { background: #faf3f3; }
.upload-btn:disabled { opacity: 0.6; cursor: default; }
.upload-btn svg { width: 14px; height: 14px; }
.upload-status { font-size: 12px; color: #888; }
.upload-status.ok { color: #1b5e20; }
.upload-status.err { color: #b71c1c; }

.group { margin-bottom: 16px; }
.group:last-child { margin-bottom: 0; }
.group > .group-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--maroon);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.array-item {
  background: #faf8f5;
  border: 1px solid #e8e2d8;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.item-header > .item-title {
  font-size: 12px;
  font-weight: 700;
  color: #8a6d1f;
}
.array-item .remove {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  line-height: 1;
  font-size: 15px;
  color: #b71c1c;
  border-color: #e3c6c6;
  background: #fff;
  border-radius: 6px;
}
.array-item .remove:hover { background: #fdecea; }

.add {
  font-size: 13px;
  padding: 7px 14px;
  color: var(--maroon);
  border: 1px dashed var(--maroon);
  background: #fff;
  border-radius: 6px;
  width: 100%;
}
.add:hover { background: #faf3f3; }

/* ---------- backups view ---------- */

.backup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}
.backup-item:last-child { border-bottom: none; }
.backup-item .when { font-size: 14px; }
.backup-item .when small { display: block; color: #999; font-size: 11px; }
.backup-item button { font-size: 13px; padding: 6px 14px; }

.hint-box {
  background: #fffbe9;
  border: 1px solid #f0e3b0;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #6b5b22;
  margin-bottom: 16px;
  line-height: 1.6;
}

.loading { color: #777; }
.empty { color: #999; font-size: 14px; }

/* ---------- registrations view ---------- */

main.wide { max-width: none; }

.reg-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.reg-toolbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 240px;
}
.reg-count { font-size: 14px; color: #555; font-weight: 600; white-space: nowrap; }
.reg-search {
  flex: 1;
  max-width: 380px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.reg-search:focus { outline: 2px solid var(--gold); border-color: var(--gold); }

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  font-size: 13.5px;
  color: #222;
  text-decoration: none;
}
.btn-link:hover { filter: brightness(0.96); }
.btn-link svg { width: 14px; height: 14px; }

.table-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--maroon);
  margin: 24px 0 10px;
}
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }

.table-scroll table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
.table-scroll th, .table-scroll td {
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: top;
  max-width: 260px;
  min-width: 110px;
}
.table-scroll th {
  position: sticky;
  top: 0;
  background: #faf8f5;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--maroon);
  white-space: nowrap;
}
.table-scroll tbody tr:hover { background: #fcfaf6; }
.table-scroll td.nowrap { white-space: nowrap; }
.table-scroll a { color: var(--maroon); }
.cell-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
