/* Tanays Basecamp – Styles
   Farben als Tokens; Dunkelmodus folgt dem System oder dem Schalter in der Seitenleiste. */

:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --border: #e6e5e1;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #8a8984;
  --side: #0b0b0b;
  --side-ink: #f4f4f2;
  --chip: #f0efec;
  --grid: #ecebe7;
  --hl: rgba(11, 11, 11, .045);

  /* Datenfarben (validiert, feste Reihenfolge) */
  --s1: #2a78d6; /* Umsatz */
  --s2: #eb6834; /* Ausgaben */
  --s3: #1baf7a; /* Gewinn */
  --s4: #eda100;
  --o1: #9ec5f4; --o2: #3987e5; --o3: #184f95; /* Zeitverlauf hell → dunkel */

  --good: #0b7a0b;
  --bad: #c23434;
  --warn: #b37400;
  --warn-bg: #fff4d6;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --radius: 20px;
  --s1-soft: rgba(42,120,214,.10); --s2-soft: rgba(235,104,52,.10); --s3-soft: rgba(27,175,122,.11); --s4-soft: rgba(237,161,0,.13);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0d; --surface: #181817; --surface-2: #1d1d1c; --border: #2a2a28;
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8f8e86;
    --side: #000000; --side-ink: #f0efec; --chip: #262624; --grid: #262624; --hl: rgba(255,255,255,.05);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --o1: #184f95; --o2: #2a78d6; --o3: #86b6ef;
    --good: #3fbf3f; --bad: #e66767; --warn: #e0a83a; --warn-bg: #2e2716;
    --shadow: none;
    --s1-soft: rgba(57,135,229,.18); --s2-soft: rgba(217,89,38,.18); --s3-soft: rgba(25,158,112,.18); --s4-soft: rgba(201,133,0,.2);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0d; --surface: #181817; --surface-2: #1d1d1c; --border: #2a2a28;
  --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8f8e86;
  --side: #000000; --side-ink: #f0efec; --chip: #262624; --grid: #262624; --hl: rgba(255,255,255,.05);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --o1: #184f95; --o2: #2a78d6; --o3: #86b6ef;
  --good: #3fbf3f; --bad: #e66767; --warn: #e0a83a; --warn-bg: #2e2716;
  --shadow: none;
  --s1-soft: rgba(57,135,229,.18); --s2-soft: rgba(217,89,38,.18); --s3-soft: rgba(25,158,112,.18); --s4-soft: rgba(201,133,0,.2);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }

