/* ─── Partner 360 — design tokens ───
   Derived from the OpenAFF brand book (Brandbook OpenAFF.pdf):
   - OpenAFF blue gradient (#001e4b → #000a22) — background
   - OpenAFF cian (#00ffff) — UI/text accents
   - OpenAFF gradient (#1BCEEF → #00D37E) — brand mark, used sparingly
     for the logotype and primary CTAs
   - OpenAFF black (#000000) — brand-mark ink, not used on this dark UI
   Fonts: brand faces are Zero Hour (Latin) + EBENYA (Cyrillic) for
   display, Futura PT for body/h2/h3. Neither is a free web font, so
   the closest Cyrillic-complete open equivalents are used instead:
   Unbounded (display — geometric, full Cyrillic) and Montserrat
   (body — the standard free stand-in for Futura, full Cyrillic). */
:root {
  --bg:          #000a22;
  --bg-elev-1:   #071a3a;
  --bg-elev-2:   #0f2650;
  --border:      #1f3a63;
  --text:        #eaf2ff;
  --muted:       #7d93b8;
  --brand-cyan:      #00ffff;
  --brand-grad-from: #1bceef;
  --brand-grad-to:   #00d37e;
  --brand-navy-from: #001e4b;
  --brand-navy-to:   #000a22;
  --primary:     var(--brand-cyan);
  --primary-dk:  #00b3b3;
  --on-primary:  #00121a;
  --gradient-brand: linear-gradient(135deg, var(--brand-grad-from), var(--brand-grad-to));
  --accent:      #00d37e;
  --warning:     #d29922;
  --danger:      #f85149;
  --tier1:       #00d37e;
  --tier2:       #d29922;
  --tier3:       #7d93b8;
  --white:       #ffffff;

  --font-display: 'Unbounded', 'Futura PT', sans-serif;
  --font-body:    'Montserrat', 'Futura PT', system-ui, -apple-system, sans-serif;

  --fs-display: clamp(28px, 4vw, 40px);
  --fs-h2:      clamp(22px, 3vw, 28px);
  --fs-h3:      17px;
  --fs-body:    15px;
  --fs-label:   11px;
  --ls-label:   0.1em;

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 16px;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.4);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text);
  background: radial-gradient(1200px 800px at 15% -10%, var(--brand-navy-from) 0%, var(--brand-navy-to) 55%) fixed,
              var(--bg);
  font-family: var(--font-body); font-size: var(--fs-body); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ─── Header ─── */
.app-header {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3) var(--space-5);
  padding: calc(var(--space-3) + var(--safe-top)) var(--space-5) var(--space-3);
  background: var(--bg-elev-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand span {
  background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.header-nav { display: flex; align-items: center; gap: var(--space-3); flex-wrap: nowrap; flex-shrink: 0; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); flex-wrap: nowrap; flex-shrink: 0; }
.username { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* On narrow screens the three groups (brand / nav / right) wrap onto their
   own full-width rows instead of each shrinking and wrapping its own text
   mid-word — see PLAN.md UI notes. */
@media (max-width: 560px) {
  .app-header { padding-left: var(--space-4); padding-right: var(--space-4); }
  .header-nav, .header-right { flex-basis: 100%; justify-content: space-between; }
  .header-right { order: 2; }
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 10px 16px; border-radius: var(--radius); border: 1px solid transparent;
  font-weight: 600; cursor: pointer; background: var(--bg-elev-2); color: var(--text);
  transition: transform .15s, background .15s, border-color .15s;
  min-height: 40px; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--gradient-brand); color: var(--on-primary); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 32px; }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }

/* ─── Layout ─── */
.content { padding: var(--space-5); max-width: 1200px; margin: 0 auto; padding-bottom: calc(var(--space-6) + var(--safe-bottom)); }
.page-title { font-size: var(--fs-h2); margin: 0 0 var(--space-4); font-family: var(--font-display); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }

/* ─── Toolbar (search + filters) ─── */
.toolbar { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-5); }
.search-input {
  flex: 1 1 280px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-elev-1); color: var(--text); min-height: 40px;
}
.search-input:focus { outline: none; border-color: var(--primary); }
.chip-group { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev-1);
  color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip.active { color: var(--on-primary); background: var(--primary); border-color: var(--primary); font-weight: 700; }
.select-sort {
  padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-elev-1); color: var(--text); min-height: 40px;
}

