:root {
  --ink: #14231c;
  --muted: #66716b;
  --line: #dfe6e1;
  --surface: #fff;
  --bg: #f3f6f4;
  --green: #16784a;
  --green2: #24a66a;
  --pale: #e8f5ee;
  --danger: #c44444;
  --shadow: 0 18px 60px rgba(23, 52, 39, 0.09);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "DM Sans", "Noto Sans HK", sans-serif;
}
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  background: #10271d;
  color: #fff;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 36px;
  color: #fff;
  text-decoration: none;
  font-size: 18px;
}
.brand b {
  color: #72d7a0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, #30bd79, #168451);
  font-weight: 700;
}
.sidebar nav {
  display: grid;
  gap: 8px;
}
.nav-item {
  border: 0;
  padding: 13px 15px;
  display: flex;
  gap: 13px;
  align-items: center;
  border-radius: 12px;
  background: transparent;
  color: #aebdb5;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.nav-item:hover,
.nav-item.active {
  background: #1e3a2d;
  color: #fff;
}
.nav-icon {
  font-size: 20px;
  width: 22px;
  text-align: center;
}
.sidebar-foot {
  margin-top: auto;
  padding: 18px 10px 4px;
  border-top: 1px solid #2b4438;
  color: #b7c5bd;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5bce8b;
  box-shadow: 0 0 0 4px rgba(91, 206, 139, 0.12);
}
.health-dot.bad {
  background: #e27a72;
}
.health-dot.pending {
  background: #e9ae43;
}
main {
  min-width: 0;
  padding: 48px clamp(28px, 5vw, 72px);
}
.view {
  display: none;
  max-width: 1120px;
  margin: auto;
}
.view.active {
  display: block;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 48px);
  letter-spacing: -0.045em;
  line-height: 1.08;
}
h2,
h3 {
  margin: 0;
  letter-spacing: -0.02em;
}
.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
}
button,
input,
textarea,
select {
  font: inherit;
}
.primary {
  border: 0;
  border-radius: 12px;
  padding: 13px 19px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(22, 120, 74, 0.2);
}
.primary:hover {
  background: #11643d;
}
.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.primary.wide {
  width: 100%;
  margin-top: 20px;
}
.stat-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
  margin-bottom: 40px;
}
.stat {
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
}
.stat > span {
  color: var(--muted);
  font-size: 13px;
}
.stat strong {
  grid-row: 1/3;
  grid-column: 2;
  font-size: 34px;
}
.stat small {
  color: var(--muted);
  margin-top: 5px;
}
.stat.accent {
  background: linear-gradient(115deg, #173a2b, #1f533b);
  border: 0;
  color: #fff;
}
.stat.accent span,
.stat.accent small {
  color: #b9d2c6;
}
.stat.accent strong {
  font-size: 20px;
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  cursor: pointer;
}
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(285px, 1fr));
  gap: 14px;
}
.device-card {
  padding: 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(23, 52, 39, 0.035);
}
.device-top {
  display: flex;
  align-items: center;
  gap: 13px;
}
.device-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--pale);
  color: var(--green);
  font-weight: 700;
}
.device-title {
  min-width: 0;
  flex: 1;
}
.device-title h3 {
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.status-pill:before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e1a544;
}
.status-pill.connected:before {
  background: #3ab77a;
}
.status-pill.disconnected:before {
  background: #d75b56;
}
.device-info {
  margin: 18px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid #edf0ee;
  display: grid;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}
.device-info div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.device-info b {
  color: var(--ink);
  font-weight: 500;
}
.danger-button {
  margin-top: 16px;
  width: 100%;
  padding: 9px;
  border: 1px solid #f0d4d2;
  border-radius: 10px;
  color: var(--danger);
  background: #fff;
  cursor: pointer;
}
.empty {
  grid-column: 1/-1;
  padding: 55px 20px;
  text-align: center;
  border: 1px dashed #cdd8d1;
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
}
.composer {
  padding: 30px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}
