:root {
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #fff;
  --canvas: #f5f7fa;
  --primary: #174ea6;
  --primary-dark: #123c80;
  --focus: #84adff;
  --danger: #b42318;
  --success: #067647;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 68px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 28px;
  background: #101828;
  color: white;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .24);
}
.brand { display: flex; align-items: center; gap: 10px; color: white; min-width: 210px; }
.brand:hover { text-decoration: none; }
.brand span:last-child, .account > span { display: flex; flex-direction: column; }
.brand small, .account small { color: #98a2b3; font-size: 12px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(145deg, #2970ff, #004eeb);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}
.brand-mark.large { width: 52px; height: 52px; font-size: 24px; border-radius: 14px; }
.topnav { display: flex; gap: 6px; flex: 1; }
.topnav a { color: #d0d5dd; padding: 10px 13px; border-radius: 7px; font-weight: 600; font-size: 14px; }
.topnav a:hover, .topnav a.active { color: white; background: #344054; text-decoration: none; }
.account { display: flex; align-items: center; gap: 14px; text-align: right; font-size: 13px; }

.shell { width: min(1520px, calc(100% - 42px)); margin: 0 auto; padding: 28px 0 64px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #e9efff, #f6f8fb 48%, #eef2f6); }
.page-heading, .ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 22px; }
.page-heading h1, .ticket-head h1 { margin: 2px 0 5px; font-size: clamp(26px, 3vw, 36px); letter-spacing: -.03em; }
.page-heading p, .ticket-head p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--primary) !important; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 800; }
.title-line { display: flex; gap: 8px; margin-bottom: 8px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 15px;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.1;
  white-space: nowrap;
}
.button:hover { text-decoration: none; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { background: #fff; color: #344054; border-color: #d0d5dd; box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.button.secondary:hover { background: #f9fafb; }
.button.ghost { color: #475467; background: transparent; border-color: transparent; }
.topbar .button.ghost { color: #d0d5dd; }
.button.small { padding: 7px 10px; font-size: 12px; }
.button.full { width: 100%; }

.alert { padding: 12px 15px; border-radius: 8px; margin-bottom: 18px; font-weight: 600; border: 1px solid; }
.alert.danger { color: #912018; background: #fef3f2; border-color: #fecdca; }
.alert.success { color: #05603a; background: #ecfdf3; border-color: #abefc6; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  overflow: hidden;
}
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .panel h2 { margin: 0; font-size: 17px; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.panel.compact { padding: 18px; }
.panel.compact h3 { margin: 20px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: #475467; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.metric-card {
  min-height: 126px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid var(--line);
  border-top: 3px solid #98a2b3;
  border-radius: 9px;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.metric-card:hover { text-decoration: none; border-color: #b2ccff; box-shadow: 0 4px 12px rgba(16,24,40,.08); }
.metric-card span { color: #475467; font-size: 13px; font-weight: 700; }
.metric-card strong { font-size: 32px; margin: 8px 0 auto; letter-spacing: -.04em; }
.metric-card small { color: var(--primary); font-weight: 700; }
.metric-card.blue { border-top-color: #2e90fa; }
.metric-card.green { border-top-color: #12b76a; }
.metric-card.red { border-top-color: #f04438; }
.metric-card.amber { border-top-color: #f79009; }
.metric-card.purple { border-top-color: #7f56d9; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 11px 14px; color: #475467; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; background: #f9fafb; border-bottom: 1px solid var(--line); }
td { padding: 13px 14px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
tbody tr:hover { background: #f9fbff; }
td small { display: block; color: var(--muted); margin-top: 3px; max-width: 340px; }
.ticket-link { font-weight: 800; }
.empty { text-align: center; color: var(--muted); padding: 34px; }

.status, .priority, .entry-type {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: .02em;
  background: #f2f4f7;
  color: #344054;
  white-space: nowrap;
}
.status-neu, .status-unzugewiesen { background: #eff8ff; color: #175cd3; }
.status-in_bearbeitung, .status-loesung_freigegeben { background: #ecfdf3; color: #067647; }
[class*="status-wartet"] { background: #fffaeb; color: #b54708; }
.status-eskaliert, .status-abgelehnt { background: #fef3f2; color: #b42318; }
.status-erledigt, .status-geschlossen { background: #f2f4f7; color: #475467; }
.priority-niedrig { color: #475467; }
.priority-normal { background: #eef4ff; color: #3538cd; }
.priority-hoch { background: #fff6ed; color: #c4320a; }
.priority-dringend { background: #fef3f2; color: #b42318; }

.filter-bar {
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 14px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.filter-bar .grow { flex: 1; min-width: 220px; }
label { display: flex; flex-direction: column; gap: 6px; color: #344054; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  color: var(--ink);
  background: white;
  border: 1px solid #d0d5dd;
  border-radius: 7px;
  padding: 10px 11px;
  outline: none;
  font-weight: 400;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #528bff; box-shadow: 0 0 0 3px rgba(82,139,255,.14); }
.form-panel { padding: 22px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.small-gap { gap: 10px; }

.login-card {
  width: min(440px, 100%);
  padding: 32px;
  background: white;
  border: 1px solid #e4e7ec;
  border-radius: 15px;
  box-shadow: 0 16px 50px rgba(16,24,40,.10);
}
.login-heading { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 28px; }
.login-heading h1 { margin: 1px 0 5px; font-size: 29px; }
.login-heading p { margin: 0; color: var(--muted); }

.ticket-head { padding: 19px 21px; background: white; border: 1px solid var(--line); border-radius: 11px; }
.quick-status { display: grid; grid-template-columns: 190px 230px auto; gap: 8px; align-items: end; min-width: 520px; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 18px; align-items: start; }
.ticket-main, .ticket-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.composer form { padding: 18px; }
.composer-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 9px; }

.timeline { padding: 20px; }
.timeline-entry { display: grid; grid-template-columns: 18px 1fr; position: relative; }
.timeline-entry:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 15px; bottom: -5px; width: 2px; background: #eaecf0; }
.timeline-dot { width: 13px; height: 13px; margin-top: 13px; border-radius: 50%; background: #98a2b3; border: 3px solid white; box-shadow: 0 0 0 1px #d0d5dd; z-index: 1; }
.visibility-kunde .timeline-dot { background: #2e90fa; }
.visibility-lager .timeline-dot { background: #7f56d9; }
.visibility-system .timeline-dot { background: #667085; }
.timeline-card { padding: 10px 0 21px 8px; min-width: 0; }
.timeline-card header { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.timeline-card header time { margin-left: auto; }
.timeline-card p { margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.timeline-card footer { color: var(--muted); font-size: 11px; }

.details { margin: 14px 0 0; }
.details div { display: grid; grid-template-columns: 100px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f0f1f3; }
.details dt { color: var(--muted); font-size: 12px; }
.details dd { margin: 0; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.linked-object { padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; margin: 6px 0; display: flex; flex-direction: column; }
.linked-object span, .muted { color: var(--muted); font-size: 12px; }
.action-panel { padding: 0; }
.action-panel summary { cursor: pointer; padding: 15px 18px; font-weight: 800; border-bottom: 1px solid transparent; }
.action-panel[open] summary { border-bottom-color: var(--line); }
.action-panel form { padding: 16px; }
.integration-state { display: flex; align-items: center; gap: 7px; font-size: 12px; margin: 8px 0; }
.integration-state span { width: 8px; height: 8px; border-radius: 50%; background: #f79009; }
.integration-state.ok span { background: #12b76a; }

@media (max-width: 1250px) {
  .metric-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
  .ticket-layout { grid-template-columns: minmax(0, 1fr) 330px; }
}
@media (max-width: 940px) {
  .topbar { padding: 0 16px; gap: 12px; flex-wrap: wrap; padding-block: 10px; }
  .brand { min-width: 0; }
  .topnav { order: 3; width: 100%; }
  .account { margin-left: auto; }
  .shell { width: min(100% - 24px, 900px); padding-top: 18px; }
  .metric-grid { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .ticket-layout { grid-template-columns: 1fr; }
  .ticket-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .ticket-side .panel:first-child, .ticket-side .panel:last-child { grid-column: span 2; }
  .ticket-head { flex-direction: column; }
  .quick-status { min-width: 0; width: 100%; }
}
@media (max-width: 700px) {
  .account > span { display: none; }
  .topnav a { padding: 8px 10px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { align-self: flex-start; }
  .metric-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .metric-card { min-height: 110px; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar .grow { min-width: 0; }
  .form-grid.two, .ticket-side { grid-template-columns: 1fr; }
  .span-2, .ticket-side .panel:first-child, .ticket-side .panel:last-child { grid-column: span 1; }
  .quick-status, .composer-row { grid-template-columns: 1fr; }
  .login-card { padding: 24px; }
  th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5), th:nth-child(6), td:nth-child(6) { display: none; }
}

