:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #16202c;
  --muted: #6b7785;
  --line: #d8dde3;
  --accent: #10508c;
  --accent-ink: #ffffff;
  --user: #e8eef5;
  --warn: #b4531a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; text-decoration: none; color: var(--ink); letter-spacing: .2px; }
.brand span { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.linkish { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: 14px; }

.flashes { max-width: 1180px; margin: 12px auto 0; padding: 0 20px; }
.flash {
  background: #fff6e6; border: 1px solid #f0d9ad; color: #6b4a12;
  padding: 8px 12px; border-radius: 6px; margin-bottom: 8px; font-size: 14px;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px; }
.muted { color: var(--muted); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 4px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 22px 0 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.empty { color: var(--muted); }

button.primary {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 7px;
  padding: 9px 16px; font-size: 14px; font-weight: 550; cursor: pointer;
}
button.primary:disabled { background: #a8b6c4; cursor: default; }
input[type=text], input[name=name], input[name=username], input[type=password], textarea {
  border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px;
  font: inherit; background: #fff; color: var(--ink); width: 100%;
}
input:focus, textarea:focus { outline: 2px solid #b9d3ea; border-color: var(--accent); }

/* ---------- login ---------- */
.login-wrap { display: flex; justify-content: center; padding: 70px 20px; }
.login { width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 20px; }
.login p { margin: -8px 0 0; font-size: 13px; }
.login label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }

/* ---------- dashboard ---------- */
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.inline { display: flex; gap: 8px; }
.inline input { width: 260px; }
.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.grid th { background: #eef1f4; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.grid tr:last-child td { border-bottom: 0; }
.grid a { color: var(--accent); text-decoration: none; font-weight: 550; }

/* ---------- progetto ---------- */
.project { display: grid; grid-template-columns: 310px 1fr; gap: 20px; max-width: 1400px; margin: 0 auto; padding: 20px; align-items: start; }
.side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; position: sticky; top: 16px; max-height: calc(100vh - 100px); overflow-y: auto; }
.back { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 10px; }

.upload { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.filebtn { position: relative; display: block; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.filebtn span {
  display: block; text-align: center; padding: 10px; border: 1.5px dashed var(--line);
  border-radius: 7px; color: var(--muted); font-size: 13px;
}
.upload small { min-height: 14px; font-size: 12px; }

.drawings, .outputs { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.drawings li { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.drawings img { width: 96px; height: 68px; object-fit: contain; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.drawings div { display: flex; flex-direction: column; min-width: 0; }
.drawings span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outputs li { font-size: 13px; display: flex; flex-direction: column; }
.outputs a { color: var(--accent); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; min-height: calc(100vh - 110px); }
.messages { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.intro { color: var(--muted); }
.intro h3 { margin-top: 0; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 15px; }

.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 16px; max-width: 78ch; white-space: pre-wrap; word-wrap: break-word;
}
.msg.user .bubble { background: var(--user); border-color: #cfdceb; }

/* l'attributo hidden deve vincere sulla display della classe */
.progress[hidden] { display: none; }
.progress {
  display: flex; align-items: flex-start; gap: 12px; background: #eef4fa;
  border: 1px solid #cddff0; border-radius: 10px; padding: 12px 14px; font-size: 13px; color: #21496e;
}
.progress ul { margin: 6px 0 0; padding-left: 16px; }
.progress li { color: #3d6488; }
.cost { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.spinner {
  width: 16px; height: 16px; border: 2px solid #b9d3ea; border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; flex: none; margin-top: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; color: var(--ink);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.composer { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { resize: vertical; }

@media (max-width: 900px) {
  .project { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
}
