:root {
  --bg: #f3ebe6;
  --surface: #ffffff;
  --surface-soft: #eef2f2;
  --primary: #25666a;
  --primary-dark: #1d4f52;
  --text: #2c3e40;
  --muted: #7a8a8e;
  --border: #e0e0e0;
  --success-bg: #e6f5ea;
  --success-text: #1b8e3e;
  --error-bg: #fce9e7;
  --error-text: #c05448;
  --warning-bg: #fff4de;
  --warning-text: #8f6a1d;
  --shadow: 0 16px 40px rgba(44, 62, 64, 0.08);
  --radius: 18px;
  --compact-gap: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px 28px;
}

.topbar {
  position: relative;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: nowrap;
  padding-right: 86px;
}

.topbar h1,
.card-header h2 {
  margin: 0;
}

.topbar h1 {
  line-height: 1.05;
}

.topbar-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}

.topbar-logout {
  margin: 0;
}

.meta-label,
.helper {
  color: var(--muted);
  font-size: 0.92rem;
}

.employee-box strong {
  display: block;
  margin-top: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(37, 102, 106, 0.1);
  color: var(--primary);
  text-decoration: none;
  border: 1px solid transparent;
  font-weight: 700;
}

.tab:hover,
.tab-button:hover {
  background: rgba(37, 102, 106, 0.16);
}

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

.tab-action {
  margin-left: auto;
}

.tab-button {
  cursor: pointer;
}

.logout-button {
  background: rgba(192, 84, 72, 0.12);
  color: var(--error-text);
  border-color: rgba(192, 84, 72, 0.18);
}

.logout-button:hover {
  background: rgba(192, 84, 72, 0.2);
}

.alert {
  border: 1px solid transparent;
  box-shadow: var(--shadow);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: rgba(27, 142, 62, 0.18);
}

.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: rgba(192, 84, 72, 0.18);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: rgba(143, 106, 29, 0.18);
}

.content {
  display: grid;
  gap: var(--compact-gap);
}

