:root {
  --bg: #f5f5f5;
  --surface: #fff;
  --surface-soft: #fafafa;
  --line: #d9d9d9;
  --line-soft: #ededed;
  --text: #262626;
  --muted: #7a7a7a;
  --disabled: #b8b8b8;
  --primary: #424242;
  --primary-hover: #1f1f1f;
  --danger: #8a2f2f;
  --ok: #2f5e3a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: 14px;
}

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

button { cursor: pointer; }

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

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.brand__mark {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.brand__name {
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
}

.company-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.company-switch select {
  width: 180px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 0 10px;
}

.operator {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.avatar {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e8e8e8;
  color: var(--text);
}

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 216px;
  flex-shrink: 0;
  padding: 10px 0;
  border-right: 1px solid var(--line-soft);
  background: var(--surface);
}

.sidebar__group {
  padding: 10px 20px 5px;
  color: var(--disabled);
  font-size: 12px;
}

.nav-item {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0 20px;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: #ededed;
}

.nav-item.is-active {
  font-weight: 650;
}

.content {
  min-width: 0;
  flex: 1;
  padding: 18px 24px 40px;
  overflow: auto;
}

.breadcrumb {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.page-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
}

.page-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.scope {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-left: 3px solid var(--primary);
  border-top: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface);
  line-height: 1.6;
}

.card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 16px; }

.card-title {
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.input,
.select,
.textarea {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.textarea {
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { border-color: var(--primary); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  color: var(--danger);
  border-color: #c9a8a8;
}

.btn-link {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0 6px;
}

.btn:disabled {
  cursor: not-allowed;
  color: var(--disabled);
  border-color: var(--line-soft);
  background: #fafafa;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

tbody tr:nth-child(even) { background: #fbfbfb; }
tbody tr:hover { background: #f1f1f1; }

.code {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12px;
  color: #555;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fafafa;
  color: #555;
  padding: 1px 7px;
  font-size: 12px;
}

.tag-strong {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.muted { color: var(--muted); }
.empty { color: var(--disabled); }
.right { text-align: right; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }

.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 14px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field .input,
.field .select,
.field .textarea {
  width: 100%;
}

.image-box {
  width: 128px;
  height: 128px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #e8e8e8;
  color: var(--disabled);
  font-size: 12px;
}

.detail-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr 110px 1fr;
  gap: 8px 18px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  word-break: break-word;
}

.team-tree {
  max-height: 390px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.tree-node {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 8px;
  border-radius: 4px;
}

.tree-node.is-active,
.tree-node:hover {
  background: #ededed;
}

.split {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 14px;
  overflow: auto;
}

.tab {
  min-height: 40px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 16px;
  white-space: nowrap;
}

.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--primary);
  font-weight: 650;
}

.log-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: 10px;
}

.log-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.diff-old {
  color: #999;
  text-decoration: line-through;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 5px;
  background: rgba(38, 38, 38, 0.94);
  color: #fff;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s;
  z-index: 99;
}

.toast.is-visible { opacity: 1; }

@media (max-width: 900px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 12px;
  }
  .brand { min-width: 0; }
  .operator { margin-left: 0; }
  .workspace { flex-direction: column; }
  .sidebar {
    width: 100%;
    display: flex;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    padding: 0;
  }
  .sidebar__group { display: none; }
  .nav-item {
    width: auto;
    flex: 0 0 auto;
    padding: 0 14px;
  }
  .content { padding: 14px; }
  .page-header { flex-direction: column; }
  .split,
  .grid-2,
  .grid-3,
  .grid-4,
  .kv {
    grid-template-columns: 1fr;
  }
  .detail-head { flex-direction: column; }
  .filters > *,
  .actions > *,
  .company-switch,
  .company-switch select {
    width: 100%;
  }
}
