/* ============================================================
   CertifyPro — Interface
   ============================================================ */

:root {
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(99, 102, 241, .12);
  --accent-ring: rgba(99, 102, 241, .30);
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceef2;
  --border: #e4e6ec;
  --border-strong: #d3d6df;
  --text: #101218;
  --text-2: #5c6070;
  --text-3: #8e92a3;
  --shadow-xs: 0 1px 2px rgba(16, 18, 24, .06);
  --shadow-sm: 0 2px 6px rgba(16, 18, 24, .06);
  --shadow: 0 10px 26px rgba(16, 18, 24, .10);
  --shadow-lg: 0 24px 60px rgba(16, 18, 24, .18);
  --r-xs: 6px;
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;
  --danger: #e5484d;
  --success: #12a594;
  --sidebar-w: 244px;
  --navbar-h: 60px;
  --tabbar-h: 66px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --spring: cubic-bezier(.2, .9, .3, 1.25);
}

[data-theme="dark"] {
  --bg: #0b0c10;
  --surface: #14161d;
  --surface-2: #191c24;
  --surface-3: #22252f;
  --border: #24272f;
  --border-strong: #333743;
  --text: #f0f1f5;
  --text-2: #a2a6b5;
  --text-3: #71758a;
  --accent-soft: rgba(129, 132, 255, .16);
  --accent-ring: rgba(129, 132, 255, .38);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .4);
  --shadow: 0 12px 30px rgba(0, 0, 0, .55);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
::selection { background: var(--accent-ring); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
#app { min-height: 100vh; }

/* ============================================================
   SIDEBAR — dark rail
   ============================================================ */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 20px 14px 16px;
  z-index: 40;
  color: #fff;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(99,102,241,.35), transparent 60%),
    radial-gradient(120% 60% at 100% 100%, rgba(139,92,246,.28), transparent 60%),
    linear-gradient(180deg, #16182a, #0e0f1c);
  border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(180deg, #000, transparent 70%);
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 70%);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; position: relative; z-index: 1; }
.brand-logo {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(99,102,241,.5);
}
.brand-logo svg { width: 22px; height: 22px; stroke-width: 2; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.brand-text span { font-size: 11.5px; color: rgba(255,255,255,.5); }

.side-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; position: relative; z-index: 1; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 550; color: rgba(255,255,255,.62);
  transition: color .18s var(--ease), background .18s var(--ease);
}
.nav-item::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%) scaleY(.2);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent);
  opacity: 0; transition: opacity .2s var(--ease), transform .28s var(--spring);
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.10); }
.nav-item.active::before { opacity: 1; transform: translateY(-50%) scaleY(1); }
.nav-item svg { width: 19px; height: 19px; }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 1; }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--navbar-h);
  z-index: 45; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 clamp(20px, 3vw, 40px);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.navbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.navbar-mark { display: none; }
.navbar-title h1 { font-size: 17px; font-weight: 750; letter-spacing: -.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navbar-right { display: flex; align-items: center; gap: 10px; }

/* ============================================================
   SEGMENTED / LANG
   ============================================================ */
.lang-switch, .seg {
  display: flex; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; gap: 2px;
}
.lang-switch button, .seg button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 8px; border-radius: var(--r-xs);
  font-size: 12.5px; font-weight: 650; color: var(--text-2);
  transition: color .16s var(--ease), background .16s var(--ease), box-shadow .16s var(--ease);
  white-space: nowrap;
}
.lang-switch button:hover, .seg button:hover { color: var(--text); }
.lang-switch button.active, .seg button.active {
  background: var(--surface); color: var(--accent);
  box-shadow: var(--shadow-xs);
}
.seg button svg { width: 16px; height: 16px; }
.seg-sm button { padding: 5px 9px; font-size: 11.5px; }
.lang-switch-compact button { padding: 5px 7px; font-size: 11.5px; }

/* dark sidebar variant for the language switch */
.sidebar .lang-switch { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); }
.sidebar .lang-switch button { color: rgba(255,255,255,.6); }
.sidebar .lang-switch button:hover { color: #fff; }
.sidebar .lang-switch button.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: none; }

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
  width: 42px; height: 42px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--text-2);
  border: 1px solid var(--border); background: var(--surface-2);
  transition: color .2s var(--ease), border-color .2s var(--ease), transform .3s var(--spring);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent-ring); }
