:root {
  --bg: #f5f7fa;
  --card: #fff;
  --border: #e1e5eb;
  --primary: #2fc6f6;
  --primary-dark: #1aa9d8;
  --text: #333;
  --muted: #828b95;
  --success: #9dcf00;
  --warning: #ffa900;
  --danger: #ff5752;
  --radius: 8px;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.loading {
  padding: 24px 20px;
  color: var(--muted);
}

.app-root {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.app {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 16px 20px;
  overflow-x: hidden;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  width: 100%;
  max-width: 100%;
}

@media (max-width: 760px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }
}

.layout-side,
.layout-main {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  max-width: 100%;
}

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

.header-btn {
  flex-shrink: 0;
  margin-top: 2px;
}

.header h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.card h3 {
  margin: 16px 0 8px;
  font-size: 14px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.radio-group,
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.managers-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}

.managers-list label {
  display: block;
  padding: 4px 0;
  font-weight: normal;
  cursor: pointer;
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: #eef2f4;
  color: var(--text);
}

.btn-large {
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  font-size: 15px;
  font-weight: 600;
}

.hidden { display: none !important; }

.access-denied {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.access-denied-card {
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.access-denied-card h1 {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 20px;
}

.access-denied-card ul {
  text-align: left;
  margin: 12px 0;
  padding-left: 20px;
}

.access-hint {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 0;
}

.placeholder-text {
  margin: 0;
  color: var(--muted);
}

.preview-placeholder {
  min-height: 200px;
}
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.summary-item {
  background: #f8fafb;
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
}

.summary-item .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
}

.summary-item .label {
  font-size: 12px;
  color: var(--muted);
}

.stats-table table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

.stats-table th,
.stats-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.stats-table th {
  background: #f8fafb;
  font-weight: 600;
}

.existing-block {
  background: #fff8e6;
  border: 1px solid #ffe0a3;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.scroll-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}

.companies-list .company-item {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.companies-list .company-item:last-child { border-bottom: none; }

.company-title { font-weight: 600; }

.company-meta {
  font-size: 12px;
  color: var(--muted);
}

.badge-existing {
  display: inline-block;
  background: var(--warning);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.contacts-list .contact-item {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.hint {
  font-weight: normal;
  color: var(--muted);
  font-size: 12px;
}

.warnings {
  margin-top: 12px;
  padding: 10px;
  background: #fff0f0;
  border: 1px solid #ffc9c9;
  border-radius: var(--radius);
  font-size: 12px;
  max-height: 120px;
  overflow-y: auto;
}

.progress-bar-wrap {
  height: 24px;
  background: #eef2f4;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 0.4s ease;
  border-radius: 12px;
}

.progress-text {
  font-size: 15px;
  font-weight: 600;
}

.progress-eta,
.progress-action {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: min(85vh, 900px);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  overflow-y: auto;
  padding: 16px 20px 20px;
}

.instruction-content h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}

.instruction-content h3:first-child {
  margin-top: 0;
}

.instruction-content ul,
.instruction-content ol {
  margin: 0 0 8px;
  padding-left: 20px;
}

.instruction-content li {
  margin: 4px 0;
}

.instruction-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.instruction-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
  word-break: break-word;
}

.instruction-table th,
.instruction-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.instruction-table th {
  background: #f8fafb;
}
