:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #059669;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --space: 1rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: min(100% - 2rem, 1100px);
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  width: min(100% - 2rem, 1100px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
}

.nav-toggle {
  display: none;
}

.nav-toggle-label {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 0.5rem;
}

.nav-toggle-label span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-user {
  color: var(--muted);
  font-size: 0.95rem;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card-narrow {
  max-width: 560px;
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.card-link:hover {
  border-color: var(--primary);
  text-decoration: none;
}

.card-grid,
.card-list {
  display: grid;
  gap: 1rem;
}

.highlight-card {
  margin-bottom: 1.5rem;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.empty-state {
  text-align: center;
  color: var(--muted);
}

.form {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 500;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  min-height: 44px;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-small {
  min-height: 36px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.form-actions,
.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.action-group + .form {
  margin-top: 1rem;
}

.inline-form {
  display: inline;
}

.inline-form-row {
  align-items: end;
}

.grow {
  flex: 1;
}

.muted {
  color: var(--muted);
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.alert {
  padding: 0.875rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.form-intro {
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
  border-radius: 10px;
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  white-space: pre-wrap;
}

.form .form-intro {
  margin-bottom: 0;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-severity.badge-critical { background: #fee2e2; color: #991b1b; }
.badge-severity.badge-high { background: #ffedd5; color: #9a3412; }
.badge-severity.badge-medium { background: #fef9c3; color: #854d0e; }
.badge-severity.badge-low { background: #dbeafe; color: #1e40af; }
.badge-open { background: #e5e7eb; color: #374151; }
.badge-handled { background: #d1fae5; color: #065f46; }
.badge-archived { background: #ede9fe; color: #5b21b6; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-block {
  margin-top: 1rem;
}

.label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.checkbox-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}

.checkbox-label input {
  width: auto;
  min-height: auto;
}

.field-labels-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.field-labels-help {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.danger-zone {
  border-color: #fecaca;
}

.danger-text {
  color: #991b1b;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.875rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  font-size: 0.85rem;
  color: var(--muted);
}

.mobile-only {
  display: none;
}

.hidden {
  display: none;
}

.incident-card h2,
.incident-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.project-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.project-card h2 a {
  color: inherit;
  text-decoration: none;
}

.project-card h2 a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.75rem;
}

.admin-override-form {
  width: 100%;
}

.admin-override-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.5rem;
}

.admin-override-btn.is-active {
  color: var(--primary);
}

.admin-override-btn .icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 768px) {
  .admin-override-form {
    width: auto;
  }

  .admin-override-btn {
    width: auto;
  }
}

@media (max-width: 767px) {
  .nav-toggle-label {
    display: flex;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    flex-direction: column;
    align-items: stretch;
  }

  .nav-toggle:checked ~ .site-nav {
    display: flex;
  }

  .site-header {
    position: relative;
  }

  .data-table thead {
    display: none;
  }

  .data-table tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem;
    background: #fff;
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border: 0;
    padding: 0.5rem 0.75rem;
  }

  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
  }

  .mobile-only {
    display: grid;
  }

  .table-wrap .data-table {
    display: none;
  }
}

@media (min-width: 600px) {
  .page-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .detail-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