.theme-toggle:active { transform: rotate(45deg) scale(.9); }
.theme-toggle .ico-sun { display: none; }
[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
.navbar .theme-toggle { width: 38px; height: 38px; }
.sidebar .theme-toggle { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); color: rgba(255,255,255,.7); }
.sidebar .theme-toggle:hover { color: #fff; border-color: rgba(255,255,255,.25); }

/* ============================================================
   MAIN / VIEWS / MOTION
   ============================================================ */
#main {
  margin-left: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  padding: calc(var(--navbar-h) + 22px) clamp(20px, 3vw, 48px) 60px;
}
.view { display: none; }
.view.active { display: block; animation: viewIn .34s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }

h1 { font-size: clamp(22px, 2.6vw, 30px); font-weight: 750; letter-spacing: -.6px; line-height: 1.15; }
.muted { color: var(--text-2); font-size: 13.5px; margin-top: 5px; }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px 22px; border-radius: var(--r);
  background: linear-gradient(115deg, #1c1f38 0%, #2a2450 45%, #3a2b63 100%);
  color: #fff; box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.hero::before {
  content: ''; position: absolute; inset: -50% -20%;
  background: conic-gradient(from 0deg, transparent, rgba(139,92,246,.35), transparent 30%);
  animation: heroSpin 14s linear infinite; pointer-events: none;
}
@keyframes heroSpin { to { transform: rotate(360deg); } }
.hero > * { position: relative; z-index: 1; }
.hero-text p { color: rgba(255,255,255,.82); font-size: 14px; margin: 0; }

/* ============================================================
   STATS
   ============================================================ */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
  animation: rise .45s var(--ease) both;
}
.stat-card:nth-child(1) { animation-delay: .03s; }
.stat-card:nth-child(2) { animation-delay: .09s; }
.stat-card:nth-child(3) { animation-delay: .15s; }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.stat-ico { width: 46px; height: 46px; border-radius: var(--r-sm); display: grid; place-items: center; transition: transform .3s var(--spring); }
.stat-card:hover .stat-ico { transform: scale(1.07); }
.stat-ico svg { width: 22px; height: 22px; }
.stat-ico.c1 { background: var(--accent-soft); color: var(--accent); }
.stat-ico.c2 { background: rgba(18,165,148,.13); color: var(--success); }
.stat-ico.c3 { background: rgba(245,158,11,.14); color: #e08b00; }
.stat-card > div { display: flex; flex-direction: column; }
.stat-num { font-size: 26px; font-weight: 750; line-height: 1; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--text-2); margin-top: 5px; }

/* ============================================================
   PANEL
   ============================================================ */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-xs); padding: 22px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -.3px; }
