:root {
  --bg: #faf7f2;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --muted: #6f5a4f;
  --line: #e8e1d8;
  --brand: #e56f42;
  --brand-soft: #fdeee7;
  --ok: #2f8f5b;
  --warn: #b7791f;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(60, 40, 30, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

button, input, select { font: inherit; color: inherit; }

[hidden] { display: none !important; }

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
}

.brand-mark.small { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 10%, #fff4ee 0, var(--bg) 55%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.brand h1 { font-size: 18px; margin: 0 0 4px; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.mfa-box { border-top: 1px dashed var(--line); padding-top: 14px; margin-top: 6px; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.error { color: var(--danger); font-size: 13px; margin: 4px 0 12px; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  background: #fff;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #d15f35; }
.btn-ghost { border-color: var(--line); background: #fff; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 8px; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: #221c19;
  color: #f4eee9;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { display: flex; gap: 10px; align-items: center; font-weight: 600; margin-bottom: 22px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  text-align: left;
  background: transparent;
  border: 0;
  color: #cfc4bc;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.admin-name { font-size: 12px; color: #cfc4bc; }
.sidebar-foot .btn-ghost { background: transparent; color: #cfc4bc; border-color: rgba(255,255,255,.18); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 247, 242, .9);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h2 { font-size: 17px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.view { padding: 20px 24px 48px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--brand); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel + .panel { margin-top: 16px; }
.panel-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-body { padding: 16px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { margin: 0; min-width: 130px; }
.filters .field input, .filters .field select { height: 36px; border-radius: 8px; }
.filters .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: #fcfaf7; }
tbody tr:hover { background: #fdf8f3; }
td .muted { color: var(--muted); font-size: 12px; }
.cell-clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #f1ece6; color: var(--muted); }
.badge.pending { background: #fff4e5; color: var(--warn); }
.badge.done { background: #e8f5ee; color: var(--ok); }
.badge.rejected { background: #fbe9e7; color: var(--danger); }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; }

.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer-mask { position: absolute; inset: 0; background: rgba(20, 14, 10, .38); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(520px, 92vw);
  background: var(--panel); box-shadow: -12px 0 40px rgba(0,0,0,.16);
  display: flex; flex-direction: column;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 15px; }
.drawer-body { padding: 18px; overflow: auto; }

.kv { display: grid; grid-template-columns: 88px 1fr; gap: 8px 12px; margin-bottom: 16px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; word-break: break-word; }

.preview { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #f7f3ee; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #221c19; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 60; box-shadow: var(--shadow);
}
.toast.error { background: var(--danger); }

.section-title { font-size: 13px; color: var(--muted); margin: 22px 0 10px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; bottom: 0; top: auto; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 8px; z-index: 30; }
  .sidebar-brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .nav-item { white-space: nowrap; padding: 8px 10px; font-size: 13px; }
  .main { padding-bottom: 64px; }
  .view { padding: 14px; }
  .topbar { padding: 12px 14px; }
  .cell-clip { max-width: 160px; }
}
