:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3ad;
  --accent: #4f8cff;
  --accent-2: #6ea0ff;
  --danger: #e5534b;
  --success: #2ea043;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: .2px;
}

.topbar nav { display: flex; gap: 8px; align-items: center; }

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 18px; }

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

.stack > * + * { margin-top: 12px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input[type="text"],
.field input[type="password"],
.field input[type="file"] {
  width: 100%;
  padding: 11px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, .18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
}
.btn:hover { text-decoration: none; border-color: #3a4150; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { background: transparent; border-color: rgba(229, 83, 75, .55); color: #ff8a84; }
.btn-danger:hover { background: rgba(229, 83, 75, .12); }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-block { width: 100%; }

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

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.flash-error { background: rgba(229, 83, 75, .15); border: 1px solid rgba(229, 83, 75, .4); }
.flash-success { background: rgba(46, 160, 67, .15); border: 1px solid rgba(46, 160, 67, .4); }

.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }

.list { display: grid; gap: 10px; }
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: inherit;
}
.list-item:hover { border-color: #3a4150; text-decoration: none; }
.avatar {
  width: 52px; height: 52px; border-radius: 10px;
  object-fit: cover; flex: 0 0 auto; background: var(--panel-2);
  display: grid; place-items: center; color: var(--muted); font-size: 20px; font-weight: 700;
}
.list-item .meta { min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .sub { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* =============================================================
   Public business card
   -------------------------------------------------------------
   Mobile (default): vertical paper card, photo capped at ~25vh
   (a quarter of the screen), content stacked below.
   Wide screens (>= 560px): classic 90x50mm landscape business card.
   ============================================================= */
.view-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(120% 120% at 50% 0%, #171b22 0%, #0b0d11 70%);
}

.view-stage {
  width: min(92vw, 420px);
}

.biz-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: 
    linear-gradient(160deg, #ffffff 0%, #f6f8fb 58%, #e8edf4 100%);
  color: #12161c;
  border-radius: 18px;
  box-shadow:
    0 24px 48px -12px rgba(0, 0, 0, .55),
    0 2px 0 rgba(255, 255, 255, .55) inset,
    0 0 0 1px rgba(255, 255, 255, .08);
}

/* blue brand stripe on the left edge */
.biz-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, #5b95ff, #2f6fd6);
  z-index: 2;
}

/* ---- Photo ------------------------------------------------- */
.biz-media {
  position: relative;
  width: 100%;
  /* a quarter of the screen at most, with sensible bounds */
  height: clamp(150px, 25vh, 300px);
  flex: 0 0 auto;
  background: #dde3ea;
  overflow: hidden;
}

/* Without a photo, the initials block is a compact banner instead
   of a full quarter-screen area. */
.biz-media.is-empty {
  height: clamp(84px, 12vh, 140px);
}

.biz-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
}

.biz-photo-empty {
  display: grid;
  place-items: center;
  font-size: 64px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #b3bdca;
  background: linear-gradient(150deg, #eef2f7, #dfe5ee);
}

/* ---- Text -------------------------------------------------- */
.biz-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 22px 18px 24px;
  min-width: 0;
}

.biz-head { min-width: 0; }

.biz-name {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0d1116;
}
.biz-first, .biz-last { display: block; word-break: break-word; }
.biz-last { color: #1b2430; }

.biz-company {
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.biz-org {
  font-size: 15px;
  font-weight: 600;
  color: #2b3440;
}

.biz-dept {
  font-size: 13.5px;
  color: #6b7686;
}

/* ---- Footer: contacts + QR --------------------------------- */
.biz-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px solid #e4e9f0;
  padding-top: 14px;
}

.biz-contacts {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.biz-telegram {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 8px 13px;
  border-radius: 9px;
  background: #eaf1ff;
  border: 1px solid rgba(47, 111, 214, .3);
  color: #1f5fd1;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.biz-telegram svg { flex: 0 0 auto; font-size: 15px; }
.biz-telegram span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.biz-telegram:hover { background: #dfeaff; text-decoration: none; }

.biz-id {
  font-size: 10px;
  color: #a9b3c0;
  letter-spacing: .05em;
  font-variant-numeric: tabular-nums;
}

.biz-qr {
  flex: 0 0 auto;
  width: clamp(64px, 22vw, 96px);
  height: clamp(64px, 22vw, 96px);
  padding: 3px;
  background: #fff;
  border: 1px solid #e1e6ee;
  border-radius: 6px;
  image-rendering: pixelated;
}

/* ---- Landscape paper card for tablets / desktop ------------- */
@media (min-width: 560px) {
  .view-stage {
    width: min(92vw, 780px);
    /* 1em = 1/90 of the card width: every size below scales together */
    font-size: calc(min(92vw, 780px) / 90);
  }

  .biz-card {
    display: grid;
    grid-template-columns: 32% 1fr;
    gap: 1.6em;
    padding: 1.6em;
    min-height: 0;
    aspect-ratio: 18 / 10;
    border-radius: .7em;
    box-shadow: 0 1.5em 3em rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .06);
  }

  .biz-card::before { width: .45em; }

  .biz-media {
    height: 100%;
    border-radius: .5em;
  }

  .biz-body {
    padding: 0;
    gap: 1em;
    height: 100%;
    min-width: 0;
  }

  .biz-name { font-size: 1.7em; }
  .biz-company { margin-top: .5em; }
  .biz-org { font-size: .95em; }
  .biz-dept { font-size: .82em; }

  .biz-foot {
    padding-top: .7em;
    gap: .7em;
  }

  .biz-telegram {
    padding: .42em .72em;
    font-size: .82em;
    border-radius: .45em;
    gap: .4em;
  }
  .biz-telegram svg { font-size: 1.05em; }

  .biz-id { font-size: .5em; }

  .biz-qr {
    width: 8.5em;
    height: 8.5em;
    padding: .12em;
    border-radius: .25em;
  }
}

/* Admin previews */
/* Admin previews */
.preview-photo {
  width: 120px; height: 120px; border-radius: 12px; object-fit: cover;
  border: 1px solid var(--border); display: block; margin-bottom: 12px;
}

.preview-qr {
  width: 132px; height: 132px;
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  display: block;
  image-rendering: pixelated;
}

@media (max-width: 480px) {
  .container { padding: 12px; }
  h1 { font-size: 20px; }
}
