* { box-sizing: border-box; }
body.page { margin:0; font-family: Arial, sans-serif; background:#f5f6f7; color:#111; }

.topbar{
  display:flex; justify-content:space-between; align-items:center; gap:10px;
  padding:12px 16px; background:#111827; color:#fff;
}
.topbar-left{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.link{ color:#a7f3d0; text-decoration:none; }

/* Stacked layout for all screens (as requested) */
.layout{
  display:grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "controls"
    "actions"
    "preview";
  gap:16px;
  padding:16px;
  align-items:start;
  max-width: 1100px;
  margin: 0 auto;
}
.controls{ grid-area: controls; }
.actions-card{ grid-area: actions; }
.preview{ grid-area: preview; }

.card{
  background:#fff; border:1px solid #e5e7eb; border-radius:12px;
  padding:16px;
}

h1,h2{ margin:0 0 12px 0; }
label{ display:block; font-size:12px; color:#374151; margin-bottom:6px; }

input{
  width:100%; padding:10px; border:1px solid #d1d5db; border-radius:10px;
}

/* Responsive items list (replaces table) */
.items{ margin-top:10px; }
.items-head{
  display:grid;
  grid-template-columns: 1.4fr 1fr 1fr 0.8fr 44px;
  gap:10px;
  padding:8px 6px;
  color:#374151;
  font-size:12px;
  border-bottom:1px solid #eee;
}
.items-body{ display:flex; flex-direction:column; gap:18px; padding-top:12px; }
.item-row{
  display:grid;
  grid-template-columns: 1.4fr 1fr 1fr 0.8fr 44px;
  gap:10px;
  align-items:end;
}
.field label{ margin:0 0 6px 0; }
/* Mobile: stack fields inside each item row */
@media (max-width: 700px){
  .items-head{ display:none; }
  .item-row{
    grid-template-columns: 1fr 1fr;
    gap:14px;
    padding:12px;
    border:1px solid #e5e7eb;
    border-radius:12px;
    background:#fff;
  }
  .item-row .delwrap{
    grid-column: 1 / -1;
  }
  }


.row{ display:grid; grid-template-columns: 1fr 1fr 1fr; gap:14px; }

.actions{ display:flex; gap:10px; flex-wrap:wrap; }
button{
  padding:10px 12px; border:0; border-radius:10px; cursor:pointer;
  background:#111827; color:#fff;
}
button:disabled{ opacity:0.5; cursor:not-allowed; }

.error{ background:#fee2e2; color:#991b1b; padding:10px; border-radius:10px; margin-bottom:10px; }

.stats{ margin-top:12px; font-size:13px; color:#111827; }
.notfit{ margin-top:10px; font-size:13px; color:#7c2d12; }
.hint{ margin-top:12px; font-size:12px; color:#6b7280; }

.canvas-wrap{
  width:100%;
  min-height: 520px;
  height: 70vh;
  border:1px dashed #d1d5db;
  border-radius:12px;
  background:#fafafa;
  overflow:auto;
  padding:10px;
}
.svg{ width:100%; height:100%; }

.legend{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:10px;
  font-size:13px;
}

.auth-card{
  max-width:420px;
  margin:10vh auto;
}

/* Mobile tweaks: make buttons nicer */
@media (max-width: 900px){
  .row{ grid-template-columns: 1fr; }
  .actions{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
  .actions button{ width:100%; }
  .canvas-wrap{ height: 60vh; }
  .legend{ font-size:12px; }
  .topbar-left{ max-width: 70vw; }
}

@media (max-width: 520px){
  .actions{ grid-template-columns: 1fr; }
}

/* Print */
@media print {
  .topbar, .controls, .actions-card { display:none !important; }
  body.page{ background:#fff; }
  .layout{ display:block; padding:0; max-width:none; margin:0; }
  .card{ border:0; border-radius:0; padding:0; }
  .canvas-wrap{ height:auto; border:0; min-height:auto; }
}

.delwrap .del-link{
  display:inline-block;
  width:100%;
  text-align:center;
  padding:10px 12px;
  border-radius:10px;
  color:#b91c1c;
  text-decoration:none;
  border:1px solid #fecaca;
  background:#fff;
  font-weight:600;
}
.delwrap .del-link:hover{ background:#fee2e2; }
