/* Apple-inspired design system */
:root {
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-soft: rgba(0, 113, 227, 0.08);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.10);
  --orange: #ff9500;
  --orange-soft: rgba(255, 149, 0, 0.10);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.08);
  --purple: #af52de;
  --purple-soft: rgba(175, 82, 222, 0.10);
  --bg: #f5f5f7;
  --bg-secondary: #ececee;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #515154;
  --text-tertiary: #6e6e73;
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.03);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --sidebar-w: 220px;
  --topbar-h: 52px;
  --content-pad: 24px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "Menlo", monospace;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --dur: 180ms;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; height: 100%; }

body {
  font: 15px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  height: 100%;
  letter-spacing: -0.01em;
}

/* Toast */
.toast-host {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; max-width: 360px; pointer-events: none;
}
.toast {
  pointer-events: auto; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border); font-size: 14px;
  animation: fade-up var(--dur) var(--ease);
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.warn { border-left: 3px solid var(--orange); }
@keyframes fade-up { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Loading */
.loading-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(245,245,247,0.85);
  display: flex; align-items: center; justify-content: center;
}
.loading-overlay[hidden] { display: none !important; }
.loading-card { text-align: center; }
.spinner {
  width: 32px; height: 32px; margin: 0 auto 12px;
  border: 2.5px solid var(--border-strong); border-top-color: var(--blue);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.auth-shell[hidden] { display: none !important; }
.auth-container { width: 100%; max-width: 400px; text-align: center; }
.auth-logo { margin-bottom: 16px; }
.auth-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-secondary); font-size: 17px; margin-bottom: 32px; }
.auth-panel { text-align: left; }
.auth-panel[hidden] { display: none !important; }
.auth-switch { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-secondary); }
.auth-stats {
  display: flex; justify-content: center; gap: 24px; margin-top: 40px;
  padding-top: 24px; border-top: 1px solid var(--border);
}
.auth-stat { text-align: center; }
.auth-stat strong { display: block; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.auth-stat span { font-size: 12px; color: var(--text-tertiary); }

/* Forms */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.field em.req { color: var(--red); font-style: normal; }
.field input, .field textarea {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font: inherit; background: var(--surface);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft);
}
.form-feedback { font-size: 13px; margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); }
.form-feedback:empty { display: none; }
.form-feedback.ok { color: #1a7f37; background: rgba(52,199,89,0.1); }
.form-feedback.err { color: var(--red); background: rgba(255,59,48,0.08); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm); font: inherit; font-size: 14px;
  font-weight: 500; cursor: pointer; border: none;
  transition: background var(--dur), opacity var(--dur), transform var(--dur);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }
.btn-secondary { background: var(--bg-secondary); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #e8e8ed; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-secondary); }
.link-btn {
  border: none; background: none; padding: 0; font: inherit; font-size: inherit;
  color: var(--blue); cursor: pointer; text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }
.icon-btn {
  width: 36px; height: 36px; border: none; border-radius: 50%;
  background: transparent; color: var(--text-secondary); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; transition: background var(--dur);
}
.icon-btn:hover { background: var(--bg-secondary); }

/* App shell — full viewport */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.app-shell[hidden] { display: none !important; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 1px 0 8px rgba(0, 0, 0, 0.04);
  display: flex; flex-direction: column; padding: 16px 12px;
  position: sticky; top: 0; height: 100vh; z-index: 50;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 24px;
}
.sidebar-brand-text { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-group-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-tertiary);
  padding: 20px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: transparent; color: var(--text-secondary);
  padding: 9px 10px 9px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 500; text-align: left;
  transition: background var(--dur), color var(--dur);
  border-left: 2px solid transparent;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.6; }
.nav-item:hover { background: var(--bg-secondary); color: var(--text); }
.nav-item.active {
  background: var(--blue-soft); color: var(--blue);
  border-left-color: var(--blue);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--border); }
