:root {
  --bg-main: #080d1a;
  --bg-gradient: radial-gradient(circle at top center, #152243 0%, #080d1a 70%, #03060c 100%);
  --panel: rgba(18, 28, 54, 0.65);
  --panel-border: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f3f4f6;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --danger: #ef4444;
  --danger-hover: #f87171;
  --ok: #10b981;
  --input-bg: rgba(11, 18, 32, 0.8);
  --shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5);
  --backdrop: blur(12px);
}

*{
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 16px 32px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(8, 13, 26, 0.75);
  backdrop-filter: var(--backdrop);
  -webkit-backdrop-filter: var(--backdrop);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: #bfdbfe;
}

.badge {
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.badge.hidden {
  display: none;
}

.badge.success {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.25);
  color: #a7f3d0;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: var(--backdrop);
  -webkit-backdrop-filter: var(--backdrop);
}

.control, input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  margin: 8px 0 16px;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  font-size: 0.95rem;
}

.control:focus, input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='w3.org' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

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

.actions, .dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  border: 1px solid var(--line);
  background: rgba(31, 41, 55, 0.6);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover {
  background: rgba(55, 65, 81, 0.8);
  border-color: var(--muted);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}
.btn.primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn.danger {
  background: linear-gradient(135deg, var(--danger), #b91c1c);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}
.btn.danger:hover {
  background: linear-gradient(135deg, var(--danger-hover), var(--danger));
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
}

th, td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

th {
  font-weight: 600;
  color: #bfdbfe;
  background: #111a2e;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  user-select: none;
  cursor: pointer;
}

th:hover {
  background: #16223b;
  color: #ffffff;
}

tr {
  background: rgba(18, 26, 43, 0.3);
}

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

tr:hover {
  background: rgba(59, 130, 246, 0.08) !important;
}

tr.selected {
  background: rgba(59, 130, 246, 0.22) !important;
  box-shadow: inset 4px 0 0 var(--accent);
}

tr.selected td {
  color: #ffffff;
}

dialog {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: linear-gradient(180deg, #0f172a 0%, #070b14 100%);
  color: var(--text);
  width: min(720px, 94vw);
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.7);
  padding: 0;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease, display 0.2s allow-discrete;
}

dialog[open] {
  opacity: 1;
  transform: scale(1);
}

@starting-style {
  dialog[open] {
    opacity: 0;
    transform: scale(0.95);
  }
}

dialog::backdrop {
  background: rgba(3, 7, 18, 0.6);
  backdrop-filter: blur(8px);
  transition: display 0.2s allow-discrete, overlay 0.2s allow-discrete, background-color 0.2s;
}

dialog form, dialog > div {
  padding: 28px;
}

.dialog-head {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0 0 4px 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0;
}

.full {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: #94a3b8;
  font-size: 0.88rem;
  font-weight: 500;
}

.card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.card-list li {
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-list li b {
  color: #94a3b8;
  font-weight: 500;
}

.hint {
  margin-top: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }
}
