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

:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --border:    #cbd5e1;
  --divider:   #e2e8f0;
  --text:      #0f172a;
  --muted:     #64748b;
  --accent:    #1e293b;
  --accent-fg: #f8fafc;
  --danger:    #b91c1c;
  --danger-dk: #991b1b;
  --radius:    3px;

  --offen:       #0284c7;
  --gekippt:     #4f46e5;
  --geschlossen: #475569;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */

nav {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  padding: 0.7rem 0.2rem;
  min-height: 44px;
}
.nav-item:hover { color: var(--text); }
.nav-logout { margin: 0; padding: 0; }
.nav-btn {
  width: 100%;
  height: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.7rem 0.2rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-btn:hover { color: var(--text); }

/* ── Main ────────────────────────────────────────────────────────────────── */

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 1rem 0.75rem 5rem;
}

/* ── Flash ───────────────────────────────────────────────────────────────── */

.flash {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 0.55rem 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #166534;
}

/* ── Cards (index) ───────────────────────────────────────────────────────── */

.cards { display: flex; flex-direction: column; gap: 0.55rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  overflow: hidden;
}
.card.state-offen       { border-left-color: var(--offen); }
.card.state-gekippt     { border-left-color: var(--gekippt); }
.card.state-geschlossen { border-left-color: var(--geschlossen); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem 0.35rem;
}
.card-name   { font-weight: 600; font-size: 0.9rem; }
.card-status { display: flex; align-items: center; gap: 0.4rem; }
.card-time   {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
}

/* ── State buttons ───────────────────────────────────────────────────────── */

.state-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--divider);
}
.state-btns-form {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.state-rl,
.state-radio-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.2rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  min-height: 40px;
  color: var(--muted);
  user-select: none;
  border-right: 1px solid var(--divider);
}
.state-rl:last-child,
.state-radio-btn:last-child { border-right: none; }

.state-rl input[type="radio"],
.state-radio-btn input[type="radio"] { display: none; }

