:root {
  --bg: #f4f6f9; --card: #fff; --text: #1c2430; --muted: #6b7684; --line: #dde2e8;
  --primary: #1f3a5f; --primary-2: #2c5282; --accent: #f5a623; --danger: #c0392b; --ok: #2e7d32;
  --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12161c; --card: #1b2129; --text: #e6e9ee; --muted: #98a2ae; --line: #2c3540; --primary: #5b8bd0; --primary-2: #7aa3dd; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary-2); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: #1f3a5f; color: #fff; }
[hidden] { display: none !important; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; }
.brand img { width: 28px; height: 28px; }
.brand span { font-weight: 400; opacity: .8; }
.topbar nav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.topbar nav a { color: #fff; text-decoration: none; padding: .4rem .7rem; border-radius: 6px; opacity: .85; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.15); opacity: 1; }

main { max-width: 1150px; margin: 0 auto; padding: 1rem; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; text-decoration: none; color: inherit; }
.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: .5rem .9rem;
  border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.link { border: 0; background: none; color: var(--danger); padding: 0 .25rem; }
button:disabled { opacity: .6; cursor: default; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

form .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .8rem 1rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
label.full { grid-column: 1 / -1; }
label.check { flex-direction: row; align-items: center; gap: .4rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; width: 100%; }
label.check input { width: auto; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-2); outline-offset: 0; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.filters input { flex: 1 1 220px; width: auto; }
.filters select { flex: 0 1 200px; width: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(127,127,127,.07); }
td.num, th.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: #e3e8ef; color: #34495e; }
.s-Anfrage { background: #e8eaf6; color: #3949ab; }
.s-Angebot { background: #fff3e0; color: #e65100; }
.s-Beauftragt { background: #e3f2fd; color: #1565c0; }
.s-In-Arbeit { background: #fff8e1; color: #8d6e00; }
.s-Abgeschlossen { background: #e8f5e9; color: #2e7d32; }
.s-Abgerechnet { background: #eceff1; color: #455a64; }
.s-Storniert { background: #fbe9e7; color: #b71c1c; text-decoration: line-through; }
.overdue { color: var(--danger); font-weight: 600; }

dl.info { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--line); padding: .25rem 0 .75rem .8rem; }
.timeline .meta { font-size: .8rem; color: var(--muted); }
.timeline .text { white-space: pre-wrap; word-break: break-word; }
.files { list-style: none; padding: 0; margin: 0; }
.files li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.files img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.files .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1rem; text-align: center; color: var(--muted); margin-top: .75rem; }
.drop.over { border-color: var(--primary-2); color: var(--primary-2); }

.login { max-width: 360px; margin: 10vh auto; }
.login .logo { text-align: center; margin-bottom: 1rem; }
.login .logo img { width: 64px; }
.error { color: var(--danger); min-height: 1.2em; margin: .5rem 0 0; }

#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: #1c2430; color: #fff;
  padding: .6rem 1rem; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }

@media (max-width: 700px) {
  main { padding: .75rem; }
  .topbar nav { margin-left: 0; width: 100%; justify-content: space-between; }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .15rem 0; text-align: right; }
  table.responsive td::before { content: attr(data-l); color: var(--muted); text-align: left; }
  table.responsive td.num { text-align: right; }
}
