/* ── DESIGN TOKENS ─────────────────────────────────────────────── */
:root {
  --bg:        #F7F7F5;
  --bg2:       #EFEFEC;
  --bg3:       #E5E5E1;
  --surface:   #FFFFFF;
  --border:    rgba(0,0,0,0.08);
  --text:      #1A1A1A;
  --text2:     #666666;
  --text3:     #999999;
  --accent:    #2A9D8F;
  --accent2:   #1F7A6E;
  --accent-bg: rgba(42,157,143,0.08);
  --red:       #E05252;
  --green:     #2A9D6A;
  --yellow:    #E0A83A;
  --bar-track: #EFEFEC;
  --bar-alt:   #E5E5E1;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --font:      'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --font-disp: 'Bebas Neue', sans-serif;
  --transition: 0.15s ease;
}
[data-theme="dark"] {
  --bg:        #141414;
  --bg2:       #1E1E1E;
  --bg3:       #282828;
  --surface:   #1E1E1E;
  --border:    rgba(255,255,255,0.08);
  --text:      #F0F0EE;
  --text2:     #999999;
  --text3:     #666666;
  --accent:    #2EC4B3;
  --accent2:   #25A99A;
  --accent-bg: rgba(46,196,179,0.1);
  --bar-track: #282828;
  --bar-alt:   rgba(46,196,179,0.55);
  --red:       #F07070;
  --green:     #4ABA8A;
  --yellow:    #F0BA5A;
  --shadow:    0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ── HEADER ─────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.logo {
  font-family: var(--font-disp);
  font-size: 1.6rem;
  letter-spacing: 0.08em;
  color: var(--text);
}
.logo span { color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg2); color: var(--text); }

/* ── NAV ─────────────────────────────────────────────────────────── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
  position: sticky;
  top: 56px;
  z-index: 99;
}
.tab-btn {
  padding: 0.85rem 1.25rem;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── MAIN ────────────────────────────────────────────────────────── */
main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

/* ── PROJECT ZERO ────────────────────────────────────────────────── */
.project-zero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: center;
  box-shadow: var(--shadow);
}
.pz-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pz-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.pz-dot.green { background: var(--green); }
.pz-stats { display: flex; gap: 2rem; flex-wrap: wrap; }
.pz-stat-label { font-size: 11px; color: var(--text3); margin-bottom: 2px; }
.pz-stat-value { font-family: var(--font-mono); font-size: 14px; font-weight: 500; color: var(--text); }
.pz-stat-value.red { color: var(--red); }
.pz-stat-value.green { color: var(--green); }
.pz-progress-wrap { min-width: 180px; }
.pz-progress-label { font-size: 11px; color: var(--text3); margin-bottom: 5px; display: flex; justify-content: space-between; }
.pz-progress-track { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.pz-progress-fill { height: 100%; border-radius: 3px; background: var(--red); transition: width 0.6s cubic-bezier(0.16,1,0.3,1); }
.pz-progress-fill.green { background: var(--accent); }
.pz-bilanz { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 600; line-height: 1; color: var(--text); }
.pz-bilanz.red { color: var(--red); }
.pz-bilanz.green { color: var(--green); }
.pz-bilanz-label { font-size: 11px; color: var(--text3); margin-top: 3px; text-align: right; }

/* ── METRICS ─────────────────────────────────────────────────────── */
.metrics {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.metric {
  background: var(--surface);
  padding: 1rem 1.25rem;
}
.metric-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 5px;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}
.metric-value.green { color: var(--green); }
.metric-value.red { color: var(--red); }
.metric-sub { font-size: 11px; color: var(--text3); margin-top: 3px; }

/* ── CHARTS ──────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.chart-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 1rem;
}
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.bar-label { font-size: 12px; color: var(--text); width: 130px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.bar-track { flex: 1; height: 14px; background: var(--bar-track); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.6s cubic-bezier(0.16,1,0.3,1); }
.bar-fill.alt { background: var(--bar-alt); }
.bar-val { font-size: 11px; color: var(--text); font-family: var(--font-mono); min-width: 55px; }

/* ── TOOLBAR ─────────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 8px; margin-bottom: 1rem; flex-wrap: wrap; }
input[type=text], input[type=date], select {
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input[type=text]:focus, input[type=date]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
input[type=text] { flex: 1; min-width: 160px; }
select { min-width: 130px; }

/* ── TABLE ───────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--bg2); }
th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
th:hover { color: var(--text); }
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg2); }

/* ── BADGES ──────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-nein { background: var(--bg2); color: var(--text3); }
.badge-ja { background: rgba(224,168,58,0.15); color: var(--yellow); }
.badge-später { background: var(--accent-bg); color: var(--accent); }
.badge-verkauft { background: rgba(42,157,106,0.12); color: var(--green); }

/* ── PAGINATION ──────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 12px; color: var(--text3); font-family: var(--font-mono); }
.pag-btns { display: flex; gap: 6px; }
.pag-btn { padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 12px; cursor: pointer; color: var(--text2); transition: all var(--transition); }
.pag-btn:hover { background: var(--bg2); }
.pag-btn:disabled { opacity: 0.35; cursor: default; }

/* ── ADD FORM ────────────────────────────────────────────────────── */
.add-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; max-width: 680px; box-shadow: var(--shadow); }
.add-title { font-family: var(--font-disp); font-size: 1.3rem; letter-spacing: 0.05em; margin-bottom: 1.5rem; color: var(--text); }
.add-section { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.add-section:last-of-type { border-bottom: none; }
.add-section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); margin-bottom: 1rem; padding-bottom: 8px; border-bottom: 2px solid var(--accent); display: inline-block; }
.form-field-full { margin-bottom: 10px; }
.lookup-row { display: flex; gap: 8px; margin-bottom: 1.25rem; align-items: flex-end; }
.lookup-row input { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-grid.full { grid-template-columns: 1fr; }
.form-grid-mobile { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
@media (max-width: 600px) { .form-grid-mobile { grid-template-columns: 1fr; } }
label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text3); margin-bottom: 4px; }
.lookup-result { background: var(--bg2); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; margin-bottom: 1.25rem; display: none; border-left: 2px solid var(--accent); }
.lookup-result.show { display: block; }
.save-btn { width: 100%; padding: 10px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer; transition: background var(--transition); margin-top: 6px; letter-spacing: 0.02em; }
.save-btn:hover { background: var(--accent2); }
.save-btn:disabled { background: var(--text3); cursor: default; }
.status-msg { font-size: 13px; text-align: center; margin-top: 10px; min-height: 20px; }
.status-msg.ok { color: var(--green); }
.status-msg.err { color: var(--red); }