/* ---------- Grundgerüst ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.side {
  background: var(--side); color: var(--side-ink);
  padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
}
.brand { padding: 0 10px; }
.brand .small { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .55; font-weight: 600; }
.brand .big { font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.navgroup { display: flex; flex-direction: column; gap: 2px; }
.navlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; opacity: .4; padding: 0 10px 6px; font-weight: 600; }
.navlink {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px;
  text-decoration: none; font-weight: 500; opacity: .62; transition: background .15s, opacity .15s;
}
.navlink:hover { opacity: 1; background: rgba(255,255,255,.06); }
.navlink.active { opacity: 1; background: rgba(255,255,255,.12); }
.navlink.active svg { color: #6fa8f0; }
.navlink svg { width: 17px; height: 17px; flex: none; }
.navlink .count { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.14); border-radius: 99px; padding: 1px 7px; }
.side-foot { margin-top: auto; font-size: 11px; opacity: .55; padding: 0 10px; display: flex; flex-direction: column; gap: 8px; }
.theme-switch { display: flex; gap: 4px; }
.theme-switch button {
  flex: 1; background: rgba(255,255,255,.06); border: 0; border-radius: 6px; padding: 5px 0;
  color: var(--side-ink); cursor: pointer; font-size: 11px; opacity: .8;
}
.theme-switch button.on { background: rgba(255,255,255,.2); opacity: 1; }

main { padding: 28px 32px 48px; max-width: 1320px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 28px; font-weight: 700; letter-spacing: -.025em; margin: 0; }
.page-head .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }

/* ---------- Zeitraum-Wahl ---------- */
.period { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.seg { display: inline-flex; background: var(--chip); border-radius: 99px; padding: 4px; }
.seg button {
  border: 0; background: transparent; padding: 6px 16px; border-radius: 99px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.chips button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 3px 11px;
  font-size: 12px; cursor: pointer; color: var(--ink-2);
}
.chips button.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chips button:disabled { opacity: .35; cursor: default; }

/* ---------- Karten ---------- */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.mb { margin-bottom: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card h2 { font-size: 14px; font-weight: 600; margin: 0; letter-spacing: -.005em; display: flex; align-items: center; }
.card h3 { font-size: 12px; font-weight: 600; margin: 0 0 8px; color: var(--ink-2); }
.more { font-size: 12px; color: var(--ink-3); text-decoration: none; white-space: nowrap; }
.more:hover { color: var(--ink); }
.src { font-size: 11px; color: var(--ink-3); margin-top: 12px; }

/* Kennzahlen */
.kpi .label { font-size: 12px; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .label i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.kpi .value { font-size: 32px; font-weight: 650; letter-spacing: -.03em; margin: 6px 0 2px; line-height: 1.1; }
.kpi.sm .value { font-size: 22px; }
.kpi .value.missing { color: var(--ink-3); font-weight: 500; }
.kpi .sub { font-size: 12px; color: var(--ink-2); }
.kpi .spark { margin-top: 10px; height: 36px; }
.delta { font-weight: 600; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.neg { color: var(--bad); }
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--warn-bg); color: var(--warn); vertical-align: 2px;
}
.badge.gray { background: var(--chip); color: var(--ink-2); }

/* ---------- Diagramme ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 3px; border-radius: 2px; width: 14px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: inherit; font-size: 11px; fill: var(--ink-3); }
.chart .xl { fill: var(--ink-2); }
.chart .xl.on { fill: var(--ink); font-weight: 700; }
.chart .dlabel { font-size: 11px; font-weight: 600; fill: var(--ink-2); }
.tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--ink); color: var(--surface);
  padding: 9px 11px; border-radius: 9px; font-size: 12px; white-space: nowrap; opacity: 0;
  transition: opacity .12s; transform: translate(-50%, calc(-100% - 10px)); box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.tip .row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tip .row span:first-child { display: inline-flex; align-items: center; gap: 6px; opacity: .8; }
.tip .row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tip .t { font-weight: 600; margin-bottom: 4px; }
details.tbl { margin-top: 10px; font-size: 12px; }
details.tbl summary { cursor: pointer; color: var(--ink-3); }

/* ---------- Tabellen ---------- */
table.data { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border); }
table.data td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data th:first-child, table.data td:first-child { text-align: left; padding-left: 0; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.sum td { font-weight: 600; border-top: 2px solid var(--border); }
table.data tr.on td { background: var(--hl); }
.scroll-x { overflow-x: auto; }

/* ---------- Listen ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.list .right { margin-left: auto; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .right small { display: block; font-weight: 400; color: var(--ink-3); font-size: 11px; }
.datebox {
  flex: none; width: 44px; text-align: center; border-radius: 12px; background: var(--chip); padding: 5px 0;
  line-height: 1.1;
}
.datebox b { display: block; font-size: 15px; }
.datebox span { font-size: 10px; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }

.tag { font-size: 11px; color: var(--ink-2); background: var(--chip); border-radius: 5px; padding: 1px 7px; white-space: nowrap; }
.tag.link { text-decoration: none; }
.tag.link:hover { background: var(--ink); color: var(--surface); }

/* Hinweise */
.alerts li { align-items: flex-start; }
.alerts .ic {
  flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; background: var(--chip);
}
.alerts .ic.warn { background: var(--warn-bg); }
.alerts .t { font-size: 13px; }

/* To-Dos */
.todos li { align-items: center; }
.todos input[type=checkbox] { width: 17px; height: 17px; margin: 0; accent-color: var(--ink); flex: none; cursor: pointer; }
.todos label { flex: 1; cursor: pointer; }
.todos li.done label { color: var(--ink-3); text-decoration: line-through; }
.todos .num { width: 18px; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.tomorrow { margin-top: 16px; border-radius: 16px; padding: 14px 16px; background: var(--s4-soft); }
.tomorrow h3 { margin-bottom: 4px; }
.tomorrow ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.tomorrow li { padding: 3px 0; }
.progress { height: 6px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ink); border-radius: 99px; }
.progress.blue > div { background: var(--s1); }

/* Kalender */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { font-size: 15px; }
.iconbtn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; display: inline-grid; place-items: center; font-size: 15px;
}
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: 11px; color: var(--ink-3); text-align: center; padding-bottom: 4px; font-weight: 600; }
.cal .day {
  min-height: 74px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
  padding: 5px 6px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
.cal .day.out { opacity: .35; }
.cal .day.today { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.cal .day .n { font-weight: 600; font-size: 12px; }
.cal .ev { font-size: 10.5px; line-height: 1.25; padding: 2px 5px; border-radius: 5px; background: var(--chip); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.tax { background: var(--warn-bg); color: var(--warn); font-weight: 600; }

/* Projekte */
.proj { display: flex; flex-direction: column; gap: 10px; }
.proj .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.proj h2 { font-size: 15px; }
.proj .goal { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.proj ul { margin: 0; padding-left: 16px; font-size: 13px; }
.proj ul li { padding: 2px 0; }
.proj .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; color: var(--ink-3); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 99px; padding: 7px 14px; font-size: 12px; font-weight: 500; text-decoration: none; cursor: pointer; color: var(--ink);
}
.btn:hover { border-color: var(--ink); }
.btn.dark { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* Geplante Statistiken (noch ohne Daten) */
.planned { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.planned div { border: 1.5px dashed var(--border); border-radius: 16px; padding: 12px 14px; }
.planned b { display: block; font-size: 13px; margin-bottom: 3px; }
.planned span { font-size: 12px; color: var(--ink-3); }

.hbar { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; }
.hbar .bar { height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.hbar .bar div { height: 100%; background: var(--ink-2); border-radius: 99px; }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

.skus { display: flex; flex-wrap: wrap; gap: 5px; }
.skus span { font-size: 12px; font-variant-numeric: tabular-nums; border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }

.empty { color: var(--ink-3); font-size: 13px; }
.print-only { display: none; }

/* ---------- Responsiv ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center;
    justify-content: space-between; padding: 12px 16px; gap: 12px;
  }
  .brand { display: flex; gap: 5px; align-items: baseline; white-space: nowrap; padding: 0; }
  .brand .small { font-size: 16px; letter-spacing: -.02em; text-transform: none; opacity: 1; font-weight: 700; }
  .brand .big { font-size: 16px; margin: 0; }
  .side-foot { margin: 0; padding: 0; flex-direction: row; align-items: center; opacity: .85; }
  .side-foot #sync-info { display: none; }
  .navs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; flex-direction: row !important; gap: 2px !important;
    background: var(--side); color: var(--side-ink); overflow-x: auto; scrollbar-width: none;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,.08);
  }
  .navs::-webkit-scrollbar { display: none; }
  .navlabel, .navlink .count { display: none; }
  .navgroup { flex-direction: row; gap: 2px; }
  .navlink { flex-direction: column; gap: 3px; padding: 7px 8px; min-width: 60px; font-size: 10.5px; border-radius: 12px; }
  .navlink svg { width: 20px; height: 20px; }
  main { padding: 18px 16px 96px; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .period { align-items: flex-start; }
  .chips { justify-content: flex-start; }
  .page-head h1 { font-size: 24px; }
  .hbar { grid-template-columns: 110px 1fr 60px; }
  .cal .day { min-height: 46px; padding: 4px; }
  .cal .ev { font-size: 0; height: 6px; padding: 0; border-radius: 3px; background: var(--s1); }
  .cal .ev.tax { background: var(--s2); }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .hero-value { font-size: 34px !important; }
  .theme-switch button { padding: 5px 8px; }
}
@media (max-width: 480px) {
  .g4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .card { padding: 14px; }
  .kpi .value { font-size: 24px; }
}

/* ---------- Druck: nur die Tagesplanung ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --border: #bbb; --shadow: none; }
  .side, .navs, .no-print { display: none !important; }
  .app { display: block; }
  main { padding: 0; }
  .grid { display: block; }
  .card { border: 0; padding: 0; }
  .print-only { display: block; }
  .todos li { padding: 12px 0; font-size: 15px; }
}

/* ---------- Farbakzente ---------- */
.navs { display: flex; flex-direction: column; gap: 22px; }
.chip-ic { width: 28px; height: 28px; border-radius: 9px; display: inline-grid; place-items: center; margin-right: 9px; flex: none; }
.chip-ic svg { width: 15px; height: 15px; }
.chip-ic.blue { background: var(--s1-soft); color: var(--s1); }
.chip-ic.orange { background: var(--s2-soft); color: var(--s2); }
.chip-ic.green { background: var(--s3-soft); color: var(--s3); }
.chip-ic.yellow { background: var(--s4-soft); color: var(--warn); }
.badge.live { background: var(--s3-soft); color: var(--s3); }
.tint-orange { background: linear-gradient(180deg, var(--s2-soft), transparent 110px), var(--surface); }
.tint-green { background: linear-gradient(180deg, var(--s3-soft), transparent 110px), var(--surface); }
.tint-blue { background: linear-gradient(180deg, var(--s1-soft), transparent 110px), var(--surface); }

.hero { background: radial-gradient(120% 140% at 0% 0%, var(--s1-soft), transparent 55%), var(--surface); padding: 22px 24px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.eyebrow { display: flex; align-items: center; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.hero-value { font-size: 44px; font-weight: 700; letter-spacing: -.035em; line-height: 1.05; }
.hero-value.missing { color: var(--ink-3); font-weight: 500; font-size: 34px; }
.hero .sub { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.hero-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.hero-stats > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-stats span { font-size: 12px; color: var(--ink-2); }
.hero-stats b { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.hero-stats small { font-size: 11px; color: var(--ink-3); }
.today-strip {
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; text-decoration: none; padding: 8px 16px 8px 8px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border); margin-bottom: 14px; font-size: 13px; max-width: 100%;
}
.today-strip .chip-ic { margin-right: 0; border-radius: 99px; }
.today-strip b { font-size: 14px; }
.today-strip:hover { border-color: var(--ink); }
.logout { color: inherit; opacity: .7; font-size: 11px; }
