:root {
  --bg: #f3f0ff;
  --card: #ffffff;
  --text: #1c1233;
  --muted: #6b5c89;
  --border: #e8e0ff;
  --primary-a: #7b3af1;
  --primary-b: #b35cff;
  --danger: #dc2626;
  --shadow-sm: 0 6px 20px rgba(77, 45, 140, 0.08);
  --shadow-md: 0 12px 30px rgba(77, 45, 140, 0.12);
}

* {
  box-sizing: border-box;
}

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

.container {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none;
}

.form {
  display: grid;
  gap: 11px;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

input:focus {
  outline: none;
  border-color: #b99af9;
  box-shadow: 0 0 0 3px rgba(166, 110, 255, 0.18);
}

textarea:focus,
select:focus {
  outline: none;
  border-color: #b99af9;
  box-shadow: 0 0 0 3px rgba(166, 110, 255, 0.18);
}

button {
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary-a), var(--primary-b));
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 18px rgba(123, 58, 241, 0.28);
}

button:hover {
  opacity: 0.95;
}

button:active {
  transform: translateY(1px);
}

.ghost {
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: none;
}

.error {
  color: var(--danger);
  min-height: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.topbar h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

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

.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-a), var(--primary-b));
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 3px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 0;
  min-height: 100vh;
}

.sidebar {
  align-self: stretch;
  position: sticky;
  top: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #fff 0%, #fbf9ff 100%);
  box-shadow: var(--shadow-md);
  border-radius: 0 18px 18px 0;
  padding: 24px 18px;
}

.sidebar h3 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.nav {
  display: grid;
  gap: 8px;
  margin: 16px 0 18px;
}

.nav-btn {
  width: 100%;
  text-align: left;
  font-size: 14px;
}

.nav-btn.active {
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.26), 0 12px 24px rgba(124, 58, 237, 0.24);
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.toolbar select {
  min-width: 180px;
  max-width: 220px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

.toolbar input {
  flex: 1 1 320px;
  min-width: 260px;
}

.toolbar input:focus,
.toolbar select:focus {
  outline: none;
  border-color: #b99af9;
  box-shadow: 0 0 0 3px rgba(166, 110, 255, 0.18);
}

.cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.item-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.item-card:hover {
  transform: translateY(-1px);
  border-color: #cfbcff;
  box-shadow: var(--shadow-md);
}

.item-card h4 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.25;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 2px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 14, 60, 0.45);
}

.modal-content {
  position: relative;
  max-width: 620px;
  margin: 8vh auto 0;
  box-shadow: var(--shadow-md);
}

.modal-body {
  font-size: 14px;
  line-height: 1.6;
}

.modal-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.modal-row:last-child {
  border-bottom: none;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .container {
    padding: 0;
  }

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

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    border-radius: 0;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .content {
    padding: 14px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .toolbar {
    padding: 10px;
  }

  .toolbar input,
  .toolbar select {
    min-width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
  }
}
