:root {
  --ink: #14252b;
  --ink-soft: #5e7075;
  --paper: #f3f5f4;
  --surface: #ffffff;
  --line: #dfe6e4;
  --header: #102027;
  --accent: #0f9f8d;
  --accent-dark: #087567;
  --accent-soft: #e5f6f2;
  --warning: #dc922b;
  --danger: #ca4d45;
  --shadow: 0 20px 50px rgba(16, 32, 39, 0.14);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

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

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

[hidden] {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(15, 159, 141, 0.09), transparent 42%),
    #edf2f0;
}

.login-panel {
  position: relative;
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid #d7e1de;
  border-radius: 10px;
  background: white;
  box-shadow: var(--shadow);
}

.login-brand,
.admin-brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 39px;
  height: 39px;
  border-radius: 8px;
  place-items: center;
  color: #8ce2d3;
  background: linear-gradient(145deg, #1f4a4f, #15343b);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.login-brand strong,
.login-brand small,
.admin-brand strong,
.admin-brand small {
  display: block;
}

.login-brand strong,
.admin-brand strong {
  font-size: 17px;
}

.login-brand small,
.admin-brand small {
  margin-top: 2px;
  color: #839297;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.login-panel h1 {
  margin: 42px 0 10px;
  font-size: 28px;
}

.login-panel > p {
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.login-panel code {
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
}

.back-link {
  display: inline-block;
  margin-top: 18px;
  color: #6d7e82;
  font-size: 13px;
}

.back-link:hover {
  color: var(--accent-dark);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field > span {
  color: #42575d;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  padding: 0 13px;
  border: 1px solid #cbd6d3;
  border-radius: 7px;
  outline: 0;
  background: white;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input {
  height: 43px;
}

.field textarea {
  min-height: 180px;
  padding: 12px 13px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 159, 141, 0.12);
}

.button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 41px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button svg {
  width: 18px;
  height: 18px;
}

.button-primary {
  color: white;
  background: var(--accent);
  box-shadow: 0 9px 20px rgba(15, 159, 141, 0.2);
}

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

.button-secondary,
.button-quiet {
  border-color: var(--line);
  color: var(--ink);
  background: white;
}

.button-secondary:hover,
.button-quiet:hover {
  border-color: #bfcac7;
  background: #f8fbfa;
}

.button-quiet {
  min-height: 35px;
  border-color: rgba(255, 255, 255, 0.18);
  color: #d8e1e2;
  background: rgba(255, 255, 255, 0.06);
}

.button-full {
  width: 100%;
}

.icon-button {
  display: grid;
  width: 37px;
  height: 37px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  place-items: center;
  background: white;
  cursor: pointer;
}

.icon-button:hover {
  background: #f7faf9;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.admin-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  padding: 0 28px;
  color: white;
  background: var(--header);
  box-shadow: 0 10px 30px rgba(7, 20, 25, 0.16);
}

.admin-brand span:last-child {
  color: white;
}

.admin-header-actions {
  display: flex;
  gap: 18px;
  align-items: center;
}

.connection-state {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  color: #b9c9cc;
  font-size: 12px;
}

.connection-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #50d3a7;
  box-shadow: 0 0 0 4px rgba(80, 211, 167, 0.12);
}

.header-link {
  color: #ced9db;
  font-size: 13px;
}

.header-link:hover {
  color: white;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 68px);
}

.admin-sidebar {
  position: sticky;
  top: 68px;
  display: flex;
  height: calc(100vh - 68px);
  flex-direction: column;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: #f8faf9;
}

.admin-sidebar nav {
  display: grid;
  gap: 5px;
}

.admin-nav-item {
  display: flex;
  gap: 11px;
  align-items: center;
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  color: #64767b;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.admin-nav-item:hover,
.admin-nav-item.is-active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.admin-nav-item svg {
  width: 18px;
  height: 18px;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #d7e2df;
  border-radius: 8px;
  background: white;
}

.sidebar-note strong {
  font-size: 13px;
}

.sidebar-note p {
  margin: 7px 0 0;
  color: #74858a;
  font-size: 11px;
  line-height: 1.6;
}

.admin-main {
  min-width: 0;
  padding: 28px;
}

.admin-view {
  width: min(1440px, 100%);
  margin: 0 auto;
}

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

.view-kicker {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.view-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.view-header p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

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

.metric-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 6px 18px rgba(16, 32, 39, 0.04);
}

.metric-card span {
  display: block;
  margin-bottom: 9px;
  color: #78898e;
  font-size: 12px;
}

.metric-card strong {
  display: block;
  font-size: 25px;
}

.metric-card small {
  display: block;
  margin-top: 7px;
  color: #87969a;
  font-size: 11px;
}

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

.data-panel {
  min-width: 0;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 6px 18px rgba(16, 32, 39, 0.04);
}

.data-panel-heading {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.data-panel-heading h2 {
  margin: 0 0 5px;
  font-size: 16px;
}

.data-panel-heading p {
  margin: 0;
  color: #849397;
  font-size: 12px;
}

.alert-list,
.recent-orders {
  display: grid;
  gap: 8px;
}

.alert-item,
.recent-order {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid #e4eae8;
  border-radius: 7px;
  background: #fafcfb;
}

.alert-item > div,
.recent-order > div {
  min-width: 0;
}

.alert-item strong,
.recent-order strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.alert-item span,
.recent-order span {
  display: block;
  margin-top: 4px;
  color: #87969a;
  font-size: 11px;
}

.stock-pill,
.status-pill {
  display: inline-flex;
  min-width: max-content;
  padding: 4px 8px;
  border-radius: 20px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 800;
}

.stock-pill.is-low {
  color: #946117;
  background: #fff3dd;
}

.status-pill.is-pending {
  color: #8c621c;
  background: #fff2d8;
}

.empty-list {
  padding: 28px 16px;
  border: 1px dashed #d4dddb;
  border-radius: 7px;
  color: #839397;
  font-size: 12px;
  text-align: center;
}

.product-form-panel {
  margin-bottom: 18px;
}

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

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

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-panel {
  margin: 0;
}

.switch-control {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  min-width: max-content;
  color: #42575d;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.switch-control input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

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

.qr-setting {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 16px;
  border: 1px solid #e2e9e7;
  border-radius: 8px;
  background: #fafcfb;
}

.qr-preview {
  display: grid;
  width: min(230px, 100%);
  aspect-ratio: 1;
  padding: 9px;
  border: 1px dashed #cbd7d4;
  border-radius: 8px;
  place-items: center;
  overflow: hidden;
  color: #8a999c;
  background: white;
  font-size: 12px;
  text-align: center;
}

.qr-preview img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  object-fit: contain;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.danger-text {
  color: var(--danger);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-panel .data-panel-heading {
  margin: 0;
  padding: 18px 19px;
  border-bottom: 1px solid var(--line);
}

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

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

th {
  padding: 11px 14px;
  color: #74858a;
  background: #f8faf9;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 13px 14px;
  border-top: 1px solid #edf1f0;
  color: #53676d;
  vertical-align: middle;
}

tbody tr:hover {
  background: #fbfdfc;
}

.table-product {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 200px;
}

.table-product img {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
}

.table-product strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.table-product small {
  display: block;
  margin-top: 3px;
  color: #8c9a9e;
  font-size: 10px;
}

.table-actions {
  display: flex;
  gap: 7px;
}

.mini-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #d8e1df;
  border-radius: 6px;
  color: #52666b;
  background: white;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.mini-button:hover {
  border-color: #b7c6c2;
  color: var(--accent-dark);
}

.mini-button.is-danger:hover {
  border-color: #e7b8b4;
  color: var(--danger);
}

.mini-button.is-highlight {
  border-color: #93d2c6;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.code-preview {
  max-width: 280px;
  overflow: hidden;
  color: #42575d;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal {
  width: min(580px, calc(100% - 28px));
  max-height: calc(100vh - 30px);
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(7, 20, 25, 0.64);
  backdrop-filter: blur(4px);
}

.modal-shell {
  position: relative;
  max-height: calc(100vh - 30px);
  padding: 30px;
  overflow-y: auto;
  border-radius: 10px;
  background: white;
}

.modal-shell h2 {
  margin: 6px 0 8px;
  font-size: 24px;
}

.dialog-note {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 9px;
  width: min(360px, calc(100% - 40px));
  pointer-events: none;
}

.toast {
  padding: 13px 15px;
  border-radius: 8px;
  color: white;
  background: #183039;
  box-shadow: 0 10px 25px rgba(16, 32, 39, 0.14);
  font-size: 13px;
  animation: toast-in 180ms ease both;
}

.toast.is-error {
  background: #8e3531;
}

.toast.is-success {
  background: #116c60;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

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

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

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

@media (max-width: 760px) {
  .admin-header {
    height: auto;
    min-height: 64px;
    padding: 12px 16px;
  }

  .connection-state,
  .header-link {
    display: none;
  }

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

  .admin-sidebar {
    position: sticky;
    z-index: 15;
    top: 64px;
    display: block;
    width: 100%;
    height: auto;
    padding: 8px 12px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .admin-sidebar nav {
    display: flex;
    width: max-content;
  }

  .admin-nav-item {
    width: auto;
    min-width: max-content;
  }

  .sidebar-note {
    display: none;
  }

  .admin-main {
    padding: 20px 12px;
  }

  .view-header {
    align-items: flex-start;
  }

  .qr-settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .admin-brand small {
    display: none;
  }

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

  .view-header {
    flex-direction: column;
  }

  .view-header .button {
    width: 100%;
  }

  .modal-shell {
    padding: 28px 18px 20px;
  }
}
