:root {
  --sidebar-w: 230px;

  /* Life Puzzle brand */
  --brand:       #0057B8;  /* Royal Blue */
  --brand-dark:  #001968;  /* Navy */
  --navy:        #001968;
  --teal:        #0D7C87;
  --grey:        #AAA9AD;

  --surface:        #ffffff;
  --surface-subtle: #fafafa;
  --surface-hover:  #f3f4f6;
  --bg:             #f4f6fb;
  --text:           #1a1a2e;
  --text-secondary: #374151;
  --text-muted:     #6b7280;
  --text-faint:     #9ca3af;
  --border:         #e5e7eb;
  --radius:         10px;
  --shadow:         0 2px 12px rgba(0,0,0,0.07);

  /* Status badge tokens */
  --status-green-bg:     #dcfce7;
  --status-green-text:   #166534;
  --status-yellow-bg:    #fef9c3;
  --status-yellow-text:  #854d0e;
  --status-red-bg:       #fee2e2;
  --status-red-text:     #991b1b;
  --status-danger-border:#fca5a5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Auth ── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-shell { width: 100%; max-width: 400px; padding: 24px; }
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 28px; font-size: 1.1rem; font-weight: 700; }
.auth-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 24px; }

/* ── Shell ── */
.admin-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 16px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  gap: 0;
}

.logo-mark-lg {
  width: 62px; height: 62px;
  background: linear-gradient(145deg, #1a7ddd 0%, #0057B8 55%, #003d96 100%);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,87,184,0.45), 0 2px 6px rgba(0,0,0,0.3);
  flex-shrink: 0;
  margin-bottom: 14px;
}

.sidebar-brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.01em;
  line-height: 1.2;
  margin-bottom: 6px;
}

.sidebar-brand-tag {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
}

/* Small mark used on login page */
.logo-mark {
  width: 32px; height: 32px;
  background: var(--brand);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800; color: white;
}

.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  margin: 1px 8px;
  transition: all 0.15s;
}
.sidebar-nav li a svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-nav li a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav li a.active { background: var(--brand); color: #fff; }
.sidebar-nav li.sidebar-section-label {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: rgba(255,255,255,0.25);
  padding: 14px 16px 4px; margin-top: 4px;
}

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.btn-logout {
  display: block; text-align: center;
  padding: 8px; border-radius: 6px;
  color: #94a3b8; text-decoration: none; font-size: 0.8rem;
  transition: all 0.15s;
}
.btn-logout:hover { color: #fff; background: rgba(255,255,255,0.06); }

/* ── Main ── */
.admin-main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }

.admin-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}

.page-heading { font-size: 1.15rem; font-weight: 700; }

