:root {
  color-scheme: dark;
  --bg: #0c0c0e;
  --surface: #151518;
  --surface-raised: #1c1c20;
  --surface-soft: #232329;
  --border: #303037;
  --border-strong: #44444d;
  --text: #f7f4f5;
  --muted: #a7a1a5;
  --accent: #ed4f8b;
  --accent-hover: #fa6b9f;
  --accent-soft: rgba(237, 79, 139, 0.14);
  --success: #55d59a;
  --warning: #f2bb5e;
  --danger: #ff6b76;
  --info: #71a8ff;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  --topbar-height: 68px;
  --sidebar-width: 248px;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 90% -10%, rgba(237,79,139,.1), transparent 30rem), var(--bg); color: var(--text); }
body.modal-open { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
img, video, canvas { max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid rgba(237,79,139,.42); outline-offset: 3px; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 200; padding: .7rem 1rem; border-radius: 8px; background: white; color: black; }
.skip-link:focus { top: 1rem; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.75rem, 4vw, 2.35rem); line-height: 1.1; letter-spacing: -.045em; }
h2 { margin-bottom: 1rem; font-size: 1.05rem; letter-spacing: -.02em; }
h3 { margin-bottom: .35rem; font-size: 1rem; }
p { color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0 0 .35rem; color: var(--accent); font-size: .72rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); font-size: .8rem; }
.centered { text-align: center; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: .8rem; }
.wrap { flex-wrap: wrap; }

