:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #dbe4ef;
  --accent: #0a66c2;
  --accent-soft: #e6f0fb;
  --danger: #b42318;
  --danger-soft: #fdecec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.app-header,
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand-link {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.user-controls {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.user-email {
  font-size: 0.9rem;
  color: var(--muted);
}

.app-nav {
  gap: 0.5rem;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
}

.nav-link.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.page-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0.2rem 0 1rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
  margin-bottom: 1rem;
}

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

.table th,
.table td {
  padding: 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.btn,
input[type="submit"],
button {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 0.46rem 0.78rem;
  cursor: pointer;
  font-size: 0.92rem;
}

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

.btn.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f9c6c6;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  background: #e2e8f0;
  color: #1e293b;
}

.badge-draft {
  background: #fff3d6;
  color: #8a5a00;
}

.badge-committed {
  background: #dff3e5;
  color: #11632b;
}

.badge-archived {
  background: #eceff3;
  color: #475569;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  background: #e7f1fb;
  color: #0d4d86;
  border-radius: 999px;
  padding: 0.17rem 0.52rem;
  font-size: 0.78rem;
}

.form-grid,
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.input-group label {
  font-size: 0.85rem;
  color: var(--muted);
}

.input-group input,
.input-group select,
.input-group textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem;
  font-size: 0.95rem;
  background: #fff;
}

.input-checkbox {
  justify-content: flex-end;
}

.input-checkbox label {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}

.field-rows {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.field-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: #fbfdff;
}

.field-row-top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.meta-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
}

.meta-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.field-header {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: baseline;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.version-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.25rem;
}

.version-list a.is-active {
  font-weight: 700;
}

.probability-table {
  min-width: 320px;
}

.pagination {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.8rem;
}

.flash {
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.8rem;
}

.flash-notice {
  background: #e4f3e7;
  color: #155f2d;
  border: 1px solid #c3e8ca;
}

.flash-alert {
  background: #fdeceb;
  color: #9d2020;
  border: 1px solid #f6c5c5;
}

.auth-shell {
  min-height: calc(100vh - 2rem);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(460px, 96vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem;
}

.auth-form {
  display: grid;
  gap: 0.75rem;
}

.auth-links {
  margin-top: 0.8rem;
  font-size: 0.9rem;
}

.result-list {
  display: grid;
  gap: 0.8rem;
}

.artifact-content {
  margin: 0;
  padding: 0.8rem;
  background: #f8fbff;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.55rem;
}

.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
}

mark {
  background: #fff0a8;
  padding: 0 0.1rem;
}

@media (max-width: 720px) {
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }

  .table {
    min-width: 560px;
  }
}
