:root {
  --accent: #4cc9ff;
  --accent-strong: #1e9bd7;
  --accent-ink: #04263d;
  --accent-soft: rgba(76, 201, 255, 0.12);
  --accent-line: rgba(76, 201, 255, 0.2);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  --text-faint: rgba(255, 255, 255, 0.5);
  --danger: #ff6b6b;
  --warn: #ffc107;
  --ok: #3ddc97;
  --surface: linear-gradient(135deg, rgba(19, 58, 92, 0.3), rgba(15, 49, 80, 0.2));
  --well: rgba(0, 0, 0, 0.2);
  --bg: linear-gradient(135deg, #0a1f33 0%, #133a5c 50%, #0f3150 100%);
  --radius: 12px;
  --shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

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

html {
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', 'Liberation Sans', Arial, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: #0a1f33;
  background-image: var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
  overscroll-behavior: none;
}

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

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 0.5rem;
  font-weight: 500;
  line-height: 1.2;
}

button {
  font: inherit;
}

a,
button,
label {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Two page widths only: lists and dashboards, and narrow pages for reading, forms and details */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem;
}

.page.narrow {
  max-width: 900px;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
}

.back:hover {
  color: var(--accent);
}

.header-card {
  background: linear-gradient(135deg, rgba(76, 201, 255, 0.1) 0%, rgba(19, 58, 92, 0.2) 100%);
  padding: 2rem;
  border-radius: 10px;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--accent-line);
  backdrop-filter: blur(8px);
}

.header-card h1 {
  color: var(--accent);
  font-size: 2rem;
  margin: 0 0 0.5rem;
}

.header-card .subtitle {
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid rgba(76, 201, 255, 0.15);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 1.5rem;
}

/* Stacked panels never touch, also when one comes from a component (person page: scores, contracts) */
.page > * + .panel,
.page > .panel + * {
  margin-top: 1.25rem;
}

.panel h2 {
  color: var(--accent);
  font-size: 1.3rem;
  margin: 0 0 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn:hover:not(:disabled) {
  background: rgba(76, 201, 255, 0.22);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--accent);
  opacity: 0.6;
  margin-bottom: 1rem;
}

.empty-state h3 {
  color: var(--text);
  margin: 0 0 0.5rem;
}

.empty-state p {
  margin: 0 auto;
  max-width: 46ch;
}

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

.alert.error {
  background: rgba(255, 80, 80, 0.15);
  border: 1px solid rgba(255, 80, 80, 0.3);
  color: var(--danger);
}

.alert.success {
  background: rgba(76, 201, 255, 0.1);
  border: 1px solid var(--accent-line);
  color: var(--accent);
}

.loading {
  text-align: center;
  padding: 3rem;
  color: var(--accent);
  font-size: 1.5rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  white-space: nowrap;
}

.badge.warn {
  background: rgba(255, 193, 7, 0.12);
  border-color: rgba(255, 193, 7, 0.35);
  color: var(--warn);
}

.badge.danger {
  background: rgba(255, 80, 80, 0.12);
  border-color: rgba(255, 80, 80, 0.35);
  color: var(--danger);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem 1.25rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.form-field.wide {
  grid-column: 1 / -1;
}

.form-field > span {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  border: 1px solid rgba(76, 201, 255, 0.25);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font: inherit;
  font-size: 16px;
  color-scheme: dark;
}

.form-field select option,
.form-field select optgroup {
  background: #0c2238;
}

.form-field input:focus,
.form-field select:focus {
  border-color: rgba(76, 201, 255, 0.6);
  outline: none;
}

.form-field.invalid input,
.form-field.invalid select {
  border-color: rgba(255, 107, 107, 0.7);
}

.field-error {
  color: var(--danger);
  font-size: 0.82rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Traffic light: red = act now, yellow = follow-up, green = no concern */
.risk {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  white-space: nowrap;
}

.risk::before {
  content: '';
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.risk.red {
  color: var(--danger);
}

.risk.yellow {
  color: var(--warn);
}

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

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

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

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

table.data th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* A row of filter chips (one per page). Wraps on wide screens, one swipeable line on phones. */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Phones: the page header loses its card and becomes a short intro under the top bar */
@media (max-width: 768px) {
  .page {
    padding: 0 16px;
  }

  .header-card {
    padding: 0;
    margin-bottom: 1rem;
    background: none;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
  }

  .header-card h1 {
    font-size: 1.3rem;
  }

  .header-card .subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.4;
  }

  /* Section pages: the top bar already shows the title */
  .main-content.top-level .header-card h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .header-card .btn {
    gap: 0.35rem;
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
  }

  .panel {
    padding: 1.1rem;
  }

  .panel h2 {
    font-size: 1.15rem;
    margin-bottom: 0.9rem;
  }

  /* !important: pages style their chips and rows with scoped (more specific) rules */
  /* Filter chips wrap onto the next line, so none is cut off at the screen edge */
  .chip-row {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }

  .chip-row > * {
    flex: none !important;
    white-space: nowrap;
    font-size: 0.88rem;
  }
}

/* Tables become one card per row on phones; each cell needs data-label. */
@media (max-width: 600px) {
  table.data.stack thead {
    display: none;
  }

  table.data.stack,
  table.data.stack tbody,
  table.data.stack tr,
  table.data.stack td {
    display: block;
    width: 100%;
  }

  table.data.stack tr {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  table.data.stack td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.25rem 0;
    border: none;
    text-align: right;
  }

  table.data.stack td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--text-faint);
    font-size: 0.8rem;
    text-align: left;
  }

  table.data.stack td.num {
    text-align: right;
  }
}


@page {
  size: A4;
  margin: 14mm;
}

@media print {
  html,
  body {
    background: #fff !important;
    color: #000;
  }

  .sidebar,
  .mobile-bar,
  .tab-bar,
  .mobile-overlay {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
