:root {
  --ink: #13203b;
  --muted: #65728b;
  --line: #dfe5f0;
  --paper: #ffffff;
  --canvas: #f4f6fb;
  --blue: #4a5cf2;
  --blue-dark: #3443c7;
  --blue-soft: #edf0ff;
  --green: #0c9b72;
  --green-soft: #e7f8f1;
  --amber: #ca7a0d;
  --amber-soft: #fff4df;
  --red: #c73d52;
  --red-soft: #ffedf1;
  --shadow: 0 18px 50px rgba(40, 57, 100, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button, .button { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code { padding: 2px 5px; border-radius: 5px; background: #eef1f7; color: #39455c; }

.install-body { min-height: 100vh; background: radial-gradient(circle at 5% 0%, #d9e0ff 0, transparent 31rem), linear-gradient(160deg, #f9fbff, #eef1fb); }
.install-shell { max-width: 1000px; padding: 44px 22px 64px; margin: 0 auto; }
.brand-panel { display: flex; gap: 12px; align-items: center; margin: 0 0 25px; color: #13203b; }
.brand-panel strong { display: block; font-size: 21px; line-height: 1.05; letter-spacing: -.03em; }
.brand-panel small { display: block; margin-top: 2px; font-weight: 800; color: #f14563; font-size: 9px; letter-spacing: .12em; }
.brand-icon { width: 46px; height: 46px; border-radius: 13px; box-shadow: 0 8px 18px rgba(74, 92, 242, .24); }
.install-card { max-width: 790px; background: rgba(255,255,255,.96); border: 1px solid rgba(225,230,242,.95); box-shadow: var(--shadow); border-radius: 26px; padding: clamp(25px, 5vw, 52px); }
.install-card h1 { margin: 8px 0 12px; font-size: clamp(26px, 4vw, 38px); line-height: 1.1; letter-spacing: -.04em; }
.install-card h2 { margin: 35px 0 14px; font-size: 17px; }
.install-card > p { color: var(--muted); line-height: 1.55; max-width: 670px; }
.eyebrow { font-size: 11px; letter-spacing: .12em; color: var(--blue); font-weight: 800; }
.eyebrow.success { color: var(--green); }
.requirements { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 25px 0 5px; }
.requirement { display: grid; grid-template-columns: 23px 1fr auto; align-items: center; gap: 8px; padding: 11px 12px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px; }
.requirement b { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; font-size: 12px; }
.requirement.ok b { background: var(--green-soft); color: var(--green); }
.requirement.bad { border-color: #ffd0d9; background: #fff7f8; }
.requirement.bad b { background: var(--red-soft); color: var(--red); }
.requirement span { font-weight: 650; font-size: 14px; }
.requirement small { color: var(--muted); text-align: right; font-size: 11px; }
.setup-form label, .form-field { display: grid; gap: 7px; color: #47546a; font-size: 13px; font-weight: 700; }
.setup-form input, .form-field input, .form-field textarea, .form-field select, .input, .share-modal input, .share-modal select { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); border: 1px solid #dbe1ed; background: #f9faff; border-radius: 11px; outline: none; transition: .18s border, .18s box-shadow, .18s background; }
.form-field textarea { min-height: 110px; resize: vertical; }
.setup-form input:focus, .form-field input:focus, .form-field textarea:focus, .form-field select:focus, .input:focus, .share-modal input:focus, .share-modal select:focus { border-color: #8491ff; background: #fff; box-shadow: 0 0 0 3px rgba(74,92,242,.12); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.button { display: inline-flex; min-height: 44px; padding: 10px 15px; align-items: center; justify-content: center; gap: 8px; border: 1px solid #d8deea; background: #fff; color: #30405d; border-radius: 11px; font-weight: 750; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; }
.button:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 7px 18px rgba(41, 57, 104, .12); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.button.primary { border-color: var(--blue); background: linear-gradient(135deg, #5367ff, #3e4de3); color: #fff; box-shadow: 0 8px 18px rgba(74,92,242,.23); }
.button.danger { color: #b52d44; border-color: #ffcbd5; background: #fff7f8; }
.button.success { color: #057a59; border-color: #b9e8d9; background: #effcf7; }
.button.wide { width: 100%; margin-top: 28px; min-height: 50px; }
.install-actions, .inline-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 26px 0 14px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.alert { margin: 20px 0; padding: 13px 15px; border-radius: 13px; font-size: 14px; }
.alert p { margin: 4px 0; }
.alert.error { background: var(--red-soft); color: #9f2b41; border: 1px solid #ffcbd5; }
.alert.ok { background: var(--green-soft); color: #087353; border: 1px solid #bae9d9; }
.alert.info { background: var(--blue-soft); color: #3545c4; border: 1px solid #d6dcff; }

/* Portal */
.portal-shell { min-height: 100vh; }
.portal-header { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(18px, calc((100vw - 1240px) / 2)); background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 20; }
.portal-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 800; letter-spacing: -.025em; }
.portal-brand:hover { text-decoration: none; }
.portal-brand img { width: 36px; height: 36px; border-radius: 10px; }
.portal-brand small { display: block; color: #e84761; letter-spacing: .11em; font-size: 8px; margin-top: 1px; }
.header-nav, .header-actions { display: flex; align-items: center; gap: 8px; }
.header-nav a { padding: 8px 10px; color: #60708a; font-weight: 650; font-size: 14px; }
.header-nav a.active { color: var(--blue); }
.lang-select { border: 1px solid #dce2ef; background: #fff; color: #4b5870; border-radius: 10px; padding: 8px; font-weight: 700; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #54637a; padding: 5px 9px 5px 5px; border: 1px solid #e1e5ee; border-radius: 999px; }
.avatar { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; color: #fff; background: linear-gradient(135deg, #6c7cff, #3f4ddd); font-size: 12px; font-weight: 800; }
.portal-main { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 34px 0 60px; }
.portal-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 28px; align-items: stretch; margin-bottom: 30px; }
.hero-copy { padding: clamp(26px, 5vw, 58px); min-height: 372px; border-radius: 26px; overflow: hidden; position: relative; color: #fff; background: linear-gradient(135deg, #172550 0%, #283cc4 64%, #7358ef); box-shadow: 0 18px 42px rgba(49,68,171,.22); }
.hero-copy:after { content: ""; position: absolute; right: -92px; top: -145px; width: 335px; height: 335px; border: 40px solid rgba(255,255,255,.09); border-radius: 50%; }
.hero-copy > * { position: relative; z-index: 1; }
.hero-copy .eyebrow { color: #bfc8ff; }
.hero-copy h1 { font-size: clamp(31px, 4.3vw, 53px); line-height: 1.02; letter-spacing: -.055em; max-width: 630px; margin: 12px 0; }
.hero-copy p { max-width: 560px; color: rgba(255,255,255,.8); line-height: 1.55; }
.hero-list { display: flex; gap: 8px; flex-wrap: wrap; margin: 24px 0; }
.hero-list span { padding: 7px 10px; border-radius: 999px; background: rgba(255,255,255,.13); color: #fff; font-size: 13px; font-weight: 650; }
.hero-copy .button { border-color: #fff; color: #2637b9; }
.access-card, .panel-card { background: #fff; border: 1px solid #e0e5f1; border-radius: 21px; box-shadow: 0 12px 32px rgba(57,72,105,.08); }
.access-card { padding: 25px; }
.access-card h2 { margin: 0 0 7px; letter-spacing: -.03em; font-size: 22px; }
.access-card > p { color: var(--muted); margin: 0 0 19px; line-height: 1.5; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px; border-radius: 12px; background: #f1f3f9; margin-bottom: 16px; }
.auth-tabs button { border: 0; background: transparent; color: #758199; padding: 10px; border-radius: 9px; font-weight: 800; cursor: pointer; }
.auth-tabs button.active { background: #fff; color: #3344cf; box-shadow: 0 2px 7px rgba(38,48,104,.12); }
.auth-form { display: grid; gap: 12px; }
.auth-form label { display: grid; gap: 6px; color: #536078; font-size: 12px; font-weight: 700; }
.auth-form input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #dce2ee; border-radius: 10px; outline: none; }
.auth-form input:focus { border-color: #8190ff; box-shadow: 0 0 0 3px rgba(74,92,242,.11); }
.auth-form .button { margin-top: 3px; }
.privacy-note { display: flex; gap: 8px; margin-top: 16px; padding-top: 15px; border-top: 1px solid #e7eaf1; color: #748097; font-size: 12px; line-height: 1.4; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px #e8f8f2; flex: 0 0 auto; margin: 4px 2px 0 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin: 35px 0 14px; }
.section-heading h2 { margin: 0; letter-spacing: -.035em; font-size: 24px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.campaign-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.campaign-card { display: flex; flex-direction: column; padding: 20px; min-height: 230px; background: #fff; border: 1px solid #e0e5f1; border-radius: 18px; }
.campaign-card .campaign-top { display: flex; justify-content: space-between; gap: 9px; align-items: center; }
.campaign-card .campaign-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: #4d5ef2; background: #edf0ff; font-weight: 900; }
.tag { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .04em; background: var(--blue-soft); color: #3e4fda; }
.tag.green { background: var(--green-soft); color: #087e5d; }
.tag.amber { background: var(--amber-soft); color: #a76200; }
.campaign-card h3 { margin: 17px 0 7px; font-size: 18px; letter-spacing: -.025em; }
.campaign-card p { flex: 1; margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.campaign-card .button { width: 100%; }
.empty-card { padding: 31px; text-align: center; color: var(--muted); border: 1px dashed #cbd4e5; border-radius: 18px; }
.dashboard-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.panel-card { padding: 22px; }
.panel-card h2, .panel-card h3 { margin: 0 0 8px; letter-spacing: -.025em; }
.access-state { display: flex; gap: 13px; padding: 17px; background: var(--green-soft); color: #087451; border-radius: 14px; }
.access-state.warning { background: var(--amber-soft); color: #9a5e0d; }
.access-state .state-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: currentColor; border-radius: 50%; filter: saturate(.75); }
.access-state .state-icon span { filter: invert(1); font-weight: 900; }
.access-state strong { display: block; font-size: 15px; }
.access-state small { display: block; margin-top: 3px; line-height: 1.4; }
.redeem-form { display: flex; gap: 9px; margin-top: 15px; }
.redeem-form .input { flex: 1; min-width: 0; }
.claim-list { display: grid; gap: 10px; }
.claim-item { display: flex; align-items: center; gap: 11px; padding: 12px 0; border-bottom: 1px solid #edf0f5; }
.claim-item:last-child { border-bottom: 0; }
.claim-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: #f0f3ff; color: #4355de; font-size: 12px; font-weight: 900; }
.claim-item strong { font-size: 13px; }
.claim-item small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.claim-item .tag { margin-left: auto; }
.message-list { display: grid; gap: 9px; }
.message { padding: 11px 13px; border-radius: 11px; background: #f7f8fc; border: 1px solid #e8ebf3; }
.message strong { display: block; font-size: 13px; }
.message p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.message time { display: block; margin-top: 5px; color: #9aa5b7; font-size: 11px; }
.share-modal-backdrop { position: fixed; inset: 0; z-index: 100; display: none; align-items: end; justify-content: center; padding: 20px; background: rgba(15,25,52,.45); backdrop-filter: blur(3px); }
.share-modal-backdrop.is-open { display: flex; }
.share-modal { width: min(560px, 100%); padding: 25px; background: #fff; border-radius: 22px; box-shadow: 0 20px 60px rgba(8,16,41,.24); }
.share-modal h2 { margin: 0 0 7px; }
.share-modal p { color: var(--muted); line-height: 1.5; font-size: 14px; }
.share-steps { margin: 17px 0; padding: 0; list-style: none; counter-reset: share; }
.share-steps li { display: flex; gap: 10px; margin: 9px 0; color: #536078; font-size: 13px; line-height: 1.45; }
.share-steps li:before { counter-increment: share; content: counter(share); display: grid; place-items: center; width: 21px; height: 21px; flex: 0 0 auto; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 800; }
.share-modal label { display: grid; gap: 6px; margin: 12px 0; color: #536078; font-size: 12px; font-weight: 750; }
.share-modal-actions { display: flex; gap: 9px; justify-content: end; margin-top: 18px; }

/* App wrapper */
.app-bar { position: fixed; z-index: 1000; top: calc(env(safe-area-inset-top, 0px) + 11px); right: 14px; display: flex; gap: 7px; align-items: center; padding: 6px; border: 1px solid rgba(217,224,239,.9); border-radius: 13px; background: rgba(255,255,255,.9); box-shadow: 0 8px 22px rgba(31,48,82,.14); backdrop-filter: blur(10px); }
.app-bar .app-status { display: flex; gap: 7px; align-items: center; padding: 0 4px; color: #506079; font-size: 12px; font-weight: 700; }
.app-bar .app-status .dot { width: 7px; height: 7px; margin: 0; box-shadow: 0 0 0 3px #e7f8f1; }
.app-bar a { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 5px 9px; border-radius: 8px; background: #f0f3f8; color: #3d4d68; font-size: 12px; font-weight: 800; }
.app-bar a:hover { text-decoration: none; background: #e5eaff; color: #4253d7; }

/* Admin */
.admin-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.admin-side { position: sticky; top: 0; height: 100vh; padding: 24px 14px; color: #dce4ff; background: #101a38; }
.admin-side .portal-brand { color: #fff; padding: 0 8px; margin-bottom: 26px; }
.admin-side .portal-brand small { color: #ff8092; }
.admin-nav { display: grid; gap: 4px; }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; color: #b5c0df; font-weight: 700; font-size: 14px; }
.admin-nav a:hover, .admin-nav a.active { color: #fff; text-decoration: none; background: #24335f; }
.nav-symbol { width: 20px; text-align: center; color: #aab9ff; }
.admin-side-bottom { position: absolute; bottom: 22px; left: 22px; right: 22px; color: #8e9cbe; font-size: 12px; }
.admin-content { min-width: 0; padding: 30px clamp(18px, 4vw, 48px) 60px; }
.admin-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; max-width: 1300px; margin: 0 auto 26px; }
.admin-top h1 { margin: 0; font-size: clamp(25px, 4vw, 35px); letter-spacing: -.045em; }
.admin-top p { margin: 7px 0 0; color: var(--muted); }
.admin-user-tools { display: flex; gap: 9px; align-items: center; }
.admin-page { max-width: 1300px; margin: 0 auto; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 18px; background: #fff; border: 1px solid #e0e5f0; border-radius: 15px; }
.stat-card strong { display: block; margin-top: 7px; font-size: 28px; letter-spacing: -.05em; }
.stat-card span { color: #6d7a90; font-weight: 700; font-size: 13px; }
.stat-card small { color: var(--green); font-size: 11px; font-weight: 750; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 18px; }
.admin-table-wrap { overflow-x: auto; background: #fff; border: 1px solid #e0e5f0; border-radius: 16px; }
.admin-table { width: 100%; min-width: 670px; border-collapse: collapse; }
.admin-table th { padding: 12px 14px; text-align: left; color: #758299; background: #f8f9fc; border-bottom: 1px solid #e8ebf2; font-size: 11px; letter-spacing: .03em; text-transform: uppercase; }
.admin-table td { padding: 13px 14px; border-bottom: 1px solid #edf0f5; color: #3f4d65; font-size: 13px; vertical-align: top; }
.admin-table tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tiny-button { padding: 6px 8px; border: 1px solid #dbe1ed; color: #4d5d77; background: #fff; border-radius: 7px; font-size: 11px; font-weight: 800; cursor: pointer; }
.tiny-button.green { color: #087a59; border-color: #b8e6d7; background: #f0fcf8; }
.tiny-button.red { color: #b83449; border-color: #ffc7d0; background: #fff7f8; }
.admin-form-card { padding: 21px; background: #fff; border: 1px solid #e0e5f0; border-radius: 16px; }
.admin-form-card h2 { margin: 0 0 6px; font-size: 19px; letter-spacing: -.025em; }
.admin-form-card > p { margin: 0 0 17px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.admin-form { display: grid; gap: 13px; }
.admin-form .form-field.inline { grid-template-columns: 1fr auto; align-items: center; }
.admin-form .form-field.inline input { width: auto; min-width: 78px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.note-box { padding: 13px; background: #fff8e7; border: 1px solid #f7d99e; border-radius: 11px; color: #895d14; font-size: 12px; line-height: 1.45; }
.connection-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid #edf0f5; }
.connection-row:last-child { border-bottom: 0; }
.connection-row h3 { margin: 0; font-size: 14px; }
.connection-row small { display: block; color: var(--muted); margin-top: 3px; }
.switch { display: inline-flex; gap: 7px; align-items: center; color: #546279; font-size: 13px; font-weight: 700; }
.switch input { width: 18px; height: 18px; accent-color: var(--blue); }

/* self test */
.test-list { display: grid; gap: 9px; margin: 22px 0; }
.test-row { display: grid; grid-template-columns: 24px 1fr auto; gap: 9px; align-items: center; padding: 12px 14px; background: #f8fafc; border: 1px solid #e3e8f1; border-radius: 11px; }
.test-row b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; }
.test-row.ok b { color: #047757; background: var(--green-soft); }
.test-row.bad { border-color: #ffd0d8; background: #fff7f8; }
.test-row.bad b { color: #b93449; background: var(--red-soft); }
.test-row small { text-align: right; color: var(--muted); }

@media (max-width: 920px) {
  .portal-hero, .dashboard-grid, .admin-grid { grid-template-columns: 1fr; }
  .campaign-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-shell { grid-template-columns: 70px 1fr; }
  .admin-side { padding: 20px 9px; }
  .admin-side .portal-brand { justify-content: center; padding: 0; }
  .admin-side .portal-brand > span, .admin-nav span:last-child, .admin-side-bottom { display: none; }
  .admin-nav a { justify-content: center; padding: 12px; }
  .nav-symbol { font-size: 18px; }
}

@media (max-width: 680px) {
  .install-shell { padding: 24px 14px 38px; }
  .install-card { padding: 24px 18px; border-radius: 20px; }
  .requirements, .field-grid, .form-row { grid-template-columns: 1fr; }
  .requirement small { text-align: left; }
  .portal-header { height: 64px; padding: 0 14px; }
  .portal-brand img { width: 32px; height: 32px; }
  .portal-brand > span { font-size: 14px; }
  .header-nav { display: none; }
  .header-actions .user-chip { display: none; }
  .header-actions .button { min-height: 37px; padding: 7px 9px; font-size: 12px; }
  .portal-main { width: min(100% - 24px, 1240px); padding-top: 16px; }
  .portal-hero { gap: 14px; }
  .hero-copy { min-height: 0; border-radius: 20px; padding: 27px 22px; }
  .hero-copy h1 { font-size: 32px; }
  .access-card, .panel-card { border-radius: 17px; }
  .access-card { padding: 20px; }
  .campaign-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; margin-top: 27px; }
  .redeem-form { flex-direction: column; }
  .app-bar { top: calc(env(safe-area-inset-top, 0px) + 7px); right: 8px; padding: 4px; }
  .app-bar .app-status { display: none; }
  .app-bar a { min-height: 30px; padding: 5px 7px; font-size: 11px; }
  .admin-shell { display: block; }
  .admin-side { position: static; height: auto; padding: 12px; display: flex; align-items: center; justify-content: space-between; }
  .admin-side .portal-brand { margin: 0; }
  .admin-nav { display: flex; gap: 3px; overflow-x: auto; }
  .admin-nav a { padding: 9px; flex: 0 0 auto; }
  .admin-content { padding: 22px 13px 44px; }
  .admin-top { align-items: flex-start; flex-direction: column; margin-bottom: 18px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 14px; }
  .stat-card strong { font-size: 23px; }
  .admin-form-card { padding: 17px; }
}
