:root{
  --bg:#f5f7fb;
  --panel:#fff;
  --text:#11182c;
  --muted:#667085;
  --line:#dfe4ee;
  --line-strong:#cfd6e3;
  --primary:#4f52e8;
  --primary-soft:#eef0ff;
  --nav:#11192c;
  --nav-2:#16223a;
  --success:#18864b;
  --danger:#c33d49;
  --shadow:0 12px 30px rgba(16,24,40,.08),0 1px 2px rgba(16,24,40,.03);
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  margin:0;
  min-height:100vh;
  font-family:"Inter",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color:var(--text);
  background:radial-gradient(circle at 50% -10%,rgba(79,82,232,.06),transparent 34%),var(--bg);
}
button,input{font:inherit}
button{cursor:pointer}
.topbar{
  height:92px;
  background:linear-gradient(135deg,var(--nav),var(--nav-2));
  display:flex;
  align-items:center;
}
.topbar__inner{
  width:min(1180px,calc(100% - 44px));
  margin:auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.brand{display:flex;align-items:center;gap:15px;color:#fff;text-decoration:none;font-size:24px;font-weight:750}
.brand__icon{
  width:46px;height:46px;border-radius:14px;display:grid;place-items:center;
  background:linear-gradient(135deg,#5559ed,#6258e8);box-shadow:0 10px 22px rgba(79,82,232,.28)
}
.brand__icon svg{width:23px}
.icon-btn{
  width:46px;height:46px;border:0;border-radius:13px;color:#fff;
  background:rgba(255,255,255,.08);display:grid;place-items:center
}
.page-shell{width:min(1180px,calc(100% - 44px));margin:34px auto 28px}
.panel{
  background:rgba(255,255,255,.96);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
}
.setup-panel{padding:34px}
.setup-head{display:flex;align-items:center;justify-content:space-between;gap:22px}
.setup-title{display:flex;align-items:center;gap:22px}
.number-logo{
  width:70px;height:70px;border-radius:18px;display:grid;grid-template-columns:1fr 1fr;
  place-items:center;padding:13px;color:#fff;font-size:17px;font-weight:800;
  background:linear-gradient(135deg,#4f52e8,#6264eb)
}
.eyebrow{
  display:flex;align-items:center;gap:7px;margin-bottom:7px;
  color:var(--primary);font-size:12px;font-weight:800;text-transform:uppercase;letter-spacing:.08em
}
.eyebrow svg{width:14px;height:14px}
h1,h2,p{margin-top:0}
.setup-title h1{font-size:32px;line-height:1.05;margin-bottom:8px;letter-spacing:-.9px}
.setup-title p{margin:0;color:var(--muted);font-size:15px;max-width:630px;line-height:1.55}
.btn{
  min-height:46px;border:1px solid var(--line-strong);border-radius:11px;background:#fff;color:#596177;
  padding:0 17px;display:flex;align-items:center;gap:9px
}
.btn svg{width:17px}
.range-row{
  display:grid;grid-template-columns:180px 180px 1fr 220px;gap:18px;
  align-items:stretch;margin-top:30px
}
.field{border:1px solid var(--line);border-radius:12px;padding:16px;background:#fcfdff}
.field label{display:block;font-weight:650;font-size:14px;margin-bottom:10px}
.field input{
  width:100%;height:44px;border:1px solid var(--line-strong);border-radius:9px;padding:0 12px;
  color:var(--text);background:#fff;outline:none;font-size:18px
}
.field input:focus,.mini-input:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(79,82,232,.1)}
.field small{display:block;color:var(--muted);font-size:12px;margin-top:9px}
.a3-badge-card{
  border:1px solid var(--line);border-radius:12px;padding:14px 16px;background:#fcfdff;
  display:flex;align-items:center;gap:13px
}
.a3-icon{
  width:46px;height:46px;border-radius:12px;display:grid;place-items:center;
  color:var(--primary);background:var(--primary-soft)
}
.a3-icon svg{width:21px}
.a3-badge-card div{display:flex;flex-direction:column;gap:3px}
.a3-badge-card strong{font-size:15px}
.a3-badge-card span:not(.a3-icon):not(.status-pill){color:var(--muted);font-size:12px}
.status-pill{
  margin-left:auto;padding:6px 9px;border-radius:999px;background:#eaf7f0;color:var(--success);
  font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.05em
}
.generate-btn{
  border:0;border-radius:12px;color:#fff;font-weight:700;font-size:15px;
  background:linear-gradient(90deg,#5154e8,#4b4fdc);
  display:flex;align-items:center;justify-content:center;gap:10px
}
.generate-btn svg{width:19px}
.workspace{display:grid;grid-template-columns:330px 1fr;gap:24px;margin-top:24px;align-items:start}
.editor-panel{padding:24px;position:sticky;top:18px}
.panel-heading{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:24px}
.panel-heading h2,.preview-head h2{margin:0;font-size:20px;letter-spacing:-.35px}
.panel-heading>svg{width:21px;color:#768096}
.control-group{padding:16px 0;border-top:1px solid #edf0f5}
.control-title{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:12px}
.control-title label{font-size:13px;font-weight:700}
.control-title output{font-size:12px;color:var(--primary);font-weight:800;background:var(--primary-soft);padding:5px 8px;border-radius:7px}
.control-line{display:grid;grid-template-columns:1fr 68px;gap:10px;align-items:center}
input[type="range"]{width:100%;accent-color:var(--primary)}
.mini-input{
  width:68px;height:36px;border:1px solid var(--line-strong);border-radius:8px;padding:0 8px;
  background:#fff;color:var(--text);outline:none;text-align:center;font-size:13px
}
.switch-row{
  display:flex;align-items:center;justify-content:space-between;gap:14px;
  padding:15px 0;border-top:1px solid #edf0f5;cursor:pointer
}
.switch-row>span:first-child{display:flex;flex-direction:column;gap:3px}
.switch-row strong{font-size:13px}
.switch-row small{font-size:11px;color:var(--muted);line-height:1.35}
.switch-row input{position:absolute;opacity:0;pointer-events:none}
.switch{
  width:42px;height:24px;border-radius:999px;background:#cfd5df;position:relative;flex:0 0 auto;transition:.2s
}
.switch:after{
  content:"";position:absolute;width:18px;height:18px;left:3px;top:3px;border-radius:50%;background:#fff;
  box-shadow:0 1px 3px rgba(0,0,0,.18);transition:.2s
}
.switch-row input:checked+.switch{background:var(--primary)}
.switch-row input:checked+.switch:after{transform:translateX(18px)}
.secondary-btn{
  width:100%;height:46px;border:1px solid #cfd5e5;border-radius:10px;background:#fff;color:#444be0;
  display:flex;align-items:center;justify-content:center;gap:9px;font-weight:700;margin-top:8px
}
.secondary-btn svg{width:17px}
.metrics-card{
  display:grid;grid-template-columns:1fr 1fr;margin-top:18px;border:1px solid var(--line);
  border-radius:12px;overflow:hidden;background:#fbfcff
}
.metrics-card div{padding:13px;border-right:1px solid var(--line);border-bottom:1px solid var(--line)}
.metrics-card div:nth-child(2n){border-right:0}
.metrics-card div:nth-last-child(-n+2){border-bottom:0}
.metrics-card span{display:block;color:var(--muted);font-size:10px;text-transform:uppercase;letter-spacing:.05em;margin-bottom:4px}
.metrics-card strong{font-size:17px}
.fit-message{
  margin-top:15px;padding:12px;border-radius:10px;display:flex;gap:9px;align-items:flex-start;font-size:12px;line-height:1.4
}
.fit-message svg{width:17px;flex:0 0 auto}
.fit-message.is-ok{background:#edf8f2;color:#187c49}
.fit-message.is-warning{background:#fff0f1;color:#a92f3d}
.preview-panel{padding:24px;min-width:0}
.preview-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:18px}
.preview-meta{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.preview-meta span{
  padding:7px 10px;border-radius:8px;background:#f1f3f8;color:#596177;font-size:11px;font-weight:650
}
.sheet-viewport{
  min-height:700px;border-radius:14px;border:1px solid #dfe4ee;
  background:
    linear-gradient(45deg,#e8ebf1 25%,transparent 25%) 0 0/18px 18px,
    linear-gradient(45deg,transparent 75%,#e8ebf1 75%) 0 0/18px 18px,
    linear-gradient(45deg,transparent 75%,#e8ebf1 75%) 9px -9px/18px 18px,
    linear-gradient(45deg,#e8ebf1 25%,#f2f4f8 25%) 9px -9px/18px 18px;
  display:flex;align-items:center;justify-content:center;padding:28px;overflow:auto
}
.a3-sheet{
  position:relative;width:min(100%,495px);aspect-ratio:297/420;background:#fff;
  box-shadow:0 14px 36px rgba(16,24,40,.22),0 0 0 1px rgba(16,24,40,.12);
  flex:0 0 auto
}
.print-safe-area{
  position:absolute;
  border:1px dashed rgba(79,82,232,.35);
  overflow:hidden;
  display:flex;align-items:flex-start;justify-content:flex-start
}
.number-grid{
  display:grid;
  width:max-content;height:max-content;
  border-left:1px solid #cfd6e3;border-top:1px solid #cfd6e3;
  transform-origin:top left
}
.number-cell{
  display:flex;align-items:center;justify-content:center;
  border-right:1px solid #cfd6e3;border-bottom:1px solid #cfd6e3;
  color:#0f172a;background:#fff;font-weight:750;line-height:1;
  overflow:hidden
}
.sheet-legend{display:flex;gap:18px;flex-wrap:wrap;margin-top:14px;color:var(--muted);font-size:11px}
.sheet-legend span{display:flex;align-items:center;gap:6px}
.legend-dot{width:9px;height:9px;border-radius:2px;display:inline-block}
.legend-paper{background:#fff;border:1px solid #b8c0cf}
.legend-safe{background:#eef0ff;border:1px dashed #7377eb}
.legend-grid{background:#d7dce6}
.export-bar{
  margin-top:24px;padding:22px;border:1px solid var(--line);border-radius:16px;
  background:linear-gradient(180deg,#f7f8ff,#f8f9fc);display:grid;grid-template-columns:repeat(3,1fr);gap:18px
}
.export-btn{
  height:54px;border:1px solid var(--line-strong);border-radius:10px;background:#fff;color:#4348e6;
  display:flex;align-items:center;justify-content:center;gap:10px;font-weight:650
}
.export-btn svg{width:18px}
footer{
  min-height:82px;border-top:1px solid #e7eaf0;display:flex;align-items:center;justify-content:center;
  gap:9px;color:#71798b;font-size:12px;background:rgba(255,255,255,.5)
}
footer svg{width:17px;color:var(--primary)}
.toast{
  position:fixed;left:50%;bottom:22px;transform:translate(-50%,20px);opacity:0;pointer-events:none;
  background:#111827;color:#fff;padding:11px 15px;border-radius:10px;font-size:13px;z-index:50;
  box-shadow:0 12px 28px rgba(0,0,0,.22);transition:.22s
}
.toast.is-visible{opacity:1;transform:translate(-50%,0)}
body.dark{
  --bg:#0d1321;--panel:#121a2b;--text:#f7f9fc;--muted:#aab3c5;--line:#2a3549;--line-strong:#354158;
  --shadow:0 12px 30px rgba(0,0,0,.24)
}
body.dark .panel,body.dark .field,body.dark .a3-badge-card,body.dark .mini-input,body.dark .btn,
body.dark .secondary-btn,body.dark .export-btn{background:#121a2b;color:var(--text)}
body.dark .field input{background:#0e1727;color:#fff;border-color:#354158}
body.dark .metrics-card{background:#11192a}
body.dark .export-bar{background:#11192a}
body.dark footer{background:#0d1422;border-color:#212b3d}
@media(max-width:1000px){
  .range-row{grid-template-columns:1fr 1fr}
  .a3-badge-card,.generate-btn{min-height:76px}
  .workspace{grid-template-columns:1fr}
  .editor-panel{position:static}
}
@media(max-width:650px){
  .topbar{height:78px}
  .topbar__inner,.page-shell{width:calc(100% - 26px)}
  .brand{font-size:18px}
  .setup-panel{padding:22px}
  .setup-head{align-items:flex-start}
  .setup-title{gap:14px}
  .number-logo{width:55px;height:55px;font-size:14px}
  .setup-title h1{font-size:24px}
  .setup-title p{font-size:13px}
  .btn--ghost{width:44px;padding:0;font-size:0}
  .range-row{grid-template-columns:1fr}
  .workspace{gap:16px}
  .editor-panel,.preview-panel{padding:18px}
  .sheet-viewport{min-height:520px;padding:16px}
  .export-bar{grid-template-columns:1fr}
}
