/* KVS Capital Register — dark navy / gold design */
:root {
  --navy: #0d1b2a;
  --navy2: #152235;
  --navy3: #1e3351;
  --gold: #c9a84c;
  --gold-light: #e8c97a;
  --text: #e8edf3;
  --text-muted: #8fa3b8;
  --border: #2a4060;
  --danger: #c0392b;
  --success: #27ae60;
  --warn: #e67e22;
  --info: #2980b9;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

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

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--navy);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── NAV ── */
nav {
  background: var(--navy2);
  border-bottom: 2px solid var(--gold);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 0;
  height: 54px;
}
nav .brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .03em;
  margin-right: 2rem;
  white-space: nowrap;
}
nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0 1rem;
  height: 54px;
  display: flex;
  align-items: center;
  font-size: .9rem;
  transition: color .15s, border-bottom .15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
nav a:hover, nav a.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold-light);
}

/* ── LAYOUT ── */
main {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
}

footer {
  background: var(--navy2);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .78rem;
  text-align: center;
  padding: .75rem 1rem;
  letter-spacing: .04em;
}

/* ── TYPOGRAPHY ── */
h1 { font-size: 1.6rem; font-weight: 700; color: var(--gold); margin-bottom: 1.2rem; }
h2 { font-size: 1.2rem; font-weight: 600; color: var(--gold-light); margin: 1.8rem 0 .8rem; }
h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin: 1.2rem 0 .5rem; }
p  { line-height: 1.6; color: var(--text-muted); margin-bottom: .75rem; }
a  { color: var(--gold-light); }

