@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #0c1f1e;
  --bg-2: #102827;
  --panel: #132f2d;
  --panel-2: #153838;
  --border: #24524f;
  --text: #eef5f3;
  --muted: #b4c7c3;
  --accent: #f4b860;
  --accent-2: #59c2a2;
  --danger: #e5706b;
  --shadow: rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 80% -10%, rgba(244, 184, 96, 0.12), transparent 60%),
    radial-gradient(800px 500px at 10% 20%, rgba(89, 194, 162, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  min-height: 100vh;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-page {
  width: min(520px, 92vw);
  padding: 32px;
}

.login-card {
  width: 100%;
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

header {
  padding: 32px 48px 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

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

.brand {
  font-size: 28px;
  letter-spacing: 1px;
  font-weight: 600;
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
}

main {
  padding: 0 48px 48px;
}

.view.hidden {
  display: none;
}

/* Search and Filters */
.controls {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 250px;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding-right: 36px;
}

.btn.icon.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%) !important;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 12px;
  opacity: 0.6;
  box-shadow: none !important;
}

.btn.icon.search-clear:hover {
  opacity: 1;
}

.btn.icon.search-clear i {
  font-size: 12px;
}

.filter-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-select {
  min-width: 120px;
  padding: 8px 12px;
  font-size: 13px;
}

.date-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.date-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.date-input {
  min-width: 140px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 24px;
}

.panel {
  background: linear-gradient(180deg, rgba(19, 47, 45, 0.98), rgba(19, 47, 45, 0.9));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 40px var(--shadow);
  animation: fadeUp 0.6s ease both;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input, select, textarea {
  background: #0f2625;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

textarea {
  min-height: 64px;
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 12px;
}

.add-tabs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 38, 37, 0.7);
  margin: 8px 0 16px;
}

.add-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.add-tab:hover {
  transform: translateY(-1px);
}

.add-tab.active {
  background: var(--accent);
  color: #1b1b1b;
}

.add-panel.hidden {
  display: none;
}

.bulk-input {
  min-height: 160px;
}

.bulk-help {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(15, 38, 37, 0.5);
  color: var(--muted);
  font-size: 12px;
  display: grid;
  gap: 6px;
}

.bulk-help-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}

.bulk-help code {
  display: inline-flex;
  background: rgba(9, 19, 18, 0.8);
  border-radius: 8px;
  padding: 4px 8px;
  color: var(--text);
  font-size: 12px;
  width: fit-content;
}

.bulk-results {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(15, 38, 37, 0.6);
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.bulk-results.hidden {
  display: none;
}

.bulk-result {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bulk-result-line {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.bulk-result-message {
  flex: 1;
}

.bulk-status {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}

.bulk-status.success {
  color: #7fe3a2;
}

.bulk-status.error {
  color: #ff9b9b;
}

.bulk-status.info {
  color: #94d8ff;
}

.btn {
  background: var(--accent);
  color: #1b1b1b;
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 16px;
  line-height: 1;
  position: relative;
}

.btn.icon i {
  display: inline-flex;
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
}

.btn-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #1b1b1b;
  font-size: 11px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.btn-badge.show {
  display: flex;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(244, 184, 96, 0.3);
}

.btn.is-loading {
  pointer-events: none;
  opacity: 0.75;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.is-loading .spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn.danger {
  background: var(--danger);
  color: #160c0c;
}

.btn.danger:hover {
  background: #d45a55;
}

.btn.danger:disabled {
  background: rgba(229, 112, 107, 0.4);
  color: rgba(22, 12, 12, 0.6);
}

.btn.ghost.danger-text {
  color: var(--danger);
  border-color: var(--danger);
  opacity: 0.7;
}

.btn.ghost.danger-text:hover {
  opacity: 1;
  background: rgba(229, 112, 107, 0.1);
}

.btn.ghost.active {
  background: rgba(0, 255, 170, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.table-wrap {
  position: relative;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  overflow-x: auto;
  box-shadow: 0 20px 40px var(--shadow);
}

.table-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 20, 0.65);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  z-index: 2;
  text-align: center;
  padding: 24px;
  border-radius: inherit;
}

.table-overlay.hidden {
  display: none;
}

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

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(244, 184, 96, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(36, 82, 79, 0.6);
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: var(--panel-2);
  position: sticky;
  top: 0;
  z-index: 1;
}

#servers-view table {
  min-width: 1660px;
  table-layout: fixed;
}

#servers-view th,
#servers-view td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#servers-view th:nth-child(1),
#servers-view td:nth-child(1) {
  width: 44px;
}

#servers-view th:nth-child(2),
#servers-view td:nth-child(2) {
  width: 140px;
}

#servers-view th:nth-child(3),
#servers-view td:nth-child(3) {
  width: 110px;
}

#servers-view th:nth-child(4),
#servers-view td:nth-child(4) {
  width: 140px;
}

#servers-view th:nth-child(5),
#servers-view td:nth-child(5) {
  width: 120px;
}

#servers-view th:nth-child(6),
#servers-view td:nth-child(6) {
  width: 120px;
}

#servers-view th:nth-child(7),
#servers-view td:nth-child(7) {
  width: 120px;
}

