
:root{
  --bg:#0b1220;
  --panel:#0f1a2e;
  --card:#121f36;
  --text:#e8eefc;
  --muted:#a7b3cf;
  --border:rgba(255,255,255,.10);
  --accent:#7aa2ff;
  --danger:#ff5c7a;
  --warn:#ffcc66;
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: radial-gradient(1200px 700px at 10% 0%, #12244a 0%, var(--bg) 55%);
  color:var(--text);
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:14px 18px;
  border-bottom:1px solid var(--border);
  background: rgba(7, 12, 24, .65);
  backdrop-filter: blur(10px);
  position: sticky;
  top:0;
  z-index:10;
}

.topbar-right{
  display:flex;
  align-items:center;
  gap:14px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.brand{display:flex;align-items:center;gap:12px}
.logo{width:36px;height:36px;border-radius:10px;background:rgba(122,162,255,.12);display:grid;place-items:center;border:1px solid var(--border)}
.logo-dot{width:12px;height:12px;border-radius:50%;background:var(--accent);display:inline-block;box-shadow:0 0 22px rgba(122,162,255,.6)}
.brand-title{font-weight:700;letter-spacing:.3px}
.brand-subtitle{font-size:12px;color:var(--muted)}

.nav{display:flex;flex-wrap:wrap;gap:10px}
.nav a{
  color:var(--muted);
  text-decoration:none;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid transparent;
}
.nav a:hover{color:var(--text);border-color:var(--border);background:rgba(255,255,255,.04)}
.nav a.active{color:var(--text);border-color:rgba(122,162,255,.35);background:rgba(122,162,255,.10)}

.session-area{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.session-chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.05);
  color:var(--muted);
  font-size:12px;
  font-weight:600;
}

.container{max-width:1100px;margin:18px auto;padding:0 16px 30px}
.grid{display:grid;gap:14px}
.grid-2{grid-template-columns: 1fr 1fr}
@media (max-width: 920px){.grid-2{grid-template-columns:1fr}}

.card{
  background: rgba(18, 31, 54, .75);
  border:1px solid var(--border);
  border-radius:16px;
  padding:14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.card h2, .card h3{margin:0 0 10px 0}
.muted{color:var(--muted)}

.table{
  width:100%;
  border-collapse: collapse;
  overflow:hidden;
  border-radius:14px;
  border:1px solid var(--border);
}
.table th,.table td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  vertical-align:top;
}
.table th{color:var(--muted);font-weight:600;text-align:left;background:rgba(255,255,255,.03)}
.table tr:hover td{background:rgba(255,255,255,.03)}
.table tr:last-child td{border-bottom:none}

.row{display:flex;gap:10px;flex-wrap:wrap;align-items:flex-end}
.field{display:flex;flex-direction:column;gap:6px;min-width:180px;flex:1}
.field label{font-size:12px;color:var(--muted)}
.field input,.field select, .field textarea{
  background: rgba(255,255,255,.04);
  color: var(--text);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 10px;
  outline:none;
}
.field textarea{min-height:80px;resize:vertical}

.actions{display:flex;gap:10px;flex-wrap:wrap}
.btn{
  appearance:none;
  border:1px solid var(--border);
  background: rgba(255,255,255,.05);
  color: var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-weight:600;
}
.btn:hover{background: rgba(255,255,255,.08)}
.btn-primary{border-color:rgba(122,162,255,.45);background:rgba(122,162,255,.18)}
.btn-danger{border-color:rgba(255,92,122,.55);background:rgba(255,92,122,.15)}
.btn-ghost{background:transparent}

.alert{border-radius:14px;padding:10px 12px;border:1px solid var(--border);margin-bottom:12px}
.alert-error{border-color:rgba(255,92,122,.55);background:rgba(255,92,122,.12)}
.alert-warning{border-color:rgba(255,204,102,.55);background:rgba(255,204,102,.10)}
.alert-info{border-color:rgba(122,162,255,.55);background:rgba(122,162,255,.10)}

.footer{
  max-width:1100px;
  margin:0 auto;
  padding:18px 16px 30px;
  color:var(--muted);
  font-size:12px;
}

.portal-hero{
  padding:28px;
  background:
    radial-gradient(900px 240px at 0% 0%, rgba(122,162,255,.18) 0%, rgba(122,162,255,0) 60%),
    rgba(18, 31, 54, .78);
}

.portal-kicker,
.portal-card-kicker{
  color:var(--warn);
  font-size:12px;
  font-weight:700;
  letter-spacing:.14em;
  text-transform:uppercase;
}

.portal-title{
  margin:10px 0 8px;
  font-size:2.25rem;
}

.portal-copy{
  max-width:720px;
  color:var(--muted);
  font-size:1.02rem;
  line-height:1.6;
}

.portal-grid{
  margin-top:14px;
}

.portal-card{
  min-height:220px;
  display:flex;
  flex-direction:column;
  gap:12px;
  justify-content:space-between;
}

.flight-form{display:flex;flex-direction:column;gap:18px}
.flight-block{
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
  background:rgba(255,255,255,.03);
}
.flight-block-title{
  margin:0 0 14px 0;
  text-align:center;
  font-size:1.25rem;
  letter-spacing:.4px;
}
.flight-form .row{gap:14px}
.flight-form .field{min-width:220px}

.flight-group{
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(255,255,255,.03);
  overflow:hidden;
}

.flight-group-summary{
  list-style:none;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:14px 16px;
  cursor:pointer;
  user-select:none;
  background:rgba(255,255,255,.04);
}

.flight-group-summary::-webkit-details-marker{
  display:none;
}

.flight-group-summary:hover{
  background:rgba(255,255,255,.07);
}

.flight-group-title{
  font-size:1.05rem;
  font-weight:700;
}

.flight-group-toggle{
  border:1px solid rgba(122,162,255,.35);
  border-radius:999px;
  background:rgba(122,162,255,.10);
  color:var(--text);
  padding:8px 12px;
  font-size:12px;
  font-weight:700;
  min-width:72px;
  text-align:center;
}

.flight-group[open] .flight-group-toggle{
  background:rgba(122,162,255,.18);
  color:var(--text);
  font-size:0;
}

.flight-group[open] .flight-group-summary{
  border-bottom:1px solid var(--border);
}

.flight-group[open] .flight-group-toggle::before{
  content:"Close";
  font-size:12px;
}

.flight-group-body{
  padding:14px;
}

@media (max-width: 720px){
  .flight-group-summary{
    align-items:flex-start;
    flex-direction:column;
  }
}

.builder-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.builder-item{
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:12px;
  border:1px solid var(--border);
  border-radius:14px;
  text-decoration:none;
  color:var(--text);
  background:rgba(255,255,255,.03);
}

.builder-item:hover{
  background:rgba(255,255,255,.06);
}

.builder-item-active{
  border-color:rgba(122,162,255,.45);
  background:rgba(122,162,255,.12);
}

.spec-list{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
  gap:12px;
}

.spec-list div,
.stack div{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.stack{
  display:grid;
  gap:10px;
}

.plain-list{
  margin:0;
  padding-left:18px;
  display:grid;
  gap:8px;
}

code{
  font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:12px;
  color:#d7e5ff;
  background:rgba(255,255,255,.06);
  border:1px solid var(--border);
  border-radius:10px;
  padding:4px 8px;
  width:fit-content;
  max-width:100%;
  overflow-wrap:anywhere;
}

.hero-card{
  background:
    radial-gradient(800px 300px at 0% 0%, rgba(122,162,255,.18) 0%, rgba(122,162,255,0) 60%),
    rgba(18, 31, 54, .82);
}

.hero-kicker{
  font-size:12px;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:var(--accent);
  margin-bottom:8px;
}

.hero-copy{
  max-width:840px;
}

.cnc-workspace{
  display:grid;
  gap:16px;
}

.cnc-topbar{
  display:grid;
  gap:16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.03) 0%, rgba(255,255,255,.01) 100%),
    radial-gradient(900px 320px at 0% 0%, rgba(122,162,255,.16) 0%, rgba(122,162,255,0) 60%),
    rgba(18, 31, 54, .82);
}

