:root {
  --bg: #f5f7fa;
  --card: #fff;
  --soft: #f8fafc;
  --line: #dce4ee;
  --text: #172033;
  --sub: #667085;
  --nav: #101828;
  --nav2: #1d2939;
  --teal: #0f766e;
  --teal-bg: #e6fffb;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --green: #047857;
  --green-bg: #ecfdf3;
  --red: #b42318;
  --red-bg: #fef3f2;
  --amber: #b45309;
  --amber-bg: #fff7ed;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

.hidden { display: none !important; }
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { position: sticky; top: 0; width: 240px; height: 100vh; flex: 0 0 240px; overflow-y: auto; background: var(--nav); color: #fff; padding: 28px 16px; }
.brand { font-size: 22px; font-weight: 800; }
.brand-sub { color: #cbd5e1; font-size: 12px; margin-top: 8px; }
.nav { margin-top: 42px; display: grid; gap: 8px; }
.nav button { width: 100%; border: 0; color: #cbd5e1; background: transparent; border-radius: 6px; padding: 11px 14px; text-align: left; cursor: pointer; font: inherit; }
.nav button.active, .nav button:hover { background: var(--nav2); color: #fff; font-weight: 700; }
.main { flex: 1 1 auto; min-width: 0; width: calc(100vw - 240px); height: 100vh; overflow-y: auto; }
.topbar { position: sticky; top: 0; z-index: 20; height: 72px; background: var(--card); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; border-bottom: 1px solid #eef2f6; }
.page-title { font-size: 22px; font-weight: 800; }
.page-hint { margin-top: 4px; color: var(--sub); font-size: 12px; }
.top-actions { display: flex; gap: 14px; align-items: center; }
.role { height: 28px; line-height: 28px; padding: 0 14px; border-radius: 999px; background: var(--teal-bg); color: var(--teal); font-weight: 700; font-size: 12px; }
.content { padding: 32px; width: 100% !important; max-width: none !important; }
.content > .card,
.content > form,
.content > .table-card,
.content > div {
  width: 100%;
  max-width: none;
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-pad { padding: 24px; }
.card-title { font-size: 20px; font-weight: 800; margin: 0 0 22px; }
.filters { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) auto auto; gap: 18px; align-items: end; padding: 20px; margin-bottom: 24px; }
.quota-summary { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: -8px 0 20px; }
.quota-item { height: 38px; display: inline-flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--sub); }
.quota-label { color: var(--text); font-weight: 800; }
.quota-item strong { color: var(--teal); font-size: 16px; }
.field label, .login-card label { display: block; color: var(--sub); font-size: 12px; font-weight: 700; margin-bottom: 8px; }
input, select { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; background: #fff; color: var(--text); font: inherit; }
.textarea { width: 100%; min-height: 180px; border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: #fff; color: var(--text); font: inherit; resize: vertical; }
.readonly-value { width: 100%; min-height: 38px; border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; background: var(--soft); color: var(--sub); }
.checkbox-group { height: 38px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.platform-permissions { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; line-height: 1.45; white-space: normal; }
.platform-permission { display: inline-flex; align-items: center; gap: 2px; color: #98a2b3; font-size: 12px; }
.platform-permission.checked { color: var(--teal); font-weight: 800; }
.platform-permission .checkmark { font-size: 13px; line-height: 1; }
.platform-toggle { margin: 0 !important; cursor: pointer; user-select: none; }
.platform-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.platform-toggle .checkmark::before { content: "☐"; }
.platform-toggle input:checked + .checkmark::before { content: "☑"; }
.platform-toggle input:checked ~ span { color: var(--teal); font-weight: 800; }
.platform-toggle:focus-within { outline: 2px solid rgba(15, 118, 110, .22); outline-offset: 3px; border-radius: 4px; }
.platform-toggle.disabled { cursor: not-allowed; opacity: .45; }
.btn { height: 38px; border: 1px solid transparent; border-radius: 6px; padding: 0 18px; background: var(--teal); color: #fff; font-weight: 800; cursor: pointer; font: inherit; white-space: nowrap; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn.danger { background: var(--red); }
.btn.warn { background: var(--amber); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.equal-action { width: 96px; padding: 0 10px; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { height: 48px; padding: 0 16px; border-bottom: 1px solid #eef2f6; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
th { height: 46px; background: var(--soft); color: var(--sub); font-size: 12px; font-weight: 800; }
.table-card { overflow-x: auto; margin-bottom: 24px; }
.data-table th,
.data-table td { padding: 0 8px; text-align: center; }
.data-table .row-actions { justify-content: center; flex-wrap: wrap; gap: 4px 8px; }
.data-table .link-btn { line-height: 20px; }
.data-table .tag { padding: 0 8px; }
.operations-table th,
.operations-table td { text-align: center; }
.tag { display: inline-flex; align-items: center; justify-content: center; height: 24px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tag.teal { color: var(--teal); background: var(--teal-bg); }
.tag.blue { color: var(--blue); background: var(--blue-bg); }
.tag.green { color: var(--green); background: var(--green-bg); }
.tag.red { color: var(--red); background: var(--red-bg); }
.tag.amber { color: var(--amber); background: var(--amber-bg); }
.row-actions { display: flex; gap: 8px; }
.link-btn { border: 0; background: transparent; color: var(--teal); cursor: pointer; padding: 0; font-weight: 700; }
.copy-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}
.copy-cell-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-mini-btn {
  flex: 0 0 auto;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 8px;
  background: #fff;
  color: var(--teal);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}
.copy-mini-btn:hover {
  border-color: var(--teal);
  background: var(--teal-bg);
}
.form-card { padding: 24px; margin-top: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 24px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.form-section-title { margin-top: 6px; padding: 10px 0 0; border-top: 1px solid #eef2f6; color: var(--text); font-size: 14px; font-weight: 800; }
.form-section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 16px; margin-top: 28px; }
.form-actions.inline-actions { align-items: end; justify-content: flex-start; margin-top: 0; height: 100%; }
.lookup-results { margin: 18px 0 22px; }
.selected-user {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px 16px;
  display: flex;
  align-items: center;
}
.selected-user strong { margin-right: 18px; font-size: 16px; }
.selected-user span { margin-right: 18px; color: var(--sub); }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 12px; color: var(--sub); }
.empty { padding: 48px; color: var(--sub); text-align: center; }
.empty.compact { padding: 18px; border: 1px dashed var(--line); border-radius: 8px; background: var(--soft); }
.error { min-height: 20px; color: var(--red); margin: 12px 0 0; }
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(15, 23, 42, .42);
  display: grid;
  place-items: center;
  padding: 32px;
}
.modal-panel {
  width: min(720px, calc(100vw - 64px));
  max-height: calc(100vh - 80px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
}
.modal-header {
  height: 58px;
  padding: 0 22px;
  border-bottom: 1px solid #eef2f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 22px; }
.modal-body .table-card { margin-bottom: 0; }
.modal-form label { display: block; color: var(--sub); font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.modal-summary p { margin: 0 0 16px; color: var(--sub); }
.sub-title { margin: 18px 0 12px; font-size: 16px; }
.login-view { min-height: 100vh; display: grid; place-items: center; background: var(--nav); }
.login-card { width: 360px; background: #fff; border-radius: 8px; padding: 30px; display: grid; gap: 14px; }
.login-card .brand { color: var(--text); }
.login-card .brand-sub { color: var(--sub); margin-bottom: 12px; }
.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100vw - 48px));
  min-height: 72px;
  padding: 22px 28px;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  background: rgba(17, 24, 39, .86);
  color: #fff;
  box-shadow: 0 18px 48px rgba(16, 24, 40, .30);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.5;
}
