:root {
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --border-focus: #4f46e5;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-bg: #eef2ff;
  --secondary-text: #3730a3;
  --success-bg: #ecfdf5;
  --success-border: #6ee7b7;
  --success-text: #065f46;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;
  --warn-text: #92400e;
  --error-bg: #fef2f2;
  --error-border: #fca5a5;
  --error-text: #991b1b;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
}

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

body {
  font-family: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* 扩展弹窗紧凑自适应模式 */
body.is-popup {
  width: 480px;
  min-height: 560px;
}

body.is-popup .app-shell {
  padding: 14px;
}

body.is-popup .main-grid {
  grid-template-columns: 1fr;
}

body.is-popup .brand-subtitle {
  display: none;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
  flex-shrink: 0;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ext {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.badge-web {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

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

.guide-card {
  margin-bottom: 20px;
  background: #f8fafc;
  border-color: #cbd5e1;
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 14px;
}

.guide-text {
  font-size: 13px;
  color: #334155;
  margin-bottom: 8px;
}

.guide-steps {
  padding-left: 20px;
  font-size: 13px;
  color: #334155;
  display: grid;
  gap: 4px;
}

code {
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

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

.card-head h2 {
  font-size: 16px;
  font-weight: 700;
}

.list-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.field {
  margin-bottom: 14px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.field > .field-label {
  display: block;
  margin-bottom: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}

.field-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.req {
  color: #ef4444;
}

.input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea.input {
  resize: vertical;
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: 13px;
}

.input-sm {
  padding: 7px 10px;
  font-size: 13px;
}

.textarea-sm {
  font-size: 12px;
}

.input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

.batch-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.batch-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.advanced-details {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafbfe;
}

.advanced-details summary {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  user-select: none;
}

.advanced-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

.advanced-grid .field {
  margin-bottom: 0;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn-primary {
  flex: 1;
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary-bg);
  color: var(--secondary-text);
  border-color: #c7d2fe;
}

.btn-secondary:hover {
  background: #e0e7ff;
}

.btn-ghost {
  background: #fff;
  color: #475569;
  border-color: var(--border);
}

.btn-ghost:hover {
  background: #f8fafc;
  color: var(--text);
}

.btn-danger-text {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}

.btn-danger-text:hover {
  text-decoration: underline;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 6px;
}

.status-banner {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  word-break: break-all;
}

.status-success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
}

.status-warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
}

.status-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

.fallback-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.fallback-title {
  font-size: 13px;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 4px;
}

.fallback-desc {
  font-size: 12px;
  color: #78350f;
  margin-bottom: 8px;
}

.fallback-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.code-preview {
  background: #1e293b;
  color: #e2e8f0;
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: 11.5px;
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-bar .input {
  flex: 1;
  min-width: 180px;
}

.sync-filter {
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.cookie-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.cookie-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 12px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

.cookie-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

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

.cookie-table tr:hover td {
  background: #f8fafc;
}

.cell-domain {
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  color: #334155;
  max-width: 160px;
  word-break: break-all;
}

.cell-name {
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-weight: 600;
  font-size: 12.5px;
  color: #0f172a;
  max-width: 150px;
  word-break: break-all;
}

.cell-value {
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  color: #475569;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.cell-value:hover {
  color: var(--primary);
}

.col-actions {
  width: 108px;
  white-space: nowrap;
  text-align: right;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  font-size: 13px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.hidden {
  display: none !important;
}
