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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f8f9fb;
  color: #1a1a2e;
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
aside.sidebar {
  width: 220px;
  min-height: 100vh;
  background: #1e1e2e;
  color: #c9cde0;
  display: flex;
  flex-direction: column;
  padding: 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

aside.sidebar h1 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  padding: 24px 20px 20px;
  border-bottom: 1px solid #2e2e42;
  letter-spacing: 0.02em;
}

aside.sidebar a {
  display: block;
  padding: 11px 20px;
  color: #c9cde0;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

aside.sidebar a:hover {
  background: #2a2a3e;
  color: #fff;
}

aside.sidebar a.active {
  background: #2a2a3e;
  color: #7b9cff;
  border-left-color: #7b9cff;
}

aside.sidebar button {
  margin: auto 20px 20px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid #3e3e56;
  color: #9ca3af;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

aside.sidebar button:hover {
  background: #2a2a3e;
  color: #fff;
}

/* ---- Main content ---- */
main {
  flex: 1;
  padding: 32px 36px;
  max-width: 1100px;
}

main h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #111;
  margin-bottom: 24px;
}

/* ---- Card ---- */
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 28px 32px;
  margin-bottom: 24px;
}

/* ---- Forms ---- */
.field {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 5px;
  color: #374151;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  background: #fafafa;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: #4f6ef7;
  background: #fff;
}

input.error, select.error, textarea.error {
  border-color: #ef4444;
  background: #fef2f2;
}

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

.radio-group {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row label { margin-bottom: 0; }

.hint { font-size: 0.75rem; color: #9ca3af; margin-top: 3px; }

.separator { border: none; border-top: 1px solid #e8eaed; margin: 20px 0; }

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6b7280;
  margin: 24px 0 12px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 9px 22px;
  background: #4f6ef7;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.btn:hover { background: #3b55d9; }
.btn:active { background: #2f44bb; }

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

.btn-secondary:hover { background: #e5e7eb; }

.btn-sm {
  padding: 5px 14px;
  font-size: 0.8rem;
}

.btn-danger {
  background: #ef4444;
}
.btn-danger:hover { background: #dc2626; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-blue    { background: #eff6ff; color: #1d4ed8; }
.badge-green   { background: #f0fdf4; color: #15803d; }
.badge-yellow  { background: #fefce8; color: #a16207; }
.badge-purple  { background: #f5f3ff; color: #6d28d9; }
.badge-red     { background: #fef2f2; color: #991b1b; }
.badge-gray    { background: #f3f4f6; color: #374151; }
.badge-orange  { background: #fff7ed; color: #c2410c; }

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

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

tbody tr:hover td { background: #f8f9fb; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  font-size: 0.85rem;
  color: #6b7280;
}

/* ---- Response box ---- */
.response-box {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 6px;
  font-size: 0.83rem;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-all;
  display: none;
}

.response-box.ok    { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.response-box.error { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }

/* ---- Alert banners ---- */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 0.88rem;
  display: none;
}

.alert.info   { background: #fefce8; border: 1px solid #fde047; color: #854d0e; display: block; }
.alert.error  { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; display: block; }

/* ---- Image thumbnail ---- */
.thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
}

/* ---- Upload preview ---- */
#uploadPreview {
  margin-top: 8px;
  display: none;
}

#uploadPreview img {
  max-height: 80px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

/* ---- User autocomplete ---- */
#userSearchBox { position: relative; }

#userSearchResults {
  position: absolute;
  left: 0; right: 0;
  background: #fff;
  border: 1px solid #d1d5db;
  border-top: none;
  border-radius: 0 0 6px 6px;
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

#userSearchResults .result-item {
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
}

#userSearchResults .result-item:last-child { border-bottom: none; }
#userSearchResults .result-item:hover { background: #f0f4ff; }
#userSearchResults .result-item strong { color: #111; }
#userSearchResults .result-item span { color: #6b7280; font-size: 0.78rem; margin-left: 6px; }

/* ---- Filters bar ---- */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.filters-bar .field {
  margin-bottom: 0;
  min-width: 150px;
}

.filters-bar label {
  font-size: 0.78rem;
}

/* ---- Detail block ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 16px;
  font-size: 0.88rem;
}

.detail-grid .dl { color: #6b7280; font-weight: 500; }
.detail-grid .dv { color: #111; }

.json-pre {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 0.8rem;
  font-family: monospace;
  overflow-x: auto;
  white-space: pre;
  margin-top: 8px;
}

/* ---- Coming soon ---- */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: #9ca3af;
  font-size: 1rem;
  gap: 12px;
}

.coming-soon .icon { font-size: 2.5rem; }

/* ---- Spinner ---- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #d1d5db;
  border-top-color: #4f6ef7;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-left: 6px;
}

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

/* ---- Inline error ---- */
.inline-error {
  font-size: 0.78rem;
  color: #ef4444;
  margin-top: 4px;
  display: none;
}

/* ---- Responsive ---- */
@media (max-width: 800px) {
  body {
    flex-direction: column;
  }

  aside.sidebar {
    width: 100%;
    min-height: unset;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0 12px;
  }

  aside.sidebar h1 {
    padding: 12px 8px;
    border-bottom: none;
    border-right: 1px solid #2e2e42;
    margin-right: 4px;
    font-size: 0.85rem;
  }

  aside.sidebar a {
    padding: 12px 10px;
    border-left: none;
    border-bottom: 3px solid transparent;
    font-size: 0.82rem;
  }

  aside.sidebar a.active {
    border-bottom-color: #7b9cff;
    border-left: none;
  }

  aside.sidebar button {
    margin: 8px 0 8px auto;
  }

  main {
    padding: 20px 16px;
    max-width: 100%;
  }
}
