:root {
  --brand: #ff7301;
  --brand-soft: #fff3ea;
  --brand-deep: #ff6900;
  --text: #2d2525;
  --muted: #8a817c;
  --line: #eee7e1;
  --bg: #f7f5f3;
  --card: #ffffff;
  --ok: #2f9b5b;
  --warn: #d48806;
  --danger: #d4380d;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(45, 37, 37, 0.06);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }

/* login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, #ffe0c8 0, transparent 40%),
    linear-gradient(160deg, #ff7301 0%, #ff9a45 42%, #f7f5f3 42%);
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 20px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
}
.login-brand {
  font-size: 28px;
  font-weight: 700;
  color: var(--brand);
  margin: 0 0 6px;
}
.login-sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}
.field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  outline: none;
  background: #fff;
}
.field input:focus { border-color: var(--brand); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: #f0ece8;
  color: var(--text);
}
.btn-primary {
  background: linear-gradient(135deg, #ff8a18, #ff6900);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
}
.btn-block { width: 100%; height: 46px; margin-top: 8px; }
.login-hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
}
.sidebar {
  background: #1f1a17;
  color: #f7f2ed;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand {
  font-size: 20px;
  font-weight: 700;
  color: #ff9a45;
  padding: 8px 10px 20px;
}
.nav-item {
  display: block;
  padding: 11px 12px;
  border-radius: 10px;
  color: #d9d0c8;
  margin-bottom: 4px;
  font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, #ff8a18, #ff6900);
  color: #fff;
}
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 700;
}
.content { padding: 22px 24px 40px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  color: var(--brand-deep);
}
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-title h2 {
  margin: 0;
  font-size: 16px;
}
.muted { color: var(--muted); font-size: 13px; }

.list { display: grid; gap: 10px; }
.list-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.list-item strong { display: block; margin-bottom: 4px; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
}
.tag.ok { background: #e8f7ef; color: var(--ok); }
.tag.warn { background: #fff7e6; color: var(--warn); }
.tag.danger { background: #fff1f0; color: var(--danger); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.toolbar input,
.toolbar select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  background: #fff;
  min-width: 160px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr:hover td { background: #fffaf5; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  background: #fff;
}
.form-grid textarea { min-height: 96px; resize: vertical; }
.form-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
}

.chat {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 12px;
  min-height: 420px;
}
.chat-list, .chat-main {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.chat-user {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.chat-user.active { background: var(--brand-soft); }
.chat-msgs {
  height: 320px;
  overflow: auto;
  padding: 14px;
  background: #faf8f6;
}
.bubble {
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.5;
}
.bubble.me {
  margin-left: auto;
  background: linear-gradient(135deg, #ff8a18, #ff6900);
  color: #fff;
}
.bubble.them { background: #fff; border: 1px solid var(--line); }
.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}
.chat-input input {
  flex: 1;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  background: rgba(31, 26, 23, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 99;
  box-shadow: var(--shadow);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(31, 26, 23, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-card {
  width: min(520px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-head h3 { margin: 0; font-size: 18px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal .field textarea,
.modal .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  background: #fff;
}
.modal .field textarea:focus,
.modal .field select:focus { border-color: var(--brand); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    height: auto;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 12px;
  }
  .side-brand { display: none; }
  .nav-item { white-space: nowrap; margin: 0; }
  .stats { grid-template-columns: 1fr 1fr; }
  .form-grid, .chat { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}