label { display: grid; gap: .45rem; color: #d7d2d5; font-size: .82rem; font-weight: 650; }
input, textarea, select {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #101012; color: var(--text);
  padding: .78rem .9rem; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: #121215; }
textarea { resize: vertical; line-height: 1.6; }

.button {
  display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: .45rem; border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: .65rem .95rem; font-weight: 720; transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.button--primary { background: var(--accent); color: #18030b; }
.button--primary:hover { background: var(--accent-hover); }
.button--secondary { border-color: var(--border); background: var(--surface-soft); color: var(--text); }
.button--secondary:hover { border-color: var(--border-strong); background: #2b2b31; }
.button--danger { border-color: rgba(255,107,118,.3); background: rgba(255,107,118,.1); color: #ff9ca4; }
.button--full { width: 100%; }
.button-row { display: flex; gap: .65rem; }
.text-button { border: 0; background: none; color: var(--accent); font-weight: 700; }
.icon-button {
  display: inline-grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: var(--surface-raised); font-size: 1.5rem;
}
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }

.auth-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; overflow-y: auto; padding: 1.25rem; background: radial-gradient(circle at 50% 0, rgba(237,79,139,.2), transparent 42%), var(--bg); }
.auth-card { width: min(100%, 430px); border: 1px solid var(--border); border-radius: var(--radius-lg); background: rgba(21,21,24,.93); box-shadow: var(--shadow); padding: clamp(1.5rem, 5vw, 2.25rem); backdrop-filter: blur(18px); }
.auth-card h1 { font-size: 2rem; }
.auth-copy { margin: .75rem 0 1.5rem; }
.auth-card form { display: grid; gap: .8rem; }
.auth-card > .button { margin-top: .75rem; }
.google-entry { width: min(100%, 320px); margin: 1rem auto 0; }
.google-signin-slot { display: flex; min-height: 44px; justify-content: center; }
.google-signin-slot iframe { max-width: 100%; }
.google-entry > .button { margin-top: .65rem; }
.account-panel .google-signin-slot { margin: .35rem 0 .6rem; }
.account-panel > .button { margin-bottom: .55rem; }
.admin-toggle { display: flex; align-items: center; gap: .7rem; min-height: 44px; border-bottom: 1px solid var(--border); }
.admin-toggle input { width: 19px; height: 19px; flex: 0 0 auto; accent-color: var(--accent); }
.admin-audit-panel { margin-top: 1rem; }
.admin-google-guide { margin-bottom: 1rem; }
.admin-google-guide p { margin-bottom: .65rem; }
.admin-google-guide ol { display: grid; gap: .6rem; margin: .4rem 0 1rem; padding-left: 1.3rem; color: #d7d2d5; font-size: .84rem; line-height: 1.55; }
.admin-google-guide a { color: #ff8cb5; text-underline-offset: 3px; }
.admin-google-guide a:hover { color: #ffc1d6; }
.admin-doc-link { font-size: .82rem; font-weight: 700; }
.admin-google-guide code { border: 1px solid var(--border); border-radius: 5px; background: var(--surface-raised); padding: .12rem .3rem; font-size: .76rem; }
.audit-row { display: grid; grid-template-columns: minmax(120px, .5fr) 1fr auto; align-items: center; gap: .8rem; border-bottom: 1px solid var(--border); padding: .65rem 0; }
.audit-row strong { font-size: .84rem; }
.audit-row small, .audit-row time { color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
@media (max-width: 620px) { .audit-row { grid-template-columns: 1fr; gap: .2rem; } }
.privacy-note { margin: 1rem 0 0; font-size: .75rem; text-align: center; }
.auth-stage { width: min(100%, 480px); text-align: center; perspective: 1100px; }
.auth-stage > .brand-mark { margin-inline: auto; }
.auth-stage .auth-copy { max-width: 390px; margin-inline: auto; }
.identity-card-3d {
  --rx: 0deg; --ry: 0deg; --mx: 50%; --my: 50%;
  position: relative; display: block; width: min(100%, 420px); aspect-ratio: 1.68 / 1; overflow: hidden;
  margin: 1.6rem auto 0; border: 1px solid rgba(255,255,255,.18); border-radius: 24px;
  background: linear-gradient(145deg, #2b1421 0%, #17151b 47%, #0d0d10 100%); color: var(--text);
  box-shadow: 0 34px 80px rgba(0,0,0,.52), 0 2px 0 rgba(255,255,255,.08) inset;
  padding: 1.25rem; text-align: left; transform-style: preserve-3d;
  transform: rotateX(var(--rx)) rotateY(var(--ry)) translateZ(0); transition: transform .18s ease, box-shadow .18s ease;
}
.identity-card-3d:hover { box-shadow: 0 42px 95px rgba(0,0,0,.62), 0 2px 0 rgba(255,255,255,.12) inset; }
.identity-card-3d:focus-visible { outline-offset: 6px; }
.identity-card-glow { position: absolute; inset: -1px; background: radial-gradient(circle at var(--mx) var(--my), rgba(255,126,175,.34), transparent 37%); pointer-events: none; }
.identity-card-grid { position: absolute; inset: 0; opacity: .14; background-image: linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px); background-size: 28px 28px; mask-image: linear-gradient(to bottom right, black, transparent 72%); }
.identity-card-topline, .identity-card-person, .identity-card-signature, .identity-card-footer { position: relative; z-index: 1; transform: translateZ(30px); }
.identity-card-topline, .identity-card-footer { display: flex; align-items: center; justify-content: space-between; }
.identity-chip { display: grid; width: 40px; height: 29px; grid-template-columns: repeat(3, 1fr); overflow: hidden; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; background: linear-gradient(135deg, #d8af62, #755526); padding: 5px; }
.identity-chip i { border-right: 1px solid rgba(0,0,0,.34); }
.identity-chip i:last-child { border-right: 0; }
.identity-card-status { display: flex; align-items: center; gap: .42rem; color: #d7cdd1; font-size: .66rem; font-weight: 720; letter-spacing: .08em; text-transform: uppercase; }
.identity-card-status > span { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 12px var(--success); }
.identity-card-person { display: flex; align-items: center; gap: .9rem; margin-top: 2rem; }
.identity-avatar { display: grid; width: 58px; height: 58px; flex: 0 0 58px; place-items: center; overflow: hidden; border: 1px solid rgba(255,255,255,.2); border-radius: 18px; background: linear-gradient(145deg, var(--accent), #8f2750); color: #1c0610; font-size: 1.05rem; font-weight: 900; box-shadow: 0 12px 25px rgba(0,0,0,.32); }
.identity-avatar img { width: 100%; height: 100%; object-fit: cover; }
.identity-card-copy { display: block; min-width: 0; }
.identity-card-copy strong, .identity-card-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-card-copy strong { font-size: 1.05rem; }
.identity-card-copy small { margin-top: .28rem; color: #bcb3b7; font-size: .72rem; }
.identity-card-signature { display: block; max-width: 68%; margin: .85rem 0 0 auto; overflow: hidden; color: #ffd3e3; font-size: 1.25rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; transform: translateZ(38px) rotate(-3deg); }
.profile-signature-image { display: block; width: 100%; height: 100%; max-height: 55px; margin-left: auto; object-fit: contain; object-position: right center; }
.identity-card-footer { position: absolute; right: 1.25rem; bottom: 1rem; left: 1.25rem; color: #91878c; font-size: .58rem; font-weight: 760; letter-spacing: .15em; }
.brand-mark { display: inline-grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 11px; background: var(--accent); color: #18030b; font-weight: 900; box-shadow: 0 8px 24px rgba(237,79,139,.22); }
.brand-mark--large { width: 54px; height: 54px; margin-bottom: 1.5rem; border-radius: 17px; font-size: 1.4rem; }
.brand-mark--logo { position: relative; overflow: hidden; }
.brand-mark--logo > span { grid-area: 1 / 1; }
.brand-mark--logo > img { grid-area: 1 / 1; width: 100%; height: 100%; background: var(--surface); object-fit: contain; }
.brand-mark--large.brand-mark--logo { width: 92px; height: 92px; border-radius: 24px; background: var(--surface); }

.loading-screen { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; justify-items: center; gap: .85rem; background: var(--bg); color: var(--muted); }
.spinner { width: 38px; height: 38px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.topbar { position: fixed; inset: 0 0 auto 0; z-index: 40; height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: rgba(12,12,14,.88); padding: 0 clamp(1rem, 3vw, 1.5rem); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--text); font-size: 1.05rem; font-weight: 820; text-decoration: none; letter-spacing: -.03em; }
.topbar-actions { display: flex; align-items: center; gap: .65rem; }
.connection-pill { display: inline-flex; align-items: center; gap: .45rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); padding: .42rem .7rem; color: var(--muted); font-size: .75rem; font-weight: 650; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px rgba(242,187,94,.1); }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 3px rgba(85,213,154,.1); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(255,107,118,.1); }

.sidebar { position: fixed; inset: var(--topbar-height) auto 0 0; z-index: 35; display: flex; width: var(--sidebar-width); flex-direction: column; border-right: 1px solid var(--border); background: rgba(16,16,18,.94); padding: 1rem; }
.sidebar-user { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.35rem; padding: .55rem; }
.sidebar-user > div { min-width: 0; flex: 1; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user small { margin-top: .12rem; color: var(--muted); }
.sidebar-profile-trigger { display: flex; min-width: 0; flex: 1; align-items: center; gap: .7rem; border: 0; border-radius: 12px; background: transparent; padding: .25rem; text-align: left; }
.sidebar-profile-trigger:hover { background: var(--surface-raised); }
.sidebar-profile-trigger > span:last-child { min-width: 0; flex: 1; }
.sidebar-profile-trigger strong, .sidebar-profile-trigger small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile-trigger small { margin-top: .12rem; color: var(--muted); }
.avatar { display: inline-grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; overflow: hidden; border-radius: 13px; background: var(--accent-soft); color: #ff8eb7; font-weight: 850; }
.avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.nav-list { display: grid; gap: .25rem; }
.nav-item { display: flex; min-height: 45px; align-items: center; gap: .75rem; border: 0; border-radius: 11px; background: transparent; padding: .65rem .8rem; color: var(--muted); font-weight: 680; text-align: left; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #ff85b2; }
.badge { margin-left: auto; border-radius: 999px; background: var(--accent); padding: .1rem .4rem; color: #18030b; font-size: .68rem; }
.sidebar-sync { margin-top: auto; }
.bottom-nav { display: none; }
.mobile-only { display: none; }

.main-content { min-height: 100vh; margin-left: var(--sidebar-width); padding: calc(var(--topbar-height) + 2.2rem) clamp(1.1rem, 4vw, 3.5rem) 3rem; }
.view-section { width: min(100%, 1060px); margin: 0 auto; animation: enter .24s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(7px); } }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.search-field { position: relative; display: block; margin-bottom: 1rem; }
.search-field span { position: absolute; left: .95rem; top: 50%; z-index: 1; transform: translateY(-50%); color: var(--muted); }
.search-field input { padding-left: 2.45rem; }
.select-field { width: min(100%, 280px); margin-bottom: 1rem; }

.panel, .notice, .document-card, .template-card, .queue-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel { padding: 1.15rem; }
.panel > p { margin-bottom: 1rem; font-size: .86rem; }
.compact-panel { padding: 1rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-heading h2 { margin-bottom: .8rem; }
.notice { display: grid; gap: .2rem; margin-bottom: 1rem; padding: 1rem 1.1rem; }
.notice strong { font-size: .95rem; }
.notice span { color: var(--muted); font-size: .82rem; }
.danger-panel { border-color: rgba(255,107,118,.2); }

.card-list { display: grid; gap: .75rem; }
.document-card, .queue-card { padding: 1rem; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.document-card:hover { border-color: var(--border-strong); background: var(--surface-raised); transform: translateY(-1px); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.card-header h3 { overflow-wrap: anywhere; }
.card-meta { margin: .3rem 0 0; color: var(--muted); font-size: .78rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.card-action { min-height: 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-soft); padding: .35rem .65rem; font-size: .75rem; font-weight: 700; }
.card-action:hover { border-color: var(--border-strong); }
.card-action.danger { color: #ff9ca4; }
.status-badge { display: inline-flex; flex: 0 0 auto; border-radius: 999px; padding: .28rem .52rem; background: var(--surface-soft); color: var(--muted); font-size: .68rem; font-weight: 760; text-transform: capitalize; }
.status-badge.signed, .status-badge.synced { background: rgba(85,213,154,.1); color: #77e2b3; }
.status-badge.conflict { background: rgba(255,184,92,.14); color: #ffd18a; }

.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: .8rem; }
.template-card { display: flex; min-height: 190px; flex-direction: column; overflow: hidden; padding: 1rem; }
.template-thumbnail-frame { position: relative; width: calc(100% + 2rem); aspect-ratio: 4 / 3; margin: -1rem -1rem 1rem; overflow: hidden; background: var(--surface-soft); }
.template-thumbnail { display: block; width: 100%; height: 100%; object-fit: cover; }
.template-thumbnail-code { position: absolute; right: .55rem; bottom: .55rem; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; background: rgba(18,17,19,.82); padding: .28rem .48rem; color: #fff2f7; font-size: .58rem; font-weight: 800; letter-spacing: .08em; }
.template-brand-logo { position: absolute; top: .65rem; left: .65rem; width: 50px; height: 50px; border: 2px solid rgba(255,255,255,.85); border-radius: 13px; background: rgba(255,255,255,.94); padding: .35rem; object-fit: contain; box-shadow: 0 5px 18px rgba(0,0,0,.22); }
.template-card:has(.template-brand-logo) { border-top: 2px solid var(--template-accent, var(--accent)); }
.template-card p { margin-bottom: 1rem; font-size: .84rem; }
.template-card .card-actions { margin-top: auto; }
.category-chip { display: inline-flex; align-self: flex-start; margin-bottom: .85rem; border-radius: 999px; background: var(--accent-soft); padding: .25rem .55rem; color: #ff8eb7; font-size: .67rem; font-weight: 760; text-transform: capitalize; }
.empty-state { display: grid; min-height: 250px; place-content: center; justify-items: center; border: 1px dashed var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; }
.empty-state-icon { display: grid; width: 48px; height: 48px; place-items: center; margin-bottom: .8rem; border-radius: 15px; background: var(--surface-raised); color: var(--accent); font-size: 1.3rem; }
.empty-state h2 { margin-bottom: .35rem; }
.empty-state p { margin-bottom: 1rem; font-size: .86rem; }
.error-state { border-color: rgba(255,107,118,.25); }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.profile-row { display: flex; align-items: center; gap: .8rem; }
.profile-row strong, .profile-row small { display: block; }
.profile-row small { margin-top: .15rem; color: var(--muted); }
.settings-signature { min-height: 48px; margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .7rem; color: #f8a9c7; font-size: 1.45rem; text-align: right; }
.settings-grid .danger-panel { grid-column: 1 / -1; }

.brand-workspace { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.2fr); gap: .85rem; align-items: start; }
.brand-workspace > .panel { min-width: 0; }
.brand-workspace h2 { margin: 0; font-size: 1rem; }
.brand-workspace .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.brand-workspace input[type="color"] { min-height: 43px; padding: .25rem; }
.brand-logo-preview { display: flex; align-items: center; gap: .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); padding: .55rem; color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; }
.brand-logo-preview img { width: 58px; height: 58px; border-radius: 8px; background: white; object-fit: contain; padding: .3rem; }
.brand-template-choices { display: grid; max-height: 260px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; overflow: auto; border: 1px solid var(--border); border-radius: 11px; padding: .65rem; }
.brand-template-choice { display: flex; align-items: center; gap: .5rem; min-width: 0; border-radius: 7px; padding: .35rem; color: var(--muted); font-size: .75rem; }
.brand-template-choice:hover { background: var(--surface-soft); color: var(--text); }
.brand-template-choice input { flex: 0 0 auto; }
.brand-template-choice span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-batch { display: grid; gap: .7rem; }
.brand-batch-heading { display: flex; align-items: center; justify-content: space-between; gap: .8rem; border-bottom: 1px solid var(--border); padding-bottom: .55rem; }
.brand-batch-heading h2 { margin: 0; font-size: 1rem; }
.document-brand-preview { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; border-bottom: 2px solid var(--brand-accent, var(--accent)); padding-bottom: .7rem; }
.document-brand-preview img { max-width: 76px; max-height: 54px; object-fit: contain; }
.document-brand-preview strong { font-size: 1rem; }

.editor-view { width: min(100%, 1180px); }
.editor-topbar { display: flex; align-items: center; gap: .85rem; margin-bottom: 1rem; }
.editor-topbar h1 { font-size: 1.45rem; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(270px, .75fr); gap: .85rem; align-items: start; }
.editor-main { display: grid; gap: 1rem; }
.editor-aside { display: grid; gap: .85rem; }
.evidence-status { margin-bottom: .75rem; color: var(--muted); font-size: .79rem; line-height: 1.45; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; margin: .8rem 0; }
.photo-thumb { position: relative; overflow: hidden; aspect-ratio: 1; border-radius: 9px; background: var(--surface-soft); }
.photo-open { display: block; width: 100%; height: 100%; border: 0; padding: 0; background: transparent; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove { position: absolute; top: .25rem; right: .25rem; display: grid; width: 26px; height: 26px; place-items: center; border: 0; border-radius: 50%; background: rgba(0,0,0,.72); color: white; }
.signature-field { display: grid; width: 100%; min-height: 125px; place-items: center; overflow: hidden; border: 1px dashed var(--border-strong); border-radius: 12px; background: #0f0f11; color: var(--muted); }
.signature-field:hover { border-color: var(--accent); color: var(--text); }
.signature-field img { max-height: 110px; object-fit: contain; }

.modal { width: min(calc(100% - 2rem), 620px); max-height: calc(100dvh - 2rem); overflow: auto; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow); padding: 1rem; }
.modal::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(8px); }
.modal[open] { animation: modal-in .2s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } }
.modal--wide { width: min(calc(100% - 2rem), 900px); }
.modal--small { width: min(calc(100% - 2rem), 390px); text-align: center; }
.modal--viewer { width: min(calc(100% - 2rem), 1000px); background: #050506; }
.modal--viewer > img { display: block; max-height: calc(100dvh - 8rem); margin: auto; object-fit: contain; }
.modal--camera { width: min(calc(100% - 2rem), 760px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.modal-header h2 { margin: 0; font-size: 1.2rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: 1rem; }
.signature-canvas-wrap { height: 260px; overflow: hidden; border: 1px solid var(--border); border-radius: 13px; background: #0c0c0e; }
#signature-pad { width: 100%; height: 100%; touch-action: none; }
.camera-stage { display: grid; overflow: hidden; aspect-ratio: 4 / 3; place-items: center; border-radius: 14px; background: black; }
.camera-stage video { width: 100%; height: 100%; object-fit: cover; }
.camera-controls { display: flex; align-items: center; justify-content: space-between; margin-top: .9rem; }
.shutter { width: 58px; height: 58px; border: 5px solid var(--surface-raised); border-radius: 50%; background: white; box-shadow: 0 0 0 2px white; }
.form-grid { display: grid; grid-template-columns: 2fr 1fr; gap: .8rem; }
.rich-editor { min-height: 310px; margin-bottom: .8rem; background: white; color: #17171a; }
.ql-toolbar.ql-snow { border-radius: 10px 10px 0 0; background: #f1eff0; }
.ql-container.ql-snow { border-radius: 0 0 10px 10px; }
.config-layout { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(0, 1.3fr); gap: 1rem; }
.document-preview, .paper-preview { overflow: auto; border-radius: 12px; background: #fbf9f7; color: #262326; padding: clamp(1rem, 4vw, 2rem); white-space: pre-wrap; line-height: 1.55; }
.template-config-preview h2 { margin: 1.2rem 0 .45rem; color: #4b4145; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; }
.template-config-preview h2:first-child { margin-top: 0; }
.template-config-preview p { margin: .35rem 0 .65rem; font-size: .8rem; }
.template-config-preview ul { margin: .35rem 0 .8rem; padding-left: 1.2rem; }
.template-config-preview li { margin: .2rem 0; font-size: .8rem; }
.template-review-note { margin: .35rem 0 0; border-left: 2px solid var(--accent); padding: .5rem .65rem; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.paper-preview { min-height: 420px; font-family: Georgia, serif; }
.qr-code { display: grid; min-height: 280px; place-items: center; margin: 1rem auto; }
.qr-code canvas, .qr-code img { width: min(100%, 280px) !important; height: auto !important; border: 12px solid white; border-radius: 8px; }
.account-modal { width: min(calc(100% - 2rem), 820px); padding: 1.15rem; }
.account-modal-header { margin-bottom: .8rem; }
.account-modal-brand { display: flex; align-items: center; gap: .75rem; text-align: left; }
.account-modal-brand .eyebrow { margin-bottom: .18rem; }
.account-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; border: 1px solid var(--border); border-radius: 13px; background: #111114; padding: .35rem; }
.account-tab { min-height: 42px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: .8rem; font-weight: 760; }
.account-tab:hover { color: var(--text); }
.account-tab.active { background: var(--surface-soft); color: #ff91b9; box-shadow: 0 1px 0 rgba(255,255,255,.08) inset; }
.account-panel { padding: 1.1rem .2rem .1rem; animation: enter .2s ease-out; }
.account-status-card { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: 14px; background: #121215; padding: .85rem; text-align: left; }
.account-status-card strong, .account-status-card small { display: block; }
.account-status-card small { margin-top: .2rem; color: var(--muted); line-height: 1.35; }
.account-avatar { width: 48px; height: 48px; flex: 0 0 48px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-soft); object-fit: cover; }
.account-avatar--large { width: 62px; height: 62px; flex-basis: 62px; border-radius: 19px; }
.account-divider { display: flex; align-items: center; gap: .75rem; margin: 1rem 0; color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.account-divider::before, .account-divider::after { height: 1px; flex: 1; background: var(--border); content: ''; }
.form-help { margin: 0; color: var(--muted); font-size: .75rem; }
.input-prefix { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #101012; }
.input-prefix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-prefix > span { padding-left: .8rem; color: var(--muted); }
.input-prefix input { border: 0; box-shadow: none; }
.input-prefix input:focus { box-shadow: none; }
.profile-hero { display: flex; align-items: center; gap: .85rem; border-bottom: 1px solid var(--border); padding: 0 0 1rem; }
.profile-hero strong, .profile-hero small { display: block; }
.profile-hero small { margin-top: .2rem; color: var(--muted); }
.signature-studio { margin: .2rem 0 0; border: 1px solid var(--border); border-radius: 15px; background: #111114; padding: .85rem; }
.signature-studio legend { padding: 0 .4rem; color: #d7d2d5; font-size: .82rem; font-weight: 700; }
.signature-mode-tabs { display: inline-flex; gap: .25rem; border-radius: 10px; background: var(--surface); padding: .25rem; }
.signature-mode { min-height: 34px; border: 0; border-radius: 7px; background: transparent; padding: .35rem .85rem; color: var(--muted); font-size: .75rem; font-weight: 750; }
.signature-mode.active { background: var(--surface-soft); color: #ff91b9; }
.signature-generator-panel { margin-top: .75rem; }
.profile-signature-canvas-wrap { height: 170px; overflow: hidden; border: 1px dashed var(--border-strong); border-radius: 11px; background: #09090b; }
#profile-signature-canvas { width: 100%; height: 100%; touch-action: none; }
.signature-generator-panel > .text-button { margin-top: .45rem; }
.typed-signature-preview { display: grid; min-height: 110px; place-items: center; margin-top: .75rem; overflow: hidden; border: 1px dashed var(--border-strong); border-radius: 11px; background: linear-gradient(145deg, #141216, #0c0c0e); padding: 1rem; color: #ffc1d8; font-size: clamp(1.7rem, 6vw, 2.8rem); text-align: center; text-overflow: ellipsis; }
.signature-classic { font-family: "Brush Script MT", "Segoe Script", cursive; font-style: italic; }
.signature-editorial { font-family: Georgia, "Times New Roman", serif; font-style: italic; letter-spacing: .03em; }
.signature-minimal { font-family: "Segoe UI", Arial, sans-serif; font-weight: 300; letter-spacing: .08em; text-transform: uppercase; }
.account-profile-actions { align-items: center; justify-content: space-between; }

.toast-container { position: fixed; right: 1rem; bottom: 1rem; z-index: 150; display: grid; width: min(calc(100% - 2rem), 360px); gap: .55rem; pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: .65rem; border: 1px solid var(--border-strong); border-left: 3px solid var(--info); border-radius: 12px; background: #242429; box-shadow: var(--shadow); padding: .85rem; animation: toast-in .22s ease-out; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast p { margin: 0; color: var(--text); font-size: .86rem; }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } }

@media (max-width: 820px) {
  :root { --topbar-height: 62px; }
  .mobile-only { display: inline-grid; }
  .sidebar { inset: 0 0 0 auto; width: min(88vw, 330px); border-left: 1px solid var(--border); border-right: 0; transform: translateX(105%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-user { margin-top: .2rem; }
  .main-content { margin-left: 0; padding: calc(var(--topbar-height) + 1.35rem) 1rem calc(88px + env(safe-area-inset-bottom)); }
  .bottom-nav { position: fixed; inset: auto 0 0; z-index: 30; display: grid; height: calc(68px + env(safe-area-inset-bottom)); grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--border); background: rgba(16,16,18,.95); padding: .35rem .35rem env(safe-area-inset-bottom); backdrop-filter: blur(18px); }
  .bottom-nav .nav-item { display: grid; min-height: 0; place-items: center; gap: 0; padding: .2rem; font-size: 1.05rem; text-align: center; }
  .bottom-nav .nav-item small { font-size: .62rem; }
  .quick-add { align-self: start; width: 52px; height: 52px; justify-self: center; border: 4px solid var(--bg); border-radius: 50%; background: var(--accent); color: #18030b; font-size: 1.7rem; font-weight: 500; transform: translateY(-15px); }
  .editor-layout { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .danger-panel { grid-column: auto; }
  .brand-workspace { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .connection-pill { padding: .4rem .55rem; }
  .page-heading { align-items: center; }
  .page-heading .button { padding-inline: .75rem; }
  .page-heading .button span { display: none; }
  .editor-topbar h1 { font-size: 1.15rem; }
  .form-grid, .config-layout { grid-template-columns: 1fr; }
  .brand-workspace .form-grid, .brand-template-choices { grid-template-columns: 1fr; }
  .modal { width: calc(100% - 1rem); max-height: calc(100dvh - 1rem); padding: .85rem; }
  .modal-actions .button { flex: 1; }
  .toast-container { right: .5rem; bottom: calc(74px + env(safe-area-inset-bottom)); width: calc(100% - 1rem); }
  .auth-screen { align-items: start; padding-top: 2rem; }
  .auth-stage > .brand-mark { width: 70px; height: 70px; margin-bottom: 1rem; }
  .auth-stage h1 { font-size: 1.9rem; }
  .identity-card-3d { border-radius: 20px; padding: 1rem; }
  .identity-card-person { margin-top: 1.25rem; }
  .identity-avatar { width: 50px; height: 50px; flex-basis: 50px; border-radius: 15px; }
  .identity-card-signature { margin-top: .55rem; font-size: 1.05rem; }
  .identity-card-footer { right: 1rem; bottom: .75rem; left: 1rem; }
  .account-modal { padding: .75rem; }
  .account-tab { padding-inline: .3rem; font-size: .7rem; }
  .account-panel { padding-top: .85rem; }
  .account-profile-actions { flex-direction: column-reverse; }
  .account-profile-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (prefers-contrast: more) {
  :root { --border: #55555e; --muted: #c5c0c3; }
}

@media print {
  .topbar, .sidebar, .bottom-nav, .editor-topbar, .editor-aside { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  body { background: white; color: black; }
}

.admin-users-scroll { overflow-x: auto; }
.admin-users-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-users-table th, .admin-users-table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid rgba(128, 128, 128, 0.25); white-space: nowrap; }
