:root {
  --bg: #eff3f8;
  --sidebar: #0e1a2b;
  --sidebar-alt: #13273f;
  --panel: #f7f9fb;
  --card: #ffffff;
  --line: #dee6f0;
  --primary: #0d2344;
  --primary-soft: #eaf4ff;
  --text: #1c2433;
  --muted: #64748b;
  --green: #19a66a;
  --green-soft: #eafaf1;
  --warning: #efb24b;
  --danger: #d84e5c;
  --shadow: 0 10px 26px rgba(15, 33, 58, 0.07);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-shell {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #edf4fb 0%, #f3f6fa 100%);
  padding: 40px 20px;
}

.auth-shell.active {
  display: flex;
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(19, 39, 63, 0.08);
  border-radius: 18px;
  box-shadow: 0 18px 28px rgba(17, 34, 58, 0.08);
  padding: 26px 28px 20px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #153a76, #3a92ec);
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.5);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px solid rgba(255,255,255,0.8);
  border-radius: 999px;
}

.brand-mark::after {
  inset: 17px;
  border-width: 1px;
}

.brand-mark.small {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.eyebrow {
  margin: 0;
  font-size: 0.71rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: #3a5b94;
}

.auth-card h1 {
  margin: 6px 0 0;
  color: var(--primary);
  font-size: clamp(1.9rem, 3vw, 2.4rem);
}

.auth-form,
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form label,
.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

input, select, textarea {
  width: 100%;
  border: 1px solid #dfe8f2;
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px 12px;
  color: var(--text);
  outline: none;
  min-height: 42px;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(16, 44, 74, 0.55);
  box-shadow: 0 0 0 4px rgba(21, 58, 118, 0.08);
}

.primary-btn,
.secondary-btn,
.publish-btn,
.panel-action,
.icon-btn,
.action-btn {
  border: none;
  border-radius: 10px;
  font-weight: 700;
  transition: 0.2s ease;
}

.primary-btn,
.publish-btn {
  background: linear-gradient(180deg, #1d4f83, #123c6a);
  color: #fff;
  min-height: 46px;
  padding: 0 16px;
  box-shadow: 0 12px 16px rgba(17, 42, 72, 0.12);
}

.primary-btn:hover,
.publish-btn:hover {
  transform: translateY(-1px);
}

.secondary-btn {
  background: #edf2f9;
  color: var(--primary);
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line);
}

.error-text {
  min-height: 20px;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
}

.error-text:empty {
  display: none;
}

.app-shell {
  display: none;
  min-height: 100vh;
  grid-template-columns: 250px 1fr;
}

.app-shell.active {
  display: grid;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar), #101f33 100%);
  color: #fff;
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand-name-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-caps {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.72);
}

.brand-name-wrap strong {
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-group-title {
  margin-top: 8px;
  padding: 0 10px;
  color: rgba(255,255,255,0.48);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.nav-link {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: rgba(255,255,255,0.84);
  text-align: left;
  padding: 11px 12px;
  font-weight: 600;
}

.nav-link.active,
.nav-link:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.08);
}

.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 0;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4f83, #3d9bf0);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 800;
}

.user-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.user-copy strong {
  font-size: 0.9rem;
}

.user-copy span {
  color: rgba(255,255,255,0.7);
  font-size: 0.7rem;
}

.icon-btn {
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.08);
  color: white;
  border: 1px solid rgba(255,255,255,0.08);
}

.main-panel {
  padding: 28px 28px 30px;
  background: #f3f6fb;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(2.1rem, 3vw, 3rem);
  line-height: 1.1;
  color: var(--primary);
  letter-spacing: -0.05em;
}

.page-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.publish-btn {
  min-width: 170px;
  height: 46px;
  font-size: 0.95rem;
}

.content-section {
  display: none;
}

.content-section.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: 0 8px 20px rgba(19, 39, 63, 0.03);
}

.stat-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #5d7189;
}

.stat-icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.stat-number {
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  line-height: 1;
  color: var(--primary);
  letter-spacing: -0.05em;
  font-weight: 700;
}

.stat-trend {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-trend span {
  font-size: 0.7rem;
}

.trend-live {
  color: var(--green);
}

.trend-alert {
  color: #c27a00;
}

.dashboard-lower {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(260px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.panel-box {
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(19, 39, 63, 0.03);
  padding: 16px 16px 8px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-head h3 {
  margin: 0;
  color: var(--primary);
  font-size: 1.1rem;
}

.panel-action {
  background: #edf3fa;
  color: var(--primary);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 0.97rem;
}

th {
  color: #6d7f96;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.warning {
  background: rgba(239, 178, 75, 0.12);
  color: #9d6500;
}

.table-action {
  border: none;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  padding: 0;
}

.quick-box {
  display: flex;
  flex-direction: column;
  gap: 18px;
  justify-content: flex-start;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  width: 100%;
  background: #f3f8ff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 14px;
  color: var(--primary);
}

.quick-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(29, 79, 131, 0.08);
  font-size: 1.2rem;
}

.quick-action strong {
  display: block;
  font-size: 1.03rem;
  margin-bottom: 2px;
}

.quick-action small {
  color: var(--muted);
  display: block;
  line-height: 1.5;
}

.table-wrap {
  overflow-x: auto;
}

.product-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(260px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.upload-block {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.upload-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 1px dashed #b7c7d9;
  background: #f5f8fc;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
}

.upload-box input {
  display: none;
}

.helper-box {
  background: #f5f8fc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.helper-box h4 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7d8fa8;
}

.helper-box pre {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--text);
}

.inline-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.inline-form input {
  flex: 1;
  min-width: 220px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(25, 166, 106, 0.2);
  background: rgba(25, 166, 106, 0.07);
  color: var(--green);
  font-weight: 700;
}

.chip .remove {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--green);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
}

.muted-note,
.section-note {
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

.full-box {
  padding: 18px 18px 12px;
}

.margin-top {
  margin-top: 18px;
}

.action-btn {
  background: #2c6fe8;
  color: white;
  padding: 8px 10px;
  border-radius: 8px;
  margin-right: 6px;
}

.action-btn.delete-btn {
  background: var(--danger);
}

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(17, 28, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.drawer.hidden {
  display: none;
}

.drawer-panel {
  width: min(540px, calc(100vw - 32px));
  background: white;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px 20px 18px;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.drawer-head h3 {
  margin: 0;
  color: var(--primary);
}

.close-drawer {
  border: none;
  background: #eef2f8;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.5rem;
  color: var(--primary);
}

.slim {
  gap: 14px;
}

@media (max-width: 1100px) {
  .dashboard-lower,
  .product-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .main-panel {
    padding: 20px 16px 30px;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