.user-chip {
  font-size: 12px; color: var(--text-secondary); padding: 8px 10px;
  margin-bottom: 8px; line-height: 1.5; white-space: pre-line;
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,0.3);
}
.sidebar-backdrop.open { display: block; }

.app-main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; height: 100vh; overflow: hidden;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); flex-shrink: 0;
  padding: 0 var(--content-pad);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.menu-btn { display: none; }
.global-search-wrap {
  flex: 1; position: relative; display: flex; align-items: center;
}
.global-search-wrap .search-icon {
  position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-tertiary);
}
.global-search-wrap input {
  width: 100%; padding: 8px 36px 8px 36px; border: none;
  border-radius: var(--radius-sm); background: var(--bg-secondary);
  font: inherit; font-size: 14px; transition: background var(--dur), box-shadow var(--dur);
}
.global-search-wrap input:focus {
  outline: none; background: var(--surface); box-shadow: 0 0 0 4px var(--blue-soft);
}
.search-kbd {
  position: absolute; right: 10px; font-size: 11px; font-family: var(--mono);
  color: var(--text-tertiary); background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}

/* Content — full width & height */
.content {
  flex: 1; width: 100%; min-height: 0;
  padding: var(--content-pad);
  overflow: auto;
  display: flex; flex-direction: column;
}
.view[hidden] { display: none !important; }
.view:not([hidden]) {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; width: 100%;
  animation: view-fade-in 200ms var(--ease);
}