.s-offen       { background: #f0f9ff; color: #0369a1; }
.s-gekippt     { background: #eef2ff; color: #3730a3; }
.s-geschlossen { background: #f8fafc; color: #475569; }
.s-unbekannt   { background: var(--surface); color: var(--muted); }

.s-offen:has(input:checked)       { background: #bae6fd; color: #0c4a6e; }
.s-gekippt:has(input:checked)     { background: #c7d2fe; color: #1e1b4b; }
.s-geschlossen:has(input:checked) { background: #cbd5e1; color: #0f172a; }
.s-unbekannt:has(input:checked)   { background: #e2e8f0; color: #334155; }

/* Fallback for browsers without :has */
.state-rl.checked,
.state-radio-btn.checked { background: var(--bg); color: var(--text); }

/* ── Save bar ────────────────────────────────────────────────────────────── */

.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin: 0.75rem -0.75rem 0;
  padding: 0.6rem 0.75rem;
  z-index: 10;
}
.save-bar-inner { display: flex; gap: 0.5rem; align-items: center; }
.notiz-input {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  min-height: 40px;
  background: var(--bg);
  color: var(--text);
}
.notiz-input::placeholder { color: var(--muted); }
.notiz-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.btn-save-all { white-space: nowrap; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  min-height: 38px;
}
.btn:hover   { background: var(--bg); }
.btn:active  { opacity: 0.75; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover { opacity: 0.85; background: var(--accent); }
.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover  { background: var(--danger-dk); }
.btn-nav     { padding: 0.35rem 0.65rem; min-height: 34px; font-size: 0.8rem; }
.btn-full    { width: 100%; }
.btn-big     { min-height: 44px; font-size: 0.9rem; font-weight: 600; padding: 0.6rem 1rem; }

/* Small text-style action links used in history rows */
.action-link {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  padding: 0.2rem 0.35rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  min-height: 28px;
}
.action-link:hover            { color: var(--text); background: var(--bg); }
.action-link.action-danger    { color: var(--danger); }
.action-link.action-danger:hover { background: #fff5f5; }

/* Icon buttons (rename / deactivate in objekte) */
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  text-decoration: none;
}
.icon-btn:hover     { color: var(--text); background: var(--bg); }
.icon-danger        { color: var(--danger); }
.icon-danger:hover  { background: #fff5f5; color: var(--danger-dk); }

/* ── Date nav ────────────────────────────────────────────────────────────── */

.datum-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.datum-label {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ── Histogram ───────────────────────────────────────────────────────────── */

.histogram {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 56px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.5rem 0.1rem;
  margin-bottom: 0.75rem;
}
.hist-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 2px;
}
.hist-bar {
  width: 100%;
  background: var(--divider);
  border-radius: 1px 1px 0 0;
  min-height: 2px;
  height: 2px;
}
.hist-active { background: var(--accent); opacity: 0.4; }
.hist-label  { font-size: 0.5rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── History list ────────────────────────────────────────────────────────── */

.history-list { display: flex; flex-direction: column; gap: 0.5rem; }

.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.hc-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem 0.35rem;
  border-bottom: 1px solid var(--divider);
}
.hc-time {
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
}
.hc-note {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}
.hc-items { padding: 0.2rem 0.5rem 0.3rem; }
.hc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.25rem;
  border-radius: var(--radius);
}
.hc-item:hover { background: var(--bg); }
.hc-state   { flex-shrink: 0; }
.hc-name    { flex: 1; font-size: 0.875rem; }
.hc-actions { display: flex; gap: 0.1rem; flex-shrink: 0; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.entry-form { display: flex; flex-direction: column; }
.field       { margin-bottom: 0.85rem; }
.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.big-input,
.big-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--surface);
  min-height: 44px;
  color: var(--text);
}
.big-input:focus, .big-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(30,41,59,.08);
}
textarea.big-input { min-height: 72px; resize: vertical; }
.field-error .big-input,
.field-error .big-select { border-color: var(--danger); }
.error-msg { display: block; color: var(--danger); font-size: 0.78rem; margin-top: 0.25rem; }
.error {
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}
.optional      { font-weight: normal; color: var(--muted); font-size: 0.75rem; text-transform: none; letter-spacing: 0; }
.form-actions  { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.page-header   {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.page-header h2 { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }

/* ── Login ───────────────────────────────────────────────────────────────── */

.login-box {
  max-width: 340px;
  margin: 3rem auto 0;
  background: var(--surface);
  padding: 2rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.login-wordmark {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 0.2rem;
}
.login-sub {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 1.75rem;
  letter-spacing: 0.02em;
}

/* ── Confirm delete ──────────────────────────────────────────────────────── */

.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem 1.5rem;
  max-width: 360px;
  margin: 1rem auto;
}
.confirm-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--divider);
}
.confirm-data {
  font-size: 0.9rem;
  line-height: 1.8;
  margin-bottom: 1.25rem;
}
.confirm-actions { display: flex; gap: 0.5rem; }

/* ── Objekte ─────────────────────────────────────────────────────────────── */

.objekt-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.objekt-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--divider);
}
.objekt-item:last-child { border-bottom: none; }
.rename-form  { flex: 1; display: flex; align-items: center; gap: 0.4rem; }
.rename-input {
  flex: 1;
  padding: 0.3rem 0.45rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: transparent;
  min-height: 32px;
  color: var(--text);
}
.rename-input:focus {
  outline: none;
  border-color: var(--border);
  background: var(--bg);
}
.item-inactive  { opacity: 0.4; }
.badge-inactive { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.add-section    { margin-top: 1.5rem; }
.add-section h3 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.add-form { display: flex; flex-direction: column; gap: 0.5rem; }

/* ── State badges ────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 2px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-offen       { background: #bae6fd; color: #075985; }
.badge-gekippt     { background: #c7d2fe; color: #3730a3; }
.badge-geschlossen { background: #cbd5e1; color: #334155; }
.badge-unbekannt   { background: #e2e8f0; color: #475569; }

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 3rem 0;
  color: var(--muted);
  font-size: 0.875rem;
  letter-spacing: 0.02em;
}
