/* ===== tyrn.ai Investor-Dashboard — dark theme ===== */
:root {
  --plane: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #201f1e;
  --surface-3: #262523;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255,255,255,0.10);
  --series-1: #3987e5;  /* blue  */
  --series-2: #199e70;  /* aqua  */
  --series-3: #c98500;  /* yellow*/
  --series-4: #9085e9;  /* violet*/
  --good: #0ca30c;
  --bad: #e66767;
  --warning: #fab219;
  /* Gold-Akzent (Marke & Bedienelemente) */
  --gold: #d4af37;
  --gold-lt: #f0d48f;
  --gold-dk: #b8973e;
  --gold-grad: linear-gradient(145deg, #f0d48f, #b8973e, #d4af37);
  --gold-soft: rgba(212, 175, 55, 0.16);
  --accent: var(--gold);
  --accent-ink: #14130f;        /* dunkler Text auf Gold */
  --radius: 14px;
  --radius-sm: 9px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }  /* muss display:grid/flex überschreiben */
html, body { height: 100%; }
body { background: var(--plane); color: var(--text-primary); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1,h2,h3 { font-weight: 650; letter-spacing: -0.01em; }
canvas { max-width: 100%; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; }
.brand-mark {
  color: var(--gold);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.45));
}
.brand-name {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);                         /* Fallback */
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)) drop-shadow(0 4px 12px rgba(0,0,0,0.2));
  line-height: 1;
}
.brand-name .dot { -webkit-text-fill-color: var(--gold-dk); color: var(--gold-dk); font-weight: 500; text-transform: lowercase; }

/* Große, zentrierte Wortmarke auf dem Login-Screen */
.login-card .brand { flex-direction: column; gap: 6px; justify-content: center; margin: 0 auto 34px; }
.login-card .brand-mark { font-size: 2rem; }
.login-card .brand-name { font-size: 2rem; text-align: center; }

/* ===== LOGIN ===== */
.login-view {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(212,175,55,0.16), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(184,151,62,0.12), transparent 55%),
    var(--plane);
}
.login-card { border-top: 2px solid var(--gold-dk); }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px 28px; box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.login-card h1 { font-size: 1.4rem; margin: 18px 0 4px; }
.login-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 22px; }
.login-card label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 14px; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-3); border: 1px solid var(--border); outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--gold-soft); }
.login-error { color: var(--bad); font-size: 0.85rem; margin-top: 12px; }
.login-demo { margin-top: 20px; font-size: 0.72rem; color: var(--muted); text-align: center; }
.login-demo code { background: var(--surface-3); padding: 2px 6px; border-radius: 5px; }

.btn-primary {
  width: 100%; padding: 12px 16px; border: none; border-radius: var(--radius-sm);
  background: var(--gold-grad); color: var(--accent-ink); font-weight: 700;
  letter-spacing: .01em; cursor: pointer; transition: filter .15s, box-shadow .15s;
  box-shadow: 0 2px 10px rgba(212,175,55,0.18);
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 4px 16px rgba(212,175,55,0.28); }
.btn-primary:disabled { opacity: .55; cursor: default; box-shadow: none; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: .82rem;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--gold-dk); color: var(--gold-lt); }