.workspace-title{
  margin:0;
}

.workspace-copy{
  max-width:920px;
  margin:8px 0 0 0;
}

.workspace-tabs{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.workspace-tab{
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  color:var(--muted);
  background:rgba(255,255,255,.03);
  font-size:12px;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.workspace-tab-active{
  color:var(--text);
  border-color:rgba(122,162,255,.45);
  background:rgba(122,162,255,.16);
}

.profile-rack{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(150px, 1fr));
  gap:10px;
}

.profile-pill{
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:12px;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.03);
}

.cnc-layout{
  display:grid;
  grid-template-columns:minmax(280px, 340px) minmax(0, 1fr) minmax(260px, 320px);
  gap:16px;
  align-items:start;
}

@media (max-width: 1180px){
  .cnc-layout{
    grid-template-columns:1fr;
  }
}

.cnc-sidebar,
.cnc-main,
.cnc-inspector{
  display:grid;
  gap:16px;
}

.cnc-form{
  display:grid;
  gap:16px;
}

.panel-card{
  padding:16px;
}

.panel-card-large{
  min-height:520px;
}

.panel-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}

.panel-header h3{
  margin:0;
}

.panel-badge{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(122,162,255,.3);
  background:rgba(122,162,255,.1);
  color:var(--accent);
  font-size:11px;
  font-weight:700;
  letter-spacing:.08em;
  text-transform:uppercase;
  white-space:nowrap;
}

