:root {
  color-scheme: dark;
  --bg: #07101e;
  --bg-soft: #0b1628;
  --panel: rgba(15, 28, 48, 0.9);
  --panel-strong: #111f35;
  --panel-light: #172943;
  --border: rgba(148, 175, 214, 0.16);
  --border-strong: rgba(148, 175, 214, 0.3);
  --text: #f6f9ff;
  --muted: #97a9c5;
  --muted-strong: #b8c6da;
  --accent: #35a6ff;
  --accent-soft: rgba(53, 166, 255, 0.15);
  --green: #35d07f;
  --green-soft: rgba(53, 208, 127, 0.16);
  --red: #ff5d6c;
  --red-soft: rgba(255, 93, 108, 0.15);
  --amber: #ffbf4b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(19, 95, 164, 0.22), transparent 32rem),
    radial-gradient(circle at 85% 75%, rgba(38, 170, 126, 0.12), transparent 30rem),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.hidden { display: none !important; }
.ambient {
  position: fixed;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: .13;
  pointer-events: none;
  z-index: -1;
}
.ambient-one { top: -12rem; right: -8rem; background: var(--accent); }
.ambient-two { bottom: -14rem; left: -10rem; background: var(--green); }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}
.login-card {
  width: min(100%, 460px);
  padding: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(18, 35, 59, .96), rgba(8, 19, 34, .96));
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-lockup h1 { margin: 3px 0 0; font-size: clamp(1.55rem, 4vw, 2rem); }
.brand-lockup-compact strong { display: block; margin-top: 2px; font-size: 1rem; }
.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #2f99f3, #43d6a0);
  color: #03121e;
  font-weight: 900;
  letter-spacing: -.06em;
  box-shadow: 0 10px 30px rgba(53, 166, 255, .28);
}
.eyebrow {
  color: var(--accent);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.login-copy { margin: 28px 0 22px; color: var(--muted-strong); line-height: 1.6; }
.stack { display: grid; gap: 17px; }
label { display: grid; gap: 7px; }
label > span, .note-composer label { color: var(--muted-strong); font-size: .83rem; font-weight: 700; }
input, textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(5, 14, 26, .72);
  color: var(--text);
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input { height: 48px; padding: 0 14px; }
textarea { padding: 12px 14px; resize: vertical; }
input:focus, textarea:focus {
  border-color: var(--accent);
  background: rgba(8, 20, 36, .95);
  box-shadow: 0 0 0 3px rgba(53, 166, 255, .12);
}
.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
  transition: transform .16s, filter .16s, border-color .16s, background .16s;
}
.button:hover { transform: translateY(-1px); filter: brightness(1.07); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.button-primary { background: linear-gradient(135deg, #249bff, #36c8d9); color: #04101b; }
.button-secondary { background: var(--accent-soft); border-color: rgba(53, 166, 255, .3); color: #a9ddff; }
.button-ghost { background: rgba(255,255,255,.04); border-color: var(--border); color: var(--muted-strong); }
.button-danger { background: var(--red-soft); border-color: rgba(255,93,108,.35); color: #ffbdc3; }
.button-success { background: var(--green); color: #03150d; }
.button-wide { width: 100%; min-height: 50px; margin-top: 4px; }
.form-error { min-height: 20px; margin: 0; color: #ff9ca6; font-size: .86rem; }
.form-message { min-height: 18px; margin: 7px 0 0; color: var(--muted); font-size: .8rem; }
.login-security { margin-top: 24px; padding-top: 19px; border-top: 1px solid var(--border); color: var(--muted); font-size: .78rem; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-secure { background: var(--green); box-shadow: 0 0 12px var(--green); }

.app-shell { min-height: 100vh; }
.topbar {
  min-height: 78px;
  padding: 12px 24px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 14, 26, .86);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand-mark { width: 43px; height: 43px; border-radius: 13px; font-size: .9rem; }
.topbar-statuses { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted-strong);
  background: rgba(255,255,255,.035);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-on { background: var(--green-soft); border-color: rgba(53,208,127,.28); color: #aaf2cb; }
.status-on .status-dot { background: var(--green); box-shadow: 0 0 9px rgba(53,208,127,.8); }
.status-off { background: var(--red-soft); border-color: rgba(255,93,108,.2); color: #f5a9b0; }
.status-off .status-dot { background: var(--red); }
.status-neutral { background: rgba(255,191,75,.1); border-color: rgba(255,191,75,.2); color: #ffd58a; }
.status-neutral .status-dot { background: var(--amber); }
.agent-box { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.agent-box > div { display: grid; text-align: right; }
.agent-name { font-weight: 800; }
.agent-extension { color: var(--muted); font-size: .75rem; margin-top: 2px; }
.icon-button {
  width: 39px;
  height: 39px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(255,255,255,.045);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
}
.icon-button:hover { border-color: var(--border-strong); background: rgba(255,255,255,.08); }

.incoming-banner {
  width: min(930px, calc(100% - 32px));
  min-height: 82px;
  margin: 18px auto -4px;
  padding: 13px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  border: 1px solid rgba(53,208,127,.35);
  border-radius: 18px;
  background: linear-gradient(120deg, rgba(29, 96, 73, .88), rgba(12, 31, 45, .96));
  box-shadow: 0 18px 50px rgba(0,0,0,.3);
  position: sticky;
  top: 90px;
  z-index: 40;
}
.incoming-pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(53,208,127,.6); animation: pulse 1.5s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 14px rgba(53,208,127,0); } 100% { box-shadow: 0 0 0 0 rgba(53,208,127,0); } }
.incoming-copy { display: grid; gap: 2px; }
.incoming-copy span, .incoming-copy small { color: #abd6c4; }
.incoming-copy strong { font-size: 1.12rem; }
.incoming-actions { display: flex; gap: 9px; }

.workspace {
  width: min(1860px, 100%);
  margin: 0 auto;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(320px, .82fr) minmax(440px, 1.35fr) minmax(300px, .8fr);
  gap: 18px;
  align-items: start;
}
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(17,31,53,.93), rgba(9,20,36,.93));
  box-shadow: 0 16px 50px rgba(0,0,0,.2);
  overflow: hidden;
}
.phone-panel, .customer-panel { padding: 20px; min-height: calc(100vh - 124px); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-heading h2 { margin: 3px 0 0; font-size: 1.22rem; }
.call-timer { font-variant-numeric: tabular-nums; font-size: 1rem; color: var(--muted); font-weight: 800; }
.call-identity { display: flex; align-items: center; gap: 13px; min-height: 73px; padding: 13px; border: 1px solid var(--border); border-radius: 15px; background: rgba(4,13,24,.42); }
.call-identity > div:last-child { display: grid; min-width: 0; gap: 4px; }
.call-identity strong, .call-identity span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-identity span { color: var(--muted); font-size: .82rem; }
.caller-avatar, .customer-initials {
  flex: 0 0 auto;
  width: 47px;
  height: 47px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(53,166,255,.25), rgba(53,208,127,.19));
  border: 1px solid rgba(53,166,255,.2);
  color: #c5e9ff;
  font-weight: 900;
}
.dial-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 16px; }
.dial-row input { text-align: center; font-size: 1rem; letter-spacing: .03em; }
.dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px auto 10px; max-width: 340px; }
.dialpad button {
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
  cursor: pointer;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
}
.dialpad button:hover { background: var(--accent-soft); border-color: rgba(53,166,255,.25); }
.dialpad strong { font-size: 1.12rem; }
.dialpad span { color: var(--muted); font-size: .55rem; letter-spacing: .12em; min-height: 8px; }
.primary-call-actions { min-height: 70px; display: grid; place-items: center; margin: 7px 0 8px; }
.round-action {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  color: #04130d;
  font-size: 1.55rem;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0,0,0,.3);
  transition: transform .16s, filter .16s;
}
.round-action:hover { transform: translateY(-2px) scale(1.02); filter: brightness(1.07); }
.round-call { background: var(--green); }
.round-hangup { background: var(--red); transform: rotate(135deg); color: #fff; }
.round-hangup:hover { transform: rotate(135deg) translateY(-2px) scale(1.02); }
.call-controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 8px; }
.call-controls button {
  min-height: 56px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
  color: var(--muted-strong);
  font-size: .7rem;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
}
.call-controls button span { font-size: 1rem; }
.call-controls button.active { background: var(--accent-soft); border-color: rgba(53,166,255,.35); color: #c6eaff; }
.call-controls button:disabled { opacity: .34; cursor: not-allowed; }
.quick-dials { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 17px; padding-top: 17px; border-top: 1px solid var(--border); }
.quick-dials button { min-height: 54px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.028); color: var(--muted); cursor: pointer; display: grid; gap: 3px; place-items: center; }
.quick-dials button:hover { color: var(--text); border-color: var(--border-strong); }
.quick-dials span { font-size: .62rem; }
.quick-dials strong { color: var(--text); }
.phone-message { min-height: 18px; margin: 13px 0 0; text-align: center; color: var(--muted); font-size: .76rem; }

.empty-state { min-height: 330px; display: grid; place-items: center; align-content: center; text-align: center; padding: 32px; }
.empty-icon { width: 62px; height: 62px; display: grid; place-items: center; border-radius: 19px; border: 1px solid var(--border); background: rgba(255,255,255,.03); color: var(--accent); font-size: 1.5rem; }
.empty-state h3 { margin: 18px 0 6px; }
.empty-state p { max-width: 390px; margin: 0; color: var(--muted); line-height: 1.55; }
.context-loading { display: grid; gap: 12px; padding-top: 14px; }
.skeleton { height: 16px; border-radius: 9px; background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.1), rgba(255,255,255,.04)); background-size: 220% 100%; animation: shimmer 1.5s infinite; }
.skeleton-title { width: 48%; height: 25px; }
.skeleton-card { height: 180px; margin-top: 18px; }
@keyframes shimmer { to { background-position: -220% 0; } }
.customer-header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; padding-bottom: 17px; border-bottom: 1px solid var(--border); }
.customer-header h3 { margin: 0 0 4px; font-size: 1.25rem; }
.customer-header p { margin: 0; color: var(--muted); font-size: .8rem; }
.separator { margin: 0 6px; }
.customer-note { margin: 14px 0; padding: 11px 13px; border-left: 3px solid var(--amber); border-radius: 8px; background: rgba(255,191,75,.08); color: #ead6ab; font-size: .82rem; line-height: 1.45; }
.trip-card { margin-top: 16px; padding: 17px; border: 1px solid var(--border); border-radius: 16px; background: rgba(4,13,24,.4); }
.trip-card-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.trip-card-heading > div { display: grid; gap: 4px; }
.trip-status { padding: 5px 9px; border-radius: 999px; background: var(--green-soft); color: #aaf2cb; font-size: .66rem; font-weight: 800; }
.route { margin-top: 18px; display: grid; grid-template-columns: 16px 1fr; column-gap: 10px; align-items: center; }
.route-point { width: 10px; height: 10px; margin-left: 3px; border-radius: 50%; z-index: 1; }
.route-start { background: var(--accent); box-shadow: 0 0 10px rgba(53,166,255,.7); }
.route-end { background: var(--green); box-shadow: 0 0 10px rgba(53,208,127,.7); }
.route-line { width: 2px; height: 25px; margin: 3px 0 3px 7px; background: linear-gradient(var(--accent), var(--green)); }
.route > div:not(.route-point):not(.route-line) { display: grid; gap: 3px; }
.route strong { font-size: .83rem; line-height: 1.35; }
.route-time { color: var(--muted); font-size: .67rem; font-weight: 700; }
.trip-meta { margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.trip-meta span { padding: 5px 8px; border-radius: 8px; background: rgba(255,255,255,.045); color: var(--muted-strong); font-size: .66rem; }
.upcoming-block { margin-top: 20px; }
.subheading { display: flex; align-items: center; gap: 8px; }
.subheading h3 { margin: 0; font-size: .93rem; }
.count-badge { min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: var(--accent-soft); color: #a9ddff; font-size: .68rem; font-weight: 800; }
.upcoming-list { display: grid; gap: 8px; margin-top: 10px; }
.upcoming-item { padding: 11px 12px; border: 1px solid var(--border); border-radius: 12px; display: grid; grid-template-columns: auto 1fr; gap: 10px; background: rgba(255,255,255,.025); }
.upcoming-date { min-width: 56px; color: var(--accent); font-weight: 900; font-size: .76rem; }
.upcoming-item strong { display: block; font-size: .78rem; }
.upcoming-item span { color: var(--muted); font-size: .7rem; }
.note-composer { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--border); }
.note-composer textarea { margin: 7px 0 9px; }

.right-column { display: grid; gap: 18px; }
.compact-panel { padding: 17px; }
.compact-panel .panel-heading { margin-bottom: 12px; }
.agent-status-list, .call-history { display: grid; gap: 8px; max-height: 340px; overflow: auto; padding-right: 2px; }
.agent-status-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 11px; border: 1px solid var(--border); border-radius: 11px; background: rgba(255,255,255,.025); }
.agent-status-item > div { display: grid; gap: 2px; }
.agent-status-item strong { font-size: .78rem; }
.agent-status-item span { color: var(--muted); font-size: .65rem; }
.presence { width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
.presence.online { background: var(--green); box-shadow: 0 0 8px rgba(53,208,127,.6); }
.presence.busy { background: var(--amber); }
.history-item { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 11px; background: rgba(255,255,255,.022); }
.history-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: #a9ddff; font-size: .8rem; }
.history-icon.inbound { background: var(--green-soft); color: #aaf2cb; }
.history-icon.ai { background: rgba(181,117,255,.14); color: #d7b8ff; }
.history-main { min-width: 0; display: grid; gap: 2px; }
.history-main strong, .history-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-main strong { font-size: .76rem; }
.history-main span { color: var(--muted); font-size: .65rem; }
.history-time { color: var(--muted); font-size: .62rem; text-align: right; }
.muted-copy { color: var(--muted); font-size: .75rem; line-height: 1.45; }
.ai-status-copy { padding: 10px 11px; border-radius: 11px; background: rgba(255,255,255,.03); color: var(--muted-strong); font-size: .74rem; line-height: 1.45; }
.ai-transcript { display: grid; gap: 7px; margin-top: 10px; max-height: 220px; overflow: auto; }
.transcript-line { padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.035); font-size: .7rem; line-height: 1.45; }
.transcript-line strong { color: var(--accent); margin-right: 5px; }

.modal { border: 0; padding: 0; background: transparent; color: var(--text); }
.modal::backdrop { background: rgba(2,7,13,.75); backdrop-filter: blur(8px); }
.modal-card { width: min(440px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--border-strong); border-radius: 20px; background: var(--panel-strong); box-shadow: var(--shadow); }
.modal-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-heading h2 { margin: 3px 0 0; }
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 9px; }

@media (max-width: 1260px) {
  .workspace { grid-template-columns: minmax(320px, .9fr) minmax(430px, 1.3fr); }
  .right-column { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); }
  .phone-panel, .customer-panel { min-height: auto; }
}
@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; padding: 10px 14px; }
  .topbar-statuses { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .agent-box .button { display: none; }
  .workspace { padding: 14px; grid-template-columns: 1fr; }
  .right-column { grid-column: auto; grid-template-columns: 1fr; }
  .incoming-banner { top: 124px; }
  .customer-header { grid-template-columns: auto 1fr; }
  .customer-header .button { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .login-card { padding: 25px; }
  .brand-lockup-compact > div:nth-child(2) { display: none; }
  .topbar { gap: 10px; }
  .agent-box > div { display: none; }
  .workspace { padding: 10px; gap: 10px; }
  .panel { border-radius: 16px; }
  .phone-panel, .customer-panel { padding: 15px; }
  .incoming-banner { width: calc(100% - 20px); grid-template-columns: auto 1fr; top: 118px; }
  .incoming-actions { grid-column: 1 / -1; }
  .incoming-actions .button { flex: 1; }
  .call-controls { grid-template-columns: repeat(2, 1fr); }
  .quick-dials { grid-template-columns: 1fr; }
}


/* Kompakte Einbettung in das bestehende Dispatcher-Frontend (?embed=1). */
body.embed-mode { min-height: 100%; }
body.embed-mode .ambient { display: none; }
body.embed-mode .topbar { position: static; padding: 10px 14px; }
body.embed-mode .brand-lockup-compact { display: none; }
body.embed-mode .workspace { padding: 12px; gap: 12px; }
body.embed-mode .panel { border-radius: 14px; }
@media (min-width: 821px) {
  body.embed-mode .workspace { grid-template-columns: minmax(300px, .85fr) minmax(400px, 1.15fr); }
  body.embed-mode .right-column { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