/* ── LOADING ─────────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; height: 200px; color: var(--text3); font-size: 13px; gap: 10px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--bg3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TABS ────────────────────────────────────────────────────────── */
.tab { display: none; }
.tab.active { display: block; }

/* ── LOGIN ───────────────────────────────────────────────────────── */
#login-screen { display: none; position: fixed; inset: 0; background: var(--bg); z-index: 999; align-items: center; justify-content: center; flex-direction: column; gap: 1.5rem; }
#login-screen.show { display: flex; }
.login-logo { font-family: var(--font-disp); font-size: 3.5rem; color: var(--text); letter-spacing: 0.08em; }
.login-logo span { color: var(--accent); }
.login-sub { color: var(--text3); font-size: 13px; }
.google-btn { display: flex; align-items: center; gap: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 22px; font-family: var(--font); font-size: 14px; font-weight: 500; cursor: pointer; box-shadow: var(--shadow); transition: box-shadow var(--transition); }
.google-btn:hover { box-shadow: var(--shadow-md); }
.google-btn svg { width: 18px; height: 18px; }

/* ── AUTOCOMPLETE ────────────────────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.autocomplete-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); max-height: 240px; overflow-y: auto; z-index: 200; box-shadow: var(--shadow-md); display: none; margin-top: 4px; }
.autocomplete-list.show { display: block; }
.autocomplete-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg2); }
.autocomplete-item img { width: 36px; height: 28px; object-fit: contain; border-radius: 4px; flex-shrink: 0; }
.autocomplete-item .ac-nr { font-family: var(--font-mono); font-size: 11px; color: var(--text3); min-width: 55px; }
.autocomplete-item .ac-titel { flex: 1; color: var(--text); }
.autocomplete-item .ac-kat { font-size: 11px; color: var(--text3); }

/* ── SIDE PANEL ──────────────────────────────────────────────────── */
.panel-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 300; backdrop-filter: blur(3px); }
.panel-overlay.show { display: block; }
.side-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 400px; background: var(--surface); z-index: 301; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.16,1,0.3,1); overflow-y: auto; display: flex; flex-direction: column; box-shadow: -4px 0 24px rgba(0,0,0,0.1); }
.side-panel.show { transform: translateX(0); }
@media (max-width: 600px) {
  .side-panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 92vh; border-radius: 16px 16px 0 0; transform: translateY(100%); }
  .side-panel.show { transform: translateY(0); }
  .col-hide-mobile { display: none; }
  td, th { padding: 7px 8px; }
  .table-wrap { border-radius: 0; border-left: none; border-right: none; }
}
.panel-header { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; z-index: 1; }
.panel-title { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.panel-close { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 50%; background: none; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; color: var(--text3); transition: all var(--transition); flex-shrink: 0; }
.panel-close:hover { background: var(--bg2); color: var(--text); }
.panel-thumb { width: 100%; height: 140px; object-fit: contain; background: var(--bg2); padding: 1rem; }
.panel-body { padding: 1.25rem; flex: 1; }
.panel-section { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); margin: 1.25rem 0 0.75rem; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.panel-field { margin-bottom: 9px; }
.panel-field label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text3); margin-bottom: 3px; }
.panel-field input, .panel-field select { width: 100%; font-family: var(--font); font-size: 13px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); }
.panel-field input:focus, .panel-field select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-bg); }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.panel-links { display: flex; gap: 6px; margin-bottom: 1rem; }
.panel-link { font-size: 12px; padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text2); text-decoration: none; background: var(--bg2); transition: all var(--transition); font-weight: 500; }
.panel-link:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.panel-footer { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 1rem 1.25rem; display: flex; gap: 8px; align-items: center; }
.panel-save { flex: 1; padding: 9px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer; transition: background var(--transition); }
.panel-save:hover { background: var(--accent2); }
.panel-status { font-size: 12px; color: var(--green); }

/* ── MONO UTIL ───────────────────────────────────────────────────── */
.mono { font-family: var(--font-mono); font-size: 12px; }

/* ── MOBILE FIX ──────────────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }
.table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }
table { min-width: 500px; }
main { padding: 1rem; }
@media (max-width: 600px) {
  html { font-size: 16px; }
  main { padding: 0.75rem; }
  .project-zero { grid-template-columns: 1fr; gap: 0.75rem; }
  .charts-grid { gap: 0.75rem; }
  nav { overflow-x: auto; }
  .tab-btn { white-space: nowrap; padding: 0.85rem 1rem; font-size: 14px; }
  .metric-value { font-size: 1.2rem; }
}