/* ===== APP LAYOUT ===== */
.app-view { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface-1); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 8px 24px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: none;
  background: transparent; color: var(--text-secondary); border-radius: var(--radius-sm);
  cursor: pointer; text-align: left; font-size: .92rem; transition: background .12s, color .12s;
}
.nav-item .ic { width: 18px; text-align: center; opacity: .85; }
.nav-item:hover { background: var(--surface-3); color: var(--text-primary); }
.nav-item.active { background: var(--surface-3); color: var(--gold-lt); box-shadow: inset 3px 0 0 var(--gold); }
.nav-item.active .ic { opacity: 1; color: var(--gold); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold-grad); color: var(--accent-ink); font-weight: 700; font-size: .85rem;
}
.user-name { font-size: .85rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { padding: 24px 28px 40px; max-width: 1220px; width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h2 { font-size: 1.4rem; }
.asof { color: var(--muted); font-size: .8rem; }

/* ===== CARDS / GRID ===== */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 18px 20px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { font-size: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-card { min-width: 0; }

/* KPI */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi .label { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.55rem; font-weight: 700; margin-top: 6px; }
.kpi .delta { font-size: .82rem; margin-top: 4px; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* range tabs */
.range-tabs, .card-head .range-tabs { display: flex; gap: 4px; }
.range-tabs button {
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-secondary);
  padding: 5px 10px; border-radius: 7px; cursor: pointer; font-size: .76rem;
}
.range-tabs button.active { background: var(--gold-grad); color: var(--accent-ink); font-weight: 700; border-color: transparent; }

/* analytics grid */
.analytics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 6px; }
.stat {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.stat .k { color: var(--muted); font-size: .74rem; }
.stat .v { font-size: 1.25rem; font-weight: 650; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .h { color: var(--muted); font-size: .68rem; margin-top: 3px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* forms */
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack input, .stack textarea, .stack select {
  padding: 11px 13px; border-radius: var(--radius-sm); background: var(--surface-3);
  border: 1px solid var(--border); outline: none;
}
.stack input:focus, .stack textarea:focus, .stack select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--gold-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text-secondary); }
.check input { width: auto; }
input[type="checkbox"] { accent-color: var(--gold); }
.hint { color: var(--muted); font-size: .76rem; }
.fld { display: block; font-size: .78rem; color: var(--text-secondary); }
.fld input { width: 100%; margin-top: 5px; }
.sub { font-size: .92rem; margin-bottom: 10px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.btn-mini { background: var(--surface-3); border: 1px solid var(--border); color: var(--text-secondary); padding: 5px 10px; border-radius: 7px; cursor: pointer; font-size: .76rem; transition: border-color .12s, color .12s; }
.btn-mini:hover { border-color: var(--gold-dk); color: var(--gold-lt); }
.btn-mini.danger:hover { border-color: var(--bad); color: var(--bad); }
.cf-list { display: flex; flex-direction: column; gap: 6px; }
.cf-item { display: grid; grid-template-columns: 78px 90px 1fr auto; gap: 10px; align-items: center; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: .84rem; }
.cf-item .cf-note { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-actions { display: flex; gap: 8px; align-items: center; }
.form-actions .btn-primary { width: auto; flex: 1; }
.item-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.news-item.is-hidden, .msg-item.is-hidden { opacity: .6; border-style: dashed; }

.tab-actions { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.btn-report {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--gold-dk);
  background: rgba(212,175,55,.10); color: var(--gold-lt); font-weight: 600; font-size: .85rem;
  transition: background .15s, border-color .15s;
}
.btn-report:hover { background: rgba(212,175,55,.18); border-color: var(--gold); }
.btn-mini.pdf { text-decoration: none; display: inline-flex; align-items: center; }

/* App-Installieren-Button (PWA) */
.btn-install {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; margin-top: 16px; padding: 12px 16px; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid var(--gold-dk);
  background: rgba(212,175,55,.10); color: var(--gold-lt); font-weight: 600;
  transition: background .15s, border-color .15s;
}
.btn-install:hover { background: rgba(212,175,55,.18); border-color: var(--gold); }
.btn-install svg { flex: none; }

.install-help {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: 20px; background: rgba(0,0,0,.6); backdrop-filter: blur(2px);
}
.install-help-card {
  width: 100%; max-width: 380px; background: var(--surface-1);
  border: 1px solid var(--border); border-top: 2px solid var(--gold-dk);
  border-radius: var(--radius); padding: 22px 22px 20px; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.install-help-card h3 { font-size: 1.1rem; margin-bottom: 12px; }
.install-help-card .ih-lead { color: var(--text-secondary); font-size: .9rem; margin-bottom: 8px; }
.install-help-card ol { margin: 0 0 18px; padding-left: 20px; color: var(--text-secondary); font-size: .9rem; line-height: 1.7; }
.install-help-card ol b { color: var(--gold-lt); font-weight: 600; }

/* news + messages */
.news-list, .msg-list { display: flex; flex-direction: column; gap: 12px; }
.news-item, .msg-item {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.news-item h4, .msg-item h4 { font-size: .98rem; margin-bottom: 4px; }
.news-item .meta, .msg-item .meta { color: var(--muted); font-size: .74rem; margin-bottom: 8px; }
.news-item p, .msg-item p { color: var(--text-secondary); font-size: .9rem; white-space: pre-wrap; line-height: 1.5; }
.badge { display: inline-block; font-size: .68rem; padding: 2px 7px; border-radius: 20px; background: var(--surface-3); color: var(--muted); margin-left: 6px; }
.badge.mail { background: var(--gold-soft); color: var(--gold-lt); }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border); color: #fff;
  padding: 12px 18px; border-radius: 10px; font-size: .88rem; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}

.mobile-nav { display: none; }

/* ===== RESPONSIVE / MOBILE ===== */
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .analytics-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  /* eigenes Mobile-Design: Sidebar weg, Bottom-Nav rein */
  .app-view { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px 16px calc(78px + env(safe-area-inset-bottom)); }
  .topbar { position: sticky; top: 0; background: var(--plane); z-index: 10; padding: 10px 0; margin-bottom: 12px; }
  .topbar h2 { font-size: 1.2rem; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .value { font-size: 1.3rem; }
  .analytics-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; border-radius: 12px; }

  .mobile-nav {
    display: grid; grid-template-columns: repeat(var(--mcols, 4), 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface-1); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mnav {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: transparent; border: none; color: var(--muted);
    font-size: .64rem; padding: 6px 2px; cursor: pointer;
  }
  .mnav span { font-size: 1.1rem; }
  .mnav.active { color: var(--gold); }
}
