@import url('/static/design-tokens.css');

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--neutral-50);
  color: var(--neutral-900);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
legend {
  margin: 0;
  letter-spacing: var(--tracking-tight);
  color: var(--neutral-900);
}

h1 { font-size: 32px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 650; }
h3 { font-size: 17px; font-weight: 620; }
h4 { font-size: 15px; font-weight: 600; }

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--neutral-400);
}

.subtitle,
.small,
.muted {
  color: var(--neutral-500);
}

.subtitle { font-size: 13px; margin: 0; }
.small { font-size: 11px; margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 16px 0 24px 236px;
  display: grid;
  gap: 24px;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--neutral-950);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-sm);
}

.topbar-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    'brand meta actions'
    'nav nav nav';
  gap: 14px 16px;
  align-items: center;
  padding: 14px 18px;
}

.brand-block { grid-area: brand; display: flex; align-items: center; gap: 10px; }
.topbar-meta { grid-area: meta; display: flex; align-items: center; gap: 8px; }
.topbar-actions { grid-area: actions; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-nav-panel { grid-area: nav; }

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  color: var(--neutral-0);
}

.brand-name {
  margin: 0;
  color: var(--neutral-0);
  font-size: 13px;
  font-weight: 590;
}

.hamburger-btn {
  display: none;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--neutral-0);
}

.meta-pill {
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 560;
}

.main-tabs {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  padding: 4px;
}

.tab-btn {
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  font-weight: 560;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  position: relative;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

.tab-btn.active {
  background: var(--neutral-0);
  color: var(--neutral-900);
  box-shadow: var(--shadow-sm);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent-500);
}

.tab-btn.disabled,
.tab-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.active-users-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 8px;
}

.presence-bubble {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--neutral-0);
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.presence-bubble img { width: 100%; height: 100%; object-fit: cover; }

.auth-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 8px 4px 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
}

/* Layout cards */
.inspiration-band,
.kpi-strip,
.lead-card,
.side-panel,
.result-section,
.activities-section,
.offers-section,
.weekend-enrichment,
.next-steps-panel,
.offers-list-card,
.offers-followup-card,
.recording-panel,
.lead-edit-card {
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.inspiration-band,
.lead-card,
.side-panel,
.result-section,
.activities-section,
.offers-section,
.weekend-enrichment,
.next-steps-panel,
.offers-list-card,
.offers-followup-card,
.lead-edit-card {
  padding: 20px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.section-pill {
  height: 22px;
  border-radius: var(--radius-sm);
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  border: 1px solid transparent;
  background: var(--accent-50);
  color: var(--accent-900);
  position: relative;
}

.section-pill:not(.section-pill-muted)::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent-500);
  margin-right: 6px;
  opacity: 0.75;
  animation: liveDot 2s ease-in-out infinite;
}

.section-pill-muted {
  background: var(--neutral-100);
  color: var(--neutral-700);
  border-color: var(--neutral-200);
}

@keyframes liveDot {
  0%, 100% { opacity: 0.6; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1); }
}

.day-run-timeline {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px;
}

.day-run-item {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--neutral-300);
  background: linear-gradient(180deg, #ffffff 0%, #f6f8fb 100%);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}

.day-run-dot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: currentColor;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.day-run-item.is-open { color: var(--neutral-400); }
.day-run-item.is-termin { color: #00a06a; }
.day-run-item.is-rueckruf { color: #1570ef; }
.day-run-item.is-nicht-erreicht { color: #667085; }
.day-run-item.is-nicht-relevant { color: #344054; }
.day-run-item.is-wiedervorlage { color: #7a5af8; }
.day-run-item.is-active { box-shadow: 0 0 0 4px var(--accent-focus); border-color: var(--accent-500); transform: translateY(-1px); }

/* KPI */
.kpi-strip {
  position: fixed;
  top: 108px;
  left: 14px;
  width: 220px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  z-index: 60;
}

.kpi-card {
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.kpi-card h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--neutral-500);
}

.kpi-card p {
  margin: 0;
  color: var(--neutral-900);
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
}

.kpi-card::after {
  content: '';
}

/* Lead workspace tabs */
.workspace-tabs-wrap {
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 8px;
}

.workspace-tabs {
  display: inline-flex;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--neutral-200);
  background: var(--neutral-100);
  padding: 4px;
}

.workspace-tab {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--neutral-700);
  font-size: 13px;
  font-weight: 580;
  padding: 0 14px;
  cursor: pointer;
}

.workspace-tab.active {
  background: var(--neutral-0);
  color: var(--neutral-900);
  box-shadow: var(--shadow-xs);
}

/* Two column */
.dialer-section {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(320px, 1fr);
  gap: 24px;
}

.lead-empty {
  border: 1px dashed var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-100);
  color: var(--neutral-500);
  padding: 14px;
}

#lead-content { display: grid; gap: 12px; }

.lead-meta {
  margin: 4px 0;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 0;
}

.lead-meta dt,
.lead-meta dd {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--neutral-100);
}

.lead-meta dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--neutral-500);
}