.field em {
  font-style: normal;
  color: var(--green);
  font-size: 10px;
  text-transform: uppercase;
  margin-left: 5px;
}
.field > small {
  color: var(--muted);
  font-weight: 400;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ced8d2;
  border-radius: 11px;
  outline: none;
  background: #fff;
  color: var(--ink);
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green2);
  box-shadow: 0 0 0 3px rgba(36, 166, 106, 0.1);
}
fieldset {
  border: 0;
  padding: 0;
  margin: 28px 0;
}
legend {
  padding: 0;
  margin-bottom: 11px;
  font-size: 13px;
  font-weight: 600;
}
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.type-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  cursor: pointer;
}
.type-card input {
  position: absolute;
  opacity: 0;
}
.type-card.selected {
  border-color: var(--green);
  background: #f7fcf9;
}
.type-card > span:nth-of-type(2) {
  display: grid;
}
.type-card b {
  font-size: 14px;
}
.type-card small {
  color: var(--muted);
  font-size: 11px;
}
.type-icon {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  border-radius: 10px;
  background: #edf2ef;
  color: var(--green);
  font-weight: 700;
}
.type-card i {
  margin-left: auto;
  width: 16px;
  height: 16px;
  border: 1px solid #bdc9c2;
  border-radius: 50%;
}
.type-card.selected i {
  border: 5px solid var(--green);
}
.mode-panel {
  display: none;
  padding-top: 4px;
}
.mode-panel.active {
  display: block;
}
.align-right {
  text-align: right;
}
.dropzone {
  min-height: 180px;
  border: 1.5px dashed #b9c9c0;
  border-radius: 15px;
  background: #f8faf9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.dropzone:hover {
  border-color: var(--green);
  background: #f4fbf7;
}
.dropzone input {
  display: none;
}
.dropzone small {
  color: var(--muted);
}
.upload-icon {
  font-size: 24px;
  color: var(--green);
}
.media-preview {
  position: relative;
  margin: 14px 0;
}
.media-preview img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 14px;
}
.remove-media {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 31, 23, 0.8);
  color: #fff;
  cursor: pointer;
}
.processing {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  border-radius: 15px;
  background: #f4f9f6;
}
.processing div {
  display: grid;
  gap: 4px;
}
.processing small {
  color: var(--muted);
}
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #cfe3d7;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.light {
  width: 16px;
  height: 16px;
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}
.sticker-result {
  display: flex;
  align-items: center;
  gap: 25px;
  padding: 20px;
  border-radius: 15px;
  background: #f5f9f7;
}
.checker {
  width: 170px;
  height: 170px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background-color: #eee;
  background-image:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-size: 20px 20px;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
}
.checker img {
  width: 150px;
  height: 150px;
  object-fit: contain;
}
.ready-badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 20px;
  background: #dff4e8;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}
.sticker-result h3 {
  margin-top: 9px;
}
.sticker-result p {
  margin: 5px 0;
  color: var(--muted);
  font-size: 12px;
}
.text-button {
  border: 0;
  padding: 8px 0;
  background: none;
  color: var(--green);
  font-weight: 600;
  cursor: pointer;
}
.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.form-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.send-button {
  min-width: 160px;
}
.button-loading {
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.button-loading:not(.hidden) {
  display: flex;
}
dialog {
  width: min(440px, calc(100% - 28px));
  padding: 32px;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 30px 100px rgba(13, 38, 26, 0.25);
  text-align: center;
}
dialog::backdrop {
  background: rgba(10, 30, 21, 0.55);
  backdrop-filter: blur(3px);
}
.dialog-close {
  position: absolute;
  right: 15px;
  top: 12px;
  border: 0;
  background: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
}
.dialog-icon {
  margin: 0 auto 15px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--pale);
  color: var(--green);
  font-size: 24px;
}
.dialog-step > p {
  color: var(--muted);
  font-size: 13px;
}
.dialog-step .field {
  text-align: left;
  margin-top: 20px;
}
.qr-frame {
  width: 280px;
  height: 280px;
  margin: 20px auto 13px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  display: grid;
  place-items: center;
}
.qr-frame img {
  width: 100%;
  height: 100%;
}
.qr-loading {
  display: grid;
  place-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.qr-status {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  display: grid;
  gap: 10px;
}
.toast {
  max-width: 370px;
  padding: 14px 17px;
  border-radius: 12px;
  background: #173a2b;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.2s ease;
}
.toast.error {
  background: #8d3434;
}
.hidden {
  display: none !important;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
@media (max-width: 800px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: sticky;
    z-index: 10;
    width: 100%;
    height: auto;
    padding: 12px 18px;
    flex-direction: row;
    align-items: center;
  }
  .brand {
    padding: 0;
    margin-right: auto;
  }
  .brand > span:last-child {
    display: none;
  }
  .sidebar nav {
    display: flex;
  }
  .nav-item {
    padding: 10px;
  }
  .nav-item .nav-icon {
    display: none;
  }
  .sidebar-foot {
    display: none;
  }
  main {
    padding: 30px 18px;
  }
  .page-header {
    align-items: flex-start;
  }
  .stat-row,
  .field-grid {
    grid-template-columns: 1fr;
  }
  .type-grid {
    grid-template-columns: 1fr;
  }
  .composer {
    padding: 20px;
  }
  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }
  .sticker-result {
    align-items: flex-start;
    flex-direction: column;
  }
  .checker {
    width: 140px;
    height: 140px;
  }
  .checker img {
    width: 125px;
    height: 125px;
  }
}
@media (max-width: 500px) {
  .page-header {
    flex-direction: column;
  }
  .page-header .primary {
    width: 100%;
  }
  .nav-item span:last-child {
    font-size: 12px;
  }
  .stat.accent strong {
    font-size: 17px;
  }
}