.page-hero { margin-bottom: 20px; flex-shrink: 0; }
.page-hero.compact { margin-bottom: 16px; }
.page-hero h2 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; margin-bottom: 4px;
}
.page-lead { color: var(--text-tertiary); font-size: 14px; line-height: 1.5; }

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); }

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 16px; flex-shrink: 0;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 18px 20px;
  border-left: 3px solid var(--blue);
  transition: transform 150ms var(--ease), box-shadow 150ms var(--ease);
  position: relative;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card strong {
  display: block; font-size: 28px; font-weight: 700;
  letter-spacing: -0.03em; margin-bottom: 4px;
  line-height: 1.1;
}
.stat-card span { font-size: 12px; color: var(--text-tertiary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card:nth-child(2) { border-left-color: var(--green); }
.stat-card:nth-child(3) { border-left-color: var(--orange); }
.stat-card:nth-child(4) { border-left-color: var(--red); }
.stat-card:nth-child(5) { border-left-color: var(--purple); }

.dashboard-grid {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.dashboard-grid .card {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
}
.dashboard-grid .card-head { flex-shrink: 0; }
.dashboard-grid .card-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 0 20px 16px;
}
.dashboard-grid .category-chips { padding: 4px 0 0; }
.dashboard-grid .recent-list { padding: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 980px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background var(--dur), border-color var(--dur), box-shadow var(--dur);
}
.chip:hover { background: var(--blue-soft); border-color: rgba(0,113,227,0.2); box-shadow: var(--shadow-sm); }
.chip-count { color: var(--text-tertiary); font-size: 11px; font-weight: 400; }

.category-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-list { flex: 1; min-height: 0; overflow-y: auto; }
.recent-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; cursor: pointer; transition: background var(--dur);
  border: none; background: none; width: 100%; text-align: left; font: inherit;
  border-radius: var(--radius-sm);
}
.recent-item:hover { background: var(--bg-secondary); }
.recent-item code { font-family: var(--mono); font-size: 12px; color: var(--blue); font-weight: 600; }
.recent-item span { font-size: 12px; color: var(--text-tertiary); display: block; margin-top: 2px; }

.import-warnings {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-secondary);
  border: 1px solid var(--border);
}
.import-warnings strong { font-size: 13px; }
.import-warn { margin: 6px 0 4px; font-size: 12px; font-weight: 600; }
.import-warn-error { color: #b42318; }
.import-warn-warn { color: #b54708; }
.import-warn-ok { color: #1a7f37; font-weight: 500; }
.import-warn-list {
  margin: 0 0 8px;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-secondary);
  max-height: 120px;
  overflow-y: auto;
}
.import-warn-list li { padding: 2px 0; }

.import-preview {
  margin-top: 20px; padding: 16px; border-radius: var(--radius);
  background: var(--bg-secondary); border: 1px solid var(--border);
}
.import-preview[hidden] { display: none !important; }
.preview-summary {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.preview-pill {
  padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border);
}
.preview-pill.create { color: #1a7f37; border-color: rgba(52,199,89,0.3); background: rgba(52,199,89,0.08); }
.preview-pill.update { color: var(--blue); border-color: rgba(0,113,227,0.25); background: var(--blue-soft); }
.preview-pill.unchanged { color: var(--text-tertiary); }
.import-draft-option {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}
.import-diff-line {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}
.import-diff-detail {
  display: block;
  margin-top: 2px;
  color: var(--text-tertiary);
}
.diff-pill {
  display: inline-block;
  margin-right: 4px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}
.diff-pill.added { color: #1a7f37; background: rgba(52,199,89,0.12); }
.diff-pill.removed { color: #b42318; background: rgba(255,59,48,0.1); }
.diff-pill.changed { color: var(--blue); background: var(--blue-soft); }
.status-pill.draft {
  color: #b54708;
  border-color: rgba(255,149,0,0.35);
  background: rgba(255,149,0,0.1);
}
.preview-list { max-height: 240px; overflow-y: auto; font-size: 13px; }
.preview-list details { margin-bottom: 8px; }
.preview-list summary { cursor: pointer; font-weight: 500; padding: 6px 0; }
.preview-list li { color: var(--text-secondary); padding: 2px 0 2px 12px; }

.log-toolbar {
  display: flex; gap: 12px; padding: 12px 16px; margin-bottom: 12px; flex-wrap: wrap; align-items: center;
  border-radius: var(--radius);
}
.log-toolbar .search-inline { flex: 1; min-width: 200px; }
.select-input {
  padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  font: inherit; font-size: 13px; background: var(--surface); color: var(--text);
}
.log-item-expandable { cursor: pointer; }
.log-item-expandable .log-expand-hint { font-size: 11px; color: var(--blue); margin-top: 4px; }

.modal-dialog-wide { width: min(720px, 100%); }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .diff-grid { grid-template-columns: 1fr; } }
.diff-col h4 { font-size: 12px; font-weight: 600; color: var(--text-tertiary); margin-bottom: 8px; text-transform: uppercase; }
.diff-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.diff-table td, .diff-table th { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.diff-table tbody tr:nth-child(even) td { background: rgba(0, 0, 0, 0.015); }
.diff-table tr.changed td { background: rgba(255,149,0,0.08); }
.diff-table tr.added td { background: rgba(52,199,89,0.08); }
.diff-table tr.removed td { background: rgba(255,59,48,0.06); text-decoration: line-through; color: var(--text-tertiary); }
.diff-empty { color: var(--text-tertiary); font-size: 13px; padding: 12px 0; }

/* Methods list */
.methods-panel {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--radius);
}
.methods-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; flex-shrink: 0;
}
.methods-toolbar .search-inline { flex: 1; min-width: 200px; max-width: none; }
.methods-table-head,
.methods-row {
  display: grid;
  grid-template-columns: 148px minmax(220px, 2fr) minmax(72px, 1fr) minmax(96px, 1fr) 72px minmax(120px, 1fr);
  gap: 16px; align-items: center; padding: 0 16px;
}
.methods-table-head {
  padding: 10px 16px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary);
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.methods-table-body {
  flex: 1; min-height: 0; overflow-y: auto;
}
.methods-table-body.empty { padding: 48px 20px; }
.methods-row {
  width: 100%; border: none; background: none; cursor: pointer; font: inherit;
  text-align: left; color: var(--text); min-height: 48px;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur);
}
.methods-row:hover { background: rgba(0, 113, 227, 0.03); }
.methods-row:nth-child(even) { background: rgba(0, 0, 0, 0.012); }
.methods-row:nth-child(even):hover { background: rgba(0, 113, 227, 0.03); }
.methods-row:last-child { border-bottom: 0; }
.col-code code { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--blue); }
.col-name { font-weight: 500; font-size: 14px; line-height: 1.4; }
.col-cat, .col-size, .col-time { font-size: 13px; color: var(--text-secondary); }
.col-time { font-size: 11px; color: var(--text-tertiary); font-family: var(--mono); }
.methods-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-tertiary); flex-shrink: 0;
}

