:root {
  --bg: #fdf8f1;
  --card: #ffffff;
  --cream: #f6ead8;
  --sand: #f0dcbe;
  --orange: #f4a233;
  --orange-dark: #d4851a;
  --brown: #8b5e3c;
  --green: #3f9c5a;
  --green-soft: #eaf6ee;
  --ink: #1d1d1f;
  --muted: #8a8580;
  --line: #f0dcbe;
  --red: #c94f3d;
  --radius: 18px;
  --shadow: 0 2px 12px rgba(139, 94, 60, 0.08);
}

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

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }

/* Header */
header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 8px 0 24px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  display: grid; place-items: center; font-size: 24px;
  box-shadow: var(--shadow);
}
.brand h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.brand h1 span { color: var(--orange-dark); }
.brand small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }

.conn { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 5px 12px; border-radius: 999px;
  background: var(--cream); color: var(--muted); font-weight: 500;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.ok .dot { background: var(--green); }
.badge.err { background: #fbeae7; color: var(--red); }
.badge.err .dot { background: var(--red); }

button {
  font-family: inherit; font-size: 14px; font-weight: 600;
  border: none; border-radius: 12px; padding: 11px 20px; cursor: pointer;
  background: var(--ink); color: #fff; transition: opacity .15s;
}
button:hover { opacity: .85; }
button.ghost { background: var(--cream); color: var(--brown); }

/* Login */
.login-card {
  max-width: 400px; margin: 60px auto; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px;
}
.login-card h2 { font-size: 18px; margin-bottom: 4px; }
.login-card p { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--brown); margin: 12px 0 4px; }
.login-card input {
  width: 100%; font-family: inherit; font-size: 14px;
  padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--bg); outline: none;
}
.login-card input:focus { border-color: var(--orange); }
.login-card button { width: 100%; margin-top: 20px; background: var(--orange-dark); }
.login-error { color: var(--red); font-size: 13px; margin-top: 12px; display: none; }

/* Sections */
section { margin-top: 36px; }
section > h2 {
  font-size: 15px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--brown); margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
section > h2 .hint { font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }

/* Launchpad */
.launchpad { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.app-tile {
  display: flex; align-items: center; gap: 14px; text-decoration: none;
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); color: var(--ink);
  transition: transform .12s, box-shadow .12s;
  border: 1.5px solid transparent;
}
.app-tile:hover { transform: translateY(-2px); border-color: var(--orange); }
.app-tile .icon {
  width: 46px; height: 46px; border-radius: 13px; background: var(--cream);
  display: grid; place-items: center; font-size: 22px; flex-shrink: 0;
}
.app-tile .t { font-weight: 600; font-size: 14px; }
.app-tile .d { font-size: 12px; color: var(--muted); }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.kpi {
  background: var(--card); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow);
}
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi .sub.up { color: var(--green); }
.kpi .sub.down { color: var(--red); }
.kpi.accent { background: linear-gradient(135deg, var(--orange), var(--orange-dark)); }
.kpi.accent .label, .kpi.accent .sub { color: rgba(255,255,255,.85); }
.kpi.accent .value { color: #fff; }

/* Table */
.table-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
th, td { text-align: right; padding: 13px 16px; border-bottom: 1px solid #f7efe2; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.name { font-weight: 600; }
tfoot td { font-weight: 700; background: var(--bg); }
td.pos { color: var(--green); font-weight: 600; }
td.neg { color: var(--red); font-weight: 600; }

/* Zahnrad neben Standortnamen */
.gear {
  background: none; border: none; padding: 2px 4px; font-size: 14px;
  cursor: pointer; opacity: .45; transition: opacity .12s; vertical-align: middle;
}
.gear:hover { opacity: 1; }

/* Modal: Fixkosten je Standort */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(29, 29, 31, .45);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--card); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.18);
  width: 100%; max-width: 520px; padding: 22px; max-height: 85vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { font-size: 16px; }
.cost-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cost-row input {
  font-family: inherit; font-size: 13.5px; padding: 8px 10px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); outline: none;
}
.cost-row input:focus { border-color: var(--orange); }
.cost-row .c-label, .cost-row #c-new-label { flex: 1; min-width: 0; }
.cost-row .c-amount, .cost-row #c-new-amount { width: 100px; text-align: right; }
.cost-row .unit { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cost-row .c-del {
  background: none; border: none; color: var(--muted); font-size: 14px;
  cursor: pointer; padding: 4px 6px;
}
.cost-row .c-del:hover { color: var(--red); }
.cost-row #c-add { background: var(--orange-dark); padding: 8px 14px; font-size: 13px; white-space: nowrap; }
.add-row { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.cost-sum { margin-top: 14px; font-size: 13.5px; color: var(--brown); text-align: right; }

/* EBIT settings */
.settings { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.settings .field { background: var(--card); border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); }
.settings label { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.settings input, .settings select {
  font-family: inherit; font-size: 14px; font-weight: 600; width: 110px;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 10px; outline: none;
  background: var(--card); color: var(--ink);
}
.settings select { width: auto; min-width: 150px; cursor: pointer; }
.settings input:focus, .settings select:focus { border-color: var(--orange); }

.note { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.5; }

/* Inline-Verbindungsformular (Rewards-DB) */
.connect-card { grid-column: 1 / -1; max-width: 380px; }
.connect-card .note { margin: 6px 0 10px; }
.connect-card input {
  width: 100%; font-family: inherit; font-size: 13px;
  padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--bg); outline: none; margin-bottom: 8px;
}
.connect-card input:focus { border-color: var(--orange); }
.connect-card button { width: 100%; background: var(--orange-dark); padding: 9px 16px; }
.connect-card .google-btn { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.connect-card .divider {
  font-size: 11px; color: var(--muted); text-align: center; margin: 10px 0;
  display: flex; align-items: center; gap: 10px;
}
.connect-card .divider::before, .connect-card .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.skeleton { color: var(--muted); }
.hidden { display: none !important; }

footer { margin-top: 60px; text-align: center; font-size: 12px; color: var(--muted); }

@media (max-width: 600px) {
  .kpi .value { font-size: 22px; }
  header { padding-bottom: 12px; }
}