.lead-meta dd {
  font-size: 13px;
  font-weight: 560;
  color: var(--neutral-900);
}

.lead-meta dt:nth-last-of-type(-n+1),
.lead-meta dd:nth-last-of-type(-n+1) { border-bottom: 0; }

.lead-edit-card h3 { margin-bottom: 10px; }

.workspace-panel {
  border-width: 1.5px;
}

.workspace-panel-masterdata {
  border-left: 4px solid #0ea5e9;
}

.workspace-panel-call {
  border-left: 4px solid #10b981;
}

.workspace-panel-activities {
  border-left: 4px solid #7c3aed;
}

.lead-edit-form,
#offer-followup-form,
#result-form,
.admin-collapsible-content {
  display: grid;
  gap: 12px;
}

.lead-edit-grid,
.form-grid,
.status-grid,
.admin-totals {
  display: grid;
  gap: 12px;
}

.lead-edit-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.status-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.field { display: grid; gap: 6px; }
.field-span-all { grid-column: 1 / -1; }

label,
.field label,
legend {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--neutral-500);
  font-weight: 560;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
  color: var(--neutral-900);
  font: inherit;
  font-size: 13px;
  padding: 10px 12px;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

input,
select {
  min-height: 44px;
}

textarea { min-height: 96px; resize: vertical; grid-column: 1 / -1; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236E6E73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 36px;
}

input[type='date']::-webkit-calendar-picker-indicator {
  opacity: 0;
}

input[type='date'] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236E6E73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 36px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: none;
  border-color: var(--accent-500);
  box-shadow: 0 0 0 3px var(--accent-focus);
}

/* Buttons */
.btn {
  min-height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--neutral-200);
  background: var(--neutral-0);
  color: var(--neutral-900);
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 590;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  min-height: 44px;
  background: var(--accent-500);
  border-color: var(--accent-500);
  color: var(--neutral-0);
}

.btn-primary:hover {
  background: var(--accent-600);
  border-color: var(--accent-600);
}

.btn-primary:active {
  background: var(--accent-700);
  border-color: var(--accent-700);
}

.btn-secondary,
#btn-next {
  background: var(--neutral-0);
  border-color: var(--neutral-200);
  color: var(--neutral-900);
}

.btn-secondary:hover,
#btn-next:hover {
  background: var(--neutral-50);
}

.btn-danger,
.btn-danger-soft,
.btn-stop {
  background: var(--neutral-0);
  border-color: var(--neutral-200);
  color: var(--neutral-700);
}

#btn-logout:hover {
  background: #e11d48;
  border-color: #e11d48;
  color: #fff;
}

#btn-outlook {
  background: #0078d4;
  border-color: #0078d4;
  color: #fff;
}

#btn-outlook:hover {
  background: #2f1847;
  border-color: #2f1847;
  color: #fff;
}

.form-actions,
.lead-actions,
.note-tools,
.appointment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.form-actions {
  position: sticky;
  bottom: 10px;
  justify-content: space-between;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(2px);
  z-index: 70;
}

.note-tools {
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: var(--neutral-100);
  padding: 10px;
  grid-column: 1 / -1;
}

.note-shortcuts {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.note-shortcut-btn {
  min-height: 32px;
}

.note-shortcut-btn:disabled {
  opacity: 0.5;
}

.recording-panel {
  grid-column: 1 / -1;
  padding: 12px;
}

.recording-device-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.recording-device-row select { min-width: 260px; flex: 1 1 260px; }

#audio-wave {
  width: 100%;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
}

