:root {
  --accent: #4f46e5;
  --bg: #f2f3f8;
  --surface: #ffffff;
  --text: #14141f;
  --muted: #6b7280;
  --border: #e2e3ec;
  --radius: 14px;
  --danger: #dc2626;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

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

.btn-mini { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

input, select, textarea {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

input[type="color"] { padding: 4px 6px; height: 42px; cursor: pointer; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.field + .field { margin-top: 0; }

.error { color: var(--danger); font-size: 13px; text-align: center; min-height: 1.2em; }

/* Auth */
.screen { min-height: 100vh; }

#authScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(600px 300px at 80% -10%, rgba(99, 102, 241, 0.14), transparent 70%),
    radial-gradient(500px 260px at 10% 0%, rgba(168, 85, 247, 0.1), transparent 70%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(20, 20, 40, 0.08);
  padding: 36px;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 16px;
  margin-bottom: 24px;
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}

.auth-mark svg { width: 18px; height: 18px; }

#authScreen h1 { font-size: 22px; text-align: center; }

.auth-sub { color: var(--muted); font-size: 14px; text-align: center; margin: 8px 0 22px; }

.auth-form { display: grid; gap: 12px; }

.auth-note { font-size: 12px; color: var(--muted); text-align: center; margin-top: 18px; }

/* App */
.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.admin-wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}

.admin-brand { font-size: 16px; }

.admin-actions { display: flex; gap: 10px; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 20px 0 8px;
  flex-wrap: wrap;
}

.tab {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.tab.active { background: var(--accent); color: #fff; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  padding: 22px;
}

.panel h2 { font-size: 16px; margin-bottom: 6px; }

.hint { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat strong { font-size: 22px; }
.stat > span:not(.stat-dot) { font-size: 12px; color: var(--muted); }

.stat-total strong { color: var(--accent); }

.stat-dot { width: 10px; height: 10px; border-radius: 50%; margin-bottom: 6px; }

/* Forms */
.form-grid { display: grid; gap: 12px; }

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

.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

/* Lists */
.list { display: grid; gap: 10px; }

.empty-inline { color: var(--muted); font-size: 14px; padding: 8px 0; }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--bg);
}

.list-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
}

.avatar-ghost { background: #eef0f6; color: var(--muted); }

.list-main { flex: 1; min-width: 0; }

.list-main strong { display: block; font-size: 14px; }

.list-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; align-items: center; }

.tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.tag-ghost { background: #e8e8f0; color: var(--muted); }

.price-tag { font-size: 13px; font-weight: 700; color: var(--accent); }

.list-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.rename-input { width: 140px; padding: 6px 10px; }

/* Forms inline */
.inline-form { display: flex; gap: 10px; }

.inline-form input { flex: 1; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #14141f;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  z-index: 100;
  max-width: 90vw;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}

.auth-tab {
  flex: 1;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 9px 0;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }

.code-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.5px;
}

@media (max-width: 640px) {
  .row { grid-template-columns: 1fr; }
  .header-inner { flex-wrap: wrap; gap: 10px; padding: 10px 0; }
  .list-item { flex-wrap: wrap; }
  .rename-input { width: 100%; }
  .inline-form { flex-wrap: wrap; }
  .inline-form .btn { width: 100%; }
}