*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f5f5f5;
  color: #1a1a1a;
  min-height: 100vh;
}

header {
  background: #1a1a2e;
  color: #fff;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-left { flex: 1; }

header h1 { font-size: 1.4rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.flag { width: 1.6rem; height: auto; border-radius: 2px; flex-shrink: 0; }
header .subtitle { font-size: 0.85rem; opacity: 0.7; margin-top: 0.25rem; }

.lang-switcher { display: flex; gap: 0.35rem; flex-shrink: 0; }

.lang-btn {
  margin: 0;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 4px;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lang-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.22);
  color: #fff;
}
.lang-btn.active {
  background: #fff;
  color: #1a1a2e;
  border-color: #fff;
}

main {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

input[type="password"], textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

input[type="password"]:focus, textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

button {
  margin-top: 0.75rem;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: #e2e8f0;
  color: #1a1a1a;
  transition: background 0.15s;
}

button:hover:not(:disabled) { background: #cbd5e1; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: #16a34a;
  color: #fff;
}
button.primary:hover:not(:disabled) { background: #15803d; }

.hint {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.4rem;
}

.status-msg {
  font-size: 0.95rem;
  color: #374151;
  margin-bottom: 0.5rem;
}

.error-msg {
  color: #dc2626;
  font-size: 0.95rem;
}

/* ── Loading modal ── */
#loadingModal {
  border: none;
  border-radius: 14px;
  padding: 1.75rem 2.25rem 1.5rem;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  width: 280px;
}
#loadingModal::backdrop { background: rgba(0,0,0,0.35); }

#lottieContainer {
  width: 160px;
  height: 160px;
  margin: 0 auto 0.75rem;
}

#loadingText {
  font-size: 0.92rem;
  font-weight: 600;
  color: #374151;
  line-height: 1.45;
  min-height: 2.6em;
  transition: opacity 0.25s ease;
}
#loadingText.fading { opacity: 0; }

h2 { font-size: 1.1rem; margin-bottom: 1rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

th, td {
  padding: 0.45rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

th {
  font-weight: 600;
  background: #f8fafc;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.num { text-align: right; }

tfoot td { border-bottom: none; padding-top: 0.3rem; }

.label-cell { font-weight: 600; }

.total-row td {
  font-size: 1rem;
  font-weight: 700;
  border-top: 2px solid #1a1a1a;
  padding-top: 0.5rem;
}

/* ── Action row (submit + profile button) ── */
.action-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.action-row button { margin-top: 0; }

button.secondary {
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #d1d5db;
}
button.secondary:hover:not(:disabled) { background: #e2e8f0; }

/* ── Clients panel ── */
.clients-toggle {
  margin-top: 0.6rem;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 0.82rem;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}
.clients-toggle:hover { color: #374151; }

.clients-panel {
  margin-top: 0.6rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.clients-panel table {
  margin-bottom: 0;
  font-size: 0.82rem;
}
.clients-panel th {
  background: #f8fafc;
  font-size: 0.75rem;
}
.clients-panel td.aliases { color: #6b7280; }

/* ── Profile modal ── */
dialog {
  border: none;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 0;
  max-width: 480px;
  width: calc(100vw - 2rem);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
dialog::backdrop { background: rgba(0,0,0,0.4); }

dialog form { padding: 1.5rem; }
dialog h2 { font-size: 1.1rem; margin-bottom: 1.25rem; }

.form-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.6rem 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.form-grid label {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
}
.form-grid input[type="text"] {
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
}
.color-row { display: flex; gap: 0.5rem; align-items: center; }
.color-row input[type="color"] {
  width: 2.5rem;
  height: 2.2rem;
  padding: 0.1rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  cursor: pointer;
  flex-shrink: 0;
}
.color-row input[type="text"] { width: 90px; }

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
.modal-actions button { margin-top: 0; }

/* ── Clarification inputs ── */
.clarification-inputs { margin: 0.75rem 0; }

.clarification-rate-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.clarification-rate-row label {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
}
.clarification-rate-row input[type="number"] {
  width: 110px;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  flex-shrink: 0;
}
.clarification-rate-row input[type="number"]:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

/* ── Mobile ── */
@media (max-width: 560px) {
  header {
    padding: 0.9rem 1rem;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .header-left { min-width: 0; }

  header h1 { font-size: 1rem; }

  #headerTagline, header .subtitle { display: none; }

  .lang-switcher { flex-shrink: 0; margin-top: 0.1rem; }

  main {
    margin: 1rem auto;
    padding: 0 0.75rem;
    gap: 0.75rem;
  }

  .card { padding: 1rem; }

  /* Quote table — allow horizontal scroll rather than overflow clip */
  #quoteSection .card-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
  }

  table { font-size: 0.78rem; }
  th, td { padding: 0.35rem 0.4rem; }

  /* Action row — stack buttons full width */
  .action-row {
    flex-direction: column;
  }
  .action-row button,
  #freigebenBtn {
    width: 100%;
    text-align: center;
  }

  /* Modal — single column form */
  dialog {
    width: calc(100vw - 1rem);
    max-height: 90vh;
    overflow-y: auto;
  }
  dialog form { padding: 1rem; }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 0.3rem 0;
  }
  .form-grid label { margin-top: 0.5rem; }

  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}

/* ── Header controls (Technical Info + lang switcher) ── */
.header-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.tech-info-btn {
  margin: 0;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.65);
  border: 1px solid rgba(255,255,255,0.18);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tech-info-btn:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

/* ── Tech Info modal ── */
#techInfoModal {
  max-width: 680px;
  width: min(680px, calc(100vw - 2rem));
}

.tech-modal-header {
  background: #1a1a2e;
  color: #fff;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 10px 10px 0 0;
}
.tech-modal-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}
.tech-modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  margin: 0;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.tech-modal-close:hover { background: rgba(255,255,255,0.12); color: #fff; }

.tech-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  max-height: calc(90vh - 52px);
}

.tech-modal-intro {
  font-size: 0.83rem;
  color: #4b5563;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.tech-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tech-section {
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  padding: 0.85rem 1rem;
}
.tech-section h3 {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin-bottom: 0.55rem;
}
.tech-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.tech-section li {
  font-size: 0.82rem;
  color: #374151;
  line-height: 1.45;
  padding-left: 0.9rem;
  position: relative;
}
.tech-section li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: #9ca3af;
  font-weight: 700;
}
.tech-section strong { color: #111827; font-weight: 600; }
.tech-section em { font-style: italic; color: #374151; }
.tech-section code {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.77rem;
  background: #f3f4f6;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  color: #374151;
}

.tech-flowchart {
  width: 100%;
  height: auto;
  border-radius: 6px;
  margin-bottom: 1rem;
  display: block;
}

.tech-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.78rem;
  color: #9ca3af;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.tech-modal-footer a {
  color: #16a34a;
  text-decoration: none;
  font-weight: 600;
}
.tech-modal-footer a:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .tech-grid { grid-template-columns: 1fr; }
  .tech-modal-footer { flex-direction: column; align-items: flex-start; gap: 0.3rem; }
  .tech-info-btn { font-size: 0.72rem; padding: 0.25rem 0.5rem; }
}
