:root {
  color-scheme: dark;
  --bg: #06111f;
  --sidebar: #07182b;
  --panel: #0d2138;
  --panel-2: #102a47;
  --line: #28415f;
  --text: #f4f7fb;
  --muted: #aab7c8;
  --orange: #ff7a35;
  --pink: #e03980;
  --cyan: #00d9ff;
  --danger: #ff4d68;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.eyebrow,
.muted-row,
.item-card p,
.novel-row span,
#userStatus,
#roleBadge,
.section-title span {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 7px;
}

.nav button {
  justify-content: flex-start;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.nav button.active,
.nav button:hover {
  border-color: var(--line);
  background: #10243d;
  color: var(--text);
}

.content {
  min-width: 0;
  padding: 24px;
}

.topbar,
.section-title,
.auth-actions,
.toolbar,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar,
.section-title {
  justify-content: space-between;
}

.topbar {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  margin-bottom: 14px;
  font-size: 20px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat,
.panel,
.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.18);
}

.stat {
  padding: 16px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 31px;
}

.panel {
  margin-bottom: 16px;
  padding: 18px;
}

.form-page {
  max-width: 900px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #07182b;
  color: var(--text);
  font: inherit;
  padding: 11px 12px;
  outline: none;
}

input[type="file"] {
  padding: 9px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.14);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  color: white;
  font: inherit;
  font-weight: 800;
  padding: 0 16px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.ghost {
  border: 1px solid var(--line);
  background: transparent;
}

button.danger {
  border-color: rgba(255, 77, 104, 0.7);
  color: #ffb7c2;
}

.list {
  display: grid;
  gap: 10px;
}

.item-card {
  padding: 13px;
  background: var(--panel-2);
}

.item-card strong span {
  color: var(--orange);
  font-size: 12px;
}

.item-card p {
  margin-bottom: 8px;
  line-height: 1.45;
}

.novel-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  align-items: center;
}

.cover {
  width: 58px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  object-fit: cover;
}

.novel-row strong {
  display: block;
  margin-bottom: 4px;
}

.row-actions {
  flex-wrap: wrap;
  margin-top: 10px;
}

.row-actions select {
  max-width: 180px;
}

.muted-row,
.work-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.work-item {
  width: 100%;
  justify-content: space-between;
}

.work-item span {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(460px, calc(100% - 36px));
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111f34;
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.34);
  z-index: 20;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid,
  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .auth-actions,
  .section-title,
  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
  }
}
