:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #6b778c;
  --soft: #eef3f8;
  --line: #dbe4ee;
  --navy: #111b2b;
  --navy-2: #17243a;
  --brand: #1f6fe5;
  --brand-dark: #1557b6;
  --brand-soft: #edf5ff;
  --danger: #c93535;
  --ok: #13845e;
  --warn: #a96a00;
  --amber: #fff4da;
  --shadow: 0 16px 42px rgba(20, 32, 51, 0.08);
  --shadow-soft: 0 8px 24px rgba(20, 32, 51, 0.06);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #f7f9fc 0, var(--bg) 280px),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.button-like {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 14px;
  background: white;
  color: var(--ink);
  cursor: pointer;
}

button:hover,
.button-like:hover {
  border-color: #b9c7d8;
}

.button-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

input,
select,
textarea {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(31, 111, 229, 0.18);
  border-color: var(--brand);
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--navy);
  color: white;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: grid;
  gap: 14px;
  color: white;
  text-decoration: none;
  padding: 8px 6px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 128px;
  height: 34px;
  border-radius: 8px;
  background: white;
  display: flex;
  align-items: center;
  padding: 7px 10px;
}

.brand-mark img {
  width: 100%;
  height: auto;
  display: block;
}

.brand span:last-child {
  color: #c7d4e5;
  font-size: 14px;
  font-weight: 700;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  color: #d9e4f2;
  text-decoration: none;
  border-radius: 8px;
  padding: 13px 14px;
  font-weight: 600;
  font-size: 15px;
}

.side-nav a:hover,
.side-nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.security-note {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.security-note strong {
  display: block;
  font-size: 14px;
  margin-bottom: 8px;
}

.security-note p {
  margin: 0;
  color: #b8c7da;
  font-size: 13px;
  line-height: 1.55;
}

.main-shell {
  min-width: 0;
}

.topbar {
  min-height: 236px;
  padding: 38px 48px 92px;
  background:
    linear-gradient(135deg, rgba(17, 27, 43, 0.98), rgba(30, 52, 82, 0.95)),
    radial-gradient(circle at 70% 10%, rgba(31, 111, 229, 0.25), transparent 28%);
  color: white;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  color: #7aa9ef;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
}

.topbar h1 {
  margin: 0;
  font-size: 31px;
  line-height: 1.18;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.audience-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #dbeafe;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.topbar p:not(.eyebrow) {
  margin: 14px 0 0;
  color: #c4d2e5;
  font-size: 16px;
  line-height: 1.55;
}

.userbox {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.user-menu-btn {
  min-height: 46px;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-menu-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  display: inline-grid;
  place-items: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 160px;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 10;
}

.user-menu.open {
  display: grid;
}

.user-menu a,
.user-menu button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  display: flex;
  align-items: center;
  padding: 8px 10px;
  text-decoration: none;
  text-align: left;
}

.user-menu a:hover,
.user-menu button:hover {
  background: #f2f5f8;
}

.user-menu a.active {
  color: var(--brand);
  font-weight: 700;
}

.layout {
  max-width: 1340px;
  margin: -58px auto 0;
  padding: 0 36px 56px;
}

.identity-gate,
.approval-gate {
  max-width: 880px;
  margin: -58px auto 0;
  padding: 0 36px 56px;
}

.identity-panel,
.approval-panel {
  margin-top: 0;
}

.identity-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 24px;
}

.identity-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.identity-card h3,
.external-request h3 {
  margin: 0;
  font-size: 20px;
}

.identity-card p,
.external-request p {
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.external-request {
  margin: 0 24px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  background: var(--brand-soft);
}

.request-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.approval-form {
  padding: 24px;
}

.approval-form p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.7;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: start;
}

.guide-panel {
  display: none;
}

.panel,
.metric,
.guide-card,
.alert-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.panel {
  margin-top: 24px;
}

.hero-grid > .panel {
  margin-top: 0;
}

.panel-head {
  min-height: 78px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.panel-head h2,
.guide-card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.upload-panel form {
  padding: 24px;
}

.publish-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(420px, 1.12fr);
  gap: 24px;
  align-items: stretch;
}

.publish-settings {
  display: grid;
  align-content: start;
}

.field {
  display: grid;
  gap: 9px;
  margin-bottom: 20px;
}

.field span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.access-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.access-choice {
  min-height: 88px;
  text-align: left;
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 16px 18px;
  background: #fbfdff;
}

.icon-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.icon-choice {
  min-height: 42px;
  border-radius: 8px;
  background: #fbfdff;
  color: var(--muted);
  font-weight: 700;
  padding: 8px 6px;
}

.icon-choice.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand);
}

.access-choice strong {
  font-size: 17px;
  line-height: 1.2;
}

.access-choice span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.access-choice.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px rgba(31, 111, 229, 0.08);
}

.access-choice:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  background: #f3f6fa;
  border-color: #d8e1ec;
  box-shadow: none;
}

.access-choice:disabled strong,
.access-choice:disabled span {
  color: #8a96a8;
}

