:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #161a23;
  --muted: #5c6474;
  --line: #e3e6ee;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --brand-soft: #eef0ff;
  --ok: #157a4a;
  --ok-soft: #e5f6ed;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn-soft: #fff6e0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --surface: #171b24; --ink: #e8ebf2; --muted: #9aa3b5; --line: #2a303d;
    --brand: #7c74ff; --brand-soft: #24224a; --ok: #4cc38a; --ok-soft: #12301f;
    --danger: #ff6b5b; --danger-soft: #3a1714; --warn-soft: #3a2f12;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 system-ui, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: clamp(1.4rem, 3vw, 2rem); }
h2 { font-size: 1.2rem; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 24px; padding-bottom: 48px; min-height: 70vh; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.brand svg { color: var(--brand); }
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav a { color: var(--ink); text-decoration: none; }
.nav a.btn { color: var(--brand-ink); }
.nav .lang { color: var(--muted); font-size: .9rem; }
.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; color: var(--ink); font: inherit; cursor: pointer; }

.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; padding: 20px 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand);
  border-radius: 10px; padding: 9px 16px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.07); }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: .9rem; }
.btn-lg { padding: 12px 22px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn[aria-disabled="true"] { opacity: .5; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; width: 38px; color: var(--muted); font-size: 1.3rem; cursor: pointer; }

/* Cards and forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.field { display: block; margin-bottom: 14px; }
.label, label { font-weight: 600; font-size: .92rem; }
.label { display: block; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
input[type=color] { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface); }
label > input, label > select { margin-top: 5px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; }
.hint, .muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
.warn { background: var(--warn-soft); border-radius: 8px; padding: 10px 12px; font-size: .92rem; }

.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.alert ul { margin: 0; padding-inline-start: 18px; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--danger-soft); color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.grid-2 > .card + .card { margin-top: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
@media (max-width: 480px) { .grid-3 { grid-template-columns: 1fr 1fr; } }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Auth */
.auth { max-width: 420px; margin: 32px auto; }

/* Home */
.hero { padding: 32px 0 24px; max-width: 760px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); }
.lead { font-size: 1.15rem; color: var(--muted); }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.checks li::before { content: "✓"; color: var(--ok); font-weight: 800; margin-inline-end: 8px; }
.generator { margin: 16px 0 40px; }
.gen-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 24px; }
@media (max-width: 820px) { .gen-grid { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 14px; font: inherit; cursor: pointer; }
.tab.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.features, .pricing, .faq { margin: 40px 0; }
.feature-grid, .price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.feature-grid .card + .card, .price-grid .card + .card { margin-top: 0; }
.feature h3 { font-size: 1.05rem; }
.feature p { margin: 0; color: var(--muted); }
.promise { border-inline-start: 4px solid var(--ok); }
.price { display: flex; flex-direction: column; }
.price.featured { border: 2px solid var(--brand); }
.price ul { padding-inline-start: 18px; flex: 1; }
.amount { font-size: 2rem; font-weight: 800; }
.amount small { font-size: .9rem; color: var(--muted); font-weight: 400; }
.faq details { margin-bottom: 10px; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq p { margin: 10px 0 0; color: var(--muted); }

/* Designer */
.designer { display: grid; gap: 16px; }
.preview-box { text-align: center; }
.qr-preview { display: inline-flex; flex-direction: column; align-items: center; background: #fff; border-radius: 12px; padding: 10px; border: 1px solid var(--line); }
.qr-preview canvas { display: block; max-width: 100%; height: auto !important; }
.qr-preview[data-frame="box"], .qr-preview[data-frame="bottom"] { background: var(--frame); }
.qr-preview[data-frame="bottom"] { padding: 0 0 0; overflow: hidden; }
.frame-caption { font-weight: 800; font-size: 1.15rem; padding: 6px 0 2px; }
.frame-caption:empty { display: none; }
.download-row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.design-panel summary { font-weight: 700; cursor: pointer; margin-bottom: 12px; }
.logo-row { display: flex; align-items: end; gap: 10px; }
.logo-row label { flex: 1; }

/* Editor */
.editor { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
.editor-main .card + .card { margin-top: 16px; }
.editor-side { position: sticky; top: 76px; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } .editor-side { position: static; order: -1; } }
.form-submit { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.link-row { display: grid; grid-template-columns: 130px 1fr 1.4fr 38px; gap: 6px; margin-bottom: 8px; }
@media (max-width: 600px) { .link-row { grid-template-columns: 1fr 38px; } .link-row select { grid-column: 1; } .link-row input { grid-column: 1; } .link-row .icon-btn { grid-row: 1; grid-column: 2; } }
.img-current { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.img-current img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.slug-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.slug-input span { padding: 0 10px; color: var(--muted); font-size: .85rem; white-space: nowrap; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.slug-input input { border: 0; border-radius: 0; border-inline-start: 1px solid var(--line); margin: 0; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.type-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--ink); }
.type-card:hover { border-color: var(--brand); }
.type-card strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.type-card span { color: var(--muted); font-size: .9rem; }

/* Dashboard */
.plan-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.meter { flex: 1; min-width: 120px; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--brand); }
.empty { text-align: center; padding: 40px 20px; }
.code-list { display: grid; gap: 12px; }
.code-list .card + .card { margin-top: 0; }
.code-item { display: grid; grid-template-columns: 96px 1fr auto auto; gap: 16px; align-items: center; padding: 14px; }
.code-item.is-paused { opacity: .65; }
.qr-thumb { width: 96px; height: 96px; background: #fff; border-radius: 8px; overflow: hidden; }
.qr-thumb canvas { width: 96px; height: 96px; }
.code-info h3 { margin: 0 0 4px; font-size: 1.05rem; }
.code-info h3 a { color: var(--ink); text-decoration: none; }
.short { font-size: .9rem; word-break: break-all; }
.tags { display: flex; gap: 6px; margin-bottom: 4px; }
.tag { font-size: .78rem; background: var(--brand-soft); color: var(--brand); padding: 2px 8px; border-radius: 99px; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-off { background: var(--danger-soft); color: var(--danger); }
.code-scans { text-align: center; }
.code-scans strong { display: block; font-size: 1.4rem; }
.code-scans span { color: var(--muted); font-size: .85rem; }
.code-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: end; max-width: 240px; }
@media (max-width: 760px) {
  .code-item { grid-template-columns: 72px 1fr auto; }
  .qr-thumb, .qr-thumb canvas { width: 72px; height: 72px; }
  .code-actions { grid-column: 1 / -1; justify-content: start; max-width: none; }
}

/* Stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis .card + .card { margin-top: 0; }
.kpi span { color: var(--muted); font-size: .9rem; }
.kpi strong { display: block; font-size: 1.8rem; }
.bars { display: flex; align-items: end; gap: 2px; height: 160px; direction: ltr; }
.bar { flex: 1; height: 100%; display: flex; align-items: end; }
.bar span { display: block; width: 100%; min-height: 1px; background: var(--brand); border-radius: 3px 3px 0 0; }
.bars-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: 6px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 48px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: .92rem; }
.hbar-track { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.hbar-track span { display: block; height: 100%; background: var(--brand); }
.hbar-n { text-align: end; font-variant-numeric: tabular-nums; }

/* Admin */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.plan-form { display: flex; gap: 6px; align-items: center; }
.plan-form select, .plan-form input { width: auto; padding: 6px 8px; }
