/* ===== Единый стиль Электропомощника ===== */

:root {
  --primary: #2E89FF;
  --primary-dark: #1f6fd1;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --dark: #212529;
  --gray: #6c757d;
  --light: #f8f9fa;
  --border: #dee2e6;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --max-width: 1100px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f4f6f9;
  color: var(--dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== Шапка ===== */
.app-header {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 20px;
  color: var(--primary);
  text-decoration: none;
}
.logo .bolt { font-size: 26px; }
.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.nav a, .btn {
  padding: 9px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  background: transparent;
  color: var(--dark);
}
.nav a:hover { background: var(--light); }
.nav a.active, .nav a.primary { background: var(--primary); color: #fff; }
.nav a.active:hover, .nav a.primary:hover { background: var(--primary-dark); color: #fff; }

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-badge {
  font-size: 14px;
  color: var(--gray);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-small { padding: 6px 12px; font-size: 13px; }

/* ===== Контейнер ===== */
.container {
  max-width: var(--max-width);
  margin: 24px auto;
  padding: 0 20px;
}
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 { margin-bottom: 16px; font-size: 20px; }
.card h3 { margin: 16px 0 10px; font-size: 16px; }

/* ===== Формы ===== */
.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; }
input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  color: var(--dark);
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 137, 255, 0.12);
}
textarea { resize: vertical; min-height: 80px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #218838; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c82333; color: #fff; }
.btn-warning { background: var(--warning); color: #212529; }
.btn-warning:hover { background: #e0a800; color: #212529; }
.btn-copy { background: #eef2f7; color: #212529; border: 1px solid #d0d7de; }
.btn-copy:hover { background: #dee3ea; color: #212529; }
.btn-block { width: 100%; display: block; margin-top: 8px; }

/* ===== Алерты / сообщения ===== */
.alert {
  padding: 11px 14px;
  border-radius: 8px;
  margin-top: 15px;
  font-size: 14px;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ===== Таблицы ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--light); font-weight: 600; }
tr:hover td { background: #f8f9fb; }

/* ===== Таблица работ в смете ===== */
/* Задаём таблице жёсткую широкую минимальную ширину, чтобы поля ввода не сжимались
   на узких экранах. Лишняя ширина уходит в горизонтальную прокрутку (.table-wrap). */
#worksTable { min-width: 820px; }
#worksTable input {
  width: 100%;
  min-width: 120px;
  padding: 8px 10px;
  font-size: 14px;
}
#worksTable th:first-child,
#worksTable td:first-child { width: 44px; padding-right: 6px; }
#worksTable th:nth-child(2),
#worksTable td:nth-child(2) { width: 320px; min-width: 320px; }
#worksTable th:nth-child(5),
#worksTable td:nth-child(5) { width: 130px; }
#worksTable th:last-child,
#worksTable td:last-child { width: 56px; text-align: center; padding-left: 6px; }
#worksTable td:last-child .btn { width: 100%; }

/* ===== Ссылка скачивания ===== */
.download-box {
  margin-top: 16px;
  padding: 14px;
  background: #e9f4ff;
  border: 1px solid #b8dcff;
  border-radius: 8px;
  display: none;
}
.download-box.show { display: block; }
.download-box a { color: var(--primary); font-weight: 600; text-decoration: none; }
.download-box a:hover { text-decoration: underline; }

/* ===== Списки / наклейки ===== */
.items-list { margin-top: 20px; }
.item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.item-actions { display: flex; gap: 6px; }

/* Иконки-селектор */
.icon-selector { display: flex; align-items: center; gap: 10px; }
.icon-preview { width: 42px; height: 42px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; padding: 3px; background: #fff; }
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  margin-top: 8px;
}
.icon-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  padding: 4px;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid transparent;
  background: #fff;
}
.icon-grid img:hover { background: var(--light); border-color: var(--primary); }
.icon-grid img.selected { border-color: var(--primary); background: #e9f4ff; }

/* Работы в смете */
.work-row {
  display: grid;
  grid-template-columns: 1fr 80px 100px 100px;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}
.work-row .tot { font-weight: 600; font-size: 15px; }

/* ===== Статус токенов / подписки ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: #e9ecef;
  color: var(--dark);
}
.badge.token { background: #fff3cd; color: #856404; }
.badge.free { background: #d1ecf1; color: #0c5460; }
.badge.paid { background: #d4edda; color: #155724; }

/* ===== Сетка колонок ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ===== Пустое состояние ===== */
.empty { text-align: center; color: var(--gray); padding: 30px; }

/* ===== Футер ===== */
.app-footer {
  text-align: center;
  color: var(--gray);
  font-size: 13px;
  padding: 24px 20px;
}

/* ===== Адаптивность (мобильные) ===== */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; align-items: stretch; }
  .nav { justify-content: center; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .work-row { grid-template-columns: 1fr 70px 90px; }
  .work-row .tot { grid-column: 1 / -1; text-align: right; }
  .card { padding: 16px; }
  .container { padding: 0 12px; margin: 16px auto; }
  .user-menu { justify-content: center; }
}