.field-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(120px, 1fr));
  gap:12px;
}

.term-panel{
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
  background:rgba(255,255,255,.03);
}

.term-panel h4{
  margin:0 0 12px 0;
}

.term-note-list{
  display:grid;
  gap:10px;
  margin-top:14px;
}

.term-note-list div{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.stats-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(140px, 1fr));
  gap:12px;
}

.stat-box{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-height:86px;
  padding:12px;
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(255,255,255,.03);
}

.stat-box strong{
  font-size:1.1rem;
}

.bounds-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
  gap:12px;
  margin-top:14px;
}

.bounds-grid div{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.code-textarea{
  min-height:280px !important;
  font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:12px;
  line-height:1.45;
}

.code-input{
  min-height:220px !important;
}

.code-output{
  min-height:420px !important;
}

.empty-state{
  min-height:320px;
  display:grid;
  place-content:center;
  gap:10px;
  text-align:center;
  border:1px dashed var(--border);
  border-radius:16px;
  background:rgba(255,255,255,.02);
  padding:20px;
}

.empty-state-short{
  min-height:160px;
}

.preview-shell{
  border:1px solid var(--border);
  border-radius:20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.02) 0%, rgba(255,255,255,.01) 100%),
    rgba(5, 10, 18, .55);
  padding:12px;
  margin-bottom:14px;
}

.toolpath-preview{
  display:block;
  width:100%;
  height:auto;
  border-radius:16px;
}

.preview-surface{
  fill:rgba(8,14,24,.96);
  stroke:rgba(255,255,255,.06);
  stroke-width:2;
}

.preview-rapid{
  fill:none;
  stroke:rgba(122,162,255,.55);
  stroke-width:2.5;
  stroke-dasharray:7 8;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.preview-cut{
  fill:none;
  stroke:#8ef0a8;
  stroke-width:3.5;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.runtime-controls{
  display:grid;
  gap:10px;
  margin-top:14px;
}

.queue-panel{
  margin-top:14px;
  display:grid;
  gap:8px;
}

.jog-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:10px;
}

.queue-preview{
  margin:0;
  padding:12px;
  min-height:110px;
  max-height:220px;
  overflow:auto;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.03);
  color:#d7e5ff;
  font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:12px;
  line-height:1.45;
}
