/* Stonewing Cards — dashboard and auth pages */
:root {
  --bg: #f4f5f7; --surface: #ffffff; --text: #111827; --muted: #5b6472; --line: #e3e6ea;
  --brand: #1f2937; --accent: #0f766e; --accent-soft: #e6f4f1; --danger: #b42318; --danger-soft: #fdecea;
  --warn: #92400e; --warn-soft: #fef3c7; --focus: #2563eb; --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 6px 20px rgba(16,24,40,.05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --surface: #171b21; --text: #f3f4f6; --muted: #a2aab6; --line: #2a3039; --accent-soft: #10302c; --danger-soft: #3a1612; --warn-soft: #3b2a08; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3); }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; word-break: break-all; }

/* layout */
.topbar { background: var(--brand); color: #fff; }
.topbar .inner { max-width: 1080px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar .logo { font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.topbar .logo span { background: rgba(255,255,255,.18); border-radius: 8px; padding: 2px 7px; font-size: .85rem; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: #fff; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: .95rem; opacity: .85; min-height: 40px; display: inline-flex; align-items: center; }
.topbar nav a.active, .topbar nav a:hover { opacity: 1; background: rgba(255,255,255,.12); }
.topbar .right { display: flex; align-items: center; gap: 8px; }
.topbar select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; max-width: 200px; }
.topbar select option { color: #111; }
.page { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr; }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (min-width: 860px) { .grid.two { grid-template-columns: 1fr 1fr; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .n { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.tile .l { color: var(--muted); font-size: .85rem; }

/* forms */
.field { display: grid; gap: 6px; margin: 0 0 14px; }
.field label { font-weight: 500; font-size: .92rem; }
.field .hint { color: var(--muted); font-size: .82rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=tel], input[type=date], input[type=color], select, textarea {
  font: inherit; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); width: 100%; min-height: 46px;
}
input[type=color] { padding: 4px; height: 46px; width: 80px; }
textarea { resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.check { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0; }
.check input { width: 20px; height: 20px; margin-top: 3px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: .88rem; }
.btn.link { border: 0; background: transparent; text-decoration: underline; font-weight: 500; padding: 4px 6px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn:focus-visible { outline-offset: 3px; }

/* lists & tables */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--line); }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.avatar-sm { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--line); }

/* states */
.alert { padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; border: 1px solid var(--line); background: var(--surface); }
.alert.error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert.warn { background: var(--warn-soft); border-color: #f59e0b; color: var(--warn); }
.alert.ok { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.loading { color: var(--muted); padding: 20px 0; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--brand); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; max-width: 90vw; }
.toast.error { background: var(--danger); }
.skeleton { background: linear-gradient(90deg, var(--line) 25%, var(--surface) 50%, var(--line) 75%); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 6px; height: 1em; }
@keyframes sh { from { background-position: 200% 0 } to { background-position: -200% 0 } }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; }
.auth .brand { text-align: center; margin-bottom: 14px; }
.auth .brand .mark { width: 48px; height: 48px; border-radius: 12px; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-weight: 700; }

/* editor */
.editor { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 960px) { .editor { grid-template-columns: 1.3fr 1fr; align-items: start; } .editor .preview-col { position: sticky; top: 16px; } }
.preview-frame { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--bg); }
.preview-frame .pv-head { padding: 12px 14px; color: #fff; font-weight: 600; }
.preview-frame .pv-body { padding: 18px 14px; text-align: center; }
.preview-frame .pv-avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 28px; }
.preview-frame .pv-actions { display: flex; gap: 8px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.preview-frame .pv-actions span { padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: .85rem; }
.preview-frame .pv-link { display: block; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; text-align: left; font-size: .9rem; }
.link-editor { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.link-editor .row > * { flex: 1; min-width: 120px; }
.link-editor .row .btn { flex: 0 0 auto; }
.lock { font-size: .78rem; color: var(--warn); }
.vis { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.photo-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.photo-row img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: var(--line); }

/* analytics chart */
.chart { width: 100%; height: 220px; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar.clicks { fill: var(--brand); opacity: .6; }
.chart text { font-size: 10px; fill: var(--muted); }
.legend { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* QR */
.qr-box { display: inline-flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; background: #fff; border-radius: 10px; border: 1px solid var(--line); }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; max-width: 520px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.onboarding li { padding: 8px 0; display: flex; gap: 10px; align-items: flex-start; border: 0; }
.onboarding .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: inline-grid; place-items: center; font-size: .8rem; flex: 0 0 auto; }
.onboarding .done .dot { background: var(--accent); border-color: var(--accent); color: #fff; }