#servers-view th:nth-child(8),
#servers-view td:nth-child(8) {
  width: 220px;
}

#servers-view th:nth-child(9),
#servers-view td:nth-child(9) {
  width: 170px;
}

#servers-view th:nth-child(10),
#servers-view td:nth-child(10) {
  width: 110px;
}

#servers-view th:nth-child(11),
#servers-view td:nth-child(11) {
  width: 360px;
}

#servers-view td.actions {
  overflow: visible;
}

#servers-view td:nth-child(9) {
  white-space: normal;
}

#servers-view td:nth-child(9) .status {
  white-space: nowrap;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.logs-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.logs-pagination {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.logs-page {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.log-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.log-status.success {
  color: var(--accent-2);
}

.log-status.error {
  color: var(--danger);
}

.log-status.info {
  color: var(--accent);
}

.log-message {
  display: grid;
  gap: 6px;
}

.log-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(15, 38, 37, 0.6);
  border: 1px solid rgba(36, 82, 79, 0.6);
  border-radius: 8px;
  padding: 6px 8px;
}

.status {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
}

.status.ok {
  color: #0d1b1a;
  background: var(--accent-2);
  border-color: transparent;
}

.status.bad {
  color: #160c0c;
  background: var(--danger);
  border-color: transparent;
}

.status.installing {
  color: #1a1309;
  background: var(--accent);
  border-color: transparent;
  animation: pulse 2s ease-in-out infinite;
}

.vpn-dual-pill {
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Два VPN установлены */
.vpn-dual-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vpn-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  white-space: nowrap;
}

/* Configs cell */
.configs-cell {
  text-align: center;
}

.configs-count {
  font-weight: 600;
  font-size: 14px;
  display: block;
}

.configs-detail {
  font-size: 10px;
  color: var(--muted);
  display: block;
  white-space: nowrap;
}

/* Прогресс установки */
.vpn-installing-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px 8px;
  width: 100%;
  border-radius: 12px;
  background: rgba(15, 38, 37, 0.6);
}

.vpn-installing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.vpn-installing-wrap .status {
  flex-shrink: 0;
}

.vpn-progress {
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.vpn-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.vpn-installing-stage {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vpn-installing-pct {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  min-width: 3ch;
  text-align: right;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 12, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal.show {
  display: flex;
}

.modal-card {
  width: min(520px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 30px 50px var(--shadow);
  animation: pop 0.2s ease;
}

.modal-card.wide {
  width: min(820px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-card.modal-lg {
  width: min(720px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-card h3 {
  margin-top: 0;
}

.share-link-note {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
}

.configs {
  display: grid;
  gap: 12px;
}

.config-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0f2625;
}

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

.config-info {
  flex: 1;
  min-width: 0;
}

.inline-loader {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0;
}

.config-name {
  font-weight: 600;
}

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

.config-pass-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

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

.config-pass {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  background: rgba(0, 255, 170, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
}

.btn.icon.copy-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 12px;
}

.btn.icon.copy-btn i {
  font-size: 12px;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #0f2625;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 20px 30px var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  border-color: var(--accent-2);
}

.toast.error {
  border-color: var(--danger);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.share-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.share-card {
  width: min(520px, 92vw);
}

.share-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}

.share-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.share-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.share-slider-wrap {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.share-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #0f2625;
  border: 1px solid var(--border);
  outline: none;
}

.share-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0f2625;
  box-shadow: 0 6px 16px var(--shadow);
  cursor: pointer;
}

.share-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0f2625;
  box-shadow: 0 6px 16px var(--shadow);
  cursor: pointer;
}

.share-slider::-moz-range-track {
  background: #0f2625;
  border: 1px solid var(--border);
  height: 12px;
  border-radius: 999px;
}

.share-slider-progress {
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.share-slider-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent-2);
  transition: width 0.2s ease;
}

.share-status {
  color: var(--muted);
  font-size: 13px;
}

.share-status.success {
  color: var(--accent-2);
}

.share-status.error {
  color: var(--danger);
}

.share-details {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
}

.share-details.hidden {
  display: none;
}

.share-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.share-detail-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.share-detail-value {
  text-align: right;
  font-size: 13px;
  word-break: break-word;
}

@media (max-width: 960px) {
  header, main {
    padding: 24px;
  }

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

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Settings Layout */
.settings-stack {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.settings-section {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: rgba(15, 38, 37, 0.6);
}

.settings-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
}

.settings-section .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.settings-section .form-actions {
  grid-column: 1 / -1;
}

.custom-dns-row.hidden {
  display: none;
}

/* Info Modal Grid */
.info-grid {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.info-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.info-value {
  color: var(--text);
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
}

/* Error modal styles */
.error-content {
  margin: 16px 0;
}

.error-summary pre {
  background: rgba(229, 112, 107, 0.15);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 150px;
  overflow-y: auto;
  margin: 8px 0;
}

.error-details {
  margin-top: 16px;
}

.error-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
}

.error-details summary:hover {
  color: var(--text);
}

.error-full-output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 8px;
}

.text-danger {
  color: var(--danger);
}

.status.clickable {
  cursor: pointer;
}

.status.clickable:hover {
  opacity: 0.8;
  text-decoration: underline;
}