/* Method detail page */
.method-detail-page { width: 100%; }
.method-detail-page.loading { padding: 80px 0; text-align: center; }

.detail-breadcrumb {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  font-size: 13px; color: var(--text-tertiary);
}
.back-link {
  border: none; background: none; padding: 0; font: inherit;
  color: var(--blue); cursor: pointer; font-weight: 500;
}
.back-link:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--border-strong); }
.breadcrumb-code { font-family: var(--mono); font-size: 12px; color: var(--text-tertiary); }
.breadcrumb-code { font-family: var(--mono); font-size: 13px; color: var(--text-tertiary); }

.detail-hero {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px; margin-bottom: 24px; flex-wrap: wrap;
}
.detail-hero-main { flex: 1; min-width: 280px; }
.detail-category {
  display: inline-block; font-size: 11px; font-weight: 600;
  color: var(--blue); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 8px;
  padding: 3px 8px; background: var(--blue-soft); border-radius: 4px;
}
.detail-hero h1 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  line-height: 1.25; margin-bottom: 10px;
}
.detail-meta-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-tertiary);
}
.detail-code-badge {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 4px;
  background: var(--blue-soft); color: var(--blue);
}
.detail-hero-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.detail-hero-actions .btn-fav { font-size: 14px; padding: 6px 12px; }

.detail-stat-bar {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  margin-bottom: 20px; flex-shrink: 0;
}
.detail-stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; text-align: center;
}
.detail-stat strong { display: block; font-size: 22px; font-weight: 700; margin-bottom: 4px; line-height: 1.1; }
.detail-stat span { font-size: 11px; color: var(--text-tertiary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

.detail-section { margin-bottom: 20px; padding: 24px 28px; }
.detail-section-muted { background: var(--bg-secondary); }
.detail-section .section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-section .section-head h2 { font-size: 16px; font-weight: 600; margin: 0; }
.detail-tools { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.detail-tools .search-inline { min-width: 180px; }
.detail-tools select {
  border: none; background: transparent; font: inherit; font-size: 14px;
  padding: 9px 0; outline: none; min-width: 120px; color: var(--text);
}
.section-hint { font-size: 12px; color: var(--text-tertiary); }

.indicator-stack { display: flex; flex-direction: column; gap: 16px; }
.indicator-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--surface);
  transition: box-shadow var(--dur);
}
.indicator-card:hover { box-shadow: var(--shadow-sm); }
.indicator-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
}
.indicator-card-head h5 { font-size: 15px; font-weight: 600; margin: 0; }
.indicator-card-head p { font-size: 12px; color: var(--text-tertiary); margin-top: 3px; }
.indicator-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Rules table — full width on detail page */
.rules-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rules-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.rules-table th {
  padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0;
}
.rules-table td {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  vertical-align: middle; line-height: 1.5;
}
.rules-table tbody tr:last-child td { border-bottom: 0; }
.rules-table tbody tr:hover td { background: rgba(0, 113, 227, 0.03); }
.rules-table tbody tr:nth-child(even) td { background: rgba(0, 0, 0, 0.012); }
.rules-table tbody tr:nth-child(even):hover td { background: rgba(0, 113, 227, 0.03); }
.range-cell { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--blue); }

