:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #17202a;
  --muted: #5f6b7a;
  --open: #ffd6d6;
  --submitted: #fff2bf;
  --completed: #d7f8d7;
  --border: #dce3eb;
  --danger: #b31212;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(145deg, #f6f7fb 0%, #eef6ff 100%);
  color: var(--text);
}

.container { max-width: 1100px; margin: 2rem auto; padding: 0 1rem; }
.auth { max-width: 480px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
}

.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: flex-start; }
.form-grid { display: grid; gap: .75rem; }
.form-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.actions { display: flex; align-items: end; }
label { display: grid; gap: .3rem; font-size: .95rem; }
input, textarea, select, button {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .65rem;
}
button {
  background: #123e72;
  color: #fff;
  border-color: #123e72;
  cursor: pointer;
}
.submit-row {
  display: flex;
  align-items: center;
  gap: .55rem;
}
.submit-field.is-saved {
  background: #2b8a3e;
  border-color: #2b8a3e;
}
.submit-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: #2b8a3e;
  color: #fff;
  font-weight: 700;
  line-height: 1;
}
.submit-check[hidden] { display: none; }
.status-block {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin: .6rem 0;
}
.status-buttons { display: flex; gap: .4rem; flex-wrap: wrap; }
.status-btn { font-weight: 600; }
.status-btn-open { background: #fff; color: #da1e28; border-color: #da1e28; }
.status-btn-open.is-active { background: #da1e28; color: #fff; }
.status-btn-submitted { background: #fff; color: #8a6d00; border-color: #f0b429; }
.status-btn-submitted.is-active { background: #f0b429; color: #17202a; }
.status-btn-completed { background: #fff; color: #2b8a3e; border-color: #2b8a3e; }
.status-btn-completed.is-active { background: #2b8a3e; color: #fff; }
.legend-completed { color: #2b8a3e; font-weight: 600; }
button.danger { background: var(--danger); border-color: var(--danger); }
button.ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.field { border-left: 8px solid transparent; }
.status-open { background: var(--card); border-left-color: #da1e28; }
.status-submitted { background: var(--card); border-left-color: #f0b429; }
.status-completed { background: var(--completed); border-left-color: #2b8a3e; }
.field.is-missing { box-shadow: 0 0 0 2px #da1e28; }

.badge {
  display: inline-block;
  background: #eaf0f8;
  border-radius: 999px;
  padding: .15rem .55rem;
  font-size: .8rem;
  margin-left: .4rem;
}
.muted { color: var(--muted); font-size: .9rem; }
.error { color: #9f1239; font-weight: 600; }
.list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .5rem; }
.comments-list li {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .6rem;
}

.editor-toolbar { display: flex; gap: .4rem; margin-bottom: .4rem; flex-wrap: wrap; }
.editor {
  min-height: 150px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem;
  background: #fff;
}
.editor h2 { font-size: 1.25rem; margin: .4rem 0; }
.editor h3 { font-size: 1.1rem; margin: .35rem 0; }
.file-list { display: grid; gap: .4rem; }
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .45rem .65rem;
}
.comment-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .6rem;
}
.comment-item form { margin: 0; }
.comment-item button { padding: .2rem .5rem; font-size: .8rem; }
.button-link {
  display: inline-block;
  background: #123e72;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  padding: .55rem .65rem;
}
.preview-text {
  white-space: pre-wrap;
  font: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem;
}
.preview-html {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem;
}
.preview-image {
  max-width: min(420px, 100%);
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
}
.image-thumb {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem;
}
.image-thumb img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.image-thumb .file-name {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  margin-top: .3rem;
  word-break: break-all;
}
.image-thumb .remove-file {
  position: absolute;
  top: .25rem;
  right: .25rem;
  padding: .15rem .4rem;
  font-size: .75rem;
}
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 1.2rem;
  background: #fbfcfe;
  text-align: center;
  cursor: pointer;
}
.dropzone.is-dragover {
  border-color: #123e72;
  background: #eef4fb;
}
.dropzone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.dropzone-pending {
  list-style: none;
  margin: .75rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
}
.dropzone-pending li {
  font-size: .8rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .2rem .55rem;
}
.dialog {
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 42, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.dialog.is-open { display: flex; }
.dialog-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.2rem 1.3rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.dialog-card p { margin: 0 0 1rem; font-weight: 600; }
.danger-zone {
  border-color: #f3c4c4;
}
.legend { display: flex; gap: 1rem; align-items: center; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-right: .25rem; }
.dot.open { background: #da1e28; }
.dot.submitted { background: #f0b429; }
.dot.completed { background: #2b8a3e; }

@media (max-width: 760px) {
  .row.between { flex-direction: column; gap: .8rem; }
  .legend { flex-wrap: wrap; }
}
