:root {
  color-scheme: dark;
  --bg: #080b12;
  --surface: #111722;
  --surface-2: #171e2a;
  --line: #2a3443;
  --text: #f2f5fb;
  --muted: #98a4b5;
  --accent: #765cf6;
  --accent-2: #54d3ff;
  --safe: #52d6a2;
  --danger: #ff7a8a;
  --shadow: 0 24px 70px rgba(0,0,0,.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: radial-gradient(circle at 50% -10%, rgba(118,92,246,.15), transparent 31rem), var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }

.topbar { min-height: 76px; padding: 14px max(22px, calc((100vw - 1240px)/2)); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; background: rgba(8,11,18,.88); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-weight: 900; font-size: 22px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 10px 30px rgba(118,92,246,.3); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; }
.brand small { color: var(--muted); margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.privacy-pill, .tag { border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; color: var(--muted); font-size: 13px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--safe); box-shadow: 0 0 0 4px rgba(82,214,162,.12); }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; font-size: 20px; }

.page-shell { width: min(1240px, calc(100% - 32px)); margin: 0 auto; }
.hero { text-align: center; padding: 76px 16px 56px; }
.eyebrow, .step { color: #aaa1ff; font-weight: 850; letter-spacing: .18em; font-size: 12px; margin: 0 0 12px; }
.hero h1 { margin: 0; font-size: clamp(40px, 7vw, 78px); line-height: .98; letter-spacing: -.05em; }
.hero h1 span { color: #9a89ff; }
.hero > p:last-child { color: var(--muted); max-width: 720px; margin: 24px auto 0; font-size: clamp(16px, 2vw, 20px); line-height: 1.65; }

.workspace { margin-bottom: 60px; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 auto 16px; max-width: 800px; }
.mode-tab { border: 1px solid var(--line); border-radius: 15px; padding: 17px; background: var(--surface); font-weight: 850; cursor: pointer; text-transform: uppercase; letter-spacing: .08em; }
.mode-tab.active { background: var(--text); color: #10131a; border-color: var(--text); box-shadow: var(--shadow); }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); gap: 18px; align-items: start; }
.control-column, .preview-column { display: grid; gap: 18px; }
.preview-column { position: sticky; top: 94px; }
.panel, .preview-panel { background: linear-gradient(180deg, rgba(255,255,255,.015), transparent), var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: 0 14px 50px rgba(0,0,0,.12); }
.panel.compact { padding: 20px 24px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.panel-heading h2 { margin: 0; font-size: 22px; }
.panel-heading .step { margin-bottom: 6px; }
.tag { color: #c6c1ff; border-color: rgba(118,92,246,.45); background: rgba(118,92,246,.1); white-space: nowrap; }
.tag.neutral { color: var(--muted); border-color: var(--line); background: transparent; }
.tag.safe { color: var(--safe); border-color: rgba(82,214,162,.35); background: rgba(82,214,162,.08); }

.file-button { display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 14px; padding: 17px; background: var(--surface-2); cursor: pointer; transition: .2s ease; }
.file-button:hover, .drop-zone:hover, .drop-zone.dragging { border-color: var(--accent); transform: translateY(-1px); }
.file-button > span:first-child { width: 38px; height: 38px; display: grid; place-items: center; background: rgba(118,92,246,.16); border-radius: 10px; font-size: 24px; color: #b7adff; }
.file-button strong, .file-button small { display: block; }
.file-button small { color: var(--muted); margin-top: 3px; }
.har-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.har-summary > div { border: 1px solid var(--line); background: rgba(0,0,0,.12); border-radius: 12px; padding: 12px; text-align: center; }
.har-summary strong, .har-summary span { display: block; }
.har-summary strong { font-size: 20px; }
.har-summary span { color: var(--muted); font-size: 12px; margin-top: 2px; }
.muted { color: var(--muted); line-height: 1.55; }
.server-upload { margin-top: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.server-upload > strong { display: block; font-size: 15px; }
.server-upload p { color: var(--muted); line-height: 1.55; margin: 8px 0 12px; font-size: 13px; }
.consent-row { display: flex; align-items: flex-start; gap: 9px; color: var(--text); font-size: 13px; line-height: 1.5; cursor: pointer; }
.consent-row input { accent-color: var(--accent); margin-top: 3px; flex: 0 0 auto; }
.server-upload .button { width: 100%; margin-top: 13px; }
.server-upload .button:disabled { opacity: .48; cursor: not-allowed; }
.server-upload #uploadStatus { margin-bottom: 0; }

.drop-zone { min-height: 230px; border: 1px dashed #3a4658; border-radius: 18px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 7px; text-align: center; cursor: pointer; background: rgba(255,255,255,.015); overflow: hidden; transition: .2s ease; position: relative; }
.drop-zone small { color: var(--muted); }
.upload-icon { font-size: 34px; color: #a99dff; }
.drop-zone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.52); }
.drop-zone img ~ * { position: relative; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: grid; gap: 7px; color: #c4ccda; font-weight: 700; font-size: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
input, select { min-width: 0; width: 100%; padding: 13px 14px; color: var(--text); background: #0b1018; border: 1px solid var(--line); border-radius: 11px; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(118,92,246,.12); }
input[type="color"] { padding: 5px; height: 48px; }

.preview-panel { padding: 24px; }
.canvas-wrap { padding: 18px; border-radius: 16px; background: repeating-conic-gradient(#111824 0 25%, #151d29 0 50%) 50%/18px 18px; display: grid; place-items: center; overflow: auto; min-height: 500px; }
canvas { display: block; max-width: 100%; height: auto; border-radius: 10px; box-shadow: 0 28px 55px rgba(0,0,0,.45); background: #111; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.button { border: 1px solid transparent; border-radius: 12px; padding: 14px 18px; font-weight: 850; cursor: pointer; }
.button.primary { background: linear-gradient(135deg, var(--accent), #987aff); color: white; }
.button.secondary { background: var(--surface-2); border-color: var(--line); }
.text-button { padding: 8px 0; border: 0; background: transparent; color: #aaa0ff; cursor: pointer; text-align: left; font-weight: 750; }
.text-button.danger { color: var(--danger); width: 100%; text-align: center; margin-top: 9px; }
.security-card ul { margin: 13px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.75; }
code { color: #bbb2ff; }

.button.small { padding: 10px 14px; font-size: 13px; }
.error-text { color: var(--danger); }
.membership-panel { margin-bottom: 18px; }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.plan-card { display: grid; gap: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.plan-card b { font-size: 22px; }
.plan-card span { color: var(--muted); line-height: 1.5; }
.payment-grid { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
.payment-grid img { width: 220px; max-width: 100%; border-radius: 12px; background: #fff; }
.payment-grid p { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.payment-grid span, .payment-grid strong { display: block; }
.payment-grid span { color: var(--muted); font-size: 13px; }
.admin-shell { padding: 36px 0 80px; }
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.stat-card { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.stat-card span, .stat-card strong { display: block; }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { margin-top: 6px; font-size: 24px; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.admin-card { padding: 20px; margin-top: 18px; }
.admin-card h2 { margin-top: 0; }
.admin-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: 13px; }
th { color: #aaa0ff; }
.table-action { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); cursor: pointer; margin: 2px; }
.table-action.danger { color: var(--danger); }
.admin-message { margin: 10px 0; color: var(--muted); }

dialog { width: min(720px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 20px; padding: 0; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(5px); }
.dialog-card { padding: 24px; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.report-box { background: #0b1018; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.report-box strong { display: block; margin-bottom: 8px; }
.report-box ul { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.55; overflow-wrap: anywhere; }

footer { width: min(1240px, calc(100% - 32px)); margin: 0 auto; border-top: 1px solid var(--line); color: var(--muted); padding: 28px 0 44px; display: flex; justify-content: space-between; gap: 18px; font-size: 13px; }

body.light { --bg: #eef2f7; --surface: #fff; --surface-2: #f2f5f9; --line: #d4dae4; --text: #111722; --muted: #667286; --shadow: 0 24px 70px rgba(44,58,80,.16); color-scheme: light; }
body.light .topbar { background: rgba(238,242,247,.9); }
body.light input, body.light select, body.light .report-box { background: #f7f9fc; }

@media (max-width: 900px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .preview-column { position: static; }
  .canvas-wrap { min-height: 420px; }
  .privacy-pill { display: none; }
}
@media (max-width: 560px) {
  .page-shell { width: min(100% - 20px, 1240px); }
  .hero { padding: 50px 8px 38px; }
  .panel, .preview-panel { padding: 18px; border-radius: 16px; }
  .form-grid, .report-grid, .plan-grid, .payment-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .har-summary { grid-template-columns: 1fr; }
  .button-row { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: 1fr; }
}
