* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --accent: #00d9ff;
  --accent-green: #00ff88;
  --accent-yellow: #ffcc00;
  --accent-blue: #0099ff;
  --accent-orange: #ff9900;
  --danger: #ff4444;
  --border: #2a2a4e;
  --input-bg: #0d1b2a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 60px;
}

/* Login Screen */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-logo {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--accent-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 30px;
}

.login-form {
  width: 100%;
  max-width: 320px;
}

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

.input-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  border-color: var(--accent);
}

.input-group select option {
  background: var(--bg-secondary);
}

.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:active {
  opacity: 0.8;
}

.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-green));
  color: #000;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 217, 255, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(0, 217, 255, 0.3);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

/* Login button special animation */
.login-form .btn-primary {
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.6), 0 0 30px rgba(0, 255, 136, 0.4);
  }
}

.login-form .btn-primary:hover {
  animation: none;
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 217, 255, 0.5);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

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

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  width: auto;
}

.sort-select {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}

.sort-select:focus {
  border-color: var(--accent);
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 100;
}

.header-title {
  font-size: 16px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* Toggle Switch */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle.active {
  background: var(--accent);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle.active::after {
  transform: translateX(20px);
}

/* Content */
.content {
  padding: 60px 12px 80px;
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.badge-active { background: rgba(0, 255, 136, 0.15); color: var(--accent-green); }
.badge-repair { background: rgba(255, 204, 0, 0.15); color: var(--accent-yellow); }
.badge-warehouse { background: rgba(0, 153, 255, 0.15); color: var(--accent-blue); }
.badge-moved { background: rgba(255, 153, 0, 0.15); color: var(--accent-orange); }

/* List items */
.list-item {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

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

.list-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  font-size: 18px;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.list-item-action {
  color: var(--text-secondary);
  font-size: 18px;
}

/* Table */
.table-container {
  overflow-x: auto;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  min-width: 1350px;
}

th {
  background: var(--bg-tertiary);
  padding: 8px 4px;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  border-right: 1px solid var(--border);
}

th:last-child {
  border-right: none;
}

th:active {
  background: var(--border);
}

td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td:last-child {
  border-right: none;
}

tr:last-child td {
  border-bottom: none;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 10px;
  cursor: pointer;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--accent);
}

.nav-icon {
  font-size: 20px;
}

/* FAB */
.fab {
  position: fixed;
  bottom: 70px;
  right: 16px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--accent), var(--accent-green));
  color: #000;
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 217, 255, 0.4);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: flex-end;
  z-index: 200;
}

