:root {
  --bg: #f4f6f8; --card: #fff; --text: #1f2933; --muted: #6b7785; --line: #e3e8ee;
  --primary: #0f5e7a; --primary-d: #0b4a60; --radius: 10px;
  --ok: #0f7a4a; --warn: #a15c00; --err: #b42318; --info: #1d5fa8;
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; line-height: 1.5; }
a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: 1.2rem 0 .6rem; }
h2 { font-size: 1.2rem; margin: 1.8rem 0 .7rem; }
h3 { font-size: 1rem; margin: 0 0 .7rem; }
code { background: #eef2f5; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 18px; }
.narrow { max-width: 520px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.lead { font-size: 1.05rem; color: var(--muted); margin-top: 0; }

/* Kopfzeile */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { color: var(--muted); font-size: .78rem; }
.mainnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.mainnav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.mainnav a:hover { background: #f0f3f6; }
.mainnav a.on { background: #e6f0f4; color: var(--primary-d); font-weight: 600; }
.usermenu { display: flex; gap: 14px; font-size: .92rem; }
.usermenu a { text-decoration: none; }
.foot { color: var(--muted); font-size: .82rem; padding: 30px 18px; text-align: center; }

/* Karten & Formulare */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card.empty { text-align: center; color: var(--muted); padding: 40px; }
.form label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 12px; }
.form label.check, label.check { font-weight: 400; display: flex; align-items: center; gap: 8px; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid #cdd5de; border-radius: 8px; background: #fff; margin-top: 4px; color: var(--text); }
input[type=checkbox], input[type=radio] { width: auto; margin: 0; }
input[type=color] { height: 40px; padding: 3px; }
input[type=file] { border: 1px dashed #cdd5de; background: #fafbfc; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc7d6; border-color: var(--primary); }
textarea { resize: vertical; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: 3px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.actions { margin-top: 10px; display: flex; gap: 10px; }
.w-80 { width: 90px; }
.form.compact label { margin-bottom: 9px; }
details { margin: 10px 0; }
summary { cursor: pointer; font-weight: 600; font-size: .9rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--primary); color: #fff; border: 1px solid var(--primary); padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--primary-d); }
.btn-ghost { background: #fff; color: var(--primary); }
.btn-ghost:hover { background: #eef5f8; }
.btn-small { padding: 6px 12px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn-ms { background: #fff; color: #1f2933; border-color: #8c959f; padding: 12px; }
.btn-ms:hover { background: #f3f5f7; }
form.inline { display: inline; }

.alert { padding: 11px 14px; border-radius: 8px; margin: 12px 0; border: 1px solid; }
.alert-ok { background: #ecf8f1; border-color: #b7e2c9; color: var(--ok); }
.alert-warn { background: #fff7e8; border-color: #f3d39a; color: var(--warn); }
.alert-error { background: #fdeeec; border-color: #f4c2bc; color: var(--err); }
.alert-info { background: #edf4fc; border-color: #c3d8f1; color: var(--info); }
.resolved-box { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.login-card { margin-top: 50px; }

/* Bereiche */
.dept { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 30%, white); white-space: nowrap; }
.dept-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 18px 0 10px; }
.dept-tile { display: flex; flex-direction: column; gap: 6px; padding: 22px; border-radius: var(--radius); text-decoration: none; color: var(--text); background: #fff; border: 1px solid var(--line); border-top: 5px solid var(--c); transition: transform .1s, box-shadow .1s; }
.dept-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.07); }
.dept-tile-name { font-size: 1.25rem; font-weight: 700; color: var(--c); }
.dept-tile-desc { color: var(--muted); font-size: .9rem; flex: 1; }
.dept-tile-cta { font-weight: 600; color: var(--c); font-size: .9rem; }
.dept-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.dept-option { display: flex !important; gap: 10px; align-items: flex-start; padding: 12px; border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 400 !important; margin: 0 !important; }
.dept-option input { margin-top: 4px; accent-color: var(--c); }
.dept-option span { display: flex; flex-direction: column; }
.dept-option strong { color: var(--c); }
.dept-option small { color: var(--muted); font-size: .8rem; }
.dept-option:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 6%, white); }
.dept-edit { border-left: 5px solid var(--c); }
.dept-checks label { margin-bottom: 6px !important; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.stat-card { border-top: 4px solid var(--c); }
.stat-card h3 { color: var(--c); }
.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-list li a { display: flex; gap: 10px; padding: 4px 0; text-decoration: none; color: var(--text); }
.stat-list strong { min-width: 28px; text-align: right; }
.stat-list a.hot strong { color: var(--err); }

/* Tabellen */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: #f7fafc; }
.list tbody tr:last-child td { border-bottom: 0; }
.list.plain tbody tr { cursor: default; }
.list.plain input { margin: 0; }
.row-critical td:first-child { box-shadow: inset 4px 0 0 var(--err); }
.row-inactive { opacity: .5; }

.status, .prio, .tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.status-neu { background: #e7f0fd; color: #1d5fa8; }
.status-in_bearbeitung { background: #fff3dc; color: #8a5300; }
.status-wartet { background: #f2ebfd; color: #6b3fb5; }
.status-geloest { background: #e5f6ed; color: var(--ok); }
.status-geschlossen { background: #eceff2; color: #56606b; }
.prio-niedrig { color: #56606b; background: #f1f3f5; }
.prio-normal { color: #1f2933; background: #eef1f4; }
.prio-hoch { color: #a15c00; background: #fff1d6; }
.prio-kritisch { color: #fff; background: var(--err); }
.tag { background: #fff1d6; color: #8a5300; font-weight: 600; }
.tag-time { background: #e8f1f4; color: var(--primary-d); }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.filters input, .filters select { width: auto; margin: 0; }
.filters input[type=search] { min-width: 240px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 10px 0 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--c, var(--primary)); border-bottom-color: var(--c, var(--primary)); font-weight: 600; }
.pager { display: flex; gap: 4px; margin: 14px 0; }
.pager a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; background: #fff; }
.pager a.on { background: var(--primary); color: #fff; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { margin: 0; max-width: 340px; }

/* Ticket-Ansicht */
.ticket-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.ticket-head h1 { margin-top: .4rem; }
.ticket-meta-top { display: flex; gap: 8px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.ref { font-family: ui-monospace, Consolas, monospace; font-weight: 600; color: var(--muted); }
.ticket-head-actions { display: flex; gap: 8px; margin-top: 18px; }
.ticket-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.entry { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.entry header { font-size: .9rem; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.entry-body { white-space: normal; overflow-wrap: anywhere; }
.entry-original { border-left: 4px solid var(--primary); }
.entry-agent { border-left: 4px solid #3aa37b; }
.entry-requester { border-left: 4px solid #8fa1b3; }
.entry-internal { background: #fffaf0; border-color: #f3dfb5; border-left: 4px solid #e0a43a; }
.entry-system { font-size: .85rem; color: var(--muted); padding: 4px 14px 12px; }
.attachments { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.attachments img { display: block; max-width: 260px; max-height: 180px; border-radius: 6px; border: 1px solid var(--line); margin-bottom: 4px; }
.reply-form textarea { margin-bottom: 10px; }
.reply-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.reply-row input[type=file] { width: auto; flex: 1 1 240px; margin: 0; }
.inline-label { display: flex !important; align-items: center; gap: 6px; margin: 0 !important; font-weight: 400 !important; }
.inline-label input, .inline-label select { width: auto; margin: 0; }
.details { margin: 0; display: grid; grid-template-columns: 1fr; }
.details dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 8px; }
.details dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 860px) {
  .ticket-layout, .grid-2 { grid-template-columns: 1fr; }
  .mainnav { order: 3; width: 100%; }
  .filters input[type=search] { min-width: 0; flex: 1 1 100%; }
}
.inline-label input.w-80 { width: 90px; }
