:root {
  --blue:#2563eb; --blue-dark:#1d4ed8; --ink:#0f172a; --muted:#64748b;
  --line:#e2e8f0; --soft:#f8fafc; --shadow:0 12px 34px rgba(15,23,42,.08);
}
* { box-sizing:border-box; }
html,body { max-width:100%; overflow-x:hidden; }
body { margin:0; font-family:Inter,"Segoe UI",system-ui,-apple-system,sans-serif; color:var(--ink); background:#fff; }
button,input,select,textarea { font:inherit; }
button { cursor:pointer; }
.header { height:68px; display:flex; align-items:center; justify-content:space-between; padding:0 36px; border-bottom:1px solid var(--line); background:rgba(255,255,255,.96); position:sticky; top:0; z-index:20; }
.brand { display:flex; align-items:center; gap:10px; font-weight:800; font-size:21px; }
.brand-mark { width:34px; height:34px; border:2px solid var(--blue); border-radius:9px; display:grid; place-items:center; color:var(--blue); }
.brand-mark svg { width:21px; }
.guide-btn { border:0; background:transparent; color:#475569; display:flex; align-items:center; gap:8px; font-weight:700; }
.guide-btn svg { width:18px; }
.workspace { width:100%; max-width:1280px; margin:0 auto; display:grid; grid-template-columns:minmax(0,1.38fr) minmax(340px,.82fr); min-height:calc(100vh - 68px); }
.editor { min-width:0; padding:32px 38px 48px 36px; border-right:1px solid var(--line); }
.preview-col { min-width:0; background:var(--soft); padding:32px 30px; }
.preview-sticky { position:sticky; top:100px; }
.tabs { display:flex; gap:28px; border-bottom:1px solid var(--line); height:43px; }
.tab { border:0; background:transparent; color:#64748b; font-weight:750; padding:0 2px 13px; position:relative; }
.tab.active { color:var(--blue); }
.tab.active:after { content:""; position:absolute; left:0; right:0; bottom:-1px; height:3px; background:var(--blue); border-radius:3px 3px 0 0; }
.tab-panel { display:none; padding-top:25px; }
.tab-panel.active { display:block; }
.section-title { margin:0 0 18px; font-size:17px; }
.type-grid { display:grid; grid-template-columns:repeat(6,minmax(88px,1fr)); gap:9px; margin-bottom:26px; }
.type-card { min-height:78px; border:1px solid var(--line); border-radius:10px; background:#fff; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:7px; color:#475569; font-size:13px; font-weight:700; }
.type-card svg { width:22px; height:22px; }
.type-card.active { border:2px solid var(--blue); color:var(--blue); background:#eff6ff; }
.field { margin-bottom:17px; }
.field label { display:block; margin-bottom:8px; font-size:13px; font-weight:750; }
.field input,.field textarea,.field select { width:100%; border:1px solid #cbd5e1; border-radius:9px; background:#fff; height:46px; padding:0 13px; color:var(--ink); outline:none; }
.field textarea { height:90px; resize:vertical; padding:12px 13px; }
.field input:focus,.field textarea:focus,.field select:focus { border-color:var(--blue); box-shadow:0 0 0 3px rgba(37,99,235,.1); }
.field-error { color:#dc2626; font-size:12px; margin-top:6px; min-height:14px; }
.two-col { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.control-card { border:1px solid var(--line); border-radius:12px; padding:18px; margin-bottom:14px; }
.control-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; font-weight:800; }
.subtle { color:var(--muted); font-size:12px; }
.patterns { display:grid; grid-template-columns:repeat(5,1fr); gap:8px; }
.pattern { height:58px; border:1px solid var(--line); border-radius:8px; background:white; display:grid; place-items:center; }
.pattern.active { border:2px solid var(--blue); background:#eff6ff; }
.pattern-icon { width:28px; height:28px; background:var(--ink); border-radius:3px; mask:radial-gradient(circle at 3px 3px,#000 2px,transparent 0) 0 0/8px 8px; }
.pattern:nth-child(2) .pattern-icon { border-radius:7px; mask:none; }
.pattern:nth-child(3) .pattern-icon { mask:radial-gradient(circle,#000 35%,transparent 38%) 0 0/7px 7px; }
.pattern:nth-child(4) .pattern-icon { border-radius:4px 10px 4px 10px; mask:none; }
.pattern:nth-child(5) .pattern-icon { border-radius:50%; mask:radial-gradient(circle,#000 35%,transparent 38%) 0 0/8px 8px; }
.color-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.color-control { display:flex; align-items:center; gap:8px; border:1px solid var(--line); border-radius:8px; height:42px; padding:6px; }
.color-control input[type=color] { width:32px; height:30px; border:0; padding:0; background:transparent; }
.color-control input[type=text] { border:0; height:auto; padding:0; text-transform:uppercase; }
.switch-row { display:flex; align-items:center; justify-content:space-between; }
.switch { width:42px; height:24px; border-radius:20px; border:0; background:#cbd5e1; padding:3px; transition:.2s; }
.switch span { display:block; width:18px; height:18px; border-radius:50%; background:#fff; box-shadow:0 1px 3px #94a3b8; transition:.2s; }
.switch.on { background:var(--blue); }
.switch.on span { transform:translateX(18px); }
.preview-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; }
.preview-head h2 { font-size:14px; margin:0; letter-spacing:.08em; }
.preview-card { background:#fff; border:1px solid var(--line); border-radius:14px; min-height:390px; display:grid; place-items:center; padding:32px; box-shadow:var(--shadow); }
.qr-canvas { width:min(310px,100%); aspect-ratio:1; display:grid; place-items:center; }
.qr-canvas canvas,.qr-canvas svg { max-width:100%; height:auto!important; }
.verify { display:flex; align-items:center; justify-content:center; gap:7px; height:32px; color:#16a34a; font-size:13px; font-weight:700; }
.verify.error { color:#dc2626; }
.verify svg { width:16px; }
.export-card { margin-top:14px; }
.export-row { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.download-btn { width:100%; max-width:100%; height:50px; overflow:hidden; border:0; border-radius:9px; background:var(--blue); color:#fff; font-weight:800; display:flex; align-items:center; justify-content:center; gap:8px; margin-top:12px; white-space:nowrap; }
.download-btn svg { width:18px; height:18px; flex:0 0 18px; }
.download-btn:hover { background:var(--blue-dark); }
.download-btn:disabled { background:#94a3b8; cursor:not-allowed; }
.header-actions,.account-actions { display:flex; align-items:center; gap:12px; }
.auth-btn,.save-btn { height:40px; border:1px solid var(--line); border-radius:8px; background:white; color:var(--ink); padding:0 14px; font-weight:750; }
.register-btn { border-color:var(--blue); color:var(--blue); background:#eff6ff; }
.save-btn { width:100%; margin-top:8px; }
.dynamic-row { margin-top:12px; font-size:13px; color:#475569; }
.dynamic-row input { accent-color:var(--blue); }
.modal-backdrop { position:fixed; inset:0; z-index:100; background:rgba(15,23,42,.45); display:grid; place-items:center; padding:20px; }
.auth-modal { width:min(420px,100%); background:white; border-radius:14px; padding:22px; position:relative; box-shadow:var(--shadow); }
.modal-close { position:absolute; right:14px; top:10px; border:0; background:transparent; font-size:26px; color:var(--muted); }
.auth-tabs { display:flex; border-bottom:1px solid var(--line); margin-bottom:18px; }
.auth-tab { border:0; background:transparent; height:42px; padding:0 14px; font-weight:750; color:var(--muted); }
.auth-tab.active { color:var(--blue); border-bottom:2px solid var(--blue); }
.dashboard-brand { text-decoration:none; color:var(--ink); }
.dashboard-wrap { max-width:1280px; margin:0 auto; display:grid; grid-template-columns:220px minmax(0,1fr); min-height:calc(100vh - 68px); }
.dashboard-side { border-right:1px solid var(--line); padding:32px 24px; display:flex; flex-direction:column; gap:8px; }
.role-badge,.dynamic-badge { display:inline-block; width:max-content; border-radius:20px; background:#dbeafe; color:#1d4ed8; padding:4px 8px; font-size:11px; }
.dashboard-main { min-width:0; padding:32px; }
.dashboard-main h1 { margin:0 0 20px; font-size:24px; }
.stat-grid { display:grid; grid-template-columns:repeat(2,minmax(0,180px)); gap:12px; margin-bottom:20px; }
.stat-card { border:1px solid var(--line); border-radius:12px; padding:16px; display:flex; flex-direction:column; gap:6px; }
.stat-card span { color:var(--muted); font-size:12px; }
.stat-card strong { font-size:28px; }
.qr-table-wrap { width:100%; overflow-x:auto; border:1px solid var(--line); border-radius:12px; }
.qr-table { width:100%; border-collapse:collapse; min-width:760px; }
.qr-table th,.qr-table td { text-align:left; padding:12px; border-bottom:1px solid var(--line); font-size:13px; }
.qr-table th { background:#f8fafc; color:var(--muted); }
.table-input { width:220px; height:36px; border:1px solid var(--line); border-radius:7px; padding:0 8px; }
.row-actions { display:flex; gap:6px; }
.row-btn { border:1px solid var(--line); border-radius:7px; background:white; padding:7px 9px; font-size:12px; }
.row-btn.danger { color:#dc2626; }
.template-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
.template-card { border:1px solid var(--line); border-radius:11px; padding:12px; background:white; text-align:left; }
.template-card.active { border:2px solid var(--blue); }
.template-preview { height:92px; border-radius:7px; display:grid; place-items:center; background:#f8fafc; margin-bottom:9px; }
.mini-qr { width:50px; height:50px; border:5px solid #0f172a; border-radius:5px; background:linear-gradient(90deg,#0f172a 40%,transparent 40%) 0 0/10px 10px; }
.template-card strong { font-size:13px; }
.template-card span { display:block; color:var(--muted); font-size:11px; margin-top:3px; }
.reset-btn { border:0; background:transparent; color:var(--muted); display:flex; gap:7px; align-items:center; padding:8px 0; font-size:13px; }
.reset-btn svg { width:15px; }
.hidden { display:none!important; }
.file-label { display:flex; align-items:center; justify-content:center; height:43px; border:1px dashed #94a3b8; border-radius:8px; color:#475569; font-size:13px; cursor:pointer; }
.file-label input { display:none; }
.logo-card { min-width:0; overflow:hidden; border-color:#dbeafe; background:linear-gradient(145deg,#fff 55%,#f8fbff); }
.logo-card .control-head { gap:10px; }
.logo-limit { flex:0 0 auto; border-radius:20px; padding:5px 8px; background:#eff6ff; color:#2563eb; font-size:10px; letter-spacing:.04em; }
.logo-hint { margin:0 0 14px; color:var(--muted); font-size:12px; line-height:1.55; }
.logo-upload { position:relative; display:flex; align-items:center; gap:12px; min-width:0; min-height:78px; padding:12px; border:1.5px dashed #93b4f8; border-radius:10px; background:#f8fbff; cursor:pointer; transition:border-color .18s,background .18s,transform .18s; }
.logo-upload:hover { border-color:var(--blue); background:#eff6ff; }
.logo-upload:focus-within { outline:3px solid rgba(37,99,235,.16); outline-offset:2px; }
.logo-upload-icon { display:grid; place-items:center; width:42px; height:42px; flex:0 0 42px; border-radius:10px; color:var(--blue); background:#dbeafe; }
.logo-upload-icon svg { width:22px; height:22px; }
.logo-upload-copy { display:flex; flex:1; flex-direction:column; gap:4px; min-width:0; }
.logo-upload-copy strong { color:#1e293b; font-size:13px; }
.logo-upload-copy small { color:var(--muted); font-size:11px; line-height:1.4; }
.logo-browse { flex:0 0 auto; border:1px solid #bfdbfe; border-radius:7px; padding:7px 9px; background:#fff; color:#1d4ed8; font-size:11px; font-weight:750; }
.logo-upload input { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }
.logo-selected { display:flex; align-items:center; gap:10px; width:100%; min-width:0; margin-top:10px; padding:9px; overflow:hidden; border:1px solid var(--line); border-radius:9px; background:#fff; }
.logo-selected img { display:block; width:48px!important; height:48px!important; max-width:48px; max-height:48px; flex:0 0 48px; object-fit:contain; overflow:hidden; background:#fff; border:1px solid var(--line); border-radius:7px; }
.logo-file-info { display:flex; flex:1; flex-direction:column; gap:3px; min-width:0; }
.logo-file-info strong { font-size:12px; }
.logo-file-info small { display:block; overflow:hidden; color:var(--muted); font-size:11px; text-overflow:ellipsis; white-space:nowrap; }
.logo-selected button { display:grid; place-items:center; width:30px; height:30px; flex:0 0 30px; border:0; border-radius:7px; background:#fef2f2; color:#b91c1c; font-size:20px; }
.logo-selected button:hover { background:#fee2e2; }
.logo-size-heading { display:flex; align-items:center; justify-content:space-between; margin:15px 0 4px; }
.logo-size-heading label { margin:0; font-size:12px; font-weight:750; }
.logo-size-heading output { color:var(--blue); font-size:12px; font-weight:800; }
.logo-card .range-row { grid-template-columns:minmax(0,1fr) auto; gap:10px; }
.logo-card .range-row input[type=range] { width:100%; min-width:0; }
.logo-range-note { color:var(--muted); font-size:10px; white-space:nowrap; }
.range-row { display:grid; grid-template-columns:1fr 54px; gap:10px; align-items:center; }
.range-row input[type=range] { accent-color:var(--blue); }
.range-row output { text-align:right; font-size:12px; color:var(--muted); }
@media (max-width:900px) {
  .header { height:60px; padding:0 18px; }
  .workspace { display:flex; flex-direction:column; }
  .editor { border-right:0; padding:20px 18px 30px; order:2; }
  .preview-col { padding:18px; order:1; }
  .preview-sticky { position:static; }
  .preview-card { min-height:280px; padding:20px; }
  .qr-canvas { width:min(230px,70vw); }
  .type-grid { grid-template-columns:repeat(3,1fr); }
  .type-card { min-height:72px; }
  .patterns { grid-template-columns:repeat(3,1fr); }
  .template-grid { grid-template-columns:repeat(2,1fr); }
  .dashboard-wrap { display:flex; flex-direction:column; }
  .dashboard-side { border-right:0; border-bottom:1px solid var(--line); padding:20px 18px; }
  .dashboard-main { padding:20px 18px; }
}
@media (max-width:520px) {
  .guide-btn span { display:none; }
  .editor { padding-inline:14px; }
  .preview-col { padding:12px; }
  .two-col,.color-row { grid-template-columns:1fr; }
  .tabs { gap:18px; overflow:auto; }
  .tab { white-space:nowrap; }
  .preview-card { min-height:250px; }
}