.status-pill {
  display: inline-block; padding: 4px 12px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; background: var(--bg-secondary); color: var(--text-secondary);
}
.status-pill.published { background: rgba(52,199,89,0.12); color: #1a7f37; }

.btn-fav {
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font: inherit; font-size: 14px; line-height: 1; padding: 7px 14px;
  border-radius: var(--radius-sm); color: var(--text-secondary);
  transition: color var(--dur), border-color var(--dur), background var(--dur);
}
.btn-fav:hover { border-color: #ff9500; color: #ff9500; }
.btn-fav.active { color: #ff9500; border-color: rgba(255,149,0,0.35); background: rgba(255,149,0,0.08); }

.page-hero-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; flex-shrink: 0;
}

/* Search */
.search-page-toolbar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 12px;
  flex-shrink: 0; flex-wrap: wrap;
}
.search-page-toolbar .search-inline.large { flex: 1; min-width: 280px; }
.search-inline {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; border-radius: var(--radius-sm); background: var(--bg-secondary);
  border: 1px solid transparent; transition: border-color var(--dur), box-shadow var(--dur);
}
.search-inline:focus-within { background: var(--surface); border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.search-inline.large { padding: 4px 14px; }
.search-inline svg { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; }
.search-inline input {
  flex: 1; border: none; background: transparent; font: inherit;
  font-size: 15px; padding: 10px 0; outline: none;
}
.result-meta { font-size: 13px; color: var(--text-tertiary); margin-bottom: 12px; flex-shrink: 0; }

.search-results {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.search-result-item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px; background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); cursor: pointer;
  transition: background var(--dur), box-shadow var(--dur);
  text-align: left; width: 100%; font: inherit; color: var(--text);
}
.search-result-item:hover { background: var(--bg-secondary); box-shadow: var(--shadow-sm); }
.search-result-item strong { font-size: 16px; font-weight: 600; display: block; }
.search-result-item .result-method { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.search-result-item .result-meta-right { text-align: right; flex-shrink: 0; }
.search-result-item code { font-family: var(--mono); font-size: 12px; color: var(--blue); font-weight: 600; }

/* Segmented control */
.segmented {
  display: inline-flex; background: var(--bg-secondary); border-radius: var(--radius-sm);
  padding: 2px; gap: 2px; flex-wrap: wrap;
}
.segmented button {
  border: none; background: transparent; padding: 5px 12px;
  border-radius: 6px; font: inherit; font-size: 12px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; transition: background var(--dur), color var(--dur);
  white-space: nowrap;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

/* Browse */
.browse-grid {
  flex: 1; min-height: 0; overflow-y: auto; align-content: start;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px;
}
.browse-card {
  padding: 24px; background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); cursor: pointer;
  transition: transform var(--dur), box-shadow var(--dur);
  text-align: left; font: inherit; color: var(--text); width: 100%;
}
.browse-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.browse-card h3 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.browse-card p { font-size: 13px; color: var(--text-secondary); }

/* Import */
.import-card { width: 100%; max-width: none; padding: 24px; border-radius: var(--radius); }
.drop-zone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 32px; text-align: center; cursor: pointer;
  transition: border-color var(--dur), background var(--dur);
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--blue); background: var(--blue-soft); }
.drop-title { font-weight: 500; margin: 8px 0 4px; }
.drop-sub { font-size: 13px; color: var(--text-tertiary); }
.drop-file { font-size: 13px; color: var(--blue); font-weight: 500; margin-top: 8px; min-height: 1.2em; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }

/* Logs */
.log-card { padding: 0; flex: 1; min-height: 0; overflow-y: auto; border-radius: var(--radius); }
.log-toolbar { flex-shrink: 0; margin-bottom: 12px; }
.log-item {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  font-size: 13px; transition: background var(--dur);
}
.log-item:hover { background: var(--bg-secondary); }
.log-item:nth-child(even) { background: rgba(0, 0, 0, 0.015); }
.log-item:nth-child(even):hover { background: var(--bg-secondary); }
.log-item:last-child { border-bottom: 0; }
.log-item time { display: block; font-size: 11px; color: var(--text-tertiary); font-family: var(--mono); margin-bottom: 2px; }
.log-item strong { font-weight: 600; }

