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

body {
  background: #0f0f0f;
  color: #e0e0e0;
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #2a2a2a;
  position: sticky;
  top: 0;
  background: #0f0f0f;
  z-index: 100;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: #1D9E75;
  letter-spacing: -0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #aaa;
}

.role-badge {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 13px;
  color: #ccc;
}

.credits-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 13px;
  color: #1D9E75;
  font-weight: 600;
}

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.85;
}

.btn-primary {
  background: #1D9E75;
  color: #fff;
  width: 100%;
  height: 42px;
  font-size: 15px;
}

.btn-secondary {
  background: #1a1a1a;
  color: #ccc;
  border: 1px solid #2a2a2a;
}

/* Main container */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 16px;
}

/* Widget card */
.widget {
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.widget-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #fff;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: #888;
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  height: 40px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 0 12px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
select:focus {
  border-color: #1D9E75;
}

input::placeholder {
  color: #555;
}

select option {
  background: #1a1a1a;
}

/* Chat */
.chat-container {
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  overflow: hidden;
}

.chat-messages {
  min-height: 200px;
  max-height: 480px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages:empty::before {
  content: 'Введите VIN и название детали, нажмите «Найти деталь»';
  color: #555;
  font-size: 14px;
  text-align: center;
  margin: auto;
}

.message {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  background: #1D9E75;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.message.bot {
  background: #1e1e1e;
  color: #ddd;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.message.error {
  background: #2a1414;
  color: #ff6b6b;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

/* Chat input bar */
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #2a2a2a;
  background: #141414;
}

.chat-input-bar input {
  flex: 1;
  height: 38px;
}

.chat-input-bar .btn {
  padding: 0 16px;
  height: 38px;
  white-space: nowrap;
}

/* Loading indicator */
.typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
}

.typing span {
  width: 7px;
  height: 7px;
  background: #555;
  border-radius: 50%;
  animation: blink 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

/* Auth page */
.auth-container {
  max-width: 420px;
  margin: 60px auto;
  padding: 0 16px;
}

.auth-card {
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 32px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  text-align: center;
}

.auth-subtitle {
  font-size: 14px;
  color: #666;
  text-align: center;
  margin-bottom: 28px;
}

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: #1a1a1a;
  border-radius: 8px;
  padding: 4px;
}

.tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  color: #777;
  transition: all 0.15s;
  border: none;
  background: transparent;
}

.tab.active {
  background: #2a2a2a;
  color: #fff;
}

.form-error {
  color: #ff6b6b;
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

.form-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: #666;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  padding: 32px;
  max-width: 520px;
  width: calc(100% - 32px);
}

.modal h2 {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  text-align: center;
}

.modal-sub {
  font-size: 14px;
  color: #777;
  text-align: center;
  margin-bottom: 24px;
}

.plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.plan-card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.plan-card:hover {
  border-color: #1D9E75;
}

.plan-name {
  font-size: 13px;
  color: #888;
  margin-bottom: 6px;
}

.plan-credits {
  font-size: 22px;
  font-weight: 700;
  color: #1D9E75;
  margin-bottom: 4px;
}

.plan-credits span {
  font-size: 13px;
  font-weight: 400;
  color: #666;
}

.plan-price {
  font-size: 14px;
  color: #ccc;
  font-weight: 600;
}

.plan-per {
  font-size: 11px;
  color: #555;
  margin-top: 2px;
}

.modal-sub-link {
  text-align: center;
  font-size: 13px;
  color: #1D9E75;
  cursor: pointer;
  text-decoration: underline;
  margin-top: 8px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: #666;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.modal {
  position: relative;
}

/* Role dropdown */
.role-dropdown-wrap {
  position: relative;
}

.role-badge {
  cursor: pointer;
  user-select: none;
}

.role-badge:hover {
  border-color: #1D9E75;
  color: #1D9E75;
}

.role-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 4px;
  z-index: 300;
  min-width: 150px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.role-option {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #ccc;
  cursor: pointer;
  transition: background 0.1s;
}

.role-option:hover {
  background: #2a2a2a;
  color: #fff;
}

.role-option.active {
  color: #1D9E75;
  font-weight: 600;
}

/* History list */
.history-item {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.history-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #555;
  margin-bottom: 6px;
}

.history-item-part {
  font-size: 14px;
  color: #e0e0e0;
  font-weight: 500;
  margin-bottom: 4px;
}

.history-item-vin {
  font-size: 12px;
  color: #777;
  margin-bottom: 6px;
}

.schema-btn {
  font-size: 13px;
  padding: 6px 14px;
  border-color: #1D9E75;
  color: #1D9E75;
}

.schema-btn:hover {
  background: #1a2e26;
}

.schema-result svg {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.history-item-reply {
  font-size: 13px;
  color: #aaa;
  white-space: pre-wrap;
  line-height: 1.5;
}
