@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #14120f;
  --bg-elev: #1d1a15;
  --bg-elev-2: #262119;
  --border: #38321f;
  --text: #f2ece0;
  --text-dim: #a79e8c;
  --accent: #c9a24b;
  --accent-strong: #e0bb63;
  --accent-ink: #241d0c;
  --teal: #2e7d6b;
  --teal-strong: #3fa88f;
  --red: #b23a2e;
  --red-strong: #d1493b;
  --radius: 10px;
  --radius-sm: 6px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --tabbar-h: 64px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-top: var(--topbar-h);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 .4em;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Top bar ---------- */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 50;
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 4px;
  background-image: radial-gradient(circle, var(--border) 1.5px, transparent 1.6px);
  background-size: 12px 4px;
  background-repeat: repeat-x;
  background-position: center;
  opacity: .8;
}

.topbar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.topbar .meta {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-dim);
  text-align: right;
  line-height: 1.25;
}

/* ---------- Bottom tab bar (mobile-first nav) ---------- */

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-dim);
  font-size: .68rem;
  font-weight: 500;
  text-decoration: none;
}

.tabbar a svg { width: 21px; height: 21px; }

.tabbar a.active {
  color: var(--accent-strong);
}

/* ---------- Layout containers ---------- */

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 14px 32px;
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.page-head p.sub {
  color: var(--text-dim);
  font-size: .85rem;
  margin: 2px 0 0;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card + .card { margin-top: 10px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .88rem;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover { border-color: var(--accent); text-decoration: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn-danger {
  background: transparent;
  border-color: var(--red);
  color: var(--red-strong);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm { padding: 6px 10px; font-size: .78rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */

label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 14px 0 6px;
}
label:first-child { margin-top: 0; }

input[type=text], input[type=email], input[type=password], input[type=date],
select, textarea {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: .92rem;
}

textarea { resize: vertical; min-height: 90px; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }

.form-actions { margin-top: 18px; display: flex; gap: 10px; }

.error-box {
  background: rgba(178,58,46,.15);
  border: 1px solid var(--red);
  color: #f3b7ae;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  margin-bottom: 14px;
}

.flash {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  margin-bottom: 10px;
  border: 1px solid;
}
.flash-ok { background: rgba(46,125,107,.15); border-color: var(--teal); color: #a9e0d3; }
.flash-error { background: rgba(178,58,46,.15); border-color: var(--red); color: #f3b7ae; }

/* ---------- Ticket-stub badges (signature element) ---------- */

.stub {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .02em;
  padding: 3px 10px 3px 8px;
  border-radius: 3px;
  position: relative;
  background: var(--bg-elev-2);
  border: 1px dashed var(--border);
}

.stub::before, .stub::after {
  content: '';
  position: absolute;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  top: 50%; transform: translateY(-50%);
}
.stub::before { left: -4px; }
.stub::after { right: -4px; }

.stub-normal { color: var(--text-dim); }
.stub-wichtig { color: var(--accent-strong); border-color: var(--accent); }
.stub-dringend { color: var(--red-strong); border-color: var(--red); background: rgba(178,58,46,.12); }
.stub-ok { color: var(--teal-strong); border-color: var(--teal); }

/* ---------- Lists ---------- */

.entry {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.entry:last-child { border-bottom: none; }

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.entry-body { font-size: .93rem; line-height: 1.5; white-space: pre-wrap; }
.entry.resolved .entry-body { color: var(--text-dim); text-decoration: line-through; text-decoration-color: var(--border); }

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filters select {
  width: auto;
  padding: 7px 10px;
  font-size: .8rem;
}

/* ---------- Checklist ---------- */

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }

.checklist-item input[type=checkbox] {
  width: 22px; height: 22px;
  margin-top: 1px;
  accent-color: var(--teal);
  flex-shrink: 0;
}

.checklist-item.checked .item-text { color: var(--text-dim); text-decoration: line-through; text-decoration-color: var(--border); }

.progress-track {
  height: 6px;
  background: var(--bg-elev-2);
  border-radius: 3px;
  overflow: hidden;
  margin: 10px 0 4px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
}

/* ---------- Dashboard tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.tile {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.tile .num {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent-strong);
  line-height: 1;
}
.tile .label {
  font-size: .74rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.login-card .logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}
.login-card .logo span { color: var(--accent-strong); }
.login-card .tagline {
  text-align: center;
  color: var(--text-dim);
  font-size: .8rem;
  margin-bottom: 22px;
}

/* ---------- Table (admin) ---------- */

table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Desktop: sidebar instead of tab bar ---------- */

@media (min-width: 860px) {
  body { padding-bottom: 0; padding-left: 220px; }

  .tabbar {
    top: var(--topbar-h); bottom: 0; left: 0; right: auto;
    width: 220px; height: auto;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--border);
    padding-top: 14px;
  }
  .tabbar a {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 11px 18px;
    font-size: .85rem;
  }
  .tabbar a.active { background: var(--bg-elev-2); border-right: 2px solid var(--accent); }

  .container { max-width: 820px; padding: 26px 28px 40px; }
}
