:root {
  --paper: #eef1f5;
  --white: #fff;
  --ink: #1d1d1b;
  --muted: #72736f;
  --line: #d8dee6;
  --soft: #ecece7;
  --orange: #f15b35;
  --green: #26815c;
  --sidebar: #162033;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  background: var(--sidebar);
  color: #f9f9f5;
  padding: 28px 17px 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 31px; }
.brand-logo { width: 36px; height: 36px; border-radius: 9px; display: block; object-fit: cover; flex-shrink: 0; }
.brand strong { display: block; font-size: 15px; line-height: 1.25; }
.eyebrow { margin: 0; color: #99a6b9; font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.nav { padding-top: 28px; }
.nav-label { margin: 0 9px 8px; color: #8491a5; font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.nav-label.second { margin-top: 25px; }
.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: #aeb9c9;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  margin: 2px 0;
  text-align: left;
  font-size: 13px;
}
.nav-item:hover { color: #fff; }
.nav-item.active { background: var(--orange); color: #fff; }
.nav-item.hidden { display: none !important; }
.nav-number { width: 23px; color: #777a73; font-size: 10px; font-variant-numeric: tabular-nums; }
.nav-item.active .nav-number { color: #fff; }
.sidebar-foot { margin-top: auto; padding: 16px 9px 0; border-top: 1px solid #354258; }
.icp-beian {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
  color: #8f9caf;
}
.icp-beian a {
  color: inherit;
  text-decoration: none;
}
.icp-beian a:hover { text-decoration: underline; }
.sidebar-foot .icp-beian { margin-top: 12px; text-align: left; }
.icp-beian-mobile { display: none; }
.security-note { font-size: 11px; color: #d9e0ea; }
.sidebar-foot > p { font-size: 11px; line-height: 1.5; color: #8f9caf; margin: 9px 0 15px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: #91948d; vertical-align: 1px; }
.status-dot.green { background: #52bb87; }
.user-menu-wrap { position: relative; }
.user-button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 0;
  text-align: left;
}
.avatar { width: 28px; height: 28px; display: grid; place-items: center; background: #31405a; font-weight: 700; font-size: 12px; }
.user-button b, .user-button small { display: block; }
.user-button b { font-size: 12px; }
.user-button small { font-size: 10px; color: #90928c; margin-top: 2px; }
.more { margin-left: auto; color: #8c8e87; letter-spacing: 2px; padding: 6px 2px; cursor: pointer; }
.user-menu {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 42px;
  background: #1c2a40;
  border: 1px solid #354258;
  z-index: 30;
}
.user-menu.open { display: block; }
.user-menu button { width: 100%; border: 0; background: transparent; color: #fff; padding: 10px 12px; text-align: left; }
.user-menu button:hover { background: var(--orange); }

.main-content { min-width: 0; background: var(--paper); }
.topbar {
  height: 88px;
  padding: 20px 46px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.breadcrumb { margin: 0 0 8px; color: #8993a1; font-size: 11px; }
.topbar h1 { margin: 0; font-size: 24px; line-height: 1.05; font-weight: 700; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 18px; }
.plugin-download {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  margin: 0 0 12px;
  border: 0;
  background: #ff4f00;
  color: #fff !important;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-sizing: border-box;
}
.plugin-download:hover { background: #e04600; color: #fff !important; }
.environment { color: var(--muted); font-size: 11px; }

.outline-button, .primary-button, .small-button {
  height: 38px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  padding: 0 15px;
  font-weight: 600;
}
.outline-button:hover { border-color: var(--orange); color: var(--orange); }
.primary-button { border-color: var(--orange); background: var(--orange); color: #fff; }
.primary-button:hover { background: #d94b1f; }
.small-button { height: 30px; padding: 0 11px; font-size: 11px; }

.purchase-shell { min-height: 100vh; }
.purchase-shell .main-content { display: flex; flex-direction: column; min-height: 100vh; }
.purchase-embed { flex: 1; min-height: 0; background: #f7f7f8; }
.purchase-embed.hidden, .admin-page.hidden { display: none !important; }
.purchase-embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 88px);
  border: 0;
  background: #f7f7f8;
}
.admin-page { flex: 1; min-height: 0; overflow: auto; padding: 28px 42px 50px; }
.admin-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.admin-toolbar select { height: 38px; border: 1px solid var(--line); padding: 0 10px; background: #fff; }
.admin-toolbar p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.admin-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); }
.admin-table th { text-align: left; background: #f7f8fa; color: #8993a1; font-size: 11px; padding: 10px 12px; font-weight: 600; }
.admin-table td { padding: 12px; border-top: 1px solid #e7ebf0; font-size: 13px; vertical-align: middle; }
.admin-table .row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-pill { margin-left: auto; padding: 5px 9px; font-size: 10px; }
.status-pill.active { background: #edf8f1; color: #276a4c; }
.status-pill.disabled { background: #f2f2ee; color: var(--muted); }
.admin-table .muted { color: var(--muted); font-size: 11px; margin-top: 4px; }
.admin-error { margin: 0 0 14px; color: #b33d24; }

dialog { border: 0; padding: 0; width: min(650px, calc(100vw - 32px)); box-shadow: 0 12px 45px rgba(20, 20, 18, .2); }
dialog::backdrop { background: rgba(20, 20, 18, .5); }
dialog form { padding: 25px; }
dialog h3 { margin: 0 0 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { color: var(--muted); font-size: 11px; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select {
  display: block;
  width: 100%;
  height: 39px;
  margin-top: 7px;
  border: 1px solid #c8c9c3;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.form-grid input:focus, .form-grid select:focus { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange); }
.date-selects { display: grid; grid-template-columns: 1.2fr .9fr .9fr; gap: 8px; margin-top: 7px; }
.date-selects select { width: 100%; height: 39px; margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.form-error { color: #b33d24; font-size: 11px; }

.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--sidebar);
  position: relative;
  padding: 32px 16px 56px;
}
.login-screen .icp-beian { position: absolute; left: 0; right: 0; bottom: 16px; color: #8f9caf; }
.login-screen.hidden, .app-shell.hidden { display: none !important; }
.login-card { width: min(380px, 92vw); background: #fff; padding: 28px 28px 24px; }
.login-card .brand-logo { margin-bottom: 14px; }
.login-card .eyebrow { color: #8993a1; margin-bottom: 8px; }
.login-card h1 { margin: 0 0 22px; font-size: 22px; }
.login-card label { display: block; margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.login-card input { display: block; width: 100%; height: 40px; margin-top: 6px; border: 1px solid #c8c9c3; padding: 0 10px; }
.login-card .primary-button { width: 100%; margin-top: 8px; }
.login-card .form-error { margin: 0 0 10px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .topbar { padding-left: 25px; padding-right: 25px; }
}
@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { min-height: auto; padding-bottom: 10px; }
  .sidebar-foot { display: block; padding-top: 12px; }
  .sidebar-foot .security-note,
  .sidebar-foot > p,
  .sidebar-foot .user-menu-wrap,
  .sidebar-foot .icp-beian { display: none; }
  .icp-beian-mobile {
    display: block;
    padding: 12px 16px 16px;
    color: var(--muted);
    background: var(--paper);
  }
  .nav { display: flex; overflow: auto; padding-top: 12px; gap: 4px; }
  .nav-label, .nav-label.second { display: none; }
  .nav-item { min-width: max-content; padding: 9px; }
  .nav-number { display: none; }
  .topbar { height: auto; padding: 18px 16px; }
  .top-actions .environment { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.wide { grid-column: auto; }
  .purchase-embed iframe { min-height: calc(100vh - 220px); }
  .admin-page { padding: 20px 16px; }
}
.erp-bind-card{max-width:640px;background:#fff;border:1px solid #d8dee6;padding:22px 24px}
.erp-bind-card label{display:block;margin:0 0 14px;color:var(--muted);font-size:12px}
.erp-bind-card select,.erp-bind-card textarea{display:block;width:100%;margin-top:6px;border:1px solid #c8c9c3;padding:8px 10px}
.erp-bind-card textarea{min-height:110px;font-family:ui-monospace,monospace;font-size:12px}
.erp-bind-card .muted{color:var(--muted);font-size:12px;line-height:1.5}
.erp-bind-steps{margin:0 0 16px;padding-left:20px;color:#444;font-size:13px;line-height:1.65}
.erp-bind-steps kbd{display:inline-block;padding:0 5px;border:1px solid #d0d0d0;border-radius:3px;background:#f6f6f6;font-size:12px}
.erp-bind-steps code{font-size:12px;background:#f4f4f4;padding:1px 4px}
