:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-alt: #fafafc;
  --border: #e5e5ea;
  --border-strong: #d2d2d7;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0060c2;
  --accent-soft: #eaf3ff;
  --ok-bg: #e7f7ee;
  --ok-ink: #0f6b3e;
  --new-bg: #fff2e2;
  --new-ink: #9c4a00;
  --legacy-bg: #f1f2f6;
  --legacy-ink: #424752;
  --paused-bg: #fdebec;
  --paused-ink: #a31f2c;
  --b2b-bg: #eef4ff;
  --b2b-ink: #1849a9;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.03);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* Header */
.site-header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 20px;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-bottom: 2px;
}

.hero-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hero-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 820px;
}

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

/* Buttons & Pills */
.btn,
button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover,
button:hover {
  background: var(--surface-alt);
  border-color: #b8b8bf;
  text-decoration: none;
}

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

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

.btn-danger {
  color: var(--paused-ink);
  border-color: #f3c4c8;
  background: #fff8f8;
}

.btn-danger:hover {
  background: var(--paused-bg);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.badge-user {
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
}

/* Main Container */
.container {
  max-width: 1240px;
  margin: 20px auto 48px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

/* Public directory */
.pub-cat {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.pub-cat:first-of-type {
  margin-top: 14px;
}

.pub-cat h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.public-platforms {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px 12px;
}

.public-platforms li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 0;
}

.public-platforms li a {
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-platforms li a:hover {
  color: var(--accent);
}

/* Semantic Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.pill-registered {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.pill-pending_new,
.pill-new {
  background: var(--new-bg);
  color: var(--new-ink);
}

.pill-pending_legacy,
.pill-muted {
  background: var(--legacy-bg);
  color: var(--legacy-ink);
}

.pill-paused {
  background: var(--paused-bg);
  color: var(--paused-ink);
}

.pill-high {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-b2b {
  background: var(--b2b-bg);
  color: var(--b2b-ink);
}

.pill-paid {
  background: #f5effd;
  color: #5d2b9c;
}

/* Login Page */
.login-shell {
  min-height: calc(100vh - 100px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 26px;
}

.login-card h1 {
  margin: 4px 0 6px;
  font-size: 21px;
  font-weight: 700;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.14);
}

.alert-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--paused-bg);
  color: var(--paused-ink);
  font-size: 13px;
  font-weight: 500;
}

.security-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #fff8eb;
  border: 1px solid #f4d8a8;
  color: #7c4700;
  font-size: 12px;
  font-weight: 500;
}

/* Workbench Controls */
.client-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.client-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.client-select {
  width: auto;
  min-width: 210px;
  font-weight: 600;
}

.client-meta {
  font-size: 12px;
  color: var(--muted);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.results-summary {
  margin: 10px 0 6px;
}

.kpi-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
}

.kpi-val {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.progress-wrap {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #e9e9ee;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--ok-ink);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.progress-label {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 84px;
  text-align: right;
}

/* Workspace Tabs */
.tabs-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.tab-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.tab-count {
  font-size: 11px;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
}

/* Filter Toolbar */
.filter-bar {
  display: grid;
  grid-template-columns: 1.6fr 1fr 0.8fr 0.8fr auto;
  gap: 10px;
  align-items: center;
}

/* 3-Column Platform Table */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.platform-table {
  width: 100%;
  border-collapse: collapse;
}

.platform-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.platform-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.platform-table tr:last-child td {
  border-bottom: none;
}

.plat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.plat-name {
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
}

.plat-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.acct-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
}

.acct-line {
  font-size: 12px;
  color: var(--ink);
  word-break: break-all;
}

.acct-line span {
  color: var(--muted);
}

.row-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  min-width: 170px;
}

.status-select {
  width: auto;
  min-width: 145px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
}

.btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Cards Grid for Dock & Guidance */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.info-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.info-card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.info-card pre {
  margin: 0;
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: var(--muted);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(29, 29, 31, 0.42);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  padding: 22px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
  z-index: 60;
}

.empty-box {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  margin-top: 12px;
}

@media (max-width: 900px) {
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }
  .filter-bar input[type="search"] {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .header-inner,
  .container {
    padding-left: 14px;
    padding-right: 14px;
  }
  .panel {
    padding: 15px;
  }
  .public-platforms {
    grid-template-columns: 1fr;
  }
  .filter-bar,
  .modal-grid-2 {
    grid-template-columns: 1fr;
  }
  .platform-table thead {
    display: none;
  }
  .platform-table,
  .platform-table tbody,
  .platform-table tr,
  .platform-table td {
    display: block;
    width: 100%;
  }
  .platform-table tr {
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
  }
  .platform-table td {
    border-bottom: none;
    padding: 4px 0;
  }
}
