:root {
  --bg: #f4f7fb;
  --card: #fff;
  --text: #1a2332;
  --muted: #5b677a;
  --accent: #0b6e4f;
  --accent-hover: #095a41;
  --error: #b42318;
  --success: #067647;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 16px 48px; }
.wrap.narrow { max-width: 560px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar > div { display: flex; gap: 8px; }
.card { background: var(--card); border: 1px solid #d8e0ea; border-radius: 14px; padding: 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
label { display: block; font-weight: 600; margin-bottom: 12px; }
input, select, textarea { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid #d8e0ea; border-radius: 10px; font: inherit; }

.btn,
button[type="submit"]:not(.link-danger):not(.btn-danger) {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn.secondary { background: #eef2f7; color: var(--text); }
.btn:hover,
button[type="submit"]:not(.link-danger):not(.btn-danger):hover {
  background: var(--accent-hover);
}
.btn.secondary:hover { background: #e2e8f0; }

form#apkForm > button[type="submit"],
.card > form:not(.inline-form) > button[type="submit"]:not(.btn-danger):not(.link-danger) {
  width: 100%;
}

.muted { color: var(--muted); }
.error { color: var(--error); }
.success { color: var(--success); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 8px; border-bottom: 1px solid #e7edf5; text-align: left; vertical-align: middle; }
.badge { padding: 4px 8px; border-radius: 999px; background: #eef2f7; font-size: 12px; }
.badge.confirmed { background: #d1fadf; color: #067647; }
.badge.draft { background: #eef2f7; }
.badge.sent, .badge.otp_pending { background: #fff4ce; color: #8a6a00; }

.actions-cell {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}
.actions-cell a {
  color: #0b6e4f;
  font-weight: 600;
  text-decoration: none;
}
.actions-cell a:hover { text-decoration: underline; }

.inline-form { display: inline; margin: 0; padding: 0; }
button.link-danger,
.inline-form button.link-danger {
  display: inline;
  width: auto !important;
  margin: 0;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  color: #b42318 !important;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button.link-danger:hover,
.inline-form button.link-danger:hover {
  background: transparent !important;
  text-decoration: underline;
}

.btn-danger {
  display: inline-block;
  width: auto !important;
  margin-top: 12px;
  border-radius: 10px;
  padding: 10px 14px;
  background: #fef3f2 !important;
  border: 1px solid #fecdca !important;
  color: #b42318 !important;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-danger:hover {
  background: #fee4e2 !important;
}

.field-section {
  margin: 28px 0 14px;
  padding-top: 16px;
  border-top: 1px solid #e7edf5;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.field-section:first-child {
  margin-top: 8px;
  padding-top: 0;
  border-top: 0;
}
.field-block {
  margin-bottom: 20px;
}
.field-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #334155;
  margin-bottom: 10px;
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}
.check-grid.check-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 520px;
}
.check-grid.check-grid--1 {
  grid-template-columns: minmax(0, 320px);
}
.check-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  column-gap: 10px;
  align-items: start;
  margin: 0;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid #e4ebf3;
  border-radius: 10px;
  background: #f8fafc;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.check-row:hover {
  background: #f1f5f9;
  border-color: #d0dae6;
}
.check-row:has(input:checked) {
  background: #eef8f3;
  border-color: #9dceb8;
}
.check-row input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  padding: 0;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}
.check-row span {
  display: block;
  line-height: 1.35;
  font-weight: 500;
  word-break: break-word;
}
.field-block textarea,
.field-block input,
.field-block select {
  width: 100%;
  margin-top: 0;
  padding: 10px 12px;
  border: 1px solid #d8e0ea;
  border-radius: 10px;
  font: inherit;
}
.field-block textarea { min-height: 90px; }
input[readonly] {
  background: #f3f6fa;
  color: #4b5563;
}

@media (max-width: 860px) {
  .check-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .check-grid.check-grid--2 {
    max-width: none;
  }
}
@media (max-width: 520px) {
  .check-grid,
  .check-grid.check-grid--2 {
    grid-template-columns: 1fr;
  }
  .check-grid.check-grid--1 {
    grid-template-columns: 1fr;
  }
}
