:root {
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-light: #ccfbf1;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f6f8;
  --card: #ffffff;
  --danger: #b91c1c;
  --warn: #b45309;
  --ok: #15803d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
.hidden { display: none !important; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }

/* 登录 */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #134e4a, #0b2f2c 60%, #08211f);
}
.login-card {
  width: 380px;
  background: #fff;
  border-radius: 18px;
  padding: 36px 34px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.login-card .brand { font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.login-card .brand span { color: var(--teal); }
.login-card .sub { color: var(--muted); margin: 6px 0 26px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 9px; margin-bottom: 16px; outline: none;
}
.login-card input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.login-card button {
  width: 100%; padding: 12px; border: 0; border-radius: 9px;
  background: var(--teal); color: #fff; font-weight: 600; font-size: 15px;
}
.login-card button:hover { background: var(--teal-dark); }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 208px; flex: 0 0 208px; background: #0b2f2c; color: #cbd5e1;
  display: flex; flex-direction: column; padding: 22px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { color: #fff; font-size: 18px; font-weight: 700; padding: 0 10px 4px; letter-spacing: 1px; }
.sidebar .logo small { display: block; font-size: 11px; color: #5eead4; font-weight: 400; margin-top: 4px; letter-spacing: 0; }
.nav { margin-top: 24px; display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; color: #94a3b8; padding: 10px 12px; border-radius: 9px; font-size: 14px;
}
.nav button:hover { background: rgba(255, 255, 255, 0.07); color: #e2e8f0; }
.nav button.active { background: var(--teal); color: #fff; font-weight: 600; }
.nav .ico { width: 16px; text-align: center; }
.sidebar .foot { margin-top: auto; padding: 10px 12px; font-size: 11px; color: #64748b; line-height: 1.6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 13px; }
.topbar-right .who { color: var(--ink); font-weight: 600; }
.btn-ghost { background: transparent; border: 1px solid var(--line); padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }
.content { padding: 22px 26px 40px; flex: 1; }

/* 卡片与栅格 */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow);
}
.card h2 { font-size: 14px; margin: 0 0 14px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.card h2 small { font-weight: 400; color: var(--muted); font-size: 12px; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 30px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -0.5px; }
.kpi .value span { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.kpi .hint { font-size: 12px; color: var(--muted); }
.kpi.accent .value { color: var(--teal); }

/* 工具条 */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.toolbar .field { display: flex; flex-direction: column; gap: 5px; }
.toolbar label { font-size: 12px; color: var(--muted); }
.toolbar input, .toolbar select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 130px; outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--teal); }
.toolbar .spacer { flex: 1; }
.btn {
  border: 0; border-radius: 8px; padding: 9px 16px; background: var(--teal); color: #fff; font-weight: 600;
}
.btn:hover { background: var(--teal-dark); }
.btn.secondary { background: #fff; color: var(--teal); border: 1px solid var(--teal); }
.btn.secondary:hover { background: var(--teal-light); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; font-weight: 500; }
.btn.danger { background: #fee2e2; color: var(--danger); }
.btn.danger:hover { background: #fecaca; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12px;
  padding: 9px 10px; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
.table-wrap { overflow: auto; border-radius: 8px; }
.empty { text-align: center; color: var(--muted); padding: 36px 0; font-size: 13px; }

/* 徽标 */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.WAITING { background: #fef3c7; color: #92400e; }
.badge.CALLED { background: #dbeafe; color: #1d4ed8; }
.badge.SERVING { background: #ccfbf1; color: #0f766e; }
.badge.DONE { background: #dcfce7; color: #15803d; }
.badge.PASSED { background: #fee2e2; color: #b91c1c; }
.badge.CANCELED { background: #e2e8f0; color: #475569; }
.badge.source { background: #f1f5f9; color: #475569; }
.badge.source.STAFF { background: #ede9fe; color: #6d28d9; }
.badge.open { background: #dcfce7; color: #15803d; }
.badge.closed { background: #f1f5f9; color: #64748b; }

/* 实时队列卡 */
.station-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.station-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: #fff; }
.station-card .name { font-weight: 600; margin-bottom: 2px; display: flex; justify-content: space-between; align-items: center; }
.station-card .svc { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; }
.station-card .nums { display: flex; gap: 16px; margin-top: 8px; font-size: 13px; }
.station-card .nums b { font-size: 18px; color: var(--teal); }
.station-card .nums span { color: var(--muted); font-size: 12px; }

/* 条形图 */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 76px 1fr 56px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-track { height: 9px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #14b8a6, #0f766e); border-radius: 6px; }
.bar-row .val { text-align: right; color: var(--muted); }

/* 弹窗 */
.modal, .drawer-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal-panel {
  background: #fff; border-radius: 14px; width: 640px; max-width: 100%; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
}
.modal-panel header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-panel header h2 { font-size: 16px; margin: 0; }
.modal-panel header button { background: transparent; border: 0; font-size: 22px; color: var(--muted); line-height: 1; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field-col label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field-col input, .field-col select, .field-col textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.field-col input:focus, .field-col select:focus, .field-col textarea:focus { border-color: var(--teal); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.check-row input { width: 15px; height: 15px; accent-color: var(--teal); }

/* 抽屉 */
.drawer { position: fixed; inset: 0; z-index: 70; display: flex; justify-content: flex-end; background: rgba(15, 23, 42, 0.4); }
.drawer-panel { width: 520px; max-width: 92vw; background: #fff; height: 100%; overflow: auto; padding: 22px 24px; }
.drawer-panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.drawer-panel header h2 { font-size: 18px; margin: 0; }
.drawer-panel header button { background: transparent; border: 0; font-size: 24px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 86px 1fr; gap: 8px 12px; font-size: 13px; margin: 14px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 16px; display: flex; flex-direction: column; gap: 12px; }
.timeline .item { position: relative; font-size: 12.5px; }
.timeline .item::before {
  content: ""; position: absolute; left: -22px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--teal);
}
.timeline .time { color: var(--muted); font-size: 11.5px; }

/* 提示 */
.toast {
  position: fixed; left: 50%; bottom: 42px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 9px; font-size: 13px; z-index: 90;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}
.toast.error { background: #991b1b; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: #f1f5f9; border-radius: 6px; padding: 2px 8px; font-size: 12px; color: #475569; }

@media (max-width: 1180px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .station-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { width: 64px; flex: 0 0 64px; padding: 16px 8px; }
  .sidebar .logo, .sidebar .foot, .nav button span:not(.ico) { display: none; }
  .nav button { justify-content: center; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .station-cards { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}
