:root {
  color-scheme: light only;
  --ink: #172033;
  --muted: #6b7280;
  --line: #e5e7eb;
  --paper: #ffffff;
  --canvas: #f4f6f8;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --red: #c62828;
  --orange: #f58746;
  --wine: #b93356;
  --radius: 12px;
  font-family: Gilroy, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@font-face { font-family: Gilroy; src: url("/static/fonts/Gilroy-Regular.woff2") format("woff2"); font-weight: 400; }
@font-face { font-family: Gilroy; src: url("/static/fonts/Gilroy-Semibold.woff2") format("woff2"); font-weight: 600; }
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
code { padding: 2px 5px; border-radius: 4px; background: #eef2f7; color: #334155; }

.topbar { min-height: 64px; padding: 0 4vw; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar .brand { color: var(--ink); font-size: 20px; font-weight: 600; }
.topbar .brand:hover { text-decoration: none; }
.topbar .brand span { margin-left: 6px; padding: 3px 7px; border-radius: 999px; color: #8a3419; background: #fff1e8; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.topbar nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topbar nav a { color: #475569; }
.danger-link, .topbar nav .danger-link { color: var(--red); }

.container { width: min(1180px, calc(100% - 32px)); margin: 34px auto 64px; }
.narrow { width: min(640px, calc(100% - 32px)); margin: 42px auto 64px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 38px); letter-spacing: -.02em; }
.page-heading p { max-width: 760px; margin: 0; line-height: 1.45; }
.eyebrow { margin-bottom: 7px !important; color: var(--orange); font-size: 12px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.panel { padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 20px rgba(15, 23, 42, .04); }
.panel h2 { margin-top: 0; }
.alert { margin: 0 0 20px; padding: 12px 15px; border-radius: 8px; }
.alert.success { color: #166534; background: #ecfdf3; border: 1px solid #bbf7d0; }
.alert.error { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; }
.button { display: inline-flex; min-height: 40px; padding: 9px 16px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-weight: 600; line-height: 1.15; }
.button:hover { text-decoration: none; }
.button.primary { color: #fff; background: var(--blue); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: #334155; background: #fff; border-color: #cbd5e1; }
.button.danger { color: #fff; background: var(--red); }
.button.wide { width: 100%; }
.link-button { padding: 0; border: 0; background: transparent; cursor: pointer; font: inherit; }
.badge { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 999px; color: #475569; background: #eef2f7; font-size: 11px; }

form label { display: block; margin-bottom: 17px; color: #334155; font-size: 14px; font-weight: 600; }
input, select, textarea { width: 100%; margin-top: 7px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 7px; color: var(--ink); background: #fff; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(37, 99, 235, .13); border-color: var(--blue); }
input[type=file] { padding: 8px; }
textarea { resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.login-page { min-height: 100vh; background: linear-gradient(135deg, #f3f6fb, #eef2ff); }
.login-shell { min-height: 100vh; padding: 24px; display: grid; place-items: center; }
.login-card { width: min(930px, 100%); min-height: 490px; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border-radius: 20px; background: #fff; box-shadow: 0 22px 65px rgba(30, 41, 59, .13); }
.login-art { padding: 52px; display: grid; place-items: center; align-content: center; color: #64748b; background: #f8fafc; text-align: center; }
.login-art img { width: 245px; }
.login-art p { margin-top: 25px; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.login-form { padding: 70px 64px; align-self: center; }
.login-form h1 { margin: 0 0 28px; text-align: center; }
.login-form .small { text-align: center; }
.password-control { margin-bottom: 17px; }
.password-control > label { margin: 0; }
.password-input { position: relative; }
.password-input input { padding-right: 48px; }
.password-toggle { position: absolute; top: 8px; right: 1px; width: 42px; height: 40px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 6px; color: #64748b; background: transparent; cursor: pointer; }
.password-toggle:hover { color: var(--blue); background: #f1f5f9; }
.password-toggle:focus-visible { outline: 3px solid rgba(37, 99, 235, .2); color: var(--blue); }
.password-toggle svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle .eye-closed { display: none; }
.password-toggle.is-visible .eye-open { display: none; }
.password-toggle.is-visible .eye-closed { display: block; }

.tabs { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.tab-list { display: flex; align-items: center; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
.tab-list button { padding: 11px 17px; border: 0; border-bottom: 3px solid transparent; color: #64748b; background: transparent; cursor: pointer; }
.tab-list button.active { border-bottom-color: var(--blue); color: var(--blue); font-weight: 600; }
.tab-list .tab-action { min-height: 36px; margin-left: auto; padding: 7px 14px; font-size: 14px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { color: #475569; background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: #fbfdff; }
.qr-cell { min-width: 280px; display: flex; align-items: center; gap: 14px; }
.qr-cell img { width: 88px; height: 88px; background: #fff; }
.actions { min-width: 126px; }
.actions > a, .actions > form { display: block; margin-bottom: 7px; }
.empty { padding: 36px; color: var(--muted); text-align: center; }
.ua { max-width: 440px; word-break: break-word; }

.edit-grid { display: grid; grid-template-columns: 260px minmax(0, 640px); justify-content: center; align-items: start; gap: 24px; }
.qr-preview { text-align: center; }
.qr-preview img { display: block; width: 210px; margin: 0 auto 14px; }
.qr-preview code { display: inline-block; }
.upload-preview { display: block; width: 120px; max-height: 160px; margin: 9px 0 4px; border: 1px solid var(--line); border-radius: 8px; object-fit: cover; }

.add-org { margin-bottom: 20px; }
.org-list { display: grid; gap: 12px; }
.org-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 18px; align-items: center; padding: 16px 18px; scroll-margin-top: 18px; }
.org-row.is-saved { border-color: #86efac; box-shadow: 0 4px 20px rgba(22, 101, 52, .1); }
.org-row label { margin: 0; }
.org-logo-picker { position: relative; display: block; cursor: pointer; text-align: center; }
.org-logo-input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.org-logo-frame { position: relative; width: 76px; height: 76px; display: grid; place-items: center; overflow: hidden; border: 1px solid #475569; border-radius: 12px; background: #334155; transition: border-color .15s ease, box-shadow .15s ease; }
.org-logo-frame img { width: calc(100% - 16px); height: calc(100% - 16px); margin: 0; padding: 0; border: 0; object-fit: contain; }
.org-logo-overlay { position: absolute; right: 0; bottom: 0; left: 0; padding: 5px 4px; color: #fff; background: rgba(23, 32, 51, .78); font-size: 11px; font-weight: 600; transform: translateY(100%); transition: transform .15s ease; }
.org-logo-picker:hover .org-logo-frame,
.org-logo-picker:focus-within .org-logo-frame { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.org-logo-picker:hover .org-logo-overlay,
.org-logo-picker:focus-within .org-logo-overlay { transform: translateY(0); }
.org-logo-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 400; }
.org-editor { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: end; }
.org-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.org-actions { display: flex; gap: 7px; }
.save-status { min-height: 40px; padding: 0 10px; display: inline-flex; align-items: center; border-radius: 8px; color: #166534; background: #ecfdf3; border: 1px solid #bbf7d0; font-size: 13px; font-weight: 600; white-space: nowrap; }

.legacy-namecard-page { min-height: 100vh; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; overflow-x: hidden; color: #000; background-color: #f4f4f4; font-family: Gilroy, sans-serif; box-sizing: content-box; }
.legacy-namecard-page * { box-sizing: content-box; }
.legacy-namecard-page .card { min-width: 400px; max-width: 100%; margin: 0; padding: 0; position: relative; overflow: hidden; border: 1px solid #ddd; border-radius: 10px; background: #fff; box-shadow: 0 4px 8px rgba(0,0,0,.1); }
.legacy-namecard-page .card-header { position: relative; height: 220px; padding: 15px; display: flex; justify-content: space-between; align-items: flex-start; color: #fff; background: linear-gradient(138deg, rgba(185,51,86,1) 0%, rgba(228,54,68,1) 35%, rgba(252,114,62,1) 100%); clip-path: polygon(0 0, 100% 0, 100% 60%, 0 100%); }
.legacy-namecard-page .card-header img.logo-default { width: auto; height: 40px; }
.legacy-namecard-page .card-header img.logo-large { width: auto; height: 60px; }
.legacy-namecard-page .card-header img.logo-larger { width: auto; height: 80px; }
.legacy-namecard-page .profile-pic { position: absolute; top: 90px; right: 15px; width: 160px; height: 160px; border: 5px solid #f58746; border-radius: 50%; background-color: #ddd; object-fit: cover; object-position: top; }
.legacy-namecard-page .card-content { padding: 0 15px; text-align: left; }
.legacy-namecard-page .card-content h1 { margin: 10px 0; font-family: Gilroy, sans-serif; font-size: 18px; font-weight: 600; }
.legacy-namecard-page .card-content h2 { margin: 5px 0; font-family: Gilroy, sans-serif; font-size: 14px; }
.legacy-namecard-page .icons { margin-top: -31px; padding: 10px 0; display: flex; justify-content: space-around; }
.legacy-namecard-page .icon { width: 45px; height: 45px; display: flex; justify-content: center; align-items: center; border-radius: 50%; color: #fff; background-color: #f58746; font-size: 5px; }
.legacy-namecard-page .icon:hover { background-color: #b93356; }
.legacy-namecard-page .icon img { width: 30px; }
.legacy-namecard-page .contact-info { font-size: 14px; line-height: 1.5; text-align: left; }
.legacy-namecard-page .contact-info span { font-weight: bold; }
.legacy-namecard-page .social-icons { margin: 5px 0; display: flex; gap: 10px; }
.legacy-namecard-page .social-icon { width: 30px; height: 30px; }
.legacy-namecard-page .social-icon:hover { opacity: .8; }
.legacy-namecard-page .save-button-container { margin-bottom: 20px; text-align: right; }
.legacy-namecard-page .save-button { padding: 5px; display: inline-flex; align-items: center; gap: 10px; border: 0; border-radius: 40px; color: #fff; background-color: #f58746; cursor: pointer; font-size: 16px; text-decoration: none; }
.legacy-namecard-page .save-button:hover { color: #fff; background-color: #b93356; text-decoration: none; }
.legacy-namecard-page .save-button-text { padding-left: 5px; font-size: 14px; }
.legacy-namecard-page p { margin-top: 8px; margin-bottom: 8px; }
.legacy-namecard-page .orange-line { margin-top: 40px; border-bottom: 1px solid #f58746; }
.legacy-namecard-page .circle { width: 30px; height: 30px; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; border-radius: 50%; color: #f58746; background-color: #fff; font-family: monospace; font-size: 20px; line-height: 1; }
.legacy-namecard-page .lang-switcher { position: absolute; top: 15px; right: 15px; }
.legacy-namecard-page #language-select { width: auto; margin-top: 0; padding: 5px; border: 0; border-radius: 5px; color: #fff; background-color: #f58746; cursor: pointer; font-size: 14px; }
.legacy-namecard-page .hidden { display: none; }

.wechat-body { min-height: 100vh; background: rgb(42,174,103); }
.wechat-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.wechat-card { width: min(360px, 100%); padding: 32px 24px; border-radius: 16px; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.15); color: #555; text-align: center; line-height: 1.5; }
.wechat-qr { width: 100%; border: 1px solid #e5e5e5; border-radius: 8px; }

.multi-body { min-height: 100vh; background: #f7f7f7; }
.multi-page { min-height: 100vh; padding: 32px 18px; display: flex; justify-content: center; }
.multi-page > section { width: min(520px, 100%); text-align: center; }
.multi-page > section > img { width: 150px; }
.multi-grid { margin: 25px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.multi-grid a { min-height: 105px; padding: 16px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; }
.multi-grid a:hover { border-color: var(--orange); text-decoration: none; }
.multi-grid span { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--orange); font-size: 20px; }

@media (max-width: 768px) {
  .legacy-namecard-page { justify-content: flex-start; align-items: flex-start; overflow: auto; height: auto; background-color: #fff; }
  .legacy-namecard-page .card { width: 100%; min-width: unset; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
}

@media (max-width: 800px) {
  .topbar { padding: 12px 16px; align-items: flex-start; }
  .topbar nav { justify-content: flex-end; flex-wrap: wrap; gap: 9px 13px; }
  .login-card { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-form { padding: 48px 28px; }
  .edit-grid { grid-template-columns: 1fr; }
  .qr-preview { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .org-row { grid-template-columns: 84px minmax(0, 1fr); align-items: start; }
  .org-editor { grid-template-columns: 1fr; gap: 12px; }
  .org-fields { grid-template-columns: 1fr; }
  .org-actions { justify-content: flex-end; }
}

@media (max-width: 540px) {
  .topbar { display: block; }
  .topbar nav { margin-top: 10px; justify-content: flex-start; }
  .container, .narrow { width: min(100% - 20px, 1180px); margin-top: 22px; }
  .page-heading { display: block; }
  .page-heading > .button { margin-top: 15px; }
  .panel { padding: 17px; }
  .org-row { grid-template-columns: 72px minmax(0, 1fr); gap: 12px; }
  .org-logo-frame { width: 64px; height: 64px; }
  .multi-grid { grid-template-columns: repeat(2, 1fr); }
}