/* ── CARDS ── */
.card {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.stats-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.stat-box {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  min-width: 140px;
  flex: 1;
}
.stat-box .val {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
}
.stat-box .lbl {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ── BADGES ── */
.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .03em;
  vertical-align: middle;
}
.badge-green  { background: #1a4a2e; color: #5bdb8a; border: 1px solid #27ae60; }
.badge-amber  { background: #3d2a00; color: #f0b429; border: 1px solid #e67e22; }
.badge-red    { background: #3d0d0d; color: #f56565; border: 1px solid #c0392b; }
.badge-blue   { background: #0d2a3d; color: #63b3ed; border: 1px solid #2980b9; }
.badge-grey   { background: #1a2535; color: #8fa3b8; border: 1px solid #2a4060; }
.badge-gold   { background: #3d2a00; color: var(--gold-light); border: 1px solid var(--gold); }

.badge-holding { background: #1a2535; color: #90cdf4; border: 1px solid #3182ce; }
.badge-spv     { background: #2d1b4e; color: #b794f4; border: 1px solid #805ad5; }
.badge-opco    { background: #1a3a2e; color: #68d391; border: 1px solid #38a169; }
.badge-venture { background: #2d1b00; color: #f6ad55; border: 1px solid #dd6b20; }
.badge-other   { background: #1a2535; color: #8fa3b8; border: 1px solid #2a4060; }

/* ── TABLES ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  margin-bottom: 1rem;
}
thead th {
  background: var(--navy3);
  color: var(--gold);
  font-weight: 600;
  padding: .6rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: rgba(201,168,76,.06); }
td { padding: .55rem .9rem; vertical-align: middle; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

/* ── FORMS ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.form-row { display: flex; flex-direction: column; gap: .3rem; }
label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
input[type=text], input[type=number], input[type=date],
select, textarea {
  background: var(--navy3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .45rem .7rem;
  font-size: .88rem;
  font-family: var(--font);
  width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
}
textarea { resize: vertical; min-height: 60px; }
select option { background: var(--navy2); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-gold    { background: var(--gold); color: var(--navy); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-sm      { padding: .3rem .7rem; font-size: .78rem; }

.btn-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }

/* ── TREE ── */
.tree { list-style: none; padding: 0; }
.tree li { position: relative; }
.tree-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
  border-radius: var(--radius);
  transition: background .1s;
}
.tree-item:hover { background: rgba(255,255,255,.04); }
.tree-item a { color: var(--text); text-decoration: none; font-weight: 500; }
.tree-item a:hover { color: var(--gold-light); }
.tree-children { margin-left: 1.3rem; border-left: 2px solid rgba(201,169,97,.38); padding-left: 0; }
.tree-children > .tree > li { padding-left: 1.15rem; }
.tree-children > .tree > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.05rem;
  width: .95rem;
  border-top: 2px solid rgba(201,169,97,.38);
}

/* ── PERCENT BAR ── */
.pct-bar-wrap { display: flex; align-items: center; gap: .6rem; }
.pct-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--navy3);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}
.pct-bar-fill { height: 100%; background: var(--gold); border-radius: 3px; }
.pct-val { font-size: .8rem; color: var(--gold-light); min-width: 44px; text-align: right; }

/* ── INTEREST MATRIX ── */
.matrix-wrap { overflow-x: auto; }
.matrix-table th.entity-col { max-width: 120px; }
.matrix-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--gold-light);
}
.matrix-cell.zero { color: var(--text-muted); }

/* ── SIMULATOR ── */
.sim-form { max-width: 600px; }
.sim-results { margin-top: 1.5rem; }
.winning-cap      { color: #68d391; font-weight: 600; }
.winning-discount { color: #f6ad55; font-weight: 600; }
.winning-round    { color: #90cdf4; font-weight: 600; }

/* ── ALERT ── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 1rem;
}
.alert-info { background: #0d2a3d; border: 1px solid #2980b9; color: #90cdf4; }
.alert-warn { background: #2d1a00; border: 1px solid #e67e22; color: #f6ad55; }

/* ── UTILS ── */
.text-muted   { color: var(--text-muted); }
.text-gold    { color: var(--gold); }
.text-sm      { font-size: .82rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.sep { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin-bottom: 1.2rem;
}
.filter-bar .form-row { min-width: 160px; }

/* ── EXPANDABLE FORM ── */
details summary {
  cursor: pointer;
  color: var(--gold);
  font-weight: 600;
  font-size: .9rem;
  padding: .5rem 0;
  user-select: none;
}
details summary:hover { color: var(--gold-light); }
details .form-inner {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-top: .4rem;
}

/* ── AUTH PAGES ── */
.auth-wrap {
  max-width: 400px;
  margin: 4rem auto;
}
.auth-wrap h1 { text-align: center; margin-bottom: 1.5rem; }
.auth-logo {
  text-align: center;
  font-size: 2rem;
  color: var(--gold);
  letter-spacing: .1em;
  font-weight: 800;
  margin-bottom: .5rem;
}

/* ── NAV USER ── */
.nav-user {
  font-size: .82rem;
  color: var(--text-muted);
  margin-left: .75rem;
  white-space: nowrap;
}

/* ── PORTAL GRID ── */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.2rem;
  margin-top: 1rem;
}
.portal-card {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, background .15s;
  display: block;
}
.portal-card:hover {
  border-color: var(--gold);
  background: var(--navy3);
  color: var(--text);
}
.portal-card .pc-name { font-weight: 600; font-size: 1rem; margin: .4rem 0 .3rem; }
.portal-card .pc-meta { font-size: .8rem; color: var(--text-muted); }
.portal-card .pc-count { font-size: .82rem; color: var(--gold-light); margin-top: .4rem; }

/* ── BADGE STATUS PORTAL ── */
.badge-draft  { background: #1a2535; color: #8fa3b8; border: 1px solid #2a4060; }
.badge-final  { background: #3d2a00; color: var(--gold-light); border: 1px solid var(--gold); }
.badge-signed { background: #1a4a2e; color: #5bdb8a; border: 1px solid #27ae60; }

/* ── 403 ── */
.err-wrap { max-width: 500px; margin: 5rem auto; text-align: center; }
.err-code { font-size: 5rem; font-weight: 800; color: var(--gold); line-height: 1; }
.err-msg  { font-size: 1.2rem; color: var(--text-muted); margin: 1rem 0 2rem; }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  main { padding: 1rem; }
  nav  { padding: 0 1rem; }
  .stats-row { gap: .5rem; }
}
