/* Norvane client app. Brand: knowledge/brand.md (blue and white).
   Strict CSP: every style lives here. No style="" attributes, no <style> blocks.
   Phone first. Hairlines, no shadows. 8px corners on controls, 12px on cards. */
:root {
  --navy: #0B1B3A;
  --blue: #1D4ED8;
  --blue-hover: #1A44BF;
  --bright: #3D7BFF;
  --light: #EAF1FF;
  --white: #FFFFFF;
  --page: #F6F8FC;
  --ink: #0B1B3A;
  --ink-2: #44506A;
  --ink-3: #5C6782;
  --line: #DCE3F0;
  --line-2: #C9D5EC;
  --good: #15803D;
  --good-bg: #E8F5EC;
  --warn: #A15C07;
  --warn-bg: #FDF3E4;
  --bad: #B91C1C;
  --bad-bg: #FDECEC;
  --f-head: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--blue); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--f-head); font-weight: 600; margin: 0; color: var(--ink); letter-spacing: -0.02em; }
h1 { font-size: clamp(1.5rem, 5vw, 2rem); line-height: 1.15; }
h2 { font-size: 1.15rem; line-height: 1.3; margin-bottom: 12px; }
h3 { font-size: .95rem; line-height: 1.3; font-family: var(--f-body); font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
p { margin: 0 0 12px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--light); padding: 2px 6px; border-radius: 4px; word-break: break-all; }
:focus-visible { outline: 2px solid var(--bright); outline-offset: 2px; }

.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 48px; outline: none; }
.narrow { max-width: 440px; margin: 24px auto 0; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.eyebrow { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); font-weight: 600; margin: 0 0 4px; }

