/* ── Google Fonts ──────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:        #2563eb;
  --primary-hover:  #1d4ed8;
  --primary-dark:   #1e40af;
  --primary-light:  #eff6ff;
  --primary-ring:   rgba(37,99,235,0.12);

  /* Status */
  --green:      #16a34a; --green-bg:  #dcfce7;
  --amber:      #b45309; --amber-bg:  #fef3c7;
  --red:        #dc2626; --red-bg:    #fee2e2;
  --orange:     #ea580c; --orange-bg: #ffedd5;
  --sky:        #0284c7; --sky-bg:    #e0f2fe;
  --teal:       #0d9488; --teal-bg:   #ccfbf1;

  /* Slate scale */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Surface aliases */
  --bg:     var(--gray-50);
  --panel:  #ffffff;
  --panel-alt: var(--gray-50);
  --text:   var(--gray-800);
  --muted:  var(--gray-500);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);

  /* Radii */
  --r-xs:  4px;
  --r-sm:  6px;
  --r:     8px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  18px;
  --r-2xl: 24px;
}

/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p  { line-height: 1.65; }
a  { color: var(--primary); }

/* ── Auth page ─────────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--gray-900) 0%, #1e3a8a 55%, var(--primary) 100%);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: var(--r-2xl);
  padding: 36px 32px;
  box-shadow: 0 32px 72px rgba(0,0,0,0.28);
}

.auth-brand-logo {
  display: block;
  max-width: 180px;
  max-height: 56px;
  margin: 0 auto 22px;
  border-radius: var(--r);
}

.auth-card h2 { margin-bottom: 6px; color: var(--gray-900); font-size: 1.5rem; }
.auth-card > p { color: var(--muted); margin-bottom: 24px; font-size: 0.875rem; }

/* ── Global form primitives ────────────────────────────────── */
form { display: flex; flex-direction: column; gap: 14px; }

input, select, textarea, button {
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  padding: 10px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  background: #fff;
  outline: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

label {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--gray-700);
  letter-spacing: 0.01em;
  display: block;
  margin-bottom: 5px;
}

small {
  color: var(--muted);
  font-size: 0.77rem;
  display: block;
  margin-top: 5px;
  line-height: 1.5;
}

textarea { min-height: 100px; resize: vertical; }

code {
  font-family: 'Courier New', monospace;
  font-size: 0.82em;
  background: var(--gray-100);
  border-radius: var(--r-xs);
  padding: 1px 5px;
  color: var(--gray-700);
}

/* ── Buttons ───────────────────────────────────────────────── */
button, .btn {
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  width: auto;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 9px 18px;
  border-radius: var(--r-md);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1), 0 0 0 1px rgba(37,99,235,0.4);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 14px rgba(37,99,235,0.3); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 9px 18px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  padding: 9px 18px;
  border-radius: var(--r-md);
  border: 1.5px solid #fecaca;
}
.btn-danger:hover { background: #fecaca; }

.btn-sm {
  padding: 5px 12px !important;
  font-size: 0.78rem;
  border-radius: var(--r-sm) !important;
}

.btn-ghost {
  background: none;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  border: 1.5px solid transparent;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--text); }

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

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--gray-900);
  color: #fff;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.brand-wrap {
  display: flex;
  align-items: center;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.brand-logo {
  max-width: 140px;
  max-height: 40px;
  display: block;
  border-radius: var(--r);
  background: rgba(255,255,255,0.08);
  padding: 5px 8px;
}

.user-chip {
  margin: 14px 12px 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-info { overflow: hidden; }
.user-info strong {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: #e2e8f0;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-info span {
  font-size: 0.68rem;
  color: var(--gray-400);
  text-transform: capitalize;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  gap: 1px;
  overflow-y: auto;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-bottom: 8px;
}

.nav-section + .nav-section {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 8px;
}

.nav-section-title {
  padding: 4px 10px 3px;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--gray-500);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--gray-300);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--r);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.12s;
  position: relative;
}

.nav-link svg {
  flex-shrink: 0;
  color: var(--gray-500);
  transition: color 0.12s;
}

