/* ==========================================================================
   陪玩 · 工作端 共用样式
   配色：背景 #f3f5f8 / 面板 #fff / 边框 #e2e7ef / 正文 #1f2733 / 次要 #6b7280 / 强调 #2456d6
   ========================================================================== */

:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --border: #e2e7ef;
  --text: #1f2733;
  --muted: #6b7280;
  --primary: #2456d6;
  --primary-light: #eef2fc;
  --primary-soft: #eaf0fd;
  --danger: #d1433b;
  --danger-light: #fbeceb;
  --success: #1f8a4c;
  --success-light: #e8f5ee;
  --warn: #b7791f;
  --warn-light: #fbf3e3;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(31,39,51,.06);
  --sidebar-w: 224px;
  --header-h: 56px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }

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

/* 顶部 */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.brand .mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .5px;
  overflow: hidden;
}
.brand .mark img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.brand .sub { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 2px; }

.top-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.top-user .who { text-align: right; line-height: 1.3; }
.top-user .who .name { font-weight: 600; }
.top-user .who .role { color: var(--muted); font-size: 12px; }

/* 侧边栏 */
.sidebar {
  position: fixed;
  top: var(--header-h);
  bottom: 0; left: 0;
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
}
.nav-group { margin-bottom: 18px; }
.nav-group .gtitle {
  font-size: 12px;
  color: var(--muted);
  padding: 0 10px;
  margin-bottom: 6px;
  letter-spacing: .3px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 2px;
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg); text-decoration: none; }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item .ico {
  width: 18px; height: 18px;
  flex: none;
  color: inherit;
  opacity: .75;
}
.nav-item.active .ico { opacity: 1; }

/* 内容区 */
.content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 24px 28px;
  flex: 1;
  min-width: 0;
}
.page-title { font-size: 20px; margin-bottom: 4px; }
.page-desc { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

/* 移动端子视图顶部栏：卡片返回按钮（左，垂直居中） + 页面名 */
.mob-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -16px -16px 16px;
  padding: 12px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.mob-back {
  flex: none;
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 18px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mob-title { font-size: 17px; font-weight: 700; color: var(--text); }

/* ---------------- 卡片 / 面板 ---------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel + .panel, .panel-group { margin-top: 18px; }
.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-title { font-size: 15px; font-weight: 600; }
.panel-body { padding: 18px; }

/* ---------------- 统计块 ---------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card .lab { color: var(--muted); font-size: 13px; }
.stat-card .val { font-size: 24px; font-weight: 700; margin-top: 6px; }
.stat-card .val small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 2px; }

/* ---------------- 概览卡片列表（近期审判房间 / room-card） ---------------- */
.case-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding: 16px 18px;
}
.room-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.room-card:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(31,39,51,.1);
  transform: translateY(-2px);
}

/* 审判庭案件列表：桌面表格 / 移动端卡片 */
.mob-cases { display: none; }          /* 移动端卡片默认隐藏 */
@media (max-width: 768px) {
  .tbl-wrap-desk { display: none; }     /* 移动端隐藏桌面表格 */
  .mob-cases { display: grid; }         /* 移动端显示卡片 */
}

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; background: #fafbfd; font-size: 12.5px; white-space: nowrap; }
.tbl tbody tr:hover { background: #fafbfd; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl .muted { color: var(--muted); }

/* ---------------- 徽章 ---------------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge.blue { background: var(--primary-light); color: var(--primary); }
.badge.gray { background: #eef1f5; color: var(--muted); }
.badge.green { background: var(--success-light); color: var(--success); }
.badge.red { background: var(--danger-light); color: var(--danger); }
.badge.amber { background: var(--warn-light); color: var(--warn); }
.badge.purple { background: #f0eefb; color: #5b4ad1; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
  line-height: 1.2;
  transition: background .15s, border-color .15s;
  text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1b44c0; }
.btn.danger { color: var(--danger); border-color: #e5c0be; }
.btn.danger:hover { background: var(--danger-light); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg); color: var(--text); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 表单 ---------------- */
.form { max-width: 620px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="tel"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36,86,214,.12); }
textarea { resize: vertical; min-height: 90px; }
input:disabled, select:disabled { background: #f5f6f8; color: var(--muted); }

.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ---------------- 弹窗（原生 <dialog>） ---------------- */
dialog.modal {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  width: 460px;
  max-width: 92vw;
  box-shadow: 0 10px 40px rgba(31,39,51,.18);
}
dialog.modal::backdrop { background: rgba(31,39,51,.4); }
.modal-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
}
.modal-body { padding: 18px; max-height: 65vh; overflow-y: auto; }
.modal-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.detail-grid { display: grid; grid-template-columns: 110px 1fr; row-gap: 9px; font-size: 13.5px; }
.detail-grid .k { color: var(--muted); }
.detail-grid .v { color: var(--text); word-break: break-word; }