/* Header and footer */
.top { background: var(--navy); color: var(--white); }
.top-in { max-width: 960px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; }
.brand { flex-shrink: 0; padding: 4px 0; }
.brand img { height: 28px; width: auto; }
.top-actions { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; justify-content: flex-end; margin-left: auto; }
.foot { border-top: 1px solid var(--line); background: var(--white); font-size: .875rem; color: var(--ink-3); }
.foot-in { display: flex; gap: 16px; padding-top: 16px; padding-bottom: 16px; flex-wrap: wrap; }
.foot a { color: var(--ink-2); }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--blue); background: var(--blue); color: var(--white);
  font: 600 .95rem/1 var(--f-body); padding: 12px 18px; border-radius: 8px; cursor: pointer; min-height: 44px;
}
.btn:hover { background: var(--blue-hover); }
.btn.ghost { background: var(--white); color: var(--blue); }
.btn.ghost:hover { background: var(--light); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.is-busy { cursor: progress; }
.link-btn { appearance: none; background: none; border: 0; color: var(--blue); font: 500 .9rem var(--f-body); cursor: pointer; padding: 10px 8px; min-height: 44px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.on-dark { color: rgba(255,255,255,.85); }
.link-btn.on-dark:hover { color: var(--white); }
.link-btn.danger { color: var(--bad); }
.link-btn.back { padding-left: 0; margin-bottom: 8px; }
.alert-btn { appearance: none; border: 1px solid rgba(255,255,255,.25); background: transparent; color: var(--white); font: 500 .9rem var(--f-body); border-radius: 8px; padding: 8px 12px; min-height: 40px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.alert-btn:hover { border-color: rgba(255,255,255,.5); }
.alert-btn .count { background: var(--white); color: var(--navy); font-weight: 600; font-size: .75rem; border-radius: 999px; padding: 1px 7px; min-width: 22px; text-align: center; }

/* Cards and layout */
.card { background: var(--white); border: 1px solid var(--line-2); border-radius: 12px; padding: 20px 16px; margin-bottom: 16px; }
.card > :last-child { margin-bottom: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.row-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.row-head h2 { margin: 0; }
.stack, .grid-form { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) {
  .card { padding: 24px; }
  .grid-form { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-items: end; }
}

/* Forms */
.field { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.field-label { font-weight: 600; font-size: .9rem; }
.hint { font-size: .8rem; color: var(--ink-3); }
input[type=text], input[type=email], input[type=tel], input[type=url], input[type=number], input[type=month], select, textarea {
  width: 100%; font: 400 1rem var(--f-body); color: var(--ink); background: var(--white);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 2px solid var(--light); }
input[type=file] { font: inherit; max-width: 100%; }
.code { font-size: 1.4rem; letter-spacing: .3em; text-align: center; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; min-height: 44px; }
.check input { width: 20px; height: 20px; }
.qr { width: 200px; height: 200px; margin: 8px auto 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
details.add summary, details summary { cursor: pointer; font-weight: 600; color: var(--blue); min-height: 32px; }
details.add[open] summary { margin-bottom: 14px; }
.snippet { background: var(--navy); color: #DCE6FF; padding: 14px; border-radius: 8px; overflow-x: auto; font-size: .78rem; line-height: 1.5; white-space: pre; }
.key { font-size: .95rem; }
.switcher { width: auto; min-width: 200px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 12px; font: 600 .95rem var(--f-body); color: var(--ink-3); cursor: pointer; white-space: nowrap; min-height: 44px; }
.tab[aria-selected=true] { color: var(--blue); border-bottom-color: var(--blue); }
.tab:hover { color: var(--ink); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.row-main { flex: 1 1 220px; }
.row:first-child { border-top: 0; }
.row.clickable { cursor: pointer; }
.row.clickable:hover .row-main strong { color: var(--blue); }
.row.unread strong::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-right: 8px; vertical-align: middle; }
.row-main { display: grid; gap: 2px; min-width: 0; }
.row-main strong { overflow-wrap: anywhere; }
.row-side { display: flex; gap: 6px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; border-radius: 999px; padding: 3px 10px; background: var(--light); color: var(--ink-2); white-space: nowrap; }
.badge.new { background: var(--light); color: var(--blue); }
.badge.working { background: var(--warn-bg); color: var(--warn); }
.badge.done { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

/* Numbers */
.metrics { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 16px; }
@media (min-width: 600px) { .metrics { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
.metric { background: var(--white); border: 1px solid var(--line-2); border-radius: 12px; padding: 16px; display: grid; gap: 10px; align-content: start; }
.metric-line { display: grid; gap: 2px; }
.metric-val { font-family: var(--f-head); font-weight: 600; font-size: 1.75rem; line-height: 1.1; color: var(--navy); }
.metric-sub { font-size: .8rem; color: var(--ink-3); }
.change { font-size: .8rem; font-weight: 600; }
.change.up { color: var(--good); }
.change.down { color: var(--ink-3); }
.row-head select { width: auto; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--white); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px; text-align: center; display: grid; }
.stat strong { font-family: var(--f-head); font-size: 1.4rem; font-weight: 600; }
.stat span { font-size: .8rem; color: var(--ink-3); }

/* Leads */
.lead { border-top: 1px solid var(--line); padding: 14px 0; display: grid; gap: 8px; }
.lead:first-child { border-top: 0; padding-top: 0; }
.lead-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.lead-top select { width: auto; min-width: 140px; }
.lead-contact { display: flex; gap: 16px; flex-wrap: wrap; }
.lead-contact a { overflow-wrap: anywhere; }
.lead p { margin: 0; }
.lead .link-btn { justify-self: start; padding-left: 0; }

/* Requests */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 12px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thread { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.thread li { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.thread li.from-staff { background: var(--light); border-color: var(--line-2); }
.thread p { margin: 4px 0 0; }
.form-source { border-top: 1px solid var(--line); padding: 16px 0; display: grid; gap: 12px; }
.form-source:first-of-type { border-top: 0; padding-top: 0; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--navy); color: var(--white); padding: 12px 18px; border-radius: 8px; font-size: .95rem; max-width: calc(100% - 32px); z-index: 10; }

/* Privacy page */
.doc { max-width: 680px; }
.doc h2 { margin-top: 24px; }
.doc ul { padding-left: 20px; }
.doc li { margin-bottom: 6px; }
