:root {
  --primary-color: #ff434f;
  --secondary-color: #e3e3e3;
  --text-color-lightest: #e7e9ec;
  --text-color-darker: #2e2e2e;
  --text-color-dark: #494949;
  --text-color-gray: #8b8b8b;
  --text-color-dark-gray: #727272;
  --section-bg: #f9fbfb;
  --card-shadow: 0 0 18px rgba(0, 0, 0, 0.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: Helvetica, "PingFang SC", "Microsoft Yahei", sans-serif;
  font-size: 14px;
  color: var(--text-color-dark);
  background: var(--section-bg);
  min-height: 100vh;
}
.hidden { display: none !important; }
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(rgba(42,42,42,.72), rgba(24,24,24,.88)),
              linear-gradient(135deg, #1a2a3a, #2c3e50 50%, #121820);
}
.login-card {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 4px;
  padding: 36px 32px;
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
}
.login-card h1 { font-size: 28px; color: var(--text-color-darker); }
.login-card h1::after {
  content: ""; display: block; width: 64px; height: 4px;
  background: var(--primary-color); margin-top: 12px;
}
.login-card .sub { color: var(--text-color-dark-gray); margin: 14px 0 22px; }
.login-card label { display:block; font-size: 13px; color: var(--text-color-gray); margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; border: 1px solid #e5e8ea; background: #f4f6f7;
  color: var(--text-color-darker); border-radius: 4px; padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary-color); background: #fff; }
button, .btn {
  border: 0; border-radius: 4px; padding: 11px 16px; background: var(--primary-color);
  color: #e7e9ec; font-weight: 600; cursor: pointer;
}
.login-card button { width: 100%; margin-top: 22px; }
.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 4px; color: var(--text-color-gray); font-size: 12px;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: #e8ebed;
}
.wx-login-btn {
  width: 100%; margin-top: 10px !important;
  background: #07c160 !important; color: #fff !important;
}
.wx-login-box {
  margin-top: 16px; padding: 14px; border: 1px dashed #d7dde0; border-radius: 4px;
  text-align: center;
}
.wx-tip { color: var(--text-color-gray); font-size: 13px; margin-bottom: 10px; }
.wx-qr { width: 200px; height: 200px; margin: 8px auto; display: block; }
.wx-auth-link {
  display: inline-block; margin: 8px 0; color: #07c160; font-size: 13px;
}
.wx-bind-form { text-align: left; margin-top: 8px; }
.wx-bind-form button { margin-top: 14px; }
.wx-cancel { margin-top: 12px !important; background: var(--secondary-color) !important; color: var(--text-color-dark-gray) !important; }
.btn.secondary { background: var(--secondary-color); color: var(--text-color-dark-gray); }
.btn.block { width: 100%; }
.error { color: var(--primary-color); min-height: 20px; font-size: 13px; margin-top: 10px; }
.login-home {
  display: block; text-align: center; margin-top: 16px;
  color: var(--text-color-gray); font-size: 13px; text-decoration: none;
}
.login-home:hover { color: var(--primary-color); }

#mainView { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sider {
  background: #181818; color: #e7e9ec; padding: 24px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.brand { font-size: 18px; font-weight: 600; color: #fff; padding: 4px 10px; display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; background: rgba(0,0,0,.25); }