.modal {
  background: var(--bg-secondary);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

/* Photo upload */
.photo-upload {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.photo-btn {
  flex: 1;
  padding: 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.photo-preview {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--input-bg);
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 16px;
}

.timeline-dot {
  position: absolute;
  left: -18px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-content {
  background: var(--bg-tertiary);
  padding: 10px;
  border-radius: 8px;
}

.timeline-date {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.timeline-text {
  font-size: 13px;
}

/* Search */
.search-box {
  margin-bottom: 12px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter-chip {
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
}

.filter-chip.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

/* Profile */
.profile-header {
  text-align: center;
  padding: 20px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: #000;
  margin: 0 auto 12px;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
}

.profile-role {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.profile-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border-radius: 16px;
  font-size: 12px;
  margin-top: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online { background: var(--accent-green); }
.status-dot.offline { background: var(--danger); }

/* Settings list */
.settings-list {
  margin-top: 20px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.settings-item-label {
  font-size: 14px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 14px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 300;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Admin forms */
.admin-section {
  margin-bottom: 24px;
}

.admin-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Heater detail */
.detail-image {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 16px;
  background: var(--input-bg);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-item {
  background: var(--bg-tertiary);
  padding: 10px;
  border-radius: 8px;
}

.detail-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.detail-value {
  font-size: 14px;
  font-weight: 500;
}

/* Sticker number display */
.sticker-number {
  display: inline-block;
  padding: 4px 10px;
  background: var(--accent);
  color: #000;
  border-radius: 4px;
  font-weight: 700;
  font-size: 12px;
  font-family: monospace;
}

/* Logs container */
.logs-container {
  margin-top: 20px;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 16px;
}

.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.logs-header span:first-child {
  font-weight: 600;
  font-size: 14px;
}

.logs-count {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 4px 8px;
  border-radius: 4px;
}

.logs-list {
  max-height: 300px;
  overflow-y: auto;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border-left: 3px solid transparent;
}

.log-item-info {
  border-left-color: #666;
}

.log-item-success {
  border-left-color: #4caf50;
}

.log-item-error {
  border-left-color: #f44336;
}

.log-item-warn {
  border-left-color: #ff9800;
}

.log-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.log-content {
  flex: 1;
  min-width: 0;
}

.log-message {
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}

.log-time {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Sync indicators */
.sync-indicator {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  animation: pulse 2s infinite;
}

.sync-indicator.pending {
  color: var(--accent-yellow);
}

.sync-indicator.failed {
  color: var(--danger);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================
   PRINT STYLES - Формы для печати на А4
   ============================================ */

@media print {
  /* Скрываем все элементы интерфейса */
  body * {
    visibility: hidden;
  }
  
  /* Показываем только контент для печати */
  .print-content, .print-content * {
    visibility: visible;
  }
  
  .print-content {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: white;
    color: black;
    padding: 15mm;
  }
  
  /* Скрываем навигацию, кнопки, модальные окна */
  .header, .bottom-nav, .fab, .modal-overlay, .toast, .content {
    display: none !important;
  }
  
  /* Настройки страницы А4 - альбомная ориентация */
  @page {
    size: A4 landscape;
    margin: 15mm;
  }
  
  /* Разрыв страницы */
  .page-break {
    page-break-before: always;
  }
}

/* Стили для форм печати (видимы только при печати) */
.print-content {
  display: none;
  font-family: 'Times New Roman', Times, serif;
  font-size: 12pt;
  line-height: 1.3;
  color: black;
  background: white;
}

.print-content .form-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.print-content .form-header-left,
.print-content .form-header-right {
  width: 45%;
}

.print-content .form-header-left {
  text-align: left;
}

.print-content .form-header-right {
  text-align: left;
}

.print-content .form-header-title {
  text-align: center;
  font-weight: bold;
  font-size: 14pt;
  margin: 20px 0;
}

.print-content .approval-block {
  margin-bottom: 15px;
}

.print-content .approval-block strong {
  display: block;
  margin-bottom: 5px;
}

.print-content .approval-block .signature-line {
  border-bottom: 1px solid black;
  display: inline-block;
  width: 150px;
  margin: 0 10px;
}

.print-content .approval-block .date-line {
  border-bottom: 1px solid black;
  display: inline-block;
  width: 100px;
  margin: 0 5px;
}

.print-content .print-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 10pt;
}

.print-content .print-table th,
.print-content .print-table td {
  border: 1px solid black;
  padding: 6px 4px;
  text-align: left;
}

.print-content .print-table th {
  background-color: #f0f0f0;
  font-weight: bold;
  text-align: center;
}

.print-content .print-table .col-num {
  width: 30px;
  text-align: center;
}

.print-content .print-table .col-name {
  width: 25%;
}

.print-content .print-table .col-small {
  width: 60px;
  text-align: center;
}

.print-content .print-table .col-medium {
  width: 90px;
}

.print-content .print-table .col-date {
  width: 80px;
}

.print-content .print-table .col-voltage {
  width: 70px;
  text-align: center;
}

.print-content .print-table .col-power {
  width: 70px;
  text-align: center;
}

.print-content .print-table .col-heater {
  width: 12%;
}

.print-content .print-table .col-protection {
  width: 12%;
}

.print-content .print-table .col-location {
  width: 15%;
}

.print-content .form-footer {
  margin-top: 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.print-content .form-footer-left {
  font-size: 10pt;
}

.print-content .form-footer-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.print-content .signature-line-long {
  border-bottom: 1px solid black;
  display: inline-block;
  width: 200px;
}

.print-content .template-label {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 9pt;
  color: #666;
}

/* Форма 2 - Эксплуатационный паспорт */
.print-content .passport-header {
  text-align: center;
  font-weight: bold;
  font-size: 14pt;
  margin-bottom: 20px;
}

.print-content .passport-table th {
  background-color: #e8e8e8;
  font-weight: bold;
}

.print-content .passport-table .col-pp {
  width: 30px;
  text-align: center;
}

.print-content .passport-table .col-type {
  width: 25%;
}

.print-content .passport-table .col-year {
  width: 60px;
  text-align: center;
}

.print-content .passport-table .col-date-wide {
  width: 100px;
}

.print-content .passport-table .col-location-wide {
  width: 20%;
}

.print-content .passport-table .col-conclusion {
  width: 25%;
}

/* Кнопка печати в интерфейсе */
.print-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(90deg, var(--accent), var(--accent-green));
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.print-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 217, 255, 0.4);
}

.print-btn:active {
  transform: translateY(0);
}

/* Модальное окно выбора формы */
.print-forms-modal .modal {
  max-height: auto;
}

.print-form-option {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  margin-bottom: 12px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.print-form-option:hover {
  border-color: var(--accent);
  background: var(--bg-secondary);
}

.print-form-option-icon {
  font-size: 48px;
}

.print-form-option-content {
  flex: 1;
}

.print-form-option-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.print-form-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
}
