*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0a;
  --bg-card: #161616;
  --bg-elevated: #1f1f1f;
  --text: #f5f5f5;
  --text-muted: #a3a3a3;
  --border: #2e2e2e;
  --red: #c8102e;
  --red-hover: #a50d26;
  --green: #22c55e;
  --danger: #ef4444;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--text);
}

.container {
  width: min(1100px, 100% - 2rem);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}

.brand-text {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.brand-logo {
  display: block;
  height: 36px;
  width: auto;
  object-fit: contain;
}

.auth-logo {
  text-align: center;
  margin-bottom: 1rem;
}

.auth-brand-logo {
  display: block;
  height: 64px;
  width: auto;
  margin: 0 auto;
  object-fit: contain;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.nav a {
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
}

.nav a:hover {
  color: #fff;
}

.main-content {
  padding: 2rem 0 3rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
}

.card-narrow {
  max-width: 480px;
  margin-inline: auto;
}

h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}

.muted {
  color: var(--text-muted);
}

.section-lead {
  margin-bottom: 1.25rem;
}

.form-group {
  margin-bottom: 1rem;
}

.turnstile-wrap {
  margin: 1rem 0;
  min-height: 65px;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}

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

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

.inline-form {
  display: inline;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

.login-alt-link {
  margin-top: 1.25rem;
  font-size: 0.9rem;
}

.error-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

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

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

.dashboard-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.dashboard-card h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.dashboard-card-value {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  line-height: 1.1;
}

.dashboard-card-value-text {
  font-size: 1.1rem;
  font-weight: 600;
}

.dashboard-card-static {
  cursor: default;
}

.dashboard-card-static:hover {
  border-color: var(--border);
  box-shadow: none;
}

.dashboard-recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dashboard-recent-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.dashboard-recent-list li:last-child {
  border-bottom: 0;
}

.health-ok-text {
  color: var(--success, #1a7f37);
}

.health-warn-text {
  color: var(--warning, #9a6700);
}

.health-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.health-card h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.health-value {
  font-size: 1.1rem;
  font-weight: 600;
}

.health-ok {
  color: var(--green);
}

.health-warn {
  color: #fbbf24;
}

.health-bad {
  color: var(--danger);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.dashboard-lead {
  margin-bottom: 1.5rem;
}

.alert-success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="file"],
select,
textarea,
.form-control,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

textarea,
.form-textarea {
  resize: vertical;
  min-height: 4rem;
}

.form-shell {
  display: grid;
  gap: 1rem;
}

.form-card {
  margin: 0;
}

.form-card-intro h1 {
  margin-bottom: 0.5rem;
}

.staff-created-note {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--accent, #c41e3a);
  background: rgba(255, 255, 255, 0.04);
}

.form-section {
  padding: 1.25rem 1.5rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-field {
  margin: 0;
}

.form-field-full,
.form-group-full {
  grid-column: 1 / -1;
}

.form-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.required {
  color: var(--red);
}

.help-text {
  margin: -0.25rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.error-summary {
  margin: 0;
}

.form-section-title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

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

.checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  font-size: 0.95rem;
  cursor: pointer;
}

.checkbox-card input {
  margin-top: 0.15rem;
  accent-color: var(--red);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.file-upload-grid {
  display: grid;
  gap: 1rem;
}

.file-upload-row input[type="file"] {
  padding: 0.5rem;
}

.file-upload-row input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
}

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

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
}

.data-table a {
  color: #fff;
  text-decoration: underline;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.page-header h1 {
  margin: 0;
}

.detail-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
}

.detail-list {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.detail-list dt {
  color: var(--text-muted);
  margin: 0;
}

.detail-list dd {
  margin: 0;
}

.text-block {
  white-space: pre-wrap;
  background: var(--bg-elevated);
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.checklist {
  margin: 0;
  padding-left: 1.25rem;
}

.attachment-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.attachment-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.attachment-cat {
  display: inline-block;
  min-width: 7rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: capitalize;
}

.comment {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--bg-elevated);
}

.comment-internal {
  border-color: rgba(200, 16, 46, 0.35);
}

.comment-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.comment-body {
  white-space: pre-wrap;
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.timeline li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.timeline-action {
  font-weight: 600;
}

.queue-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.queue-link {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.85rem;
}

.queue-link.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.compact-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.small {
  font-size: 0.85rem;
}

.card + .card {
  margin-top: 1rem;
}

.staff-created-note {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--accent, #c41e3a);
  background: rgba(255, 255, 255, 0.04);
}

.requestor-lookup-note {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--red);
  background: rgba(255, 255, 255, 0.04);
}

input[type="date"],
input[type="datetime-local"],
.form-control-date {
  color-scheme: dark;
  min-height: 2.75rem;
  appearance: auto;
  -webkit-appearance: auto;
}

.form-select-time {
  min-height: 2.75rem;
  font-size: 1rem;
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}

.time-picker-row {
  display: grid;
  grid-template-columns: minmax(4.5rem, 1fr) minmax(4.75rem, 1fr) minmax(5.5rem, 1.1fr);
  gap: 0.5rem;
  align-items: stretch;
}

.time-picker-select {
  min-height: 2.75rem;
  font-size: 1rem;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

@media (max-width: 520px) {
  .time-picker-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.attachment-grid {
  display: grid;
  gap: 1rem;
}

.attachment-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
}

.attachment-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.attachment-name {
  font-weight: 600;
  word-break: break-word;
}

.attachment-meta {
  margin-top: 0.25rem;
}

.attachment-preview {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #000;
}

.attachment-preview a {
  display: block;
  cursor: zoom-in;
}

.attachment-preview img,
.attachment-preview video {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.attachment-preview-pdf iframe {
  display: block;
  width: 100%;
  height: 420px;
  border: 0;
  background: #fff;
}

.attachment-fallback {
  margin: 0.5rem 0 0;
}

.attachment-upload-form {
  margin-top: 1.25rem;
}

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

.table-actions {
  text-align: right;
  white-space: nowrap;
}

.compact-detail-list {
  margin-top: 1rem;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

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

  .detail-list {
    grid-template-columns: 1fr;
  }

  .detail-list dt {
    margin-top: 0.5rem;
  }
}