.brand-sub { font-size: 12px; color: #c6c6c6; padding: 0 10px 18px; }
.sider nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sider nav button, .logout {
  text-align: left; border: 0; background: transparent; color: #c6c6c6;
  padding: 12px 14px; border-radius: 4px; cursor: pointer; font-size: 14px;
}
.sider nav button.active, .sider nav button:hover {
  background: rgba(255,67,79,.15); color: #fff;
}
.sider nav button.active { border-left: 3px solid var(--primary-color); padding-left: 11px; }
.logout { color: var(--primary-color); margin-top: auto; }
.content { padding: 28px 32px 48px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; }
.top h2 { font-size: 28px; color: var(--text-color-darker); }
.top h2::after {
  content: ""; display: block; width: 56px; height: 4px;
  background: var(--primary-color); margin-top: 10px;
}
.top-right { display: flex; align-items: center; gap: 14px; color: var(--text-color-gray); }
.ws-status { font-size: 12px; padding: 4px 10px; border-radius: 4px; background: var(--secondary-color); }
.ws-status.on { background: rgba(255,67,79,.12); color: var(--primary-color); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.card {
  background: #fff; border-radius: 4px; padding: 20px 18px; box-shadow: var(--card-shadow);
}
.card .n { font-size: 28px; font-weight: 600; color: var(--primary-color); }
.card .l { color: var(--text-color-gray); margin-top: 8px; font-size: 13px; }
.panel {
  background: #fff; border-radius: 4px; padding: 20px; box-shadow: var(--card-shadow); margin-top: 16px;
}
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { max-width: 220px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid #f0f2f3; text-align: left; font-size: 13px; }
th { background: #f4f6f7; color: var(--text-color-dark-gray); }
tr.row-free { background: rgba(57, 181, 74, 0.12); }
tr.row-free:hover { background: rgba(57, 181, 74, 0.18); }
.tag-free {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px;
  background: #39b54a; color: #fff; font-weight: 600;
}

.pos-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.product-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; max-height: 62vh; overflow: auto; }
.product-item {
  border: 1px solid #eef1f2; border-radius: 4px; padding: 12px; cursor: pointer; background: #fff;
}
.product-item:hover { border-color: var(--primary-color); }
.product-item .name { font-weight: 600; color: #2e2e2e; margin-bottom: 6px; }
.product-item .meta { color: #8b8b8b; font-size: 12px; }
.cart-line { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid #f0f2f3; }
.cart-total { margin-top: 16px; font-size: 22px; font-weight: 700; color: var(--primary-color); }
.form-grid { display: grid; gap: 10px; max-width: 520px; }
.bind-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: start;
}
.bind-invite { text-align: center; min-width: 140px; }
.bind-label { font-size: 13px; color: var(--text-color-gray); margin-bottom: 8px; text-align: left; }
.bind-code {
  font-size: 22px; font-weight: 700; letter-spacing: 3px; color: var(--primary-color);
  margin-bottom: 8px; text-align: left;
}
.bind-qr { width: 120px; height: 120px; background: #fff; display: block; border: 1px solid #f0f2f3; }
.bind-form { display: grid; gap: 10px; max-width: 360px; align-content: start; }
@media (max-width: 720px) {
  .bind-row { grid-template-columns: 1fr; }
}
.muted { color: var(--text-color-gray); font-size: 12px; }
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: min(520px, 100%); background: #fff; border-radius: 4px; padding: 22px;
  box-shadow: 0 18px 48px rgba(0,0,0,.25); max-height: 90vh; overflow: auto;
}
.modal h3 { margin: 0 0 14px; color: #2e2e2e; }
.modal .form-grid { box-shadow: none; max-width: none; padding: 0; }
.modal .form-grid label { font-size: 13px; color: var(--text-color-gray); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { width: auto; margin: 0; }
.socket-toast {
  position: fixed; right: 24px; top: 24px; z-index: 9999; min-width: 240px; max-width: 360px;
  background: #181818; color: #e7e9ec; border-left: 4px solid var(--primary-color);
  border-radius: 4px; padding: 14px 16px; box-shadow: 0 12px 32px rgba(0,0,0,.25);
  opacity: 0; transform: translateY(-8px); pointer-events: none; transition: .25s ease;
}
.socket-toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 960px) {
  #mainView { grid-template-columns: 1fr; }
  .pos-grid { grid-template-columns: 1fr; }
  .sider { flex-direction: row; flex-wrap: wrap; }
  .sider nav { flex-direction: row; flex-wrap: wrap; }
}
