:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --border: #dfe4ee;
  --text: #1b2432;
  --muted: #5d6a7e;
  --primary: #1877f2;
  --primary-hover: #1464cc;
  --accent: #7c3aed;
  --accent-hover: #6728d4;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(17, 24, 39, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}

.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-icon {
  font-size: 28px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.container {
  max-width: 1360px;
  margin: 20px auto;
  padding: 0 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

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

.card-header h2 {
  margin: 0;
}

.create-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 170px;
}

.input-group.grow {
  flex: 1;
  min-width: 260px;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="url"],
input[type="search"],
input[type="date"],
select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid rgba(24, 119, 242, 0.25);
  border-color: var(--primary);
}

.btn {
  height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, transform 0.05s ease;
}

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

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

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-lg {
  height: 42px;
  padding: 0 22px;
  font-size: 15px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: #eef2f8;
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: #e2e8f3;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  background: #f1f4f9;
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.layout-grid {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 18px;
  align-items: start;
}

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

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.post-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.post-item:hover {
  background: #f8faff;
}

.post-item.active {
  border-color: var(--primary);
  background: #eef5ff;
}

.post-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.post-item-title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.delete-post-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 5px;
  border-radius: 4px;
}
.delete-post-btn:hover {
  color: var(--danger);
  background: #fee2e2;
}

.main-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#post-workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hidden {
  display: none !important;
}

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

.empty-msg {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 16px;
}

.status-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.status-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e5e7eb;
  color: #374151;
}

.badge-running { background: #dbeafe; color: #1d4ed8; }
.badge-waiting_login { background: #fef3c7; color: #b45309; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-paused_error { background: #fee2e2; color: #b91c1c; }
.badge-stopped { background: #f3f4f6; color: #4b5563; }

.count-pill {
  font-size: 13px;
  color: var(--muted);
}

.post-title {
  margin: 0 0 2px;
  font-size: 17px;
}

.post-url {
  font-size: 12px;
  color: var(--primary);
  word-break: break-all;
}

.status-buttons {
  display: flex;
  gap: 8px;
}

.alert {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.logs-box {
  margin-top: 12px;
  font-size: 13px;
}

.logs-box summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}

.logs-pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  font-size: 12px;
  max-height: 170px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.draw-card {
  border-color: #d8ccf8;
  background: linear-gradient(180deg, #ffffff 0%, #faf8ff 100%);
}

.eligible-badge {
  font-size: 13px;
  color: var(--accent);
  background: #f3e8ff;
  padding: 4px 10px;
  border-radius: 999px;
}

.draw-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.winner-stage {
  margin-top: 16px;
  padding: 18px;
  border-radius: 12px;
  background: #ffffff;
  border: 2px solid var(--accent);
  text-align: center;
}

.winner-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.winner-name {
  font-size: 26px;
  font-weight: 800;
  margin: 6px 0 4px;
  color: var(--text);
}

.winner-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.winner-comment {
  margin: 0 auto;
  max-width: 640px;
  padding: 10px 14px;
  background: #f8fafc;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 14px;
  text-align: left;
  white-space: pre-wrap;
}

.draw-history-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--muted);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 14px;
  cursor: pointer;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.comments-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.comments-table th,
.comments-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.comments-table th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--muted);
  font-size: 12px;
}

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

.comments-table tr:hover td {
  background: #f9fbff;
}

.author-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.author-link:hover {
  text-decoration: underline;
}

.date-cell {
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.comment-cell {
  white-space: pre-wrap;
  max-width: 520px;
}

mark {
  background: #fef08a;
  padding: 0 2px;
  border-radius: 3px;
}

.excluded-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 12px;
  font-weight: 600;
}

.chip button {
  background: none;
  border: none;
  color: #991b1b;
  cursor: pointer;
  font-weight: 700;
  padding: 0 2px;
}

.author-cell-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.exclude-inline-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  font-size: 11px;
  padding: 2px 7px;
  cursor: pointer;
  white-space: nowrap;
}

.exclude-inline-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #fef2f2;
}