/* ---------------- Toast ---------------- */
#toast-wrap {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 11px 16px;
  border-radius: 7px;
  background: #1f2733;
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 4px 16px rgba(31,39,51,.2);
  opacity: 0;
  transform: translateY(-6px);
  transition: all .22s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------------- 空态 / 加载 ---------------- */
.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.loading { color: var(--muted); padding: 20px; text-align: center; }

/* ---------------- 登录页 ---------------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #eef2f8 0%, var(--bg) 40%);
  padding: 20px;
}
.login-card {
  width: 400px;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(31,39,51,.08);
  padding: 32px 34px 28px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-brand .mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  overflow: hidden;
}
.login-brand .mark img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.login-brand .t { font-size: 19px; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 13px; margin: 2px 0 22px; }

.seg { display: flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; margin-bottom: 18px; }
.seg button {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.seg button.active { background: var(--primary); color: #fff; font-weight: 600; }

.login-form .field { margin-bottom: 16px; }
.login-form label { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: block; }
.login-form .btn.primary { width: 100%; padding: 11px; font-size: 15px; margin-top: 6px; }

.demo-tip {
  margin-top: 20px;
  padding: 12px 14px;
  border: 1px dashed #cfd8e8;
  border-radius: 7px;
  background: #f8fafd;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
}
.demo-tip b { color: var(--text); }

.footer-note { text-align: center; color: #9aa3af; font-size: 12px; margin-top: 22px; }

/* 提示框（alert） */
.alert { padding: 10px 13px; border-radius: 7px; font-size: 13px; margin-bottom: 16px; }
.alert.info { background: var(--primary-light); color: var(--primary); }
.alert.warn { background: var(--warn-light); color: var(--warn); }
.alert.err { background: var(--danger-light); color: var(--danger); }

/* 分组金额卡 */
.balance-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.balance-cards .bc { border: 1px solid var(--border); border-radius: 9px; padding: 15px 17px; background: var(--panel); }
.balance-cards .bc .lab { color: var(--muted); font-size: 12.5px; }
.balance-cards .bc .am { font-size: 22px; font-weight: 700; margin-top: 5px; }

/* 概览步骤 / 说明卡 */
.metric-list { list-style: none; margin: 0; padding: 0; }
.metric-list li { display: flex; justify-content: space-between; padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.metric-list li:last-child { border-bottom: none; }
.metric-list .muted { color: var(--muted); }

@media (max-width: 860px) {
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { width: 178px; }
  .content { margin-left: 178px; padding: 16px; }
}

/* 订单在线沟通 */
.chat-area { margin-top: 16px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.chat-head { padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--primary-light); }
.chat-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; background: #fff; }
.chat-log .chat-msg { max-width: 78%; padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.chat-log .chat-msg .who { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.chat-log .chat-msg.mine { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.chat-log .chat-msg.other { align-self: flex-start; background: #eef1f5; color: var(--text); border-bottom-left-radius: 3px; }
.chat-input { border-top: 1px solid var(--border); display: flex; padding: 10px; gap: 8px; background: #fff; }
.chat-input input { flex: 1; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; font-size: 13px; }

/* ================= 个人工作台门户 ================= */
.portal {
  padding: 88px 24px 40px;
  max-width: 1080px;
  margin: 0 auto;
}
.portal-head { margin-bottom: 24px; }
.portal-title { font-size: 22px; font-weight: 700; color: var(--text); }
.portal-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.portal-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 20px;
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.portal-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(31, 39, 51, .1);
  border-color: var(--primary);
}
.portal-ico {
  width: 46px; height: 46px;
  border-radius: 12px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .5px;
}
.portal-name { font-size: 16px; font-weight: 600; }
.portal-desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; min-height: 38px; }
.portal-go { font-size: 13px; color: var(--primary); font-weight: 500; margin-top: 4px; }
.portal-none {
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
  line-height: 2;
}

/* ================= 移动端：侧栏收纳为左上角抽屉 ================= */
.menu-btn {
  display: none;
  flex: none;
  width: 36px; height: 36px;
  margin-right: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: rgba(15, 23, 42, .45);
  z-index: 25;
}

@media (max-width: 768px) {
  .menu-btn { display: flex; }
  /* 移动端顶部栏：去掉昵称/身份，去 logo 与「工作端」文字，保留菜单按钮 + 名字 + 工作台 + 退出登录 */
  .top-user .who { display: none; }
  .brand .mark, .brand .sub { display: none; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    bottom: 0; left: 0;
    width: 78vw;
    max-width: 264px;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 4px 0 18px rgba(15, 23, 42, .12);
    z-index: 30;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.show { display: block; }
  .content {
    margin-left: 0;
    padding: 16px;
  }
}