:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --surface: #ffffff;
  --surface-strong: #edf4ee;
  --text: #17221c;
  --muted: #5f6d64;
  --line: #dbe3dc;
  --primary: #1f6f4a;
  --primary-strong: #15583a;
  --accent: #d99c2b;
  --danger: #b64434;
  --info: #2f6f9f;
  --shadow: 0 16px 40px rgba(32, 46, 36, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(1040px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 32px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 10px;
}

.topbar h1,
.section-heading h2,
.task-header h3,
.architecture-panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 1.7rem;
}

.section-heading h2 {
  font-size: 1.35rem;
}

.task-header h3,
.architecture-panel h3 {
  font-size: 1.05rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

.badge,
.score-pill {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 9px;
  color: var(--primary-strong);
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-soft {
  color: var(--muted);
  background: var(--surface-strong);
}

.badge-offline {
  color: #7b5413;
  border-color: #e8c983;
  background: #fff4d3;
}

.badge-error,
.score-low {
  color: #7b241a;
  border-color: #efb7ad;
  background: #fff0ee;
}

.score-mid {
  color: #7b5413;
  border-color: #e8c983;
  background: #fff4d3;
}

.score-high {
  color: var(--primary-strong);
  border-color: #b9d8c4;
  background: #ecf8ef;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 16px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(245, 247, 242, 0.96);
  backdrop-filter: blur(10px);
}

.tab {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.tab.is-active {
  color: white;
  background: var(--primary);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-heading,
.task-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
}

.panel,
.table-panel,
.summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
}

.field-grid,
.filters-panel,
.sync-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

label.wide,
.check-row {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--text);
  background: white;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(47, 111, 159, 0.24);
  outline-offset: 2px;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 172px;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.task-name {
  min-width: 0;
  font-weight: 700;
}

.choice-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  min-width: 0;
}

.choice {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: white;
  font-weight: 800;
}

.choice.is-yes {
  color: white;
  border-color: var(--primary);
  background: var(--primary);
}

.choice.is-no {
  color: white;
  border-color: var(--danger);
  background: var(--danger);
}

.form-actions,
.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 46px;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--primary);
  color: white;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button {
  border: 1px solid #b9d8c4;
  color: var(--primary-strong);
  background: #ecf8ef;
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: white;
}

.compact {
  min-height: 40px;
  padding: 8px 12px;
}

.filters-panel {
  align-items: end;
  margin-bottom: 12px;
  box-shadow: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.summary-item {
  padding: 12px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.summary-item strong {
  display: block;
  margin-top: 2px;
  font-size: 1.5rem;
}

.table-panel {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #fbfcfa;
  font-size: 0.82rem;
  text-transform: uppercase;
}

td strong {
  display: block;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.mini-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  color: var(--text);
  background: white;
  font-size: 0.85rem;
  font-weight: 800;
}

.mini-button.danger {
  color: var(--danger);
}

.empty-cell {
  padding: 30px 12px;
  color: var(--muted);
  text-align: center;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.check-row input {
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  margin-top: 2px;
}

.sync-status {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
}

.sync-status p {
  margin: 0;
}

.sync-status p + p {
  margin-top: 6px;
}

.architecture-panel {
  margin-top: 12px;
  box-shadow: none;
}

.architecture-panel ul {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  max-width: min(380px, calc(100vw - 32px));
  border-radius: 8px;
  padding: 12px 14px;
  color: white;
  background: #17221c;
  box-shadow: 0 16px 40px rgba(23, 34, 28, 0.22);
  font-weight: 700;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    display: grid;
  }

  .status-stack {
    align-items: stretch;
    flex-direction: row;
  }

  .badge {
    flex: 1;
  }

  .field-grid,
  .filters-panel,
  .sync-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
  }

  .task-row {
    grid-template-columns: 1fr;
  }

  .choice-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-actions,
  .sync-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
