:root {
  --bg: #f0eef5;
  --bg-auth: linear-gradient(165deg, #1e1a2b 0%, #2d2640 45%, #1e1a2b 100%);
  --card: #fff;
  --ink: #1e1a2b;
  --muted: #625a73;
  --line: #e2dde9;
  --accent: #d1242f;
  --accent-hover: #b81e28;
  --accent2: #1b6fbd;
  --radius: 12px;
  --shadow: 0 18px 48px rgba(30, 26, 43, 0.12);
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 400 15px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

a {
  color: var(--accent2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.gal-thumb {
  width: 72px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  background: var(--line);
}

.gallery-upload {
  padding: 16px 18px;
  margin-bottom: 16px;
}

.gallery-drop {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
  background: #faf9fc;
  transition: border-color 0.2s, background 0.2s;
}

.gallery-drop.is-drag {
  border-color: var(--accent);
  background: #fff;
}

.gallery-drop-title {
  margin: 0 0 6px;
  font-weight: 600;
}

.gallery-drop-hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.gallery-drop-status {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.gallery-drop-status.is-err {
  color: var(--accent);
}

.gallery-drop-preview {
  max-width: 100%;
  max-height: 140px;
  margin-top: 14px;
  border-radius: 8px;
  object-fit: contain;
}

.gallery-add-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.gallery-or {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.gallery-add-bar input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

/* hidden must win over layout display (flex) */
[hidden] {
  display: none !important;
}

body:not(.staff-logged-in) .app-layout {
  display: none !important;
}

body.staff-logged-in .auth-layout {
  display: none !important;
}

/* —— Sign-in —— */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--bg-auth);
  position: relative;
}

.auth-exit {
  position: absolute;
  top: 20px;
  left: 24px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  font-weight: 500;
}

.auth-exit:hover {
  color: #fff;
  text-decoration: none;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.auth-logo--sm {
  width: 36px;
  height: 36px;
  font-size: 10px;
  border-radius: 10px;
  margin: 0;
}

.auth-brand h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-lede {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.auth-form .field {
  margin-bottom: 16px;
}

.auth-foot {
  margin: 20px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.form-msg {
  min-height: 1.25em;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.form-msg.is-err {
  color: var(--accent);
}

/* —— App shell —— */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.app-title {
  font-weight: 600;
  font-size: 1.05rem;
}

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

.user-pill {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  background: #f3f1f7;
  border: 1px solid var(--line);
}

.user-pill::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22a06b;
  margin-right: 8px;
  vertical-align: middle;
}

.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-card--hint {
  display: flex;
  align-items: center;
}

.stat-n {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-l {
  font-size: 13px;
  color: var(--muted);
}

.app-flash {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}

.app-flash.is-err {
  color: var(--accent);
}

.msg-preview {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}

.detail-list {
  margin: 0 0 16px;
}

.detail-list dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin-top: 12px;
}

.detail-list dt:first-child {
  margin-top: 0;
}

.detail-list dd {
  margin: 4px 0 0;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.app-body {
  flex: 1;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.app-status {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
  min-height: 1.25em;
}

.app-status.is-err {
  color: var(--accent);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab:hover {
  border-color: #c8c0d4;
}

.tab[aria-selected='true'] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.panel {
  display: none;
}

.panel.is-on {
  display: block;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head--row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.panel-head h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.field-hint {
  font-size: 13px;
  color: var(--muted);
  margin: -6px 0 12px;
  line-height: 1.45;
}

.field-hint a {
  color: var(--brand);
}

.field {
  margin-bottom: 10px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(27, 111, 189, 0.15);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  background: var(--ink);
  color: #fff;
  transition: background 0.15s;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn--primary {
  background: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--block {
  width: 100%;
  padding: 12px 16px;
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 500;
}

.btn--danger {
  background: var(--accent);
  font-size: 12px;
  padding: 6px 10px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  background: #faf9fc;
}

tbody tr:last-child td {
  border-bottom: none;
}

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eee;
}

.tag--off {
  opacity: 0.65;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 480px;
  width: calc(100% - 24px);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(30, 26, 43, 0.45);
}

.dialog-in {
  padding: 24px;
}

.dialog-in h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
  font-weight: 700;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
