/* Workbench — minimal Tailscale-admin-style */

:root {
  --fg: #0f172a;
  --fg-muted: #475569;
  --fg-weak: #64748b;
  --border: #e2e8f0;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --chip-bg: #f1f5f9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-soft);
  padding: 2px 5px;
  border-radius: 4px;
}
pre { background: var(--bg-soft); padding: 12px; border-radius: var(--radius); overflow-x: auto; }
pre code { background: transparent; padding: 0; }

/* Top navigation */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}
.nav-tabs {
  display: flex;
  gap: 4px;
  height: 100%;
}
.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nav-tab:hover { color: var(--fg); text-decoration: none; }
.nav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.icon { flex-shrink: 0; }
.nav-tab .icon { width: 16px; height: 16px; }
.logout { margin: 0; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 6px 12px;
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.btn-ghost:hover { color: var(--fg); border-color: #cbd5e1; text-decoration: none; }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost .icon { width: 14px; height: 14px; }

/* Page container */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.page-header .muted { margin: 0; }
.muted { color: var(--fg-muted); }
.small { font-size: 12px; }
.center { text-align: center; }

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: white; }

/* Search / count */
.count {
  display: inline-block;
  background: var(--chip-bg);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--fg-muted);
  margin-bottom: 12px;
}

/* Data table */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
}
.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--fg-weak);
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table .actions form { display: inline; }
.data-table .actions .btn-ghost { padding: 4px 10px; }
.truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip {
  display: inline-block;
  background: var(--chip-bg);
  color: var(--fg-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 4px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.chip-local { background: #e0e7ff; color: #3730a3; }
.chip-link { background: #dcfce7; color: #166534; }

/* Home page info strip: "访问来源 / Tailscale / LAN" */
.info-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 10px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  font-size: 12px;
}
.info-bar-bottom { margin-top: 40px; margin-bottom: 0; }
.info-bar > span {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.info-bar .info-label {
  color: var(--fg-weak);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.info-bar code {
  color: var(--fg);
  background: transparent;
  padding: 0;
  font-size: 12px;
}

.header-actions { display: flex; gap: 8px; align-items: flex-start; }

/* Card grid (home sites) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}
.site-card {
  display: block;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.15s;
}
.site-card:hover { border-color: var(--accent); text-decoration: none; color: var(--fg); }
.site-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--accent);
}
.site-card-head strong { color: var(--fg); font-size: 15px; }
.site-card-body { word-break: break-all; font-size: 12px; }

.icon-card { width: 20px; height: 20px; flex-shrink: 0; }
.icon-row  { width: 18px; height: 18px; flex-shrink: 0; }

.site-favicon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 4px;
  object-fit: contain;
  background: var(--bg-soft);
}
.site-favicon.small { width: 18px; height: 18px; border-radius: 3px; }

.name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Sub section */
.sub-section h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-weak);
  margin: 0 0 12px;
}
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 16px; }
.plain-list li:last-child { border-bottom: none; }

/* Empty */
.empty { padding: 48px 0; text-align: center; }

/* Inline hint / collapsible Add form */
.inline-hint { position: relative; }
.inline-hint summary {
  list-style: none;
  cursor: pointer;
}
.inline-hint summary::-webkit-details-marker { display: none; }
.inline-hint[open] .hint-body {
  display: block;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 360px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.inline-hint .hint-body { display: none; }
.inline-hint pre { margin: 8px 0; font-size: 12px; }

.inline-form label {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--fg-muted);
}
.inline-form input, .inline-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  margin-top: 4px;
  color: var(--fg);
}
.inline-form textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; }
.inline-form input:focus, .inline-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Login page */
.login-body {
  background: var(--bg-soft);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 360px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
}
.login-logo { margin-bottom: 16px; }
.login-logo img { display: inline-block; border-radius: 10px; }
.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
}
.login-card .muted { margin: 0 0 24px; font-size: 13px; }
.login-form { text-align: left; }
.login-form label {
  font-size: 12px;
  color: var(--fg-muted);
  display: block;
  margin-bottom: 6px;
}
.login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  color: var(--fg);
}
.login-form input:focus { outline: none; border-color: var(--accent); }
.login-form .btn-primary {
  width: 100%;
  margin-top: 16px;
  justify-content: center;
}
.form-error { color: var(--danger); font-size: 12px; margin-top: 8px; }

/* Settings blocks */
.setting-block {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 48px;
}
.setting-block:first-of-type { border-top: none; padding-top: 0; }
.setting-head h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
}
.stack-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--fg-muted);
}
.stack-form input {
  display: block;
  width: 100%;
  max-width: 360px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  margin-top: 4px;
  color: var(--fg);
}
.stack-form input:focus { outline: none; border-color: var(--accent); }

.info-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  row-gap: 8px;
  margin: 0;
}
.info-list dt { color: var(--fg-muted); }
.info-list dd { margin: 0; color: var(--fg); }

/* Flash messages */
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.flash.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Service status */
.service-status {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12); }
.dot.off { background: #94a3b8; }

.btn-danger {
  background: white;
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 8px 16px;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }

/* Toggle switch */
.toggle-form { margin: 0; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.toggle input { display: none; }
.toggle .track {
  width: 36px;
  height: 20px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  transition: background 0.15s;
}
.toggle .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.15s;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track .thumb { transform: translateX(16px); }
.toggle-label { font-size: 13px; color: var(--fg-muted); }

/* Responsive */
@media (max-width: 720px) {
  .topbar-inner { padding: 0 16px; }
  .nav-tab span { display: none; }
  .setting-block { grid-template-columns: 1fr; gap: 16px; }
}
