/* HAVHO feed portal — light companion to the landing's "coastal survey" system.
   Same DNA: dark-teal ink, teal-cyan signal, warm ochre; on a cool paper ground. */

@import url('https://fonts.googleapis.com/css2?family=Familjen+Grotesk:wght@400;500;600;700&family=Newsreader:ital,opsz,wght@0,18..40,400;1,18..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:         #F5F8F6;
  --surface:    #FFFFFF;
  --surface-2:  #EDF3F0;
  --border:     #DBE5E1;
  --border-2:   #CBD8D3;

  --ink:        #10303A;   /* headings, strong text */
  --text:       #33474B;   /* body */
  --muted:      #667C7B;   /* secondary */
  --muted-dim:  #8A9C9A;

  --teal:       #0C8474;   /* interactive: links, primary text-on-light */
  --teal-deep:  #0A6A5E;
  --teal-bright:#3FD9C1;   /* fills, focus, the "live" dot */
  --teal-soft:  #E2F4F0;
  --sun:        #B87516;   /* ochre, readable on light */
  --sun-soft:   #FBF0DD;

  --ok:         #146A46;   --ok-soft:   #E4F3EA;
  --warn:       #8A5A08;   --warn-soft: #FBEED7;
  --bad:        #A5342A;   --bad-soft:  #FBE9E7;

  --radius:     12px;
  --shadow:     0 1px 2px rgba(16,48,58,.05), 0 8px 24px -12px rgba(16,48,58,.14);
  --maxw:       1080px;

  --sans:  'Familjen Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --serif: 'Newsreader', Georgia, serif;
  --mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* legacy aliases (older inline styles) */
  --text-muted: var(--muted);
  --bg-alt: var(--surface-2);
  --brand: var(--teal);
  --brand-dark: var(--teal-deep);
  --required: var(--bad);
  --optional: var(--ok);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-deep); }
h1, h2, h3 { color: var(--ink); letter-spacing: -0.015em; line-height: 1.2; font-weight: 600; margin: 0; }
p { margin: 0 0 14px; }
code {
  font-family: var(--mono); font-size: .86em;
  background: var(--surface-2); color: var(--teal-deep);
  padding: 1px 6px; border-radius: 5px;
}
::selection { background: var(--teal-bright); color: var(--ink); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }

/* ---------- top bar (public pages) ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.topbar-inner { max-width: var(--maxw); margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink); }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  background: linear-gradient(140deg, var(--teal-bright), var(--teal));
  color: var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px;
}
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topbar nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 14.5px; }
.topbar nav a:hover { background: var(--surface-2); color: var(--ink); }
.topbar nav a.active { color: var(--teal-deep); background: var(--teal-soft); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 14.5px;
  padding: 10px 18px; border-radius: 9px; border: 1px solid transparent;
  background: var(--teal-bright); color: var(--ink); cursor: pointer; text-decoration: none;
  transition: transform .12s ease, background .15s, border-color .15s;
}
.btn:hover { background: color-mix(in srgb, var(--teal-bright) 86%, white); color: var(--ink); transform: translateY(-1px); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--border-2); }
.btn.ghost:hover { border-color: var(--teal); color: var(--teal-deep); background: var(--surface); transform: none; }
.btn.sm { padding: 7px 13px; font-size: 13.5px; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { background: #8c2a22; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- generic wrappers ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 48px 24px 90px; }
.wrap.narrow, .wrap h1 + p { max-width: 65ch; }
.wrap h1 { font-size: 2rem; margin-bottom: 6px; }
.wrap h2 { font-size: 1.35rem; margin-bottom: 8px; }
.wrap .sub { color: var(--muted); font-family: var(--serif); font-size: 1.08rem; }
.wrap p { line-height: 1.62; max-width: 68ch; }

.callout {
  border: 1px solid var(--border); border-left: 3px solid var(--teal);
  background: var(--surface); border-radius: 10px; padding: 15px 18px; margin: 18px 0;
}
.callout.warn { border-left-color: var(--sun); }
.callout .t { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--teal-deep); margin-bottom: 6px; }
.callout.warn .t { color: var(--sun); }
.callout p { margin: 0; }

/* ---------- portal shell ---------- */
.portal { display: grid; grid-template-columns: 246px 1fr; min-height: 100vh; }
.portal aside {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 22px 14px; display: flex; flex-direction: column;
}
.portal aside .brand { margin: 0 8px 22px; }
.portal aside a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 9px; margin-bottom: 2px;
  color: var(--text); font-size: 14.5px; font-weight: 500;
  position: relative;
}
.portal aside a:hover { background: var(--surface-2); color: var(--ink); }
.portal aside a.active { background: var(--teal-soft); color: var(--teal-deep); font-weight: 600; }
.portal aside a.active::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px;
  background: var(--teal); border-radius: 0 3px 3px 0;
}
.portal aside form { margin: 0; }
.portal aside .group-label {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted-dim); margin: 20px 0 8px 12px;
}
.portal aside .who {
  margin-top: auto; padding: 14px 12px 4px; font-size: 12.5px; color: var(--muted);
  border-top: 1px solid var(--border);
}
.portal aside .who strong { color: var(--ink); }
.portal main { padding: 32px 40px 90px; min-width: 0; background: var(--bg); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.7rem; margin-bottom: 4px; }
.page-head p { color: var(--muted); margin: 0; }