.pending-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.pending-row:nth-child(even) { background: rgba(0, 0, 0, 0.015); }
.pending-row:last-child { border-bottom: 0; }

.profile-grid {
  display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 16px;
}
.profile-card .card-body { padding: 20px; }
.profile-hint { font-size: 13px; color: var(--text-secondary); margin: 0 0 12px; line-height: 1.5; }
.profile-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 10px; }
.profile-dl { display: grid; gap: 12px; margin: 0; }
.profile-dl div { display: grid; grid-template-columns: 88px 1fr; gap: 8px; align-items: baseline; }
.profile-dl dt { font-size: 12px; color: var(--text-tertiary); margin: 0; }
.profile-dl dd { margin: 0; font-size: 14px; font-weight: 500; }
.sync-url-box { display: flex; gap: 8px; align-items: stretch; }
.sync-url-input {
  flex: 1; min-width: 0; height: 40px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0 12px; font: var(--mono) 12px/40px monospace;
  background: var(--bg-secondary); color: var(--text-primary);
}
.account-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; margin-bottom: 12px;
  border-radius: var(--radius);
}
.account-tabs { flex-shrink: 0; }
.account-filters { display: flex; gap: 8px; }
.account-card { padding: 0; overflow: hidden; border-radius: var(--radius); }
.account-table-head, .account-row {
  display: grid; grid-template-columns: minmax(180px, 1.4fr) 120px 130px 1fr 160px;
  gap: 12px; align-items: center; padding: 14px 20px;
}
.account-table-head {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-tertiary); border-bottom: 1px solid var(--border); background: var(--bg-secondary);
}
.account-row { border-bottom: 1px solid var(--border); }
.account-row:nth-child(even) { background: rgba(0, 0, 0, 0.015); }
.account-row:last-child { border-bottom: 0; }
.account-user strong { display: block; font-size: 14px; }
.account-user span { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.account-user time { display: block; font-size: 11px; color: var(--text-tertiary); margin-top: 4px; font-family: var(--mono); }
.account-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.account-plugin { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.plugin-token-badge {
  display: inline-flex; width: fit-content; padding: 2px 8px; border-radius: var(--radius-sm);
  background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 600;
}
.plugin-used { color: var(--text-tertiary); font-size: 11px; font-family: var(--mono); }
.status-badge.pending { color: var(--orange, #c93400); font-size: 12px; font-weight: 600; }
.select-sm { height: 32px; padding: 0 8px; font-size: 13px; }

@media (max-width: 960px) {
  .profile-grid { grid-template-columns: 1fr; }
  .account-table-head { display: none; }
  .account-row {
    grid-template-columns: 1fr; gap: 8px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 12px;
    padding: 14px;
  }
  .account-card { background: transparent; border: 0; box-shadow: none; }
  .account-table-body { padding: 0; }
}

/* Timeline */
.timeline { padding: 0; }
.timeline-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.timeline-item:nth-child(even) { background: rgba(0, 0, 0, 0.015); padding: 12px 8px; margin: 0 -8px; border-radius: var(--radius-sm); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-item time { font-size: 11px; color: var(--text-tertiary); font-family: var(--mono); }
.timeline-item strong { display: block; font-size: 13px; margin: 2px 0; }
.timeline-item p { font-size: 12px; color: var(--text-secondary); margin: 0; }

.empty-line { padding: 24px; text-align: center; color: var(--text-tertiary); font-size: 14px; }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 8500;
  background: rgba(0,0,0,0.4);
  display: flex; justify-content: flex-end;
}
.modal.centered { align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none !important; }
.modal-sheet {
  width: min(720px, 100%); height: 100vh; background: var(--surface);
  display: flex; flex-direction: column;
  animation: slide-in var(--dur) var(--ease);
}
.modal-dialog {
  width: min(600px, 100%); max-height: 80vh; background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modal-dialog-in var(--dur) var(--ease);
}
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide-out { from { transform: none; opacity: 1; } to { transform: translateX(20px); opacity: 0; } }
@keyframes modal-dialog-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes modal-dialog-out { from { transform: scale(1); opacity: 1; } to { transform: scale(0.95); opacity: 0; } }
@keyframes view-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 17px; font-weight: 600; }
.modal-body { flex: 1; overflow: auto; padding: 20px; }
.modal-body.scroll { max-height: 60vh; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}

.rules-head { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 10px; }
.rules-editor { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }

/* Rule block */
.rule-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.rule-row-main {
  display: grid;
  grid-template-columns: 32px 140px 90px 1fr 36px;
  gap: 10px; padding: 12px 14px; align-items: end;
  background: var(--bg-secondary);
}
.rule-idx {
  width: 26px; height: 26px; border-radius: 50%; background: var(--blue-soft);
  color: var(--blue); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); align-self: center;
}
.rule-field { display: flex; flex-direction: column; gap: 4px; }
.rule-field span { font-size: 11px; font-weight: 600; color: var(--text-tertiary); }
.rule-field input, .rule-field select {
  height: 36px; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 0 8px; font: inherit; font-size: 13px; background: var(--surface);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.rule-field input:focus, .rule-field select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft);
}
.rule-remove-btn { align-self: center; }

/* Range display (auto-generated sample range) */
.rule-field-preview { display: flex; flex-direction: column; gap: 4px; }
.range-display {
  height: 36px; display: flex; align-items: center;
  padding: 0 10px; border-radius: 6px;
  background: var(--blue-soft); color: var(--blue);
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Range combo: ≥ [val] ~ ≤ [val] */
.range-combo {
  display: flex; align-items: center; gap: 6px;
}
.range-combo select {
  width: 48px; height: 36px; text-align: center;
  border: 1px solid var(--border-strong); border-radius: 6px;
  font: inherit; font-size: 16px; font-weight: 700;
  background: var(--bg-secondary); cursor: pointer;
  padding: 0 4px;
}
.range-combo input {
  flex: 1; min-width: 0; height: 36px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 0 10px; font: inherit; font-size: 14px; background: var(--surface);
}
.range-combo input:focus, .range-combo select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft);
}
.range-sep { color: var(--text-tertiary); font-weight: 600; font-size: 15px; padding: 0 2px; }

