:root {
  color-scheme: dark;
  --bg: #050611;
  --surface: rgba(19, 19, 29, 0.84);
  --surface-strong: rgba(24, 24, 35, 0.96);
  --surface-soft: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #f8fafc;
  --muted: #a5adbb;
  --faint: #737b8c;
  --blue: #0ea5ff;
  --violet: #8b5cf6;
  --pink: #d946ef;
  --cyan: #22d3ee;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 8px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(150deg, rgba(7, 9, 24, 0.98) 0%, rgba(11, 10, 31, 0.92) 28%, rgba(32, 10, 62, 0.84) 54%, rgba(0, 88, 139, 0.72) 100%),
    #050611;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell,
.public-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 72px;
  padding: 0 28px;
  background: rgba(8, 8, 18, 0.62);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px) saturate(1.2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--violet), var(--blue) 55%, var(--cyan));
  color: #fff;
  box-shadow: 0 12px 32px rgba(14, 165, 255, 0.3);
}

.brand-text {
  display: grid;
  line-height: 1.1;
}

.brand-text small {
  color: var(--muted);
  font-weight: 600;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
}

.nav a,
.nav button,
.ghost-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.nav a:hover,
.nav button:hover,
.ghost-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  justify-content: flex-end;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--surface-soft), rgba(14, 165, 255, 0.22));
  border: 1px solid var(--line);
  font-weight: 800;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.main {
  width: min(1180px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 56px 0 72px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.05;
}

.hero p {
  max-width: 660px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-pad {
  padding: 24px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 34px 0 14px;
}

.section-head h2,
.panel h2,
.panel h3 {
  margin: 0;
}

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

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

.stack {
  display: grid;
  gap: 14px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(14, 165, 255, 0.2);
}

.btn:hover {
  filter: brightness(1.07);
}

.btn.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
  box-shadow: none;
}

.btn.danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.34);
  color: #fecaca;
  box-shadow: none;
}

.btn.compact {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 13px;
}

.stat {
  padding: 20px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat strong {
  display: block;
  font-size: 34px;
  line-height: 1;
}

.item-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.item-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.item-title {
  margin: 0;
  font-size: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 8px;
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.badge.green {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.34);
  background: rgba(34, 197, 94, 0.12);
}

.badge.yellow {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.36);
  background: rgba(245, 158, 11, 0.12);
}

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

.thumb {
  width: 74px;
  height: 74px;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.26), rgba(14, 165, 255, 0.24));
  border: 1px solid var(--line);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb.placeholder {
  display: grid;
  place-items: center;
  font-size: 28px;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  padding: 11px 12px;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(14, 165, 255, 0.86);
  box-shadow: 0 0 0 3px rgba(14, 165, 255, 0.18);
}

input[type="checkbox"] {
  width: auto;
}

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

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.link-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr 140px auto;
  gap: 10px;
  align-items: center;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.flash-wrap {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
}

.flash.success {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.34);
}

.flash.error {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.38);
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
}

.login-panel {
  width: min(520px, 100%);
}

.public-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
}

.public-card {
  width: min(540px, 100%);
  padding: 26px;
  text-align: center;
}

.public-card h1 {
  margin: 14px 0 6px;
  font-size: clamp(32px, 8vw, 52px);
  line-height: 1.02;
}

.public-product {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 14px;
  align-items: center;
  margin: 0 0 18px;
  text-align: left;
}

.public-links {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.public-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
  text-decoration: none;
}

.public-links a:hover {
  background: rgba(255, 255, 255, 0.14);
}

.gradient-text {
  background: linear-gradient(135deg, var(--violet), var(--blue) 58%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.copy {
  word-break: break-word;
  color: var(--cyan);
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    height: auto;
    padding: 16px;
    flex-wrap: wrap;
  }

  .brand,
  .user-chip {
    min-width: 0;
  }

  .nav {
    order: 3;
    justify-content: flex-start;
    overflow-x: auto;
    width: 100%;
    padding-bottom: 2px;
  }

  .main {
    width: min(100vw - 28px, 1180px);
    padding-top: 32px;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid.cols-2,
  .grid.cols-3,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .link-row,
  .product-row,
  .public-product {
    grid-template-columns: 1fr;
  }
}