/* ---------- stat cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 26px; }
.card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  background: var(--surface); box-shadow: var(--shadow);
}
.card .n { font-size: 1.7rem; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.card .k { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- panels ---------- */
.panel {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  margin-bottom: 22px; overflow: hidden; box-shadow: var(--shadow);
}
.panel > header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.panel > header h2 { font-size: 14px; }
.panel .body { padding: 18px; }
.panel .empty { padding: 40px 18px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- table ---------- */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th {
  text-align: left; padding: 11px 18px; background: var(--surface-2);
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 700;
}
table.list td { padding: 13px 18px; border-top: 1px solid var(--border); vertical-align: top; color: var(--text); }
table.list tr:hover td { background: var(--surface-2); }
table.list a { font-weight: 600; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.grey { background: var(--surface-2); color: var(--muted); }
.badge.blue { background: var(--teal-soft); color: var(--teal-deep); }
.badge.ok   { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad  { background: var(--bad-soft); color: var(--bad); }

/* ---------- forms ---------- */
form.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint, .hint { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea {
  font: inherit; font-size: 14.5px; padding: 10px 12px;
  border: 1px solid var(--border-2); border-radius: 9px;
  background: var(--surface); color: var(--text); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft);
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.field .err, .err { color: var(--bad); font-size: 12.5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

/* ---------- auth ---------- */
.auth-card {
  max-width: 420px; margin: 56px auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); margin-bottom: 22px; font-size: 14.5px; }
.auth-card .alt { margin-top: 18px; font-size: 14px; color: var(--muted); text-align: center; }

/* ---------- alerts ---------- */
.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; font-size: 14px; border: 1px solid; }
.alert.ok   { background: var(--ok-soft);   border-color: color-mix(in srgb, var(--ok) 30%, white);   color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, white); color: var(--warn); }
.alert.bad  { background: var(--bad-soft);  border-color: color-mix(in srgb, var(--bad) 30%, white);  color: var(--bad); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- ticket thread ---------- */
.thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.msg { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface); max-width: 82%; box-shadow: var(--shadow); }
.msg.admin { align-self: flex-start; border-left: 3px solid var(--teal); }
.msg.provider { align-self: flex-end; background: var(--surface-2); box-shadow: none; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.msg .meta strong { color: var(--ink); }
.msg .body { white-space: pre-wrap; font-size: 14.5px; color: var(--text); }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 9px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }

pre.code { background: var(--ink); color: #E6EFEC; padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-size: 13px; font-family: var(--mono); line-height: 1.6; }
pre.code .k { color: var(--teal-bright); }
pre.code .s { color: #d7e8e3; }
pre.code .n { color: #f0c987; }
pre.code .c { color: #7c9a94; }

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

/* ---------- field reference ---------- */
.spec-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin: 14px 0 8px; }
table.spec { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.spec thead th {
  text-align: left; padding: 10px 14px; background: var(--surface-2);
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700;
  position: sticky; top: 0;
}
table.spec td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: top; }
table.spec tbody tr:hover td { background: var(--surface-2); }
table.spec .fld { font-family: var(--mono); font-size: 12.5px; color: var(--teal-deep); white-space: nowrap; }
table.spec .ty { color: var(--muted); white-space: nowrap; }
table.spec .ex { font-family: var(--mono); font-size: 12px; color: var(--text); }
table.spec .note { color: var(--muted); }
table.spec caption { text-align: left; font-weight: 600; color: var(--ink); padding: 12px 14px 4px; font-size: 14px; }

.req  { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: var(--bad-soft); color: var(--bad); }
.rec  { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: var(--teal-soft); color: var(--teal-deep); }
.opt  { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: var(--surface-2); color: var(--muted); }
.cond { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: var(--warn-soft); color: var(--warn); }

details.spec-block { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 6px 0 0; }
details.spec-block > summary {
  padding: 13px 16px; cursor: pointer; font-weight: 600; color: var(--ink); font-size: 14px;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
details.spec-block > summary::-webkit-details-marker { display: none; }
details.spec-block > summary::before { content: "▸"; color: var(--teal); font-size: 12px; }
details.spec-block[open] > summary::before { content: "▾"; }
details.spec-block[open] > summary { border-bottom: 1px solid var(--border); }
details.spec-block .inner { padding: 4px 16px 16px; }

.enum-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0; }
.enum-list code { background: var(--surface-2); }

.samples-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 14px 16px; margin-bottom: 14px;
  background: var(--teal-soft); border: 1px solid color-mix(in srgb, var(--teal) 20%, transparent);
  border-radius: var(--radius);
}
.samples-row > span { font-size: 13.5px; font-weight: 600; color: var(--teal-deep); }
.samples-row a { color: var(--teal-deep); }

.footer { border-top: 1px solid var(--border); padding: 26px 24px; text-align: center; color: var(--muted); font-size: 13.5px; background: var(--surface); }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--teal); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .portal { grid-template-columns: 1fr; }
  .portal aside {
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px;
    border-right: none; border-bottom: 1px solid var(--border); padding: 12px 16px;
  }
  .portal aside .brand { margin: 0 12px 0 0; }
  .portal aside .group-label, .portal aside .who { display: none; }
  .portal aside a.active::before { display: none; }
  .portal main { padding: 24px 18px 70px; }
  .form-row { grid-template-columns: 1fr; }
  .msg { max-width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; font-weight: 600; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto; }
  .btn:hover { transform: none; }
}
