:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e6e8ec;
  --line-strong: #d4d8df;
  --text: #171b22;
  --muted: #6b7280;
  --muted-2: #9aa1ac;
  --brand: #1d4ed8;
  --brand-soft: #eef2ff;
  --ok: #0f766e;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ---------- 通用控件 ---------- */
button {
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  padding: 9px 14px;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
button:hover { background: #fafbfc; border-color: #c2c8d2; }
button:active { transform: translateY(.5px); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: #1a45c0; border-color: #1a45c0; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { background: #f1f3f6; color: var(--text); }
button.danger { color: var(--danger); border-color: #f0c7c7; background: #fff; }
button.danger:hover { background: var(--danger-soft); }
button.big { width: 100%; padding: 14px; font-size: 15px; font-weight: 500; border-radius: 12px; }

input[type=text], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 216, .1); }

.field { margin-bottom: 14px; }
.field > label, .field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: .02em;
}
.hint { font-size: 12px; color: var(--muted-2); line-height: 1.6; margin-top: 6px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-card h1 { font-size: 17px; font-weight: 500; margin: 0; }
.login-card p.sub { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.login-err { color: var(--danger); font-size: 12px; margin-bottom: 10px; min-height: 16px; }

.logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 500; letter-spacing: -.5px;
}

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.sidebar .brand h1 { font-size: 14px; font-weight: 500; margin: 0; line-height: 1.3; }
.sidebar .brand span { font-size: 11px; color: var(--muted-2); display: block; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent; text-align: left;
  padding: 10px 10px; border-radius: 9px; color: #3b4250; width: 100%;
}
.nav button:hover { background: #f4f5f7; }
.nav button.on { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.nav svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .8; }

.sidebar .foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.sidebar .foot .who { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.topbar h2 { font-size: 19px; font-weight: 500; margin: 0 0 3px; }
.topbar .sub { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  background: #f1f3f6; color: #4b5563;
}
.pill.demo { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- 包间网格 ---------- */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 14px;
}

.room-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px 13px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 132px;
  position: relative;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.room-card:hover { border-color: #c7cdd8; box-shadow: var(--shadow); }
.room-card.busy { border-color: #cfe9e2; background: linear-gradient(180deg, #fbfefd 0%, #fff 60%); }
.room-card.soon { border-color: #f3ddb5; }
.room-card.off { opacity: .6; }

.room-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-name { font-size: 15px; font-weight: 500; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: #f1f3f6; color: var(--muted); }
.badge.busy { background: var(--ok-soft); color: var(--ok); }
.badge.soon { background: var(--warn-soft); color: var(--warn); }

.room-pwd {
  font-family: var(--mono);
  font-size: 25px;
  letter-spacing: .1em;
  font-weight: 500;
  color: #0f766e;
  line-height: 1.1;
}
.room-pwd.empty { color: var(--muted-2); letter-spacing: .04em; font-size: 22px; }
.room-meta { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; letter-spacing: -.1px; }
.room-meta [data-left].expired { color: var(--danger); }
.room-meta + .room-meta { margin-top: -4px; }
.room-meta span { white-space: nowrap; }
.room-empty { font-size: 13px; color: var(--muted-2); }
.room-foot { font-size: 11px; color: var(--muted-2); font-family: var(--mono); }

/* ---------- 弹窗 / 抽屉 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .32);
  display: flex; align-items: flex-start; justify-content: flex-end;
  animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(18px); opacity: .6; } to { transform: none; opacity: 1; } }

.sheet {
  width: 460px; max-width: 100%;
  height: 100%;
  overflow-y: auto;
  background: #fff;
  border-left: 1px solid var(--line);
  padding: 20px 22px 40px;
  animation: slide .16s ease;
}
.sheet.wide { width: 620px; }

.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.sheet-head h3 { font-size: 17px; font-weight: 500; margin: 0; }
.sheet-head .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.icon-btn {
  border: none; background: transparent; padding: 6px 8px; border-radius: 8px;
  color: var(--muted); font-size: 18px; line-height: 1;
}
.icon-btn:hover { background: #f1f3f6; color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  padding: 8px 12px; border-radius: 9px; font-size: 13px; color: #3b4250;
  border: 1px solid var(--line-strong); background: #fff;
}
.chips button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 500; }

.segmented { display: flex; background: #f1f3f6; border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button {
  flex: 1; border: none; background: transparent; padding: 9px 8px;
  border-radius: 8px; font-size: 13px; color: var(--muted);
}
.segmented button.on { background: #fff; color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(16,24,40,.08); }

.divider { height: 1px; background: var(--line); margin: 18px 0; }

/* 结果区 */
.result { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; }
.result-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pwd-big {
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 500;
  letter-spacing: .16em;
  color: #0b3b34;
  background: var(--ok-soft);
  border: 1px dashed #9fd8cb;
  border-radius: 12px;
  padding: 16px 12px 16px 18px;
  text-align: center;
  user-select: all;
  word-break: break-all;
}
.result-meta { font-size: 12px; color: var(--muted); margin: 10px 0 14px; line-height: 1.7; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-actions button { padding: 11px; }

.alert {
  border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.65;
  background: var(--warn-soft); color: #7c4a03; border: 1px solid #f3e0bb;
}
.alert.info { background: var(--brand-soft); color: #1e3a8a; border-color: #d7defb; }
.alert.err { background: var(--danger-soft); color: var(--danger); border-color: #f2cccc; }

/* ---------- 表格 ---------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.panel-head h3 { font-size: 14px; font-weight: 500; margin: 0; }
.panel-body { padding: 16px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; font-size: 13px; border-bottom: 1px solid #f0f1f4; }
th { font-size: 12px; color: var(--muted); font-weight: 400; background: #fafbfc; white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
td.pwd { font-family: var(--mono); font-size: 15px; letter-spacing: .08em; color: #0b3b34; }
td.pwd span { cursor: pointer; border-bottom: 1px dashed #9fd8cb; }
.table-wrap { overflow-x: auto; }
.empty-row { text-align: center; color: var(--muted-2); padding: 34px 0; font-size: 13px; }

.tag { font-size: 11px; padding: 3px 8px; border-radius: 6px; background: #f1f3f6; color: #4b5563; white-space: nowrap; }
.tag.period { background: #eef2ff; color: #3730a3; }
.tag.single { background: #f5f3ff; color: #6d28d9; }
.tag.clear { background: var(--danger-soft); color: var(--danger); }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 12px);
  background: #111827; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .18s ease; z-index: 90;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #991b1b; }

/* ---------- 设置 ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .settings-grid { grid-template-columns: 1fr; } }

.section-title { font-size: 13px; font-weight: 500; margin: 0 0 4px; }
.section-desc { font-size: 12px; color: var(--muted); margin: 0 0 14px; line-height: 1.6; }

/* ---------- 响应式 ---------- */
@media (max-width: 780px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; align-items: center; padding: 10px 12px; overflow-x: auto;
  }
  .sidebar .brand { padding: 0 12px 0 4px; }
  .nav { flex-direction: row; }
  .nav button { white-space: nowrap; }
  .sidebar .foot { display: none; }
  .main { padding: 16px 14px 40px; }
  .sheet { width: 100%; }
  .pwd-big { font-size: 34px; }
  .two-col { grid-template-columns: 1fr !important; }
}

/* ---------- 后台锁 / 权限 ---------- */
.nav button { position: relative; }
.nav button .lock { margin-left: auto; opacity: .4; display: flex; }
.nav button .lock svg { width: 12px; height: 12px; }
.nav button.locked { color: #7c8595; }
.nav button.locked.on { color: var(--brand); }

.admin-line { font-size: 11px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.admin-off { color: var(--muted-2); }
.admin-on { color: var(--ok); }
button.mini { padding: 4px 8px; font-size: 11px; border-radius: 7px; }

.pill.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- 发码台工具条 ---------- */
.desk-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 8px; height: 8px; border-radius: 50%; background: #cfd5dd; display: inline-block; }
.legend .sw.active { background: #0f766e; }
.legend .sw.soon { background: #d97706; }
.legend .sw.none { background: #cfd5dd; }

/* ---------- 当前生效密码框 ---------- */
.active-box {
  border: 1px solid #d7e9e4; background: linear-gradient(180deg, #f7fdfb, #fff);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 4px;
}
.active-box.empty { border-color: var(--line); background: #fafbfc; }
.active-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.active-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; flex-wrap: wrap; }
.active-row + .active-row { border-top: 1px dashed #dbe9e5; }
.active-row .grow { flex: 1; }
.active-row .left { font-size: 12px; color: var(--ok); }
.active-row .left.expired { color: var(--danger); }

.pwd-code {
  font-family: var(--mono); font-size: 22px; letter-spacing: .12em;
  color: #0b3b34; font-weight: 500;
}
.pwd-code.sm { font-size: 14px; letter-spacing: .08em; }

.pwd-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pwd-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; font-size: 12px; flex-wrap: wrap;
}
.pwd-row + .pwd-row { border-top: 1px solid #f0f1f4; }
.pwd-row .grow { flex: 1; }
.pwd-row .st { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #f1f3f6; color: var(--muted); }
.pwd-row .st.active { background: var(--ok-soft); color: var(--ok); }
.pwd-row .st.expired { background: #f4f5f7; color: var(--muted-2); }
.pwd-row .st.pending { background: var(--brand-soft); color: var(--brand); }

.section-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-row h4 { font-size: 13px; font-weight: 500; margin: 0; }

/* ---------- 类型选择 ---------- */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type-grid button {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  padding: 12px 14px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: #fff; text-align: left;
}
.type-grid button b { font-size: 14px; font-weight: 500; }
.type-grid button span { font-size: 11px; color: var(--muted); }
.type-grid button.on { border-color: var(--brand); background: var(--brand-soft); }
.type-grid button.on b { color: var(--brand); }
.type-grid button.on span { color: #4b5fbf; }

.preset-chips button { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 66px; padding: 8px 10px; }
.preset-chips button em { font-style: normal; font-size: 10px; color: var(--muted-2); }
.preset-chips button:disabled { opacity: .4; cursor: not-allowed; background: #fafbfc; }
.preset-chips button.on em { color: #4b5fbf; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hidden { display: none !important; }
.bad { color: var(--danger); }

.sheet.narrow { width: 380px; }

/* ---------- 只读键值表 ---------- */
.kv { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; font-size: 12.5px; }
.kv-row + .kv-row { border-top: 1px solid #f0f1f4; }
.kv-row span { color: var(--muted); }
.kv-row b { font-weight: 500; word-break: break-all; text-align: right; }

