/* Shared shell, theme tokens and form controls for the tree utilities. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d8dce3;
  --border-strong: #b9c0cb;
  --text: #1c2128;
  --text-muted: #5b6675;
  --accent: #2f6fb5;
  --accent-soft: #e4eefb;
  --male: #3b7fc4;
  --female: #c25b8f;
  --unknown: #7d8794;
  --danger: #b3382c;
  --warning: #9a6a00;
  --ok: #2c7a4b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
  --radius: 7px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #232830;
    --border: #333a45;
    --border-strong: #454e5c;
    --text: #e6e9ee;
    --text-muted: #9aa4b2;
    --accent: #6ba5e7;
    --accent-soft: #1e2c3d;
    --male: #6ba5e7;
    --female: #e08ab5;
    --unknown: #97a1ae;
    --danger: #f08076;
    --warning: #e0aa3e;
    --ok: #63c98d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ header */

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 5;
  flex: none;
}

.app-header h1 {
  font-size: 15px;
  font-weight: 650;
  margin: 0;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.app-header .spacer { flex: 1; }

.app-nav {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--radius);
}

.app-nav a {
  padding: 4px 11px;
  border-radius: 5px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 550;
  font-size: 13px;
}

.app-nav a:hover { color: var(--text); }
.app-nav a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Company mark, back to the main site. Sits beside the View/Edit control
   rather than inside it, so it does not read as a third tab. */
.brand-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  padding: 2px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  line-height: 0;
  transition: border-color .15s ease, transform .15s ease;
}

.brand-home img { width: 28px; height: 28px; border-radius: 50%; display: block; }

.brand-home:hover { border-color: #dcc079; transform: translateY(-1px); }
.brand-home:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ inputs */

label.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

input[type="text"], input[type="search"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 9px;
  min-width: 0;
  width: 100%;
}

textarea { resize: vertical; min-height: 62px; line-height: 1.45; }

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .7; }

button, .btn {
  font: inherit;
  font-weight: 550;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button:hover:not(:disabled), .btn:hover { background: var(--surface-2); }
button:disabled { opacity: .45; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); }

button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border-strong)); }
button.icon { padding: 5px 8px; }

/* ------------------------------------------------------------------ layout */

.app-body { flex: 1; display: flex; min-height: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.muted { color: var(--text-muted); }
.mono { font-family: var(--mono); font-size: 12px; }

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state strong { color: var(--text); font-size: 15px; font-weight: 600; }

/* ----------------------------------------------------------------- toasts */

#toasts {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 9px 14px;
  font-size: 13px;
  max-width: 420px;
  animation: toast-in .18s ease-out;
}

.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--ok); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- scrollbar */

.scroll { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid var(--surface); }
.scroll::-webkit-scrollbar-track { background: transparent; }
