:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafd;
  --line: #dfe6ef;
  --text: #162235;
  --muted: #66758d;
  --primary: #0f3f93;
  --primary-hover: #184cad;
  --danger: #cf4858;
  --success-bg: #e7f7ed;
  --success-text: #2a7a43;
  --info-bg: #eef4ff;
  --radius: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
}

.layout {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 14px 28px;
}

.layout-narrow {
  max-width: 420px;
}

.login-card {
  margin-top: 24px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 650;
}

.login-subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.login-form .alert {
  margin-bottom: 12px;
}

.login-form .field + .field {
  margin-top: 14px;
}

.login-actions {
  margin-top: 8px;
}

.login-actions .btn-primary {
  min-width: 100%;
}

.task-card,
.card,
.hint-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.task-card {
  padding: 16px;
  margin-bottom: 12px;
}

.task-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.task-head h1 {
  margin: 0 0 2px;
  font-size: 30px;
  font-weight: 650;
}

.task-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.task-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

.task-info h2,
.criteria-preview h2,
.field-group h2 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 650;
}

.task-info dl {
  margin: 0;
}

.task-info dl div {
  margin-bottom: 8px;
}

.task-info dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 1px;
}

.task-info dd {
  margin: 0;
  font-weight: 600;
}

.criteria-box {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.criteria-title {
  margin: 0 0 6px;
  font-weight: 600;
}

.criteria-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.hint-panel {
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--info-bg);
}

.hint-panel h3 {
  margin: 0 0 8px;
  color: #3c5a8f;
  font-size: 18px;
}

.hint-panel ol {
  margin: 0;
  padding-left: 18px;
  color: #3c5a8f;
}

.hint-panel li + li {
  margin-top: 4px;
}

.card {
  padding: 16px;
}

.field-group {
  margin-bottom: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

textarea,
input[type="text"],
input[type="url"],
input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.35;
  min-height: 42px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

textarea:focus,
input:focus {
  outline: 2px solid #b8cdfa;
  border-color: #9ebbf8;
}

.file-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed #a6b6cf;
  border-radius: 8px;
  background: #fbfcff;
  min-height: 122px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.file-drop:hover,
.file-drop.dragover {
  border-color: #6e8fcf;
  background: #f1f6ff;
}

.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.file-drop-text {
  color: var(--muted);
  text-align: center;
  padding: 0 12px;
}

.file-name {
  color: #305ea8;
  font-size: 13px;
}

#rules-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.rule-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rule-badge {
  font-size: 12px;
  color: #315fa8;
  font-weight: 700;
}

.rule-card textarea {
  margin-top: 8px;
  min-height: 84px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  min-width: 240px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.btn-icon {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #8593a8;
  border-radius: 6px;
  cursor: pointer;
}

.btn-icon:hover {
  color: var(--danger);
  background: #fdecef;
}

.actions {
  margin-top: 4px;
}

.alert {
  margin-top: 12px;
  border: 1px solid #f2c3ca;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff5f6;
  color: #943643;
  white-space: pre-wrap;
}

.alert.success {
  border-color: #c8e8d4;
  background: #effaf3;
  color: #2d7e49;
}

.footer {
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.footer-sep {
  margin: 0 6px;
  color: var(--line);
}

.footer-link {
  color: #305ea8;
  font-weight: 600;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-logout-form {
  display: inline;
  margin: 0;
  padding: 0;
  vertical-align: baseline;
}

.footer-link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  color: #305ea8;
  font-weight: 600;
  text-decoration: none;
}

.footer-link-btn:hover {
  text-decoration: underline;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

  .task-head {
    flex-direction: column;
  }

  .btn-primary {
    min-width: 0;
    width: 100%;
  }
}