.link-btn { color: var(--accent); font-size: 13px; font-weight: 650; padding: 6px 10px; border-radius: var(--r-xs); transition: background .18s var(--ease); }
.link-btn:hover { background: var(--accent-soft); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin-top: 8px; }
.page-head.compact { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.page-head.compact .muted { margin: 0; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 17px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 650; letter-spacing: -.1px;
  transition: transform .14s var(--ease), box-shadow .22s var(--ease), background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
  white-space: nowrap; border: 1px solid transparent;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 17px; height: 17px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; border-radius: var(--r); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: var(--r-xs); gap: 6px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 6px 18px var(--accent-ring); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 26px var(--accent-ring); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: rgba(229,72,77,.35); }
.btn-danger:hover { background: rgba(229,72,77,.08); }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.searchbox {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 0 14px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.searchbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbox svg { width: 17px; height: 17px; color: var(--text-3); }
.searchbox input { flex: 1; border: none; background: none; outline: none; padding: 11px 0; font-size: 13.5px; color: var(--text); }
.searchbox input::placeholder { color: var(--text-3); }
.select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235c6070' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 11px 38px 11px 14px; font-size: 13.5px; color: var(--text); outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ============================================================
   CERT CARDS
   ============================================================ */
.card-list { display: flex; flex-direction: column; gap: 8px; }
.cert-card {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 15px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 13px 16px 13px 20px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
  animation: rise .4s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}
.cert-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(var(--thumb-a, #1e1b4b), var(--thumb-b, #312e81));
}
.cert-card:hover { transform: translateX(3px); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.cert-thumb {
  position: relative; width: 58px; height: 44px; border-radius: var(--r-xs); flex-shrink: 0;
  background: linear-gradient(135deg, var(--thumb-a, #1e1b4b), var(--thumb-b, #312e81));
  box-shadow: 0 4px 10px rgba(16,18,24,.2), inset 0 1px 0 rgba(255,255,255,.2);
  overflow: hidden;
}
.cert-thumb::after { content: ''; position: absolute; inset: 5px; border: 1.5px solid rgba(255,255,255,.4); border-radius: 4px; }
.cert-thumb::before {
  content: ''; position: absolute; left: 50%; top: 9px; transform: translateX(-50%);
  width: 20px; height: 2px; border-radius: 2px; background: rgba(255,255,255,.85);
  box-shadow: 0 5px 0 rgba(255,255,255,.35), 0 10px 0 rgba(255,255,255,.22);
}
.cert-info { flex: 1; min-width: 0; }
.cert-info h3 { font-size: 14.5px; font-weight: 650; letter-spacing: -.1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cert-info p { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.cert-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.cert-badge { font-size: 10.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; letter-spacing: .4px; background: var(--accent-soft); color: var(--accent); }
.cert-badge.all { background: rgba(245,158,11,.15); color: #c97e00; }
.cert-date { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.cert-actions { display: flex; gap: 4px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-xs);
  display: grid; place-items: center;
  color: var(--text-2); transition: color .16s var(--ease), background .16s var(--ease), transform .16s var(--ease);
}
.icon-btn:hover { color: var(--accent); background: var(--accent-soft); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.danger:hover { color: var(--danger); background: rgba(229,72,77,.1); }
.icon-btn svg { width: 17px; height: 17px; }

/* ============================================================
   EMPTY
   ============================================================ */
.empty { text-align: center; padding: 60px 24px; color: var(--text-2); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); animation: rise .45s var(--ease) both; }
.empty svg { width: 50px; height: 50px; opacity: .4; margin: 0 auto 14px; }
.empty h3 { color: var(--text); font-size: 17px; margin-bottom: 6px; font-weight: 700; }
.empty p { font-size: 13.5px; margin-bottom: 18px; }

/* ============================================================
   FORMS
   ============================================================ */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 24px; align-items: start; }
.split-form, .split-preview { min-width: 0; }
.split-form { display: flex; flex-direction: column; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 7px; color: var(--text-2); }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 13px; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.field textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.hint { font-size: 11.5px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 13px; }

.color-input { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 12px; transition: border-color .18s var(--ease); }
.color-input:hover { border-color: var(--border-strong); }
.color-input input[type="color"] { width: 30px; height: 30px; padding: 0; border: none; border-radius: var(--r-xs); background: none; cursor: pointer; }
.color-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input input[type="color"]::-webkit-color-swatch { border: none; border-radius: var(--r-xs); box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.color-input span { font-size: 12.5px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

.actions-row { display: flex; gap: 10px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.sticky-actions { position: sticky; bottom: 14px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); z-index: 5; }

/* media upload */
.media-field { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.media-upload { position: relative; width: 100%; border: 1px dashed var(--border-strong); border-radius: var(--r-sm); padding: 16px; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .18s var(--ease), background .18s var(--ease); }
.media-upload:hover { border-color: var(--accent); background: var(--accent-soft); }
.media-upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.media-placeholder { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.media-placeholder svg { width: 30px; height: 30px; }
.media-preview { width: 88px; height: 88px; margin: 0 auto; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); background: #fff; }
.media-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================================
   CARD SECTIONS
   ============================================================ */
.card-sec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; margin-bottom: 14px; box-shadow: var(--shadow-xs); animation: rise .45s var(--ease) both; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.sec-head h3 { font-size: 14.5px; font-weight: 700; letter-spacing: -.2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch-row strong { font-size: 13.5px; font-weight: 600; }
.switch-row .hint { margin-top: 2px; }

.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .25s var(--ease); cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .25s var(--spring); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }

.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.danger-zone { border-color: rgba(229,72,77,.3); }

/* ============================================================
   BACK
   ============================================================ */
.back-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13.5px; font-weight: 600; padding: 7px 11px 7px 7px; border-radius: var(--r-sm); margin-bottom: 6px; transition: color .18s var(--ease), background .18s var(--ease); }
.back-btn:hover { color: var(--accent); background: var(--accent-soft); }
.back-btn svg { width: 17px; height: 17px; }

/* ============================================================
   PREVIEW
   ============================================================ */
.split-preview { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 10px; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 700; color: var(--text-2); padding: 0 2px; }
.preview-size { font-size: 11px; color: var(--text-3); font-weight: 600; }
.preview-stage { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); padding: 22px; overflow: auto; display: flex; align-items: center; justify-content: center; min-height: 180px; }

/* ============================================================
   CERTIFICATE DOCUMENT
   ============================================================ */
.cert-scaler { width: 100%; display: block; }
.cert-canvas { position: relative; overflow: hidden; font-family: var(--c-font, 'Playfair Display', serif); display: flex; flex-direction: column; flex-shrink: 0; box-shadow: 0 18px 46px rgba(0,0,0,.28); }
.cert-canvas.landscape { width: 1122px; height: 794px; }
.cert-canvas.portrait { width: 794px; height: 1122px; }
.cert-inner { position: relative; z-index: 4; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 84px; text-align: center; }
.cert-pattern-frame { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.cert-pattern-rays { position: absolute; z-index: 2; pointer-events: none; }
.cert-glow { position: absolute; z-index: 1; pointer-events: none; left: 50%; top: 46%; transform: translate(-50%, -50%); width: 720px; height: 420px; border-radius: 50%; background: radial-gradient(ellipse, var(--glow, rgba(255,255,255,.14)), transparent 70%); }
.cert-watermark { position: absolute; z-index: 1; pointer-events: none; right: 44px; bottom: 38px; width: 180px; height: 180px; opacity: .06; }
.cert-photo { position: absolute; z-index: 5; top: 62px; right: 70px; width: 126px; height: 126px; border-radius: 50%; object-fit: cover; border: 4px solid var(--c-accent, #fbbf24); box-shadow: 0 10px 24px rgba(0,0,0,.35); background: rgba(255,255,255,.08); }
.cert-logo { max-height: 74px; max-width: 210px; margin-bottom: 14px; object-fit: contain; }
.cert-label { font-size: 46px; letter-spacing: .3em; text-indent: .3em; font-weight: 700; margin-bottom: 4px; font-family: 'Playfair Display', serif; line-height: 1.1; }
.cert-divider { width: 88px; height: 3px; border-radius: 3px; margin: 12px auto 16px; }
.cert-subtitle { font-size: 18.5px; letter-spacing: .08em; opacity: .92; }
.cert-name { font-family: 'Great Vibes', cursive; font-size: 74px; line-height: 1.12; margin: 10px 0 2px; }
.cert-body { font-size: 16px; max-width: 780px; line-height: 1.6; font-family: 'Source Sans 3', sans-serif; }
.cert-footer { font-size: 14.5px; margin-top: 16px; opacity: .85; font-style: italic; font-family: 'Source Sans 3', sans-serif; }
.cert-company { margin-top: 12px; font-size: 15.5px; font-weight: 700; letter-spacing: .06em; }
.cert-company small { display: block; font-weight: 400; font-size: 12.5px; letter-spacing: .05em; opacity: .75; margin-top: 2px; }
.cert-doc-meta { display: flex; align-items: flex-end; justify-content: space-between; width: 100%; margin-top: 26px; gap: 20px; }
.cert-meta-left { text-align: left; font-size: 12.5px; letter-spacing: .04em; opacity: .85; line-height: 1.65; }
.cert-meta-left b { font-size: 13.5px; letter-spacing: .08em; }
.cert-qr { width: 76px; height: 76px; background: #fff; padding: 5px; border-radius: var(--r-xs); }
.cert-qr img, .cert-qr canvas { width: 100%; height: 100%; }
.cert-sign { text-align: center; min-width: 205px; }
.cert-sign-img { height: 52px; object-fit: contain; margin: 0 auto 2px; }
.cert-sign-line { border-top: 1.5px solid currentColor; width: 210px; margin: 8px auto 0; opacity: .8; }
.cert-sign-name { font-size: 14.5px; font-weight: 700; letter-spacing: .05em; margin-top: 9px; font-family: 'Source Sans 3', sans-serif; }
.cert-sign-role { font-size: 12px; opacity: .75; letter-spacing: .06em; font-family: 'Source Sans 3', sans-serif; }

/* portrait composition */
.cert-canvas.portrait .cert-inner { padding: 100px 66px 74px; }
.cert-canvas.portrait .cert-photo { top: 74px; right: 50%; transform: translateX(50%); width: 140px; height: 140px; }
.cert-canvas.portrait .cert-logo { margin-top: 46px; }
.cert-canvas.portrait .cert-label { font-size: 54px; }
.cert-canvas.portrait .cert-name { font-size: 86px; }
.cert-canvas.portrait .cert-body { font-size: 17px; max-width: 600px; }
.cert-canvas.portrait .cert-doc-meta { flex-direction: column; align-items: center; gap: 22px; margin-top: 34px; }
.cert-canvas.portrait .cert-meta-left { text-align: center; }
.cert-canvas.portrait .cert-watermark { right: 50%; transform: translateX(50%); bottom: 30px; }

/* ============================================================
   TEMPLATES
   ============================================================ */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.tpl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-xs); transition: transform .28s var(--ease), box-shadow .28s var(--ease), border-color .28s var(--ease); animation: rise .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
.tpl-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.tpl-thumb { position: relative; overflow: hidden; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tpl-body { padding: 14px 16px 4px; }
.tpl-body h3 { font-size: 14.5px; font-weight: 650; letter-spacing: -.2px; }
.tpl-body p { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.tpl-actions { display: flex; gap: 6px; padding: 12px 16px 16px; flex-wrap: wrap; }

/* ============================================================
   TAB BAR (mobile)
   ============================================================ */
.tabbar { display: none; }

/* ============================================================
   TOAST
   ============================================================ */
#toastRoot { position: fixed; bottom: calc(var(--tabbar-h) + 18px); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 440px); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r); padding: 13px 18px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toastIn .4s var(--spring); }
.toast svg { width: 18px; height: 18px; color: var(--success); }
.toast.err svg { color: var(--danger); }
.toast.out { animation: toastOut .28s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(18px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.96); } }

/* ============================================================
   MODAL
   ============================================================ */
#modalRoot { position: fixed; inset: 0; z-index: 90; display: none; }
#modalRoot.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8,9,16,.55); backdrop-filter: blur(5px); animation: fade .22s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 460px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 26px; box-shadow: var(--shadow-lg); animation: modalIn .38s var(--spring); }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%,-44%) scale(.94); } to { opacity: 1; transform: translate(-50%,-50%) scale(1); } }
.modal h3 { font-size: 18px; font-weight: 750; margin-bottom: 8px; letter-spacing: -.3px; }
.modal p { font-size: 13.5px; color: var(--text-2); margin-bottom: 20px; line-height: 1.6; }
.modal .actions-row { justify-content: flex-end; }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .7s linear infinite; }

.hidden { display: none !important; }
.fade-in { animation: rise .25s var(--ease) both; }

/* ============================================================
   PRINT (native Save as PDF)
   ============================================================ */
#print-root { display: none; }
.print-page.landscape { width: 1122px; height: 794px; }
.print-page.portrait { width: 794px; height: 1122px; }

@media print {
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  body > #app { display: none !important; }
  #print-root { display: block !important; }
  #print-root .print-page { overflow: hidden; page-break-after: always; break-after: page; }
  #print-root .print-page:last-child { page-break-after: auto; break-after: auto; }
  #print-root .cert-canvas { transform: none !important; box-shadow: none !important; margin: 0 !important; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1000px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-preview { position: static; order: -1; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .navbar { left: 0; padding: 0 14px; }
  .navbar-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm);
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; flex-shrink: 0;
  }
  .navbar-mark svg { width: 18px; height: 18px; stroke-width: 2; }
  #main { margin-left: 0; height: 100vh; padding: calc(var(--navbar-h) + 16px) 14px calc(var(--tabbar-h) + 34px); }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: var(--tabbar-h); z-index: 50;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3); font-size: 10px; font-weight: 650; transition: color .18s var(--ease); }
  .tab-item svg { width: 21px; height: 21px; transition: transform .25s var(--spring); }
  .tab-item.active { color: var(--accent); }
  .tab-item.active svg { transform: translateY(-2px) scale(1.1); }
  .tab-fab { flex: 0 0 62px; }
  .tab-fab svg { width: 48px; height: 48px; padding: 13px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 8px 22px var(--accent-ring); margin-top: -20px; box-sizing: border-box; }
  .tab-fab:active svg { transform: scale(.9); }
  .hero { flex-direction: column; align-items: stretch; padding: 22px; }
  .hero .btn { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card:nth-child(3) { grid-column: span 2; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .cert-card { flex-wrap: wrap; padding: 12px 14px 12px 18px; row-gap: 2px; }
  .cert-info { flex: 1 1 auto; }
  .cert-meta { order: 3; flex: 1 1 100%; justify-content: flex-start; margin-left: 0; padding-top: 10px; border-top: 1px dashed var(--border); }
  .cert-actions { order: 4; flex: 1 1 100%; justify-content: flex-end; padding-top: 6px; }
  .sticky-actions { position: static; }
  .panel { padding: 16px; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
  .stat-card:nth-child(3) { grid-column: auto; }
  .tpl-grid { grid-template-columns: minmax(0, 1fr); }
}