:root {
  --bg: #0b0d10;
  --sidebar-bg: #000000;
  --panel: #15181d;
  --panel-border: #262b33;
  --text: #e8eaed;
  --text-dim: #9aa1ab;
  --accent: #4fa8ff;
  --accent-dim: #2c6dab;
  --danger: #ff6b6b;
  --sidebar-width: 250px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid #1a1a1a;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 0;
}

.sidebar-logo {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0 24px 24px;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
}

.sidebar-link {
  padding: 12px 24px;
  color: var(--text-dim);
  font-size: 0.95rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: #131313;
  color: var(--text);
}

.sidebar-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: #101418;
}

.sidebar-bottom {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-link {
  padding: 8px 0;
  font-size: 0.85rem;
}

.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-username {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  display: inline-block;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: #04101c;
}

.btn-primary:hover {
  background: #6cb6ff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #5c2b2b;
}

.btn-danger:hover {
  background: #2a1414;
  border-color: var(--danger);
}

.btn-block {
  width: 100%;
}

/* Content */
.content {
  flex: 1;
  padding: 40px 48px;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content > *:not(.site-footer) {
  flex-shrink: 0;
}

.site-footer {
  margin-top: auto;
  padding-top: 32px;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.site-footer p {
  margin: 0;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 1.8rem;
}

.page-subtitle {
  color: var(--text-dim);
  margin: 0 0 32px;
}

.page-subtitle a {
  color: var(--accent);
}

.magnitude-form {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 32px;
}

.magnitude-form label {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.magnitude-form input {
  width: 90px;
  background: #0d0f12;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.9rem;
}

.btn-small {
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* Home catalog cards */
.catalog-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.catalog-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 20px;
  transition: border-color 0.15s, transform 0.15s;
}

.catalog-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

.catalog-card h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.catalog-card p {
  margin: 0 0 12px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.catalog-card-progress {
  height: 6px;
  border-radius: 3px;
  background: #23272e;
  overflow: hidden;
}

.catalog-card-progress-bar {
  height: 100%;
  background: var(--accent);
}

/* Tile grid */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile:hover {
  border-color: var(--accent-dim);
}

.tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile-plus {
  font-size: 2.2rem;
  color: var(--text-dim);
  line-height: 1;
}

.tile.empty:hover .tile-plus {
  color: var(--accent);
}

.tile-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
}

.tile-code {
  font-weight: 700;
}

.tile-name {
  color: var(--text-dim);
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-magnitude {
  color: var(--text-dim);
  font-size: 0.65rem;
  opacity: 0.8;
}

/* Object page */
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.back-link:hover {
  color: var(--accent);
}

.object-name {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 1.2rem;
}

.object-photo-wrap {
  max-width: 900px;
}

.object-photo {
  width: 100%;
  border-radius: 10px;
  display: block;
  border: 1px solid var(--panel-border);
}

.object-photo-placeholder {
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  border: 1px dashed var(--panel-border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-dim);
}

.upload-form {
  margin-top: 16px;
}

.upload-form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.object-description {
  max-width: 900px;
  margin-top: 28px;
}

.object-description label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.object-description textarea {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 12px;
}

.description-text {
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--text);
}

.form-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 8px;
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
}

/* Settings page */
.settings-panel {
  max-width: 480px;
}

.settings-form {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 24px;
}

.settings-form + .settings-form {
  margin-top: 24px;
}

.settings-form label {
  display: block;
  margin-top: 20px;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.settings-form label:first-child {
  margin-top: 0;
}

.settings-form input[type="number"],
.settings-form input[type="password"] {
  background: #0d0f12;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.settings-form input[type="number"] {
  width: 140px;
}

.settings-form input.is-disabled-look {
  opacity: 0.5;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  margin-bottom: 8px;
}

.field-heading label {
  margin: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #2a2f38;
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.15s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: var(--accent);
}

.settings-form input[type="password"] {
  width: 100%;
  max-width: 280px;
}

.settings-form .form-hint,
.settings-form .form-error {
  margin: 0 0 16px;
}

/* Login modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 28px;
  width: 100%;
  max-width: 340px;
}

.modal h2 {
  margin: 0 0 20px;
}

.modal label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.modal input {
  width: 100%;
  background: #0d0f12;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

/* 404 */
.not-found {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.not-found h1 {
  font-size: 3rem;
  margin: 0;
}

@media (max-width: 760px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    overflow-x: auto;
  }

  .sidebar-top {
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .sidebar-nav {
    flex-direction: row;
  }

  .sidebar-bottom {
    padding: 0 0 0 16px;
    margin-left: auto;
  }

  .content {
    padding: 24px 20px;
  }
}