.card {
  background: var(--surface);
  border: 1px solid rgba(224, 224, 224, 0.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card-form.narrow {
  max-width: 520px;
  margin: 4vh auto 0;
}

.card-header {
  margin-bottom: 14px;
}

.card-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.compact-context {
  font-size: 0.95rem;
  line-height: 1.45;
}

.page-narrow {
  max-width: 680px;
  margin: 0 auto;
}

.employee-portal-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(224, 224, 224, 0.85);
}

.page-anomalies {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
  gap: var(--compact-gap);
  align-items: start;
}

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

.stack-lg,
.stack-md,
.stack-xl {
  display: grid;
}

.stack-md {
  gap: 10px;
}

.stack-lg {
  gap: 12px;
}

.stack-xl {
  gap: 16px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.compact {
  min-width: 180px;
}

.field span,
.segmented legend {
  font-weight: 700;
}

.field input,
.field select {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 0 12px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(37, 102, 106, 0.18);
  border-color: var(--primary);
}

.segmented {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.segmented legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.segment-option {
  position: relative;
}

.segment-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  cursor: pointer;
  font-weight: 700;
}

.entry-option input:checked + span {
  background: rgba(37, 102, 106, 0.14);
  border-color: var(--primary);
  color: var(--primary);
}

.exit-option input:checked + span {
  background: rgba(192, 84, 72, 0.12);
  border-color: var(--error-text);
  color: var(--error-text);
}

.segment-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-style: normal;
  background: rgba(37, 102, 106, 0.12);
  color: var(--primary);
}

.exit-option .segment-icon {
  background: rgba(192, 84, 72, 0.12);
  color: var(--error-text);
}

.entry-option input:checked + span .segment-icon {
  background: rgba(37, 102, 106, 0.18);
  color: var(--primary);
}

.exit-option input:checked + span .segment-icon {
  background: rgba(192, 84, 72, 0.18);
  color: var(--error-text);
}

.segment-icon::before {
  font-size: 0.95rem;
  line-height: 1;
}

.icon-entry::before {
  content: "↘";
}

.icon-exit::before {
  content: "↗";
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 12px;
  padding: 0 16px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
}

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

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

.btn-secondary {
  background: rgba(37, 102, 106, 0.1);
  color: var(--primary);
  border-color: rgba(37, 102, 106, 0.14);
}

.btn-secondary:hover,
.btn-ghost:hover {
  background: rgba(37, 102, 106, 0.14);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border-color: rgba(37, 102, 106, 0.18);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.feature-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 12px;
}

.anomaly-list,
.queued-item {
  display: grid;
  gap: 10px;
}

.anomaly-scroll {
  max-height: min(52vh, 480px);
  overflow-y: auto;
  padding-right: 4px;
}

.anomaly-item,
.queued-item,
.employee-box {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}

.anomaly-item {
  display: block;
}

.anomaly-item.is-reported {
  border-color: rgba(184, 128, 0, 0.24);
  background: #fff7df;
}

.anomaly-item-main {
  display: grid;
  gap: 6px;
  position: relative;
  padding-right: 48px;
}

.anomaly-item-row {
  display: block;
}

.anomaly-item-meta {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.anomaly-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.anomaly-selection-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.anomaly-selection-badge.is-default {
  background: rgba(122, 138, 142, 0.12);
  color: var(--muted);
}

.anomaly-selection-badge.is-active {
  background: rgba(37, 102, 106, 0.12);
  color: var(--primary);
}

.anomaly-selection-badge.is-reported {
  background: rgba(184, 128, 0, 0.14);
  color: #8a6100;
}

.anomaly-action-field {
  position: absolute;
  top: 0;
  right: 0;
}

.anomaly-action-menu {
  position: relative;
}

.anomaly-menu-trigger {
  width: 32px;
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
}

.anomaly-menu-trigger:hover,
.anomaly-action-menu.is-open .anomaly-menu-trigger {
  background: rgba(37, 102, 106, 0.08);
  border-color: rgba(37, 102, 106, 0.24);
}

.anomaly-menu-trigger.has-selection {
  background: rgba(37, 102, 106, 0.12);
  border-color: rgba(37, 102, 106, 0.28);
}

.anomaly-menu-options {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.anomaly-menu-option {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.anomaly-menu-option:hover {
  background: rgba(37, 102, 106, 0.08);
}

.anomaly-menu-option.is-selected {
  background: rgba(37, 102, 106, 0.12);
  color: var(--primary);
  font-weight: 700;
}

.anomaly-submit {
  width: 100%;
}

.anomaly-footer-actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.anomaly-secondary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

.anomaly-request-launcher {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(37, 102, 106, 0.04);
}

.subsection-title {
  margin: 0;
  font-size: 1.05rem;
}

.anomaly-item p,
.queued-item p {
  margin: 4px 0 0;
  color: var(--muted);
}

.anomaly-item-meta p,
.anomaly-item-meta small {
  margin: 0;
}

.employee-box {
  margin-bottom: 12px;
  background: rgba(37, 102, 106, 0.08);
}

.anomaly-main-card,
.anomaly-side-card {
  min-height: 0;
}

.anomaly-side-card {
  position: sticky;
  top: 12px;
}

.anomaly-item > div,
.queued-item > div {
  min-width: 0;
}

.anomaly-item small,
.queued-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.content-anomalies {
  gap: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(31, 43, 45, 0.45);
  backdrop-filter: blur(2px);
}

.modal-card {
  width: min(100%, 460px);
  padding: 20px;
  border-radius: 18px;
  background: var(--surface);
}

.modal-card-form {
  width: min(100%, 560px);
}

.modal-card:focus {
  outline: none;
}

.modal-copy {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-copy h2,
.modal-copy p {
  margin: 0;
}

.modal-eyebrow {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.modal-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

body.has-modal-open {
  overflow: hidden;
}

@media (max-width: 860px) {
  .topbar,
  .grid-two,
  .field-grid,
  .anomaly-secondary-grid,
  .page-anomalies {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    padding-right: 74px;
  }

  .topbar-actions {
    top: 0;
    right: 0;
  }

  .anomaly-side-card {
    position: static;
  }

  .modal-form-grid {
    grid-template-columns: 1fr;
  }
}

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

  .card {
    padding: 16px;
  }

  .button-row,
  .queued-item,
  .employee-box {
    align-items: stretch;
  }

  .employee-portal-link {
    align-items: stretch;
    flex-direction: column;
  }

  .field.compact {
    min-width: 0;
  }

  .anomaly-action-field {
    top: 0;
    right: 0;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  .segmented legend {
    grid-column: auto;
  }
}

@media (max-width: 420px) {
  .anomaly-item-row,
  .modal-actions {
    align-items: stretch;
  }

  .anomaly-action-field {
    top: 0;
    right: 0;
  }
}
