* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0;
  background: #f9f7f4;
  font-family: system-ui, -apple-system, sans-serif;
  color: #1a1a1a;
}

header {
  background: #1a1a1a;
  color: #fff;
  padding: 20px 24px;
  border-bottom: 1px solid #333;
}

header h1 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
}

.nav {
  display: flex;
  gap: 24px;
  align-items: center;
  font-size: 14px;
}

.nav button,
.nav a {
  background: transparent;
  color: #999;
  border: none;
  padding: 8px 0;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
}

.nav button.active,
.nav a.active { color: #154889; }

.nav a:hover { color: #ccc; }

.nav .spacer { margin-left: auto; }

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
}

.section { display: none; }
.section.active { display: block; }

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

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #333;
}

input[type="text"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d0ccc7;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

textarea {
  min-height: 60px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #154889;
  box-shadow: 0 0 0 2px rgba(21, 72, 137, 0.1);
}

button {
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  border: none;
  font-weight: 600;
  font-family: inherit;
}

button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: #154889;
  color: #fff;
  padding: 12px 24px;
}

.btn-primary:hover:not([disabled]) { background: #103a70; }

.btn-secondary {
  background: transparent;
  color: #666;
  border: 1px solid #d0ccc7;
  padding: 8px 16px;
}

.btn-secondary:hover:not([disabled]) { background: #f9f7f4; }

h2 {
  font-size: 18px;
  margin: 0 0 24px 0;
  font-weight: 600;
}

.form-card {
  background: #fff;
  border: 1px solid #e0dcd7;
  border-radius: 4px;
  padding: 28px;
  margin-bottom: 24px;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.success-card {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  border-radius: 4px;
  padding: 24px;
  margin-bottom: 24px;
}

.success-card h3 {
  margin: 0 0 16px 0;
  color: #155724;
  font-size: 16px;
}

.ticket-box {
  background: #fff;
  border: 2px solid #154889;
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 12px;
  font-size: 13px;
}

.ticket-label {
  color: #999;
  font-size: 12px;
  margin-bottom: 4px;
}

.ticket-value {
  font-size: 18px;
  font-weight: 600;
  color: #154889;
}

.status-badge {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
}

.status-new { background: #fff3cd; color: #856404; }
.status-work { background: #d1ecf1; color: #0c5460; }
.status-approve { background: #d4edda; color: #155724; }
.status-reject { background: #f8d7da; color: #721c24; }

.result-card {
  background: #fff;
  border: 1px solid #e0dcd7;
  border-radius: 4px;
  padding: 24px;
  margin-top: 20px;
}

.result-row {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e0dcd7;
}

.result-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.result-label {
  font-size: 12px;
  color: #999;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-value {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 4px;
  border: 1px solid #e0dcd7;
}

thead {
  background: #f2ebe4;
  border-bottom: 1px solid #e0dcd7;
}

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #666;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid #e0dcd7;
  font-size: 13px;
}

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

.table-wrap { overflow-x: auto; }

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

.btn-edit {
  background: transparent;
  color: #154889;
  border: none;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

.btn-delete {
  background: transparent;
  color: #999;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
}

.empty {
  background: #fff;
  padding: 40px;
  text-align: center;
  border-radius: 4px;
  border: 1px solid #e0dcd7;
  color: #999;
}

.alert-info {
  background: #fff;
  padding: 20px;
  border-radius: 4px;
  border: 1px solid #e0dcd7;
  color: #666;
  text-align: center;
  font-size: 13px;
}

/* Уведомления о состоянии связи с таблицей. Раньше ошибки синхронизации
   уходили только в console.log, и пользователь считал, что всё сохранилось. */
.notice {
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.5;
}

.notice-error { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; }
.notice-warn  { background: #fff3cd; border: 1px solid #ffc107; color: #856404; }
.notice-ok    { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }
.notice-muted { background: #fff;    border: 1px solid #e0dcd7; color: #666; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar h2 { margin: 0; }
.toolbar .spacer { margin-left: auto; }

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
  background: #fff;
  border-radius: 4px;
  padding: 32px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h2 { margin: 0; }

.modal-close {
  background: transparent;
  color: #999;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
}

@media (max-width: 900px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
  table { font-size: 12px; }
  td, th { padding: 8px 12px; }
}
