:root {
  --brand:   #1a56a0;
  --brand-d: #143f7a;
  --green:   #16a34a;
  --red:     #dc2626;
  --amber:   #d97706;
  --grey:    #6b7280;
  --bg:      #f8fafc;
  --surface: #ffffff;
  --border:  #e2e8f0;
  --text:    #1e293b;
  --muted:   #64748b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  min-height: 100vh;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

/* ── Full-page centered wrapper (login/verify) ── */
.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: #f4f6f9;
  padding: 24px 16px;
}

/* ── Layout ─────────────────────────────── */
.nav {
  background: var(--brand);
  color: #fff;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 1rem;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; flex: 1; letter-spacing: -.3px; }
.nav a { color: rgba(255,255,255,.85); text-decoration: none; font-size: .9rem; padding: .25rem .5rem; border-radius: 4px; cursor: pointer; }
.nav a:hover { background: rgba(255,255,255,.15); color: #fff; }

.container { max-width: 860px; margin: 0 auto; padding: 2rem 1rem; }

.page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.25rem; }

/* ── Cards ──────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-title { font-weight: 600; font-size: 1rem; margin-bottom: .35rem; }
.card-meta  { color: var(--muted); font-size: .85rem; }
.card-row   { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ── Buttons ────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .5rem 1.1rem; border-radius: 6px; font-size: .9rem;
  font-weight: 500; cursor: pointer; border: none; text-decoration: none;
  transition: opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--brand);  color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--brand-d); }
.btn-success  { background: var(--green);  color: #fff; }
.btn-success:hover:not(:disabled)  { opacity: .88; }
.btn-danger   { background: var(--red);    color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: .3rem .75rem; font-size: .82rem; }

/* ── Forms ──────────────────────────────── */
.form-group { margin-bottom: 1rem; }
label { display: block; font-weight: 500; font-size: .88rem; margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=number], textarea, select {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: .95rem; background: #fff;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); }
textarea { resize: vertical; min-height: 80px; }

/* ── Save button ────────────────────────── */
.save-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: none; background: none; cursor: pointer;
  font-size: .78rem; font-weight: 600; color: var(--muted);
  padding: 5px 10px; border-radius: 20px; transition: color .15s, background .15s;
  white-space: nowrap;
}
.save-btn:hover { color: var(--brand); background: #eff6ff; }
.save-btn--saved { color: var(--brand); background: #eff6ff; }

/* ── Badges ─────────────────────────────── */
.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.badge-open    { background: #dbeafe; color: #1d4ed8; }
.badge-awarded { background: #d1fae5; color: #065f46; }
.badge-closed  { background: #f1f5f9; color: var(--grey); }
.badge-draft   { background: #fef3c7; color: #92400e; }
.badge-pending    { background: #fef3c7; color: #92400e; }
.badge-funded     { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress{ background: #ede9fe; color: #5b21b6; }
.badge-submitted  { background: #ffedd5; color: #9a3412; }
.badge-released   { background: #d1fae5; color: #065f46; }

/* ── Ledger table ───────────────────────── */
.ledger-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.ledger-table th { text-align: left; padding: .5rem .75rem; border-bottom: 2px solid var(--border); font-weight: 600; color: var(--muted); }
.ledger-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.ledger-table tr:last-child td { border-bottom: none; }

/* ── Flash ──────────────────────────────── */
.flash {
  position: fixed; top: 64px; right: 1rem; z-index: 999;
  padding: .75rem 1.25rem; border-radius: 6px; font-size: .9rem; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.flash-success { background: var(--green); color: #fff; }
.flash-error   { background: var(--red);   color: #fff; }

/* ── Misc ───────────────────────────────── */
.error-msg { color: var(--red); font-size: .88rem; margin-top: .4rem; }
.muted { color: var(--muted); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.text-right { text-align: right; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex-1 { flex: 1; }

/* milestone row */
.ms-row { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.ms-row:last-child { border-bottom: none; }
.ms-desc { flex: 1; }
.ms-amount { font-weight: 600; white-space: nowrap; }
.ms-status { white-space: nowrap; }

/* ── Feed cards ─────────────────────────── */
.feed-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 18px 20px; margin-bottom: 10px; transition: box-shadow .15s, border-color .15s;
}
.feed-card-top   { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.feed-card-title { font-size: .98rem; font-weight: 700; color: var(--text); cursor: pointer; line-height: 1.3; margin: 0; }
.feed-card-meta  { font-size: 12px; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.feed-card-desc  { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.feed-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.feed-card-cta   { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Feed two-column layout ── */
.feed-wrap    { max-width: 1100px; margin: 0 auto; padding: 28px 20px; display: flex; gap: 24px; align-items: flex-start; }
.feed-sidebar { width: 200px; flex-shrink: 0; }

/* ── Opportunity detail two-column layout ── */
.opp-layout { display: flex; gap: 24px; align-items: flex-start; }
.opp-main   { flex: 1; min-width: 0; }
.opp-sidebar { width: 260px; flex-shrink: 0; position: sticky; top: 20px; }

/* ── Feed filter collapse ───────────────── */
.feed-filter-trigger {
  display: none;
}
.feed-filter-panel {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px;
}
.feed-filter-chevron { transition: transform .2s; margin-left: auto; }
.feed-filter-chevron.open { transform: rotate(180deg); }

/* ── Nav hamburger ──────────────────────── */
.nav-hamburger {
  display: none; background: none; border: none; color: #fff;
  cursor: pointer; padding: .3rem; margin-left: auto; line-height: 1;
}
.nav-links { display: flex; align-items: center; gap: 1rem; flex-wrap: nowrap; }

/* ── Ledger cards (mobile) ──────────────── */
.ledger-cards { display: none; }
.ledger-card {
  border: 1px solid var(--border); border-radius: 8px;
  padding: .75rem 1rem; margin-bottom: .6rem;
}
.ledger-card:last-child { margin-bottom: 0; }
.ledger-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .2rem; font-size: .9rem; text-transform: capitalize; }
.ledger-card-meta { font-size: .75rem; color: var(--muted); margin-bottom: .45rem; }
.ledger-card-row { display: flex; gap: .5rem; font-size: .82rem; margin-top: .25rem; }
.ledger-card-label { color: var(--muted); font-weight: 600; min-width: 68px; flex-shrink: 0; }

/* ── Mobile ─────────────────────────────── */
@media (max-width: 700px) {
  /* Nav hamburger */
  .nav { height: auto; padding: 0 1rem; position: relative; flex-wrap: wrap; }
  .nav-brand { flex: 1; line-height: 56px; }
  .nav-hamburger { display: block; line-height: 56px; padding: 0; }
  .nav-links {
    display: none; width: 100%; flex-direction: column; align-items: flex-start;
    gap: 0; padding: .5rem 0 .75rem; border-top: 1px solid rgba(255,255,255,.15);
  }
  .nav-links.open { display: flex; }
  .nav a { width: 100%; padding: .55rem .25rem; font-size: .92rem; border-radius: 0; }

  /* Feed: sidebar stacks above content */
  .container { padding: 1rem .75rem; }

  /* Two-column feed layout */
  .feed-wrap { flex-direction: column; padding: 16px 12px; }
  .feed-sidebar { width: 100%; }

  /* Filter trigger visible, panel hidden until open */
  .feed-filter-trigger {
    display: flex; align-items: center; gap: 8px;
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 14px; cursor: pointer; font-size: .88rem; color: var(--muted);
    font-weight: 500; width: 100%;
  }
  .feed-filter-panel { display: none; margin-top: 8px; border-radius: 10px; }
  .feed-filter-panel.open { display: block; }

  /* Feed cards: full-width CTA on mobile */
  .feed-card { padding: 14px 16px; }
  .feed-card-bottom { flex-direction: column; align-items: stretch; gap: 10px; }
  .feed-card-cta { justify-content: space-between; border-top: 1px solid var(--border); padding-top: 10px; }
  .feed-card-cta button:first-child { flex: 1; }

  /* Opportunity detail sidebar stacks below on mobile */
  .opp-layout { flex-direction: column; }
  .opp-sidebar { width: 100%; position: static; order: -1; }

  /* Hide timeAgo duplicate on cards */
  .card-row { flex-wrap: wrap; }

  /* Milestone rows on mobile */
  .ms-row { flex-wrap: wrap; gap: .4rem; }
  .ms-amount { margin-left: auto; }

  /* Ledger: swap table for cards on mobile */
  .ledger-desktop { display: none; }
  .ledger-cards { display: block; }
}
