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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background: #f4f5f7;
  color: #1a1a2e;
  min-height: 100vh;
}

header {
  background: #1a1a2e;
  color: #fff;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

header a {
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
header a:hover { text-decoration: underline; }

header .header-sep {
  opacity: 0.4;
  font-weight: 300;
}

header .header-page {
  opacity: 0.75;
  font-weight: 500;
}

.controls {
  background: #fff;
  border-bottom: 1px solid #e2e4e9;
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}

input[type="password"],
input[type="date"],
input[type="text"],
input[type="url"] {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}

input[type="password"] { width: 260px; }
input[type="date"]     { width: 160px; }

.controls input,
.controls button {
  height: 36px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79,70,229,.15);
  outline: none;
}

select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  background: #fff;
  outline: none;
}

textarea {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
  resize: vertical;
  font-family: inherit;
}

button {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: #4f46e5;
  color: #fff;
}
.btn-primary:hover    { background: #4338ca; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}
.btn-secondary:hover { background: #e5e7eb; }

.status {
  align-self: center;
  font-size: 13px;
  color: #6b7280;
  min-width: 180px;
}
.status.error { color: #dc2626; }
.status.ok    { color: #16a34a; }

.main {
  padding: 20px 24px;
}

.panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  overflow: hidden;
}

.panel-header {
  padding: 12px 16px;
  background: #1a1a2e;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e40af;
}
.badge.none { background: #f3f4f6; color: #9ca3af; }

.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #d1d5db;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px 60px;
  z-index: 100;
  overflow-y: auto;
}

.modal-panel {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  width: 100%;
  max-width: 620px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #1a1a2e;
  color: #fff;
  border-radius: 10px 10px 0 0;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 22px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 12px;
}
.modal-close:hover { color: #fff; }

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
}

.field-warning {
  font-size: 12px;
  color: #92400e;
  background: #fef3c7;
  border-radius: 4px;
  padding: 4px 8px;
}