/* Extra params (collapsible) */
.rule-extra {
  border-top: 1px solid var(--border);
}
.rule-extra summary {
  padding: 8px 14px; font-size: 12px; color: var(--text-secondary);
  cursor: pointer; user-select: none;
}
.rule-extra summary:hover { color: var(--blue); }
.rule-extra-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 0 14px 12px;
}
.rule-extra-grid label { display: flex; flex-direction: column; gap: 3px; }
.rule-extra-grid label span { font-size: 10px; font-weight: 600; color: var(--text-tertiary); }
.rule-extra-grid input {
  height: 30px; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 0 8px; font: inherit; font-size: 12px; background: var(--surface);
}
.rule-extra-grid input:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft);
}

/* Print */
@media print {
  .sidebar, .topbar, .modal, .toast-host, .loading-overlay, .detail-breadcrumb { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; max-width: none; }
}

/* Responsive */
@media (max-width: 960px) {
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%); transition: transform 260ms var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 16px; }
  .methods-table-head { display: none; }
  .methods-row {
    grid-template-columns: 1fr; gap: 4px; padding: 14px 16px;
  }
  .col-time { display: none; }
  .detail-hero h1 { font-size: 20px; }
  .detail-stat-bar { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .page-hero h2 { font-size: 22px; }
  .global-search-wrap { max-width: none; }
  .search-kbd { display: none; }
  .rule-row-main { grid-template-columns: 32px 1fr 36px; }
  .rule-field-range { grid-column: 1 / -1; }
  .range-combo { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .detail-section { padding: 16px; }
}
