:root {
  --bg-dark: #0f0c1b;
  --bg-card: rgba(26, 22, 45, 0.7);
  --bg-card-hover: rgba(35, 30, 60, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(230, 0, 35, 0.4);

  --primary-red: #e60023;
  --primary-red-hover: #ff1a3d;
  --primary-red-glow: rgba(230, 0, 35, 0.35);

  --telegram-blue: #0088cc;
  --telegram-blue-hover: #0099e6;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-amber: #f59e0b;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-title: 'Outfit', sans-serif;
  --font-code: 'Consolas', 'Monaco', monospace;
}

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

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(230, 0, 35, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(0, 136, 204, 0.12) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-main);
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px;
}

.hidden {
  display: none !important;
}

/* Login Screen Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 27, 0.85);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.login-card h2 {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 700;
}

.login-card h2 span {
  color: var(--primary-red);
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: -8px;
  margin-bottom: 8px;
}

.login-card form {
  width: 100%;
  text-align: left;
}

.brand-icon.lg {
  width: 60px;
  height: 60px;
  border-radius: 16px;
}

/* Container */
.app-wrapper {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-red), #990017);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 20px var(--primary-red-glow);
}

.brand-text h1 {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.brand-text h1 span {
  color: var(--primary-red);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  background: rgba(255, 255, 255, 0.05);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Layout */
.main-content {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
}

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

.sidebar-column, .feed-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

.card-header.border-bottom {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.card-header h2, .card-header h3 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
}

.title-with-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  background: var(--primary-red);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--primary-red);
  box-shadow: 0 0 10px rgba(230, 0, 35, 0.2);
}

.code-font {
  font-family: var(--font-code);
  font-size: 0.82rem;
}

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

.form-row .half {
  flex: 1;
}

.help-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
  display: block;
}

.help-text a {
  color: var(--telegram-blue);
  text-decoration: none;
}

.input-with-action {
  position: relative;
}

.btn-icon {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

/* Buttons */
.btn {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--telegram-blue), #006699);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 136, 204, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--telegram-blue-hover), #0077b3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--primary-red), #b3001b);
  color: white;
  box-shadow: 0 4px 15px var(--primary-red-glow);
}

.btn-secondary:hover {
  background: linear-gradient(135deg, var(--primary-red-hover), #cc001f);
  transform: translateY(-1px);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary-red);
}

.btn-full {
  width: 100%;
}

.button-group {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.flex-1 {
  flex: 1;
}

.btn-icon-text {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.btn-icon-text:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-link:hover {
  color: var(--text-muted);
}

/* Targets List */
.targets-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  max-height: 240px;
  overflow-y: auto;
}

.target-item {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.target-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.target-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.target-url {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.target-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-delete-target {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 4px;
  font-size: 0.9rem;
}

/* Feed Tabs */
.feed-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--primary-red);
  color: white;
}

/* Pins Grid */
.pins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  min-height: 300px;
  max-height: 650px;
  overflow-y: auto;
  padding-right: 4px;
}

.pin-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, border-color 0.2s;
}

.pin-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.2);
}

.pin-media {
  position: relative;
  width: 100%;
  height: 200px;
  background: #000;
  overflow: hidden;
}

.pin-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.pin-card:hover .pin-media img {
  transform: scale(1.05);
}

.status-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.status-badge.sent {
  background: rgba(16, 185, 129, 0.85);
  color: white;
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.85);
  color: white;
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.85);
  color: white;
}

.pin-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  gap: 10px;
}

.pin-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pin-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.pin-source-link {
  font-size: 0.75rem;
  color: var(--telegram-blue);
  text-decoration: none;
}

.pin-source-link:hover {
  text-decoration: underline;
}

.btn-send-pin {
  padding: 4px 10px;
  font-size: 0.75rem;
}

/* Console Logs */
.console-card {
  padding: 14px 20px;
}

.console-title {
  font-size: 0.95rem !important;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-green);
}

.logs-container {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-code);
  font-size: 0.78rem;
  height: 130px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-line {
  color: var(--text-muted);
  word-break: break-all;
}

.log-line.success { color: var(--accent-green); }
.log-line.warn { color: var(--accent-amber); }
.log-line.error { color: #ef4444; }

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 30px;
  grid-column: 1 / -1;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
}

.toast {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-red);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.3s ease;
}

.toast.success { border-left-color: var(--accent-green); }
.toast.error { border-left-color: #ef4444; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