.nav-link:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-link:hover svg { color: var(--gray-300); }

.nav-link.active {
  background: rgba(37,99,235,0.2);
  color: #93c5fd;
  font-weight: 600;
}
.nav-link.active svg { color: #93c5fd; }

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.nav-link-logout { color: #f87171; }
.nav-link-logout:hover { background: rgba(239,68,68,0.12); color: #fca5a5; }
.nav-link-logout svg { color: #f87171; }

/* ── Content area ──────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 28px 32px 52px;
  min-width: 0;
}

/* ── Breadcrumbs ───────────────────────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.78rem;
}

.breadcrumbs a { color: var(--muted); text-decoration: none; font-weight: 500; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .breadcrumb-current { color: var(--gray-600); font-weight: 600; }
.breadcrumbs .breadcrumb-sep { color: var(--gray-300); }

/* ── Page header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h1 { font-size: 1.45rem; color: var(--gray-900); font-weight: 800; }
.page-header p  { margin-top: 4px; color: var(--muted); font-size: 0.875rem; }

/* ── Panels ────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.panel h3 { margin-bottom: 14px; font-size: 1rem; color: var(--gray-800); }

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel-header-row h3 { margin: 0; }

/* ── Hero panel (dashboard) ────────────────────────────────── */
.hero-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--gray-900) 0%, #1e3a8a 100%);
  border: none;
  color: #fff;
  padding: 28px 28px;
  overflow: hidden;
  position: relative;
}

.hero-panel::after {
  content: '';
  position: absolute;
  right: -40px; bottom: -40px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(37,99,235,0.18);
  pointer-events: none;
}

.hero-panel h2  { margin: 6px 0 0; color: #fff; font-size: 1.3rem; font-weight: 700; }
.hero-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: rgba(255,255,255,0.65); font-size: 0.82rem; }
.hero-meta span { font-weight: 700; color: rgba(255,255,255,0.9); text-transform: capitalize; }

/* ── Eyebrow label ─────────────────────────────────────────── */
.eyebrow {
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
}

.eyebrow-dark { color: var(--muted); }

/* ── Stat cards ────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.stat-card .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--primary);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-card strong {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
  display: block;
}

/* ── Quick actions ─────────────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.action-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
  box-shadow: var(--shadow-xs);
}

.action-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring), var(--shadow-sm);
  transform: translateY(-1px);
}

.action-card strong { font-size: 0.9rem; font-weight: 700; color: var(--gray-800); }
.action-card span   { font-size: 0.8rem; color: var(--muted); }

.action-card--disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  background: var(--surface-2, #f3f4f6);
}

/* ── Tables ────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

th {
  padding: 9px 14px;
  background: var(--gray-50);
  color: var(--gray-400);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

.table-panel { overflow-x: auto; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-blue   { background: #dbeafe;         color: #1d4ed8; }
.badge-green  { background: var(--green-bg); color: var(--green); }
.badge-amber  { background: var(--amber-bg); color: var(--amber); }
.badge-red    { background: var(--red-bg);   color: var(--red); }
.badge-orange { background: var(--orange-bg);color: var(--orange); }
.badge-sky    { background: var(--sky-bg);   color: var(--sky); }
.badge-teal   { background: var(--teal-bg);  color: var(--teal); }

/* status-pill: alias to badge (used in project header) */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ── Action groups in tables ───────────────────────────────── */
.action-group { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }

.link-btn {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 4px 9px;
  border-radius: var(--r-sm);
  transition: background 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.link-btn:hover { background: var(--primary-light); }
.link-btn-danger { color: var(--red, #dc2626); }
.link-btn-danger:hover { background: #fef2f2; color: var(--red, #dc2626); }

/* ── Flash / alerts ────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  margin-bottom: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
  line-height: 1.5;
}

.alert-success { background: var(--green-bg); color: #14532d; border-color: #bbf7d0; }
.alert-error   { background: var(--red-bg);   color: #7f1d1d; border-color: #fecaca; }
.alert-warning { background: var(--amber-bg); color: #78350f; border-color: #fde68a; }
.alert-info    { background: var(--sky-bg);   color: #0c4a6e; border-color: #bae6fd; }

/* ── Form grid ─────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(200px, 1fr));
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; }
.form-group.full { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 6px;
}
.form-actions.full { grid-column: 1 / -1; }

.form-hint   { font-size: 0.77rem; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.section-hint{ font-size: 0.82rem; color: var(--muted); margin: -8px 0 16px; line-height: 1.5; }

.section-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text);
}
.checkbox-inline input { width: auto; }

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, background .15s;
  user-select: none;
}
.checkbox-item:hover { border-color: var(--primary); background: var(--primary-light); }
.checkbox-item input[type="checkbox"] { width: auto; accent-color: var(--primary); }
.checkbox-item input[type="checkbox"]:checked + span { color: var(--primary); }
.checkbox-item:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  font-size: 0.875rem;
}

/* ── Rich text editor ──────────────────────────────────────── */
.rich-editor {
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.rich-editor:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.rich-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 10px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}

.rich-editor-toolbar button {
  padding: 4px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  width: auto;
  transition: all 0.12s;
}
.rich-editor-toolbar button:hover { background: var(--gray-100); }

.rich-editor-content {
  padding: 12px;
  min-height: 120px;
  outline: none;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
}

.rich-editor-content[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--gray-400);
  pointer-events: none;
}

/* ── Project page ──────────────────────────────────────────── */
.project-page-header { align-items: center; }
.project-header-copy { display: flex; flex-direction: column; gap: 4px; }
.project-header-copy p { margin: 0; color: var(--muted); font-size: 0.875rem; }
.project-header-actions { display: flex; align-items: center; gap: 10px; }

.project-shell { display: flex; flex-direction: column; gap: 18px; }

.project-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
}

.tab-link {
  display: inline-flex;
  align-items: center;
  padding: 9px 20px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.875rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  background: none;
  white-space: nowrap;
}
.tab-link:hover { color: var(--text); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

.project-dashboard { display: flex; flex-direction: column; gap: 18px; }

.project-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 16px;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}
.metric-card span   { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
.metric-card strong { font-size: 1rem; font-weight: 700; color: var(--gray-800); }

.project-grid {
  display: grid;
  grid-template-columns: 1.7fr 0.8fr;
  gap: 20px;
}
.project-main-panel, .project-side-panel { margin-bottom: 0; }

.detail-blocks { display: flex; flex-direction: column; gap: 18px; }
.detail-block label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 4px;
}
.detail-block p { margin: 0; color: var(--text); font-size: 0.875rem; line-height: 1.65; }

.action-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.tips-box {
  margin-top: 16px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
}
.tips-box p  { margin: 0 0 8px; font-size: 0.8rem; color: var(--muted); }
.tips-box ul { margin: 0; padding: 0 0 0 16px; }
.tips-box li { font-size: 0.82rem; color: var(--gray-600); font-family: 'Courier New', monospace; line-height: 1.9; }

/* ── Certification ─────────────────────────────────────────── */
.certification-shell { display: flex; flex-direction: column; gap: 18px; }

.certification-grid {
  display: grid;
  grid-template-columns: 1.5fr 0.9fr;
  gap: 20px;
}

.certification-card { margin-bottom: 0; }

.certification-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--primary-light) 0%, #dbeafe 100%);
  border-color: #bfdbfe;
}
.certification-hero h3 { margin-bottom: 0; color: var(--primary-dark); }

.mini-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-summary span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(37,99,235,0.1);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.78rem;
}

.meta-stack { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-item span   { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.meta-item strong { font-size: 0.9rem; color: var(--text); }

.category-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.category-row:last-of-type { border-bottom: none; }
.category-create { padding-top: 14px; }
.category-field { flex: 1; }
.category-field input { margin: 0; }
.category-actions { display: flex; gap: 8px; }

/* ── Certificate bg preview ────────────────────────────────── */
.certificate-bg-preview {
  display: block;
  max-width: 240px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  margin-bottom: 8px;
}

/* ── Logs ──────────────────────────────────────────────────── */
.log-meta {
  max-height: 70px;
  border-radius: var(--r);
  background: var(--gray-50);
  padding: 6px 10px;
  border: 1px solid var(--border);
  overflow-y: auto;
  font-size: 0.8rem;
}

/* ── Category tabs (cert per-category settings) ────────────── */
.cat-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.cat-tab {
  padding: 8px 18px;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  width: auto;
}
.cat-tab:hover { color: var(--text); }
.cat-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.cat-panel { display: none; }
.cat-panel.active { display: grid; }

.cat-settings-grid { grid-template-columns: 1fr 1.4fr; gap: 28px; align-items: start; }
.cat-form-col { display: flex; flex-direction: column; gap: 0; }

/* ── Certificate live preview ──────────────────────────────── */
.cert-preview-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 72px;
}

.cert-doc-type-toggle {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  border-radius: var(--r);
  padding: 4px;
  align-self: flex-start;
}

.cert-doc-type-toggle .toggle-btn {
  padding: 6px 16px;
  border: none;
  background: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s;
  width: auto;
}
.cert-doc-type-toggle .toggle-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.cert-preview-container { container-type: inline-size; width: 100%; }

.cert-preview {
  width: 100%;
  aspect-ratio: 842 / 595;
  position: relative;
  overflow: hidden;
  border-radius: 2px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  font-family: Helvetica, Arial, sans-serif;
  background-color: #f3f6fb;
  transition: background-color 0.25s;
}

.cp-border { position: absolute; pointer-events: none; }
.cp-border-outer { top:8.4%;left:7.1%;right:7.1%;bottom:8.4%;border:2px solid #8C6B29; }
.cp-border-inner { top:10.4%;left:8.5%;right:8.5%;bottom:10.4%;border:1px solid #8C6B29; }

.cp-title      { position:absolute;top:18%;left:10%;width:80%;text-align:center;font-size:3.6cqi;font-weight:bold;letter-spacing:0.08em;text-transform:uppercase;color:#1f2937;transition:color 0.2s; }
.cp-conferimos { position:absolute;top:28%;left:10%;width:80%;text-align:center;font-size:1.3cqi;color:#1f2937;transition:color 0.2s; }
.cp-participant { position:absolute;top:33%;left:21%;width:69%;font-size:2.5cqi;font-weight:bold;color:#1f2937;transition:color 0.2s; }
.cp-name-line  { position:absolute;top:40%;left:21%;width:58%;height:1px;background-color:#8C6B29; }
.cp-project    { position:absolute;top:43%;left:16.6%;width:73.4%;font-size:1.2cqi;color:#1f2937;transition:color 0.2s; }
.cp-body       { position:absolute;top:50%;left:8.3%;width:81.7%;bottom:22%;font-size:1.35cqi;line-height:1.5;color:#1f2937;overflow:hidden;transition:color 0.2s;white-space:pre-wrap;word-break:break-word; }

.cp-footer   { position:absolute;top:91%;left:7%;font-size:0.85cqi;color:#1f2937;transition:color 0.2s; }
.cp-valcode  { position:absolute;top:87%;left:7%;font-size:0.9cqi;font-weight:600;color:#1f2937;transition:color 0.2s; }
.cp-qrcode   { position:absolute;top:74%;left:74%; }
.cp-qr-visual { width:8cqi;height:8cqi;background:repeating-conic-gradient(#333 0% 25%,transparent 0% 50%) 0 0/3px 3px; }

/* ── Portrait declaration preview ──────────────────────────── */
.cert-preview.is-portrait { aspect-ratio: 595 / 842; }
.cert-preview.is-portrait .cp-title      { top:8%;  left:7%; width:86%; font-size:3cqi; }
.cert-preview.is-portrait .cp-conferimos { top:15%; left:7%; width:86%; }
.cert-preview.is-portrait .cp-participant{ top:21%; left:7%; width:86%; font-size:2.2cqi; }
.cert-preview.is-portrait .cp-name-line  { top:26%; left:7%; width:86%; }
.cert-preview.is-portrait .cp-project    { top:29%; left:7%; width:86%; }
.cert-preview.is-portrait .cp-body       { top:35%; left:7%; width:86%; bottom:14%; }
.cert-preview.is-portrait .cp-footer     { top:90%; left:7%; width:86%; }
.cert-preview.is-portrait .cp-valcode    { top:85%; left:7%; }
.cert-preview.is-portrait .cp-qrcode     { top:78%; left:60%; }

/* ── Drag-to-position editor ───────────────────────────────── */
.cert-preview.drag-mode .cp-draggable {
  cursor: grab;
  outline: 2px dashed rgba(37,99,235,0.5);
  outline-offset: 3px;
  user-select: none;
  border-radius: 2px;
}
.cert-preview.drag-mode .cp-draggable:hover {
  outline-color: var(--primary);
  background: rgba(37,99,235,0.05);
}
.cert-preview.drag-mode .cp-draggable.is-dragging {
  cursor: grabbing;
  z-index: 10;
  outline-color: var(--primary);
  background: rgba(37,99,235,0.08);
}
.cert-preview.drag-mode .cp-draggable.is-selected {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  background: rgba(37,99,235,0.06);
}

/* ── Element context toolbar ───────────────────────────────── */
.elem-toolbar {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  display: none;
  gap: 2px;
  padding: 4px;
  align-items: center;
  pointer-events: auto;
}
.elem-toolbar.visible { display: flex; }
.elem-toolbar button {
  width: 28px; height: 28px;
  border: none; background: transparent;
  border-radius: 4px; cursor: pointer;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  color: var(--text); transition: background 0.12s;
}
.elem-toolbar button:hover { background: var(--slate-100); }
.elem-toolbar button.tb-active { background: var(--primary); color: #fff; }
.elem-toolbar button.tb-delete:hover { background: #dc2626; color: #fff; }
.elem-toolbar .tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

/* ── Restore-element dropdown ──────────────────────────────── */
.restore-wrap { position: relative; }
.restore-menu {
  position: absolute;
  top: calc(100% + 4px); left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  padding: 4px;
  display: none;
  min-width: 175px;
}
.restore-menu.visible { display: block; }
.restore-menu button {
  display: block; width: 100%; text-align: left;
  padding: 6px 10px; border: none; background: transparent;
  border-radius: 4px; cursor: pointer; font-size: 0.8rem; color: var(--text);
}
.restore-menu button:hover { background: var(--slate-100); }
.restore-menu p { padding: 6px 10px; font-size: 0.78rem; color: var(--muted); margin: 0; }

.apply-all-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.apply-all-label input[type=checkbox] { cursor: pointer; accent-color: var(--primary); }

.layout-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.drag-hint {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
  display: none;
}
.cert-preview.drag-mode ~ .drag-hint { display: block; }

.preview-caption { font-size:0.72rem;color:var(--muted);text-align:center;margin:0; }

/* ── Cat new-category row ──────────────────────────────────── */
.cat-new-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
.cat-new-row input[type=text] { flex: 1; }

/* ── Inline save toast ─────────────────────────────────────── */
.save-toast {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: var(--r);
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.save-toast.visible { opacity: 1; }
.save-toast.ok  { background: var(--green-bg); color: #14532d; }
.save-toast.err { background: var(--red-bg);   color: #7f1d1d; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 960px) {
  .app-shell { display: block; }
  .sidebar   { width: 100%; height: auto; position: static; flex-direction: row; padding: 12px 16px; gap: 12px; }
  .sidebar-nav, .user-chip { display: none; }
  .content   { padding: 16px 16px 32px; }
  .cards-grid, .project-metrics { grid-template-columns: 1fr 1fr; }
  .form-grid  { grid-template-columns: 1fr; }
  .quick-actions, .project-grid, .certification-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .cat-settings-grid { grid-template-columns: 1fr; }
  .cert-preview-area { position: static; }
  .hero-panel { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 600px) {
  .cards-grid, .project-metrics { grid-template-columns: 1fr; }
}
