/* ── 121 Matrix Platform — Styles ── */
:root {
  --bni-red:    #c8102e;
  --bni-dark:   #1a1a2e;
  --accent:     #2563eb;
  --bg:         #f8fafc;
  --card:       #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --muted:      #64748b;
  --green:      #16a34a;
  --green-bg:   #dcfce7;
  --grey-bg:    #f1f5f9;
  --radius:     .75rem;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Topbar ── */
.topbar {
  background: var(--bni-dark);
  color: #fff;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.topbar .logo {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: .03em;
  color: #fff;
  text-decoration: none;
}
.topbar .logo span { color: var(--bni-red); }
.topbar nav a {
  color: #cbd5e1;
  text-decoration: none;
  margin-left: 1.25rem;
  font-size: .875rem;
  transition: color .15s;
}
.topbar nav a:hover, .topbar nav a.active { color: #fff; }

/* ── Page containers ── */
.page     { max-width: 1400px; margin: 0 auto; padding: 2rem 1.25rem; }
.page-sm  { max-width:  520px; margin: 0 auto; padding: 2rem 1.25rem; }
.page-md  { max-width:  860px; margin: 0 auto; padding: 2rem 1.25rem; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card + .card { margin-top: 1.25rem; }
.card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 1rem; }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.25rem; }
@media (max-width:640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Stat tiles ── */
.stat { text-align: center; padding: 1.25rem; }
.stat .num  { font-size: 2.4rem; font-weight: 800; color: var(--accent); line-height: 1; }
.stat .lbl  { font-size: .8rem;  color: var(--muted); margin-top: .25rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: .5rem;
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
  line-height: 1.4;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-red  { background: var(--bni-red); color: #fff; }
.btn-red:hover { background: #a50f26; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--grey-bg); }
.btn-sm   { padding: .3rem .7rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-gap  { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
input[type=text], input[type=email], input[type=password],
input[type=url], select, textarea {
  width: 100%;
  padding: .55rem .8rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  font-size: .875rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }

/* ── Alerts ── */
.alert {
  padding: .8rem 1rem;
  border-radius: .5rem;
  font-size: .875rem;
  margin-bottom: 1rem;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--green-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert ul      { padding-left: 1.25rem; margin-top: .4rem; }

/* ── Tables ── */
.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tbl th, .tbl td {
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.tbl th { background: var(--grey-bg); font-weight: 600; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--grey-bg); }
.tbl .muted { color: var(--muted); font-size: .8rem; }
.tbl .link-cell { font-family: monospace; font-size: .75rem; color: var(--muted); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green { background: var(--green-bg);  color: var(--green); }
.badge-grey  { background: var(--grey-bg);   color: var(--muted); }
.badge-red   { background: #fee2e2; color: var(--bni-red); }

/* ── Matrix ── */
.matrix-wrap {
  overflow: auto;
  max-height: 80vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.mtable {
  border-collapse: separate;
  border-spacing: 0;
  font-size: .75rem;
  white-space: nowrap;
}
.mtable th, .mtable td {
  padding: .3rem .45rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
/* Sticky first column */
.mtable .row-head {
  position: sticky;
  left: 0;
  background: var(--bni-dark);
  color: #fff;
  font-weight: 600;
  z-index: 1;
  min-width: 140px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Sticky header row */
.mtable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bni-dark);
  color: #fff;
}
.mtable thead .row-head { z-index: 3; }

/* Rotated column headers */
.mtable .col-head {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  height: 110px;
  vertical-align: bottom;
  padding: .4rem .2rem;
  max-width: 30px;
  min-width: 30px;
  font-size: .7rem;
  font-weight: 500;
}
/* Cells */
.mtable .c-yes  { background: var(--green-bg); color: var(--green); font-weight: 700; text-align: center; cursor: default; }
.mtable .c-me   { background: #eff6ff; }
.mtable .c-self { background: var(--grey-bg); text-align: center; color: #cbd5e1; }
.mtable .c-no   { background: #fff; }
.mtable tbody tr:hover td { filter: brightness(.97); }

/* ── My 121 list ── */
.m121-list { list-style: none; }
.m121-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.m121-list li:last-child { border-bottom: none; }
.m121-partner { font-weight: 600; }
.m121-date    { color: var(--muted); font-size: .85rem; }

/* ── Landing ── */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  text-align: center;
  padding: 2rem 1.25rem;
}
.landing h1 { font-size: 2rem; font-weight: 800; color: var(--bni-dark); }
.landing .sub { color: var(--muted); font-size: 1rem; margin: .75rem 0 2rem; max-width: 460px; }
.landing .bni-link {
  color: var(--muted);
  font-size: .85rem;
  margin-top: 2.5rem;
  text-decoration: none;
}
.landing .bni-link:hover { color: var(--text); }

/* ── Auth box ── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 2rem 1.25rem;
}
.auth-box {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.auth-box h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: .4rem; }
.auth-box .sub { color: var(--muted); font-size: .875rem; margin-bottom: 1.5rem; }

/* ── Topbar pill ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  padding: .25rem .75rem;
  font-size: .78rem;
  color: #cbd5e1;
}

/* ── Tooltip (title-based) ── */
[title] { cursor: help; }

/* ── Progress bar ── */
.progress { height: 8px; background: var(--grey-bg); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.progress-bar.green { background: var(--green); }

/* ── Admin layout extras ── */
.admin-body { background: #f1f5f9; }
.page-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-title h1 { font-size: 1.4rem; font-weight: 800; margin: 0; }
.page-title .sub { color: var(--muted); font-size: .875rem; margin: .2rem 0 0; }

/* ── Grid helpers ── */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
}
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.chapter-card { transition: box-shadow .2s; }
.chapter-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }

/* ── Mini stats ── */
.mini-stat { text-align: center; }
.mini-stat .num { font-size: 1.3rem; font-weight: 800; color: var(--fg); }
.mini-stat .lbl { font-size: .7rem; color: var(--muted); }

/* ── Card action ── */
.card-action {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .2s, transform .15s;
  cursor: pointer;
}
.card-action:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); }
.card-action .icon { font-size: 1.75rem; margin-bottom: .5rem; }
.card-action .label { font-weight: 700; font-size: .95rem; }
.card-action .desc { color: var(--muted); font-size: .8rem; margin-top: .2rem; }

/* ── Data table ── */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  text-align: left;
  padding: .5rem .75rem;
  background: var(--grey-bg);
  color: var(--muted);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.row-inactive td { opacity: .5; }

/* ── Form helpers ── */
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .875rem; cursor: pointer; }

/* ── Danger card ── */
.card-danger { border-color: #fecaca; background: #fff5f5; }

/* ── Button extras ── */
.btn-xs { font-size: .75rem; padding: .25rem .6rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--accent); color: #fff; }
.btn-secondary:hover { background: #1d4ed8; }
.btn-sm { font-size: .8rem; padding: .35rem .8rem; }
.btn-block { width: 100%; }

/* ── Badge extras ── */
.badge-grey { background: var(--grey-bg); color: var(--muted); }

/* ── Link list (links.php) ── */
.link-textarea {
  width: 100%;
  font-family: monospace;
  font-size: .78rem;
  background: var(--grey-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  resize: vertical;
}
.member-link-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.member-link-row:last-child { border-bottom: none; }

/* ── Code ── */
code {
  background: var(--grey-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1em .4em;
  font-size: .85em;
}

/* ── Matrix cell colors: age-based ── */
.c-green  { background: #bbf7d0; color: #14532d; font-size: .68rem; text-align: center; }
.c-yellow { background: #fef08a; color: #713f12; font-size: .68rem; text-align: center; }
.c-orange { background: #fed7aa; color: #7c2d12; font-size: .68rem; text-align: center; }
.c-no     { background: var(--grey-bg); }
.c-self   { background: #e2e8f0; color: var(--muted); text-align: center; font-size: .8rem; }
.c-me-border { outline: 2px solid var(--accent); outline-offset: -2px; }
.c-me-col  { background: #eff6ff !important; }

/* ── Legend dots ── */
.legend-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 3px;
}
.l-green  { background: #bbf7d0; border: 1px solid #86efac; }
.l-yellow { background: #fef08a; border: 1px solid #fde047; }
.l-orange { background: #fed7aa; border: 1px solid #fdba74; }
.l-none   { background: var(--grey-bg); border: 1px solid var(--border); }

/* ── Settings page: threshold preview ── */
.threshold-preview { text-align: center; }
.tp-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 90px;
  height: 36px;
  border-radius: var(--radius);
  font-size: .75rem;
  font-weight: 600;
  margin-bottom: .4rem;
}
.tp-green  { background: #bbf7d0; color: #14532d; }
.tp-yellow { background: #fef08a; color: #713f12; }
.tp-orange { background: #fed7aa; color: #7c2d12; }
.tp-none   { background: var(--grey-bg); border: 1px solid var(--border); }
.tp-label  { font-size: .78rem; color: var(--muted); }

/* ── Site footer ─────────────────────────────────────────────────────────── */
.site-footer {
  margin-top: 3rem;
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: .78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.site-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.site-footer a:hover { text-decoration: underline; }

/* ── Zusätzliche Badges ──────────────────────────────────────────────────── */
.badge-yellow { background: #fef08a; color: #713f12; }
.badge-orange { background: #fed7aa; color: #7c2d12; }

/* ── Filter-Button active state ─────────────────────────────────────────── */
.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