.recording-live-transcript {
  min-height: 84px;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--neutral-700);
  white-space: pre-wrap;
}

/* Lists */
.cluster-list,
.activities-list,
.next-steps-list,
.offers-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.next-step-item,
.activity-item,
.offer-item {
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
  padding: 12px;
  display: grid;
  gap: 6px;
}

.next-step-item { grid-template-columns: 1fr auto; align-items: center; }

.offers-layout,
.admin-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  margin-top: 8px;
}

.offer-item-selectable {
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.offer-item-selectable:hover {
  border-color: var(--neutral-300);
  box-shadow: var(--shadow-sm);
}

.offer-item-selectable.is-active {
  border-color: var(--accent-500);
  box-shadow: 0 0 0 3px var(--accent-focus);
  background: var(--neutral-0);
}

.offer-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.offer-lead-details {
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: var(--neutral-100);
  padding: 8px 10px;
  margin: 10px 0;
}

.offer-lead-details > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--neutral-800);
}

.offer-lead-details[open] {
  background: var(--neutral-0);
}

.offer-positions-wrap {
  margin: 12px 0;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  overflow: auto;
}

.offer-positions-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.offer-positions-table th,
.offer-positions-table td {
  text-align: left;
  font-size: 12px;
  padding: 10px;
  border-bottom: 1px solid var(--neutral-100);
  vertical-align: top;
}

.offer-positions-table th {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--neutral-500);
  background: var(--neutral-100);
}

.offer-positions-table td strong { display: block; color: var(--neutral-900); }
.offer-positions-table td small { display: block; margin-top: 2px; color: var(--neutral-500); }

/* Empty state */
.offer-empty-state {
  border: 1px dashed var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-100);
  color: var(--neutral-500);
  padding: 18px;
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.offer-empty-state svg {
  width: 20px;
  height: 20px;
  stroke: var(--neutral-400);
  stroke-width: 1.5;
}

.offer-empty-state .btn {
  background: transparent;
  color: var(--neutral-700);
  border-color: transparent;
}

.offer-empty-state .btn:hover {
  background: var(--neutral-100);
  border-color: var(--neutral-200);
}

/* Hints */
.hint {
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: var(--neutral-100);
  color: var(--neutral-700);
  padding: 10px 12px;
}

.hint.warning {
  background: var(--neutral-100);
  border-color: var(--neutral-200);
  color: var(--neutral-700);
}

/* Auth */
.auth-gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(11, 11, 15, 0.56);
  z-index: 200;
}

.auth-card {
  width: min(560px, calc(100% - 24px));
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 24px;
  display: grid;
  gap: 10px;
}

.auth-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Footer */
.app-footer {
  min-height: 48px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--neutral-200);
  background: var(--neutral-100);
  color: var(--neutral-500);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.app-footer .small { color: var(--neutral-500); }

/* Status */
.status-btn {
  min-height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--neutral-200);
  background: var(--neutral-0);
  color: var(--neutral-700);
  font-size: 13px;
  font-weight: 590;
}

.status-btn.active {
  border-color: var(--accent-500);
  box-shadow: 0 0 0 3px var(--accent-focus);
  color: var(--neutral-900);
}

/* Icons rule: no FontAwesome visible */
.fa-solid,
.fa-regular,
.fa-brands,
[class*='fa-'] {
  display: none !important;
}

/* Responsive */
@media (max-width: 1180px) {
  .app-shell { padding-left: 0; }
  .kpi-strip {
    position: static;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dialer-section,
  .offers-layout,
  .admin-layout { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .topbar-row {
    grid-template-columns: 1fr auto auto;
    grid-template-areas:
      'brand meta burger'
      'actions actions actions'
      'nav nav nav';
  }

  .hamburger-btn { display: inline-grid; place-items: center; }
  .topbar-nav-panel { display: none; }
  .topbar-nav-panel.open { display: block; }
}

@media (max-width: 768px) {
  .app-shell { width: calc(100% - 24px); gap: 16px; }
  .lead-edit-grid-3,
  .form-grid,
  .status-grid { grid-template-columns: 1fr; }
  .lead-meta { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