/* ─── Partner list ─── */
.partner-list { display: flex; flex-direction: column; gap: var(--space-3); }
.partner-row {
  display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4);
  background: var(--bg-elev-1); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, transform .15s;
}
.partner-row:hover { border-color: var(--primary); transform: translateY(-1px); text-decoration: none; }
.partner-avatar {
  width: 44px; height: 44px; border-radius: 999px; background: var(--bg-elev-2);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--primary);
  flex-shrink: 0; font-size: 15px;
}
.partner-main { flex: 1; min-width: 0; }
.partner-name { font-weight: 700; color: var(--text); font-size: 16px; }
.partner-meta { color: var(--muted); font-size: 13px; margin-top: 2px; display: flex; gap: var(--space-3); flex-wrap: wrap; }
.partner-badges { display: flex; gap: var(--space-2); flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.partner-score { font-weight: 700; color: var(--primary); font-size: 15px; width: 32px; text-align: center; flex-shrink: 0; }
.empty-state { text-align: center; padding: var(--space-7) var(--space-4); color: var(--muted); }

/* ─── Badges ─── */
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge-crypto { background: rgba(0,255,255,.15); color: var(--primary); }
.badge-tier1 { background: rgba(0,211,126,.15); color: var(--tier1); }
.badge-tier2 { background: rgba(210,153,34,.15); color: var(--tier2); }
.badge-tier3 { background: rgba(125,147,184,.15); color: var(--tier3); }
.badge-rating-high { background: rgba(0,211,126,.15); color: var(--accent); }
.badge-rating-medium { background: rgba(210,153,34,.15); color: var(--warning); }
.badge-rating-low { background: rgba(248,81,73,.12); color: var(--danger); }
.badge-rating-unrated { background: var(--bg-elev-2); color: var(--muted); }

/* ─── Cards / panel ─── */
.card {
  background: var(--bg-elev-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-4);
}
.panel { background: var(--bg-elev-1); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); margin-bottom: var(--space-5); }
.section-label {
  font-size: var(--fs-label); text-transform: uppercase; letter-spacing: var(--ls-label);
  color: var(--primary); font-weight: 700; margin-bottom: var(--space-3); display: block;
}

/* ─── Partner detail: two-column ─── */
.detail-grid { display: grid; grid-template-columns: 320px 1fr; gap: var(--space-5); align-items: start; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; } }
.identity-card .partner-name-lg { font-size: 22px; font-weight: 700; font-family: var(--font-display); margin-bottom: var(--space-1); }
.identity-card .partner-id { color: var(--muted); font-size: 12px; font-family: monospace; margin-bottom: var(--space-4); }
.identity-row { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.identity-row:last-child { border-bottom: none; }
.identity-row .k { color: var(--muted); }
.identity-row .v { text-align: right; word-break: break-word; }
.sticky-sidebar { position: sticky; top: calc(72px + var(--space-4)); }

/* ─── Timeline ─── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: var(--space-4); }
.timeline-item::before {
  content: ""; position: absolute; left: -28px; top: 6px; width: 10px; height: 10px; border-radius: 999px;
  background: var(--primary); border: 2px solid var(--bg);
}
.timeline-date { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: var(--space-1); }
.timeline-event { font-weight: 700; margin-bottom: var(--space-2); }
.timeline-body p { margin: 0 0 var(--space-2); color: var(--text); }
.timeline-label { font-size: 11px; text-transform: uppercase; letter-spacing: var(--ls-label); color: var(--muted); font-weight: 600; }

/* ─── Forms ─── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.form-group { margin-bottom: var(--space-4); }
.form-group label {
  display: block; font-size: var(--fs-label); text-transform: uppercase; letter-spacing: var(--ls-label);
  color: var(--muted); font-weight: 600; margin-bottom: var(--space-2);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elev-2); color: var(--text); min-height: 40px;
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-actions { display: flex; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-4); }
.form-hint { color: var(--muted); font-size: 12px; margin-top: var(--space-1); }
.field-error { color: var(--danger); font-size: 12px; margin-top: var(--space-1); }

/* ─── Login page ─── */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-5); }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { font-size: 26px; text-align: center; display: block; margin-bottom: var(--space-6); }

/* ─── Misc ─── */
.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.flash { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); margin-bottom: var(--space-4); font-size: 14px; }
.flash-error { background: rgba(248,81,73,.12); color: var(--danger); border: 1px solid rgba(248,81,73,.3); }
.flash-ok { background: rgba(0,211,126,.12); color: var(--accent); border: 1px solid rgba(0,211,126,.3); }
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.offline-banner {
  display: none; background: var(--warning); color: #1a1300; text-align: center; padding: var(--space-2);
  font-size: 13px; font-weight: 600;
}
body.is-offline .offline-banner { display: block; }