.admin-content { padding: 28px 32px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Padded card content area — use instead of inline style="padding:20px" */
.card-body { padding: 24px; }

/* Card with title bar + optional action button */
.card-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.card-title-bar h2 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.card-title-bar p  { margin: 3px 0 0; font-size: 0.8rem; color: var(--text-muted); }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { font-size: 0.9rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

/* Card that contains a full-bleed table — no padding, clipped corners */
.card--table { overflow: hidden; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card--warn { border-color: #fca5a5; background: #fff7f7; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--text); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }
.empty { text-align: center; color: var(--text-muted); padding: 40px !important; }

/* ── Detail list ── */
.detail-list { }
.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row > span:first-child { min-width: 130px; color: var(--text-muted); font-size: 0.85rem; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge--active, .badge--synced { background: var(--status-green-bg);  color: var(--status-green-text); }
.badge--draft, .badge--pending  { background: var(--status-yellow-bg); color: var(--status-yellow-text); }
.badge--closed, .badge--failed  { background: var(--status-red-bg);    color: var(--status-red-text); }
.badge--skipped { background: var(--border); color: var(--text-secondary); }

/* ── Misc ── */
.link { color: var(--brand); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }
.muted { color: var(--text-muted); }
code, .api-key { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.82rem; background: #f3f4f6; padding: 2px 6px; border-radius: 4px; word-break: break-all; }
.code-block { background: #0f172a; color: #e2e8f0; padding: 16px 20px; font-size: 0.8rem; overflow-x: auto; font-family: 'SF Mono', monospace; line-height: 1.6; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--brand); }

.btn { display: inline-flex; align-items: center; padding: 9px 20px; border-radius: 8px; font-size: 0.9rem; font-weight: 600; cursor: pointer; border: none; font-family: inherit; transition: all 0.15s; text-decoration: none; }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { opacity: 0.88; }
.btn-secondary { background: none; border: 1.5px solid var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: none; border: 1.5px solid var(--border); color: var(--text-muted); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); background: none; }
.btn-danger { background: none; border: 1.5px solid var(--status-danger-border); color: #dc2626; }
.btn-danger:hover { background: var(--status-red-bg); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.875rem; }
.alert-error   { background: var(--status-red-bg);    color: var(--status-red-text); }
.alert-success { background: var(--status-green-bg); color: var(--status-green-text); }

/* Dashboard action link */
.dash-action { display:inline-flex;align-items:center;gap:6px;padding:8px 16px;background:var(--brand);color:#fff;border-radius:8px;font-size:0.875rem;font-weight:600;text-decoration:none; }
.dash-action:hover { opacity:0.88; }

/* Timeline */
.timeline { padding: 16px 20px; }
.timeline-item { display:flex;gap:14px;margin-bottom:18px; }
.timeline-dot { width:10px;height:10px;border-radius:50%;background:var(--brand);margin-top:4px;flex-shrink:0; }
.timeline-body { flex:1; }
.timeline-type { font-size:0.875rem;font-weight:600;text-transform:capitalize; }
.timeline-meta { font-size:0.8rem;color:var(--text-muted);margin-top:2px; }
.timeline-detail { font-size:0.75rem;color:var(--text-muted);margin-top:3px;font-family:monospace; }
.timeline-time { font-size:0.75rem;color:#9ca3af;margin-top:4px; }

/* Duplicate survey button */
.btn-duplicate { background:none;border:1.5px solid var(--border);color:var(--text-muted);padding:5px 12px;border-radius:7px;font-size:0.8rem;cursor:pointer;font-family:inherit;transition:all 0.12s; }
.btn-duplicate:hover { border-color:var(--brand);color:var(--brand); }

/* ── Filter bar ── */
.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-bar label { font-weight: 600; font-size: 0.875rem; white-space: nowrap; }
.filter-bar input[type="text"],
.filter-bar input[type="search"],
.filter-bar select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  background: var(--surface);
  transition: border-color 0.15s;
}
.filter-bar input[type="text"]:focus,
.filter-bar input[type="search"]:focus,
.filter-bar select:focus { border-color: var(--brand); }
.filter-bar .filter-grow { flex: 1; min-width: 160px; }

/* Helper text below form fields */
.hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 5px; line-height: 1.4; }

/* Colour dot — inline category/tag indicator */
.dot { display: inline-block; border-radius: 50%; flex-shrink: 0; }

/* ── Action menu dropdown ── */
.action-menu { position: relative; display: inline-block; }
.action-trigger {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 7px; font-size: 0.8rem; font-weight: 600; color: var(--text);
  cursor: pointer; font-family: inherit; transition: all 0.12s; white-space: nowrap;
}
.action-trigger:hover { border-color: var(--brand); color: var(--brand); }
.action-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 100;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 9px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); min-width: 160px; padding: 4px;
  white-space: nowrap;
}
.action-dropdown.open { display: block; }
.action-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px; border: none; background: none;
  font-size: 0.825rem; font-weight: 500; color: var(--text); cursor: pointer;
  font-family: inherit; text-decoration: none; border-radius: 6px; transition: background 0.1s;
}
.action-item svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-muted); }
.action-item:hover { background: #f3f4f6; }
.action-item--danger { color: #dc2626; }
.action-item--danger svg { color: #dc2626; }
.action-item--danger:hover { background: #fee2e2; }
.action-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
.modal {
  background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
}
.modal-close {
  width: 28px; height: 28px; border: none; background: none; cursor: pointer;
  color: var(--text-muted); border-radius: 6px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; transition: background 0.1s;
}
.modal-close:hover { background: #f3f4f6; color: var(--text); }
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: 20px; }

/* ── Export link list items ── */
.export-link-item {
  display: flex; align-items: flex-start; padding: 12px; margin-bottom: 8px;
  border: 1.5px solid var(--border); border-radius: 8px; gap: 12px;
  transition: border-color 0.12s;
}
.export-link-item:hover { border-color: #c7d2fe; }
.el-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border: 1.5px solid var(--border); background: var(--surface);
  border-radius: 6px; font-size: 0.775rem; font-weight: 600; color: var(--text);
  cursor: pointer; font-family: inherit; white-space: nowrap; transition: all 0.12s;
}
.el-btn svg { width: 13px; height: 13px; }
.el-btn:hover { border-color: var(--brand); color: var(--brand); }
.el-btn--copy:hover { border-color: #059669; color: #059669; }
.el-btn--danger { color: #dc2626; border-color: var(--status-danger-border); }
.el-btn--danger:hover { background: var(--status-red-bg); }

.btn-delete { background:none;border:1.5px solid var(--status-danger-border);color:#ef4444;padding:5px 12px;border-radius:7px;font-size:0.8rem;cursor:pointer;font-family:inherit;transition:all 0.12s; }
.btn-delete:hover { background:var(--status-red-bg);border-color:#ef4444; }

/* ── Searchable Select (ss-select lego block) ────────────────────────────── */
.ss-wrap { position:relative; display:block; }
.ss-wrap::after { content:'▾'; position:absolute; right:10px; top:50%; transform:translateY(-50%); pointer-events:none; color:var(--text-muted); font-size:0.85rem; }
.ss-input { display:block; width:100%; box-sizing:border-box; padding:7px 30px 7px 10px; border:1px solid var(--border); border-radius:6px; font-family:inherit; font-size:0.82rem; color:var(--navy); background:#fff; outline:none; transition:border-color 0.15s; cursor:pointer; }
.ss-input:focus { border-color:var(--brand); cursor:text; }
.ss-list { display:none; position:absolute; top:calc(100% + 2px); left:0; right:0; z-index:400; background:#fff; border:1px solid var(--border); border-radius:8px; box-shadow:0 4px 16px rgba(0,0,0,0.1); max-height:220px; overflow-y:auto; padding:4px; }
.ss-item { padding:7px 10px; border-radius:5px; cursor:pointer; font-size:0.82rem; color:var(--navy); }
.ss-item:hover { background:#eff6ff; color:#0057B8; }
