:root {
  color-scheme: light;
  --background: #f5f7f8;
  --surface: #fff;
  --text: #333;
  --muted: #828b95;
  --border: #dfe4e7;
  --blue: #2fc6f6;
  --blue-hover: #17b7eb;
  --danger: #e25757;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
button, textarea, input { font: inherit; }
.app { width: min(100%, 920px); margin: 0 auto; padding: 20px; }

.app-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
h1 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
.app-header p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.entity-label { flex: 0 0 auto; padding: 5px 9px; border: 1px solid var(--border); border-radius: 3px; color: #66717a; background: #fff; font-size: 12px; }

.connection { display: inline-flex; align-items: center; gap: 7px; min-height: 20px; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: #afb8bf; }
.connection[data-state="ready"] .connection-dot { background: #67bd4d; }
.connection[data-state="error"] { color: #a44b4b; }
.connection[data-state="error"] .connection-dot { background: var(--danger); }

.editor { padding: 20px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }
.editor-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 9px; }
h2 { margin: 0; font-size: 14px; font-weight: 600; }
.editor-heading span { color: var(--muted); font-size: 12px; }
textarea { display: block; width: 100%; min-height: 155px; padding: 12px 13px; resize: vertical; border: 1px solid #cfd7dc; border-radius: 3px; outline: none; background: #fff; color: var(--text); line-height: 1.5; }
textarea::placeholder { color: #a2aab0; }
textarea:focus { border-color: #6ccded; box-shadow: 0 0 0 2px rgba(47, 198, 246, .13); }
textarea:disabled { background: #f9fafb; }
.short-textarea { min-height: 95px; }
.field-label { display: block; margin: 15px 0 6px; font-size: 12px; font-weight: 600; }
.text-input { display: block; width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid #cfd7dc; border-radius: 3px; outline: none; background: #fff; color: var(--text); }
.text-input:focus { border-color: #6ccded; box-shadow: 0 0 0 2px rgba(47, 198, 246, .13); }
.field-row { display: flex; align-items: end; gap: 16px; margin: 0 0 2px; }
.field-row > div { width: 180px; max-width: 100%; }
.field-help { margin: 0 0 7px; color: var(--muted); font-size: 12px; }
.checkbox-field { display: flex; align-items: flex-start; gap: 9px; margin: 14px 0 4px; cursor: pointer; }
.checkbox-field input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: #f2bd4b; }

.controls { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding-top: 12px; }
.dictation-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 36px; padding: 0 13px; border: 1px solid transparent; border-radius: 3px; cursor: pointer; font-size: 12px; font-weight: 600; transition: background .15s ease, border-color .15s ease; }
.button[hidden] { display: none; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary, .button-save { color: #fff; background: var(--blue); }
.button-primary:hover:not(:disabled), .button-save:hover:not(:disabled) { background: var(--blue-hover); }
.button-secondary { color: #5e6972; background: #fff; border-color: #cfd7dc; }
.button-secondary:hover:not(:disabled) { background: #f4f7f8; }
.button svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.recording-indicator { display: inline-flex; align-items: center; gap: 6px; color: #c84b4b; font-size: 12px; }
.recording-indicator[hidden] { display: none; }
.recording-indicator span { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.hint { margin: 0; color: var(--muted); font-size: 12px; }

.status-line { margin-top: 16px; padding: 9px 11px; border-radius: 3px; color: #64737d; background: #f2f6f8; font-size: 12px; }
.status-line[data-state="success"] { color: #3f815a; background: #edf8f0; }
.status-line[data-state="error"] { color: #a44b4b; background: #fff0f0; }
.submit-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 19px; padding-top: 15px; border-top: 1px solid #edf0f2; }
.submit-row span { color: var(--muted); font-size: 12px; }
.button-save { min-width: 174px; }
.related-panel { margin-top: 14px; }
.related-intro { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.related-list { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.related-list li { padding: 9px 11px; border: 1px solid var(--border); border-radius: 3px; background: #fff; }
.related-list a, .related-contact { color: #168db7; text-decoration: none; }
.related-list a:hover, .related-contact:hover { text-decoration: underline; }
.related-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.related-contact { display: inline-block; margin-top: 12px; font-size: 12px; }
.related-contact[hidden] { display: none; }
.report-result { margin: 14px 0; overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; background: #fff; font-size: 12px; }
.report-table th, .report-table td { padding: 8px 10px; border: 1px solid var(--border); text-align: left; }
.report-table thead { color: #5e6972; background: #f6f8f9; }
.report-table tbody th { font-weight: 500; }
.report-table tbody td { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Bitrix24 opens the page inside a narrow side panel on smaller screens. */
@media (max-width: 600px) {
  .app { padding: 14px; }
  .app-header { display: block; }
  .entity-label { display: inline-block; margin-top: 9px; }
  .editor { padding: 14px; }
  .editor-heading { display: block; }
  .editor-heading span { display: block; margin-top: 3px; }
  .field-row { display: block; }
  .field-help { margin: 7px 0 0; }
  .submit-row { align-items: stretch; flex-direction: column; }
  .button-save { width: 100%; }
}

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