.access-choice:disabled::after {
  content: "外部伙伴不可选";
  align-self: end;
  color: #8a96a8;
  font-size: 12px;
  font-weight: 700;
}

.password-field {
  border-radius: 8px;
  padding: 14px 16px;
  background: #fbfcff;
  border: 1px solid var(--line);
}

.dropzone {
  min-height: 100%;
  border: 2px dashed #aebcd0;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(246, 249, 253, 0.85), rgba(255, 255, 255, 0.92));
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
  padding: 26px;
  cursor: pointer;
}

.dropzone.dragging {
  border-color: var(--brand);
  background: #eef5ff;
}

.dropzone input {
  display: none;
}

.dropzone strong {
  font-size: 20px;
  line-height: 1.25;
}

.dropzone span {
  color: var(--muted);
  font-size: 14px;
}

.progress {
  height: 8px;
  background: #e6ebf1;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 16px;
  display: none;
}

.progress div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), #43b5ff);
}

.actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

button[type="submit"],
.primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  font-weight: 700;
}

button[type="submit"]:hover,
.primary:hover {
  background: var(--brand-dark);
}

.danger {
  color: var(--danger);
}

.guide-panel {
  display: none;
}

.guide-card,
.alert-card {
  padding: 24px;
  box-shadow: var(--shadow-soft);
}

.steps {
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  display: grid;
  gap: 18px;
}

.steps li {
  display: grid;
  gap: 6px;
  border-left: 3px solid var(--brand);
  padding-left: 14px;
}

.steps strong {
  font-size: 16px;
  line-height: 1.3;
}

.steps span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.alert-card {
  border-color: #f3d391;
  background: var(--amber);
}

.alert-card strong {
  color: #704700;
}

.alert-card p {
  margin: 10px 0 0;
  color: #7c5a1a;
  line-height: 1.55;
  font-size: 14px;
}

.admin-only {
  display: none;
}

.admin-mode .admin-only {
  display: grid;
}

.admin-mode .metrics {
  display: grid;
}

.admin-mode section.admin-only.panel {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.metric {
  padding: 20px;
  display: grid;
  gap: 7px;
}

.metric span,
.meta,
.empty {
  color: var(--muted);
}

.metric strong {
  font-size: 27px;
}

.metric small {
  color: var(--muted);
  font-size: 12px;
}

.search {
  width: min(360px, 100%);
}

.app-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  padding: 22px;
}

.app-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  display: grid;
  gap: 13px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.app-title {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  align-items: flex-start;
}

.app-title-text {
  min-width: 0;
  flex: 1;
}

.app-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
}

.app-icon-map { background: #eaf8f1; color: #13845e; }
.app-icon-chart { background: #edf4ff; color: #1f6fe5; }
.app-icon-table { background: #f0edff; color: #684bd6; }
.app-icon-file { background: #fff5dd; color: #a96a00; }
.app-icon-tool { background: #edf1f5; color: #526071; }
.app-icon-spark { background: #fff0f5; color: #c33a72; }

.app-title h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.badge {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  white-space: nowrap;
  background: #eef1f5;
  color: var(--muted);
  font-weight: 700;
}

.badge.company { color: var(--brand); background: #edf4ff; }
.badge.public { color: var(--ok); background: #eaf8f1; }
.badge.password { color: var(--warn); background: #fff5dd; }
.badge.disabled { color: var(--danger); background: #fff0f0; }

.app-links {
  border-radius: 8px;
  background: var(--soft);
  padding: 10px;
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  word-break: break-all;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.card-actions button {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.request-actions {
  display: flex;
  flex-wrap: wrap;
}

.empty {
  padding: 28px 20px;
  display: none;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 20px;
}

.two-col h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.placeholder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.placeholder-grid #trashPanel {
  grid-column: 1 / -1;
}

.mini-panel p {
  margin: 0;
  padding: 18px 20px 22px;
  color: var(--muted);
  line-height: 1.6;
}

.trash-list {
  padding: 20px;
}

.trash-card {
  opacity: 0.88;
}

.request-list {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.request-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.request-avatar {
  width: 40px;
  height: 40px;
}

.request-body h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.request-body p {
  margin: 0;
  line-height: 1.55;
}

.request-body .meta {
  margin-bottom: 7px;
}

.request-actions {
  justify-content: flex-end;
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-item {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 32, 0.46);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.modal.open {
  display: flex;
}

.modal-panel {
  width: min(540px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 22px 70px rgba(16, 24, 32, 0.22);
}

.modal-body {
  padding: 20px;
}

.qr-modal-panel {
  width: min(760px, 100%);
}

.qr-modal-body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.qr-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 16px;
  display: grid;
  place-items: center;
}

.qr-preview img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
}

.qr-info h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.qr-url {
  margin: 0 0 14px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  padding: 10px;
  word-break: break-all;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #101820;
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .hero-grid {
    grid-template-columns: 1fr;
  }

  .publish-grid,
  .metrics,
  .placeholder-grid {
    grid-template-columns: 1fr;
  }
}
