﻿:root {
  --bg-page: #f0f2f5;
  --bg-page-soft: #e4e7ec;
  --text-main: #1a1a2e;
  --text-muted: #6b7280;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --inner-card-bg: #f9fafb;
  --inner-card-border: #e5e7eb;
  --input-bg: #ffffff;
  --input-border: #d1d5db;
  --accent: #4f6ef7;
  --accent-strong: #3b5de7;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: radial-gradient(circle at top, var(--bg-page) 0%, var(--bg-page-soft) 100%);
  color: var(--text-main);
}
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}
section {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 24px;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s ease;
}
section:hover {
  box-shadow: var(--card-shadow-hover);
}
.embedded-section {
  margin-top: 0;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.section-heading h2,
.section-heading h3 {
  margin: 0;
}
.section-heading-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
textarea, pre, input, select {
  box-sizing: border-box;
  background: var(--input-bg);
  color: var(--text-main);
  border: 1px solid var(--input-border);
  border-radius: 8px;
}
textarea, pre {
  width: 100%;
  min-height: 260px;
  max-height: 520px;
  padding: 12px;
  overflow: auto;
}
#logs {
  min-height: 180px;
  max-height: 420px;
}
input, select {
  width: 100%;
  padding: 10px 12px;
}
input[type='checkbox'] {
  width: auto;
  transform: scale(1.15);
}
textarea.is-invalid {
  border-color: #de5b6d;
  box-shadow: 0 0 0 1px #de5b6d inset;
}
.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.actions-top {
  margin-bottom: 12px;
}
.actions-inline,
.actions-runtime {
  flex-wrap: wrap;
}
.kernel-control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.kernel-pickers {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.actions-inline {
  gap: 8px;
}
.kernel-pickers select,
.actions select {
  width: auto;
  min-width: 150px;
  max-width: 240px;
  flex: 0 1 auto;
}
.kernel-pickers #kernel-arch-select {
  min-width: 170px;
  max-width: 200px;
}
.kernel-pickers #kernel-version-select {
  min-width: 200px;
  max-width: 260px;
}
button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
button:hover {
  background: var(--accent-strong);
  box-shadow: 0 2px 8px rgba(79,110,247,0.3);
}
button:disabled {
  opacity: 0.65;
  cursor: wait;
  box-shadow: none;
}
.status-bar {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--inner-card-bg);
  color: var(--text-main);
}
.status-bar.is-loading {
  border-color: #7c8cff;
  background: #eef0ff;
  color: #3b4ad6;
}
.status-bar.is-success {
  border-color: #1fa971;
  background: #ecfdf5;
  color: #065f46;
}
.status-bar.is-error {
  border-color: #de5b6d;
  background: #fef2f2;
  color: #991b1b;
}
.status-bar.is-idle {
  border-color: var(--input-border);
  background: var(--inner-card-bg);
  color: var(--text-main);
}
.editor-status {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid var(--input-border);
  background: var(--inner-card-bg);
  color: var(--text-main);
}
.editor-status.is-saved {
  border-color: #1fa971;
  background: #ecfdf5;
  color: #065f46;
}
.editor-status.is-dirty {
  border-color: #d7a647;
  background: #fffbeb;
  color: #92400e;
}
.editor-status.is-invalid {
  border-color: #de5b6d;
  background: #fef2f2;
  color: #991b1b;
}
.view-switch,
.tab-bar {
  display: inline-flex;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  overflow: hidden;
}
.switch-button,
.tab-button {
  background: #f3f4f6;
  color: var(--text-main);
  border-radius: 0;
}
.switch-button.is-active,
.tab-button.is-active {
  background: var(--accent);
  color: #fff;
}
.config-view.is-hidden,
.info-view.is-hidden,
.tab-panel.is-hidden {
  display: none;
}
.config-view,
.info-view {
  overflow: hidden;
}
.tab-panel.is-active {
  display: block;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.form-grid-basic {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-grid-basic > label {
  min-width: 0;
}
.form-row-2 {
  grid-row: 2;
}
.form-row-3 {
  grid-row: 3;
}
.form-row-custom {
  grid-column: 1 / -1;
  grid-row: 4;
}
.checkbox-field {
  justify-content: center;
}
.checkbox-field input[type='checkbox'] {
  margin-top: 6px;
}
.field-with-action {
  grid-column: span 2;
}
.inline-field {
  display: flex;
  align-items: center;
  gap: 12px;
}
.inline-field input {
  flex: 1 1 auto;
}
.inline-field button {
  flex: 0 0 auto;
  white-space: nowrap;
}
.form-note {
  margin: 14px 0 0;
  color: var(--text-muted);
}
.is-hidden {
  display: none !important;
}
.socks-services-heading {
  margin-top: 18px;
}
.timeline .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.kv-item {
  padding: 14px;
  border: 1px solid var(--inner-card-border);
  border-radius: 10px;
  background: var(--inner-card-bg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.kv-item .key {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.kv-item .value {
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.timeline-wrap {
  margin-top: 16px;
}
.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.timeline-item {
  padding: 14px;
  border: 1px solid var(--inner-card-border);
  border-radius: 10px;
  background: var(--inner-card-bg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.timeline-item .time {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.timeline-item .title {
  font-weight: 600;
  margin-bottom: 4px;
}
.timeline-item .details {
  font-size: 13px;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}
.member-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.member-option,
.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--inner-card-border);
  border-radius: 10px;
  background: var(--inner-card-bg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.sub-url-label {
  grid-column: 1 / -1;
}

.sub-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-url-row.has-side-action {
  align-items: center;
}

.sub-url-input-wrap {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-width: 0;
}

.sub-url-input-wrap.is-expanded {
  width: 100%;
  flex: 1 1 auto;
}

.sub-url-input {
  width: 100%;
  max-width: none;
  padding-right: 40px;
}

.sub-url-input.is-expanded {
  width: 100%;
  max-width: none;
}

.sub-url-zoom {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e5e7eb;
  color: #4b5563;
}

.sub-url-zoom:hover {
  background: #d1d5db;
}

.sub-url-row > button {
  flex: 0 0 auto;
  white-space: nowrap;
}
.member-row select {
  flex: 1 1 auto;
}
.member-add {
  width: fit-content;
}
.member-remove {
  background: #ef4444;
}
.member-remove:hover {
  background: #dc2626;
}
.node-pill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.node-pill {
  padding: 12px 14px;
  border: 1px solid var(--inner-card-border);
  border-radius: 12px;
  background: var(--inner-card-bg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s ease;
}
.node-pill:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.node-pill-checkable {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.node-pill-main {
  min-width: 0;
  flex: 1 1 auto;
}
.node-pill-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
  word-break: break-word;
}
.node-pill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.node-pill-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #4b5563;
}
.node-pill-tag.is-source {
  border-color: #7e9a6d;
  background: #ecfdf5;
  color: #065f46;
}
.node-check-button,
.icon-button {
  min-width: 72px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #e5e7eb;
  color: var(--text-main);
}
.node-check-button:hover,
.icon-button:hover,
.sub-url-zoom:hover {
  cursor: not-allowed;
}
.node-check-button.is-loading {
  opacity: 0.8;
}
.split-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 24px;
}
.split-panel {
  min-width: 0;
}
.node-edit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 640px;
  overflow: auto;
  padding-right: 4px;
}
.node-edit-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.node-edit-card .node-pill {
  flex: 1 1 auto;
  min-width: 0;
}
.danger-icon-button {
  min-width: 44px;
  padding: 10px;
  background: #ef4444;
}
.danger-icon-button:hover {
  background: #dc2626;
}
.success-text-button {
  min-width: 64px;
  padding: 10px 12px;
  background: #10b981;
}
.success-text-button:hover {
  background: #059669;
}
.node-pill-title.is-disabled {
  text-decoration: line-through;
  opacity: 0.7;
}
.group-panel {
  padding: 14px;
}
.group-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.group-panel-body {
  margin-top: 12px;
}
.group-summary {
  margin-top: 8px;
}
.chain-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.chain-segment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.chain-arrow {
  font-size: 20px;
  color: #9ca3af;
  line-height: 1;
}
.group-toggle {
  background: var(--accent-strong);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(36, 28, 16, 0.38);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 1;
  visibility: visible;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-card {
  width: min(560px, calc(100vw - 32px));
  border-radius: 14px;
  border: 1px solid var(--inner-card-border);
  background: var(--inner-card-bg);
  padding: 20px;
  box-shadow: 0 20px 50px rgba(63, 43, 16, 0.24);
  transform: translateY(0) scale(1);
  opacity: 1;
  transition: transform 180ms ease, opacity 180ms ease;
}

.overlay.is-hidden .overlay-card {
  transform: translateY(10px) scale(0.98);
  opacity: 0;
}

.overlay-card h3 {
  margin: 0 0 12px;
}

.overlay-step {
  font-weight: 600;
  margin-bottom: 8px;
}

.overlay-progress {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.overlay-detail {
  min-height: 24px;
  color: #4f402c;
  margin-bottom: 14px;
}

.overlay-actions {
  display: flex;
  justify-content: center;
}

#cancel-socks-config {
  background: #c93b3b;
}

#auto-configure-socks {
  background: #3f8f4f;
}

#auto-configure-socks:hover {
  background: #347a42;
}
.group-toggle:hover {
  background: #2d4cd6;
}

#socks-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 900px) {
  .form-grid-basic {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-with-action {
    grid-column: span 1;
  }

  .inline-field,
  .kernel-control-row {
    flex-direction: column;
    align-items: stretch;
  }

  .kernel-pickers {
    flex-wrap: wrap;
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  #socks-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 14px;
  }

  .section-heading-actions {
    width: 100%;
  }

  .section-heading-actions button {
    width: 100%;
  }

  .kernel-pickers,
  .kernel-pickers select,
  .actions select {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .tab-bar,
  .view-switch {
    width: 100%;
    display: flex;
  }

  .tab-button,
  .switch-button {
    flex: 1 1 0;
  }

  .node-edit-card {
    align-items: stretch;
  }

  .node-edit-card > button {
    min-width: 52px;
  }

  .overlay-card {
    width: calc(100vw - 20px);
    padding: 16px;
  }

  .section-heading h1,
  .section-heading h2,
  .section-heading h3 {
    width: 100%;
  }

  .actions,
  .actions-top,
  .actions-inline,
  .actions-runtime {
    width: 100%;
  }

  .actions button,
  .actions-top button,
  .actions-inline button,
  .actions-runtime button {
    width: 100%;
  }

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

  .member-row {
    flex-direction: column;
    align-items: stretch;
  }

  .member-row button,
  .member-add,
  .member-remove {
    width: 100%;
  }

  .node-pill-checkable {
    flex-direction: column;
    align-items: stretch;
  }

  .node-check-button {
    width: 100%;
  }

  .timeline-item {
    padding: 10px;
  }

  .sub-url-row {
    flex-direction: column;
    align-items: stretch;
  }

  .sub-url-input-wrap,
  .sub-url-input-wrap.is-expanded {
    width: 100%;
    flex: 1 1 auto;
  }

  .sub-url-input,
  .sub-url-input.is-expanded {
    flex: 1 1 auto;
    max-width: none;
  }

  .sub-url-row button {
    width: 100%;
  }

  .form-grid-basic {
    grid-template-columns: 1fr;
  }

  .form-row-2,
  .form-row-3,
  .form-row-custom {
    grid-row: auto;
  }
}
