:root {
  --brand: #185adb;
  --brand-2: #0f2d56;
  --ink: #172033;
  --muted: #647084;
  --line: #dce2ea;
  --soft: #f5f7fb;
  --white: #fff;
  --danger: #c0392b;
  --ok: #198754;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #eef2f7; color: var(--ink); }
a { color: inherit; }
input, textarea, select, button { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar { background: #101a2f; color: var(--white); padding: 28px 20px; display: flex; flex-direction: column; gap: 24px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--brand); font-weight: 800; }
.brand-lockup strong, .brand-lockup span { display: block; }
.brand-lockup span { color: #aeb8ca; font-size: 13px; }
.nav { display: grid; gap: 8px; }
.nav a { border-radius: 8px; padding: 12px 14px; color: #dce5f3; text-decoration: none; font-weight: 700; }
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.main { padding: 28px; overflow: auto; }

.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: clamp(28px, 3vw, 40px); }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-12 { grid-column: span 12; }
.stat strong { display: block; font-size: 30px; }
.stat span, .muted { color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.button, button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 1px solid transparent; border-radius: 8px; padding: 10px 14px; background: var(--brand); color: #fff; text-decoration: none; font-weight: 800; cursor: pointer; }
.button.secondary, button.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.button.danger, button.danger { background: var(--danger); }
.button.ghost { background: transparent; color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; color: #33415c; font-size: 13px; font-weight: 800; }
.field.full { grid-column: 1 / -1; }
input, textarea, select { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; color: var(--ink); }
textarea { min-height: 86px; resize: vertical; }
.list { display: grid; gap: 12px; }
.list-item { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; }
.list-item strong, .list-item span { display: block; }
.list-item span { color: var(--muted); font-size: 13px; }
.avatar, .logo-preview { width: 56px; height: 56px; border: 1px solid var(--line); background: var(--soft); object-fit: cover; }
.avatar { border-radius: 50%; }
.logo-preview { border-radius: 8px; object-fit: contain; padding: 6px; }
.upload-box { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 16px; align-items: center; padding: 14px; border: 1px dashed #c8d2e1; border-radius: 8px; background: var(--soft); }
.logo-upload { width: 128px; height: 86px; object-fit: contain; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.avatar-upload { width: 96px; height: 96px; object-fit: cover; border-radius: 50%; background: #fff; border: 1px solid var(--line); }
.flash { margin-bottom: 16px; padding: 12px 14px; border-radius: 8px; background: #e8f6ee; color: var(--ok); font-weight: 800; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.auth-card h1 { margin-top: 0; }

.card-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #eaf0ff, #f7f9fc); }
.public-card { width: min(460px, 100%); overflow: hidden; border-radius: 18px; background: #fff; box-shadow: 0 22px 70px rgba(23,32,51,.16); }
.public-cover { position: relative; z-index: 2; min-height: 214px; padding: 24px; color: #fff; overflow: visible; background: radial-gradient(circle at 84% 24%, rgba(255,255,255,.26), transparent 30%), linear-gradient(145deg, var(--tenant-brand), var(--tenant-brand-2)); }
.public-cover:after { content: ""; position: absolute; z-index: 1; left: -8%; right: -8%; bottom: -54px; height: 112px; border-radius: 50% 50% 0 0; background: #fff; pointer-events: none; }
.public-brand-row { position: relative; z-index: 3; display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.public-brand-row span { max-width: 180px; text-align: right; font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.public-logo { width: 136px; max-height: 62px; object-fit: contain; padding: 10px 12px; background: rgba(255,255,255,.94); border-radius: 8px; box-shadow: 0 14px 32px rgba(10,18,34,.18); }
.public-avatar { z-index: 4; position: absolute; left: 50%; bottom: -64px; transform: translateX(-50%); width: 132px; height: 132px; border: 5px solid #fff; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: 0 0 0 2px var(--tenant-brand), 0 0 0 6px #fff; }
.public-body { position: relative; z-index: 1; padding: 84px 24px 24px; text-align: center; background: #fff; }
.public-body h1 { margin: 0; font-size: 30px; }
.role, .bio { color: #526079; }
.bio { line-height: 1.55; }
.contact-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 22px; }
.contact-actions a { min-height: 48px; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 900; }
.contact-actions .primary { background: var(--tenant-brand); border-color: var(--tenant-brand); color: #fff; }
.qr-wrap { display: grid; grid-template-columns: 112px minmax(0,1fr); gap: 14px; align-items: center; margin-top: 22px; padding: 14px; background: var(--soft); border-radius: 8px; text-align: left; }
.qr-wrap img { width: 112px; height: 112px; border-radius: 8px; background: #fff; }
.empty { padding: 28px; border: 1px dashed var(--line); border-radius: 8px; text-align: center; color: var(--muted); }
.pdf-toolbar { position: fixed; top: 16px; left: 50%; z-index: 10; display: flex; gap: 10px; transform: translateX(-50%); padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 12px 32px rgba(23,32,51,.16); }
.pdf-link { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; word-break: break-all; }
.pdf-link a { color: var(--ink); }
.pdf-mode .card-page { padding-top: 88px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-4, .span-5, .span-6, .span-7 { grid-column: span 12; }
}

@media (max-width: 640px) {
  .main { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .form-grid, .contact-actions, .upload-box { grid-template-columns: 1fr; }
  .list-item { grid-template-columns: auto minmax(0,1fr); }
  .list-item .actions { grid-column: 1 / -1; }
}

@media print {
  @page { size: 110mm 205mm; margin: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { width: 110mm; height: 205mm; margin: 0; padding: 0; overflow: hidden; background: linear-gradient(135deg, #eaf0ff, #f7f9fc); }
  .pdf-toolbar { display: none; }
  .pdf-mode .card-page { padding-top: 5mm; }
  .card-page { display: block; width: 110mm; height: 205mm; min-height: 205mm; padding: 5mm 0 0; margin: 0; background: linear-gradient(135deg, #eaf0ff, #f7f9fc); overflow: hidden; }
  .public-card { width: 100mm; margin: 0 auto; box-shadow: none; border: 1px solid #dce2ea; break-inside: avoid; page-break-inside: avoid; }
  .public-cover { z-index: 2; min-height: 48mm; padding: 6mm; background: radial-gradient(circle at 84% 24%, rgba(255,255,255,.26), transparent 30%), linear-gradient(145deg, var(--tenant-brand), var(--tenant-brand-2)); }
  .public-cover:after { display: none; }
  .public-avatar { z-index: 4; background: #fff; box-shadow: 0 0 0 .7mm var(--tenant-brand), 0 0 0 1.6mm #fff; filter: none; }
  .public-body { z-index: 1; padding: 21mm 6mm 5mm; }
  .public-body h1 { font-size: 26px; }
  .bio { margin: 10px 0 0; }
  .contact-actions { gap: 8px; margin-top: 16px; }
  .contact-actions a { min-height: 42px; text-decoration: none; }
  .contact-actions .primary { background: var(--tenant-brand); border-color: var(--tenant-brand); color: #fff; }
  .qr-wrap { margin-top: 12px; padding: 9px; }
  .qr-wrap img { width: 90px; height: 90px; }
  .pdf-link { margin: 7px 0 0; font-size: 11px; }
}
