:root {
  --navy: #0b2141;
  --text: #112a4a;
  --muted: #718096;
  --blue: #2375ed;
  --blue-dark: #0c5fdf;
  --blue-soft: #eaf3ff;
  --border: #e3eaf3;
  --bg: #f4f7fb;
  --card: #fff;
  --green: #12a66a;
  --red: #d94f5c;
  --shadow: 0 16px 42px rgba(22, 54, 92, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 12% 15%, rgba(35, 117, 237, 0.16), transparent 28%),
    radial-gradient(circle at 90% 85%, rgba(35, 117, 237, 0.12), transparent 30%),
    linear-gradient(145deg, #f9fbff, #edf4fd);
}

.login-shell {
  width: min(520px, 100%);
  padding: 46px;
  border: 1px solid rgba(227, 234, 243, 0.95);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 30px 90px rgba(10, 36, 72, 0.13);
}

.login-brand,
.sidebar-brand {
  display: flex;
  flex-direction: column;
  width: max-content;
  margin-bottom: 38px;
}

.brand-mark {
  color: var(--navy);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.075em;
  line-height: 1;
}

.brand-mark span {
  color: var(--blue);
}

.login-brand small,
.sidebar-brand small {
  margin-top: 5px;
  color: var(--blue);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.28em;
}

.eyebrow {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.login-shell h1 {
  margin: 12px 0 14px;
  color: var(--navy);
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.login-shell > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 8px;
  color: #39506a;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  color: var(--text);
  background: #fff;
  border: 1px solid #d9e3ef;
  border-radius: 12px;
  outline: none;
  padding: 12px 14px;
  transition: 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(35, 117, 237, 0.1);
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.55;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 11px;
  padding: 0 17px;
  font-size: 13px;
  font-weight: 750;
}

.primary-button {
  color: #fff;
  background: var(--blue);
  border: 1px solid var(--blue);
}

.primary-button:hover {
  background: var(--blue-dark);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.secondary-button,
.ghost-button {
  color: #3a526d;
  background: #fff;
  border: 1px solid var(--border);
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.token-help {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.token-help summary {
  cursor: pointer;
  color: #425973;
  font-weight: 700;
}

.token-help ol {
  padding-left: 20px;
  line-height: 1.7;
}

.token-help a {
  color: var(--blue);
  font-weight: 700;
}

.admin-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 260px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  margin: 0;
  padding: 28px 28px 25px;
  border-bottom: 1px solid var(--border);
}

.sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding: 18px 15px;
}

.sidebar nav button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  color: #5f7186;
  background: transparent;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 680;
  text-align: left;
}

.sidebar nav button span {
  width: 22px;
  color: #8797a9;
  font-size: 17px;
  text-align: center;
}

.sidebar nav button:hover {
  color: var(--text);
  background: #f6f9fd;
}

.sidebar nav button.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.sidebar nav button.active span {
  color: var(--blue);
}

.nav-label {
  margin: 25px 13px 8px;
  color: #a0adba;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.15em;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 28px;
  border-top: 1px solid var(--border);
}

.connection-dot {
  width: 10px;
  height: 10px;
  background: var(--green);
  border: 3px solid #dff8ee;
  border-radius: 50%;
  box-sizing: content-box;
}

.sidebar-footer div {
  display: grid;
}

.sidebar-footer b {
  font-size: 12px;
}

.sidebar-footer small {
  color: var(--muted);
  font-size: 10px;
}

.main {
  min-height: 100vh;
  margin-left: 260px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 86px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 34px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 0;
  color: var(--navy);
  font-size: 22px;
  letter-spacing: -0.02em;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 11px;
}

.profile-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 9px 5px 5px;
  background: transparent;
  border: 0;
  border-radius: 12px;
}

.profile-button > span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--navy);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
}

.profile-button div {
  display: grid;
  text-align: left;
}

.profile-button b {
  font-size: 12px;
}

.profile-button small {
  color: var(--muted);
  font-size: 10px;
}

.menu-button {
  display: none;
  width: 42px;
  height: 42px;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.content {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 30px 34px 56px;
}

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

.metric-card,
.panel,
.loading-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 17px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 20px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 7px;
  color: var(--navy);
  font-size: 30px;
  letter-spacing: -0.04em;
}

.metric-card small {
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.panel {
  margin-top: 18px;
  overflow: hidden;
}

.panel-head {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  color: var(--navy);
  font-size: 17px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-head > :last-child:not(:first-child) {
  margin-left: auto;
}

.panel-body {
  padding: 20px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.quick-card {
  min-height: 116px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  color: var(--text);
  background: #f8fafd;
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: left;
}

.quick-card b {
  color: var(--navy);
}

.quick-card span {
  color: var(--muted);
  font-size: 12px;
}

.quick-card:hover {
  border-color: #b9d2f7;
  background: var(--blue-soft);
}

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

.toolbar input {
  width: min(340px, 100%);
}

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

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

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid #edf1f6;
  font-size: 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #8a99aa;
  background: #fbfcfe;
  font-size: 10px;
  letter-spacing: 0.08em;
}

td b {
  color: var(--navy);
}

.product-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 250px;
}

.product-cell img,
.post-cell img {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  object-fit: cover;
  background: #f2f5f8;
  border-radius: 10px;
}

.product-cell div,
.post-cell div {
  display: grid;
}

.product-cell small,
.post-cell small,
.muted {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  color: #0a8a57;
  background: #e9f9f2;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}

.status::before {
  width: 6px;
  height: 6px;
  content: "";
  background: var(--green);
  border-radius: 50%;
}

.text-button {
  color: var(--blue);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 750;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  padding-top: 6px;
}

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

.category-card {
  padding: 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.category-card input {
  margin-bottom: 10px;
  color: var(--navy);
  font-weight: 750;
}

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 230px;
  padding: 30px;
  border: 2px dashed #cbd9e8;
  border-radius: 16px;
  background: #f9fbfe;
  text-align: center;
}

.upload-zone input {
  width: auto;
  max-width: 100%;
}

.upload-zone p {
  color: var(--muted);
  font-size: 12px;
}

.upload-result {
  margin-top: 14px;
  padding: 14px;
  color: #39506a;
  background: var(--blue-soft);
  border-radius: 11px;
  font-size: 12px;
  word-break: break-all;
}

.loading-card {
  min-height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

.loading-card i {
  width: 20px;
  height: 20px;
  border: 2px solid #dce6f1;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

dialog {
  width: min(650px, calc(100% - 30px));
  max-height: calc(100vh - 36px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 30px 100px rgba(8, 30, 62, 0.25);
}

dialog::backdrop {
  background: rgba(8, 25, 47, 0.52);
  backdrop-filter: blur(5px);
}

.dialog-card {
  display: flex;
  max-height: calc(100vh - 36px);
  flex-direction: column;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 21px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
  margin: 5px 0 0;
  color: var(--navy);
  font-size: 21px;
}

.dialog-head .icon-button {
  width: 36px;
  height: 36px;
  margin-left: auto;
  color: #607187;
  background: #f4f7fa;
  border: 0;
  border-radius: 9px;
  font-size: 23px;
}

.dialog-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 21px;
  overflow-y: auto;
}

.dialog-fields .wide {
  grid-column: 1 / -1;
}

.dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: 390px;
  padding: 14px 18px;
  color: #fff;
  background: var(--navy);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 700;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1020px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 780px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(11, 33, 65, 0.18);
  }

  .main {
    margin-left: 0;
  }

  .menu-button {
    display: block;
  }

  .topbar {
    min-height: 76px;
    padding: 12px 18px;
  }

  .topbar p,
  .ghost-button,
  .profile-button div {
    display: none;
  }

  .content {
    padding: 20px 18px 42px;
  }

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

  .form-grid .wide {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .login-screen {
    padding: 14px;
  }

  .login-shell {
    padding: 30px 22px;
    border-radius: 22px;
  }

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

  .panel-head,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-head > :last-child:not(:first-child) {
    margin-left: 0;
  }

  .toolbar input {
    width: 100%;
  }

  .dialog-fields {
    grid-template-columns: 1fr;
  }

  .dialog-fields .wide {
    grid-column: auto;
  }
}
