:root {
  --bg: #f5efe6;
  --surface: #fffaf3;
  --ink: #1f2937;
  --muted: #6b7280;
  --brand: #0f766e;
  --brand-soft: #99f6e4;
  --accent: #b45309;
  --danger: #b91c1c;
  --border: #e7dbc9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: linear-gradient(145deg, #f8f4ec, #eef6f4);
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.35;
  z-index: -1;
}

.bg-a {
  width: 340px;
  height: 340px;
  background: #5eead4;
  top: -120px;
  right: -80px;
}

.bg-b {
  width: 360px;
  height: 360px;
  background: #fdba74;
  bottom: -130px;
  left: -100px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 250, 243, 0.84);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.layout {
  max-width: 1280px;
  margin: 20px auto;
  padding: 0 16px 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 14px 28px rgba(31, 41, 55, 0.08);
}

.login-card {
  max-width: 420px;
  margin: 52px auto;
}

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

label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 11px;
  background: white;
}

button {
  cursor: pointer;
}

.btn {
  border: 1px solid var(--border);
  background: white;
  padding: 9px 12px;
  border-radius: 10px;
}

.btn:hover {
  border-color: #c9b79f;
}

.btn-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.btn-primary:hover {
  background: #0c645d;
}

.btn-ghost {
  background: transparent;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tab {
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 12px;
  border-radius: 999px;
}

.tab.active {
  background: var(--brand-soft);
  border-color: #74d6c6;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.grid-2 {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.grid-form {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-form button,
.grid-form input:last-child {
  grid-column: span 2;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

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

.dashboard-title h2 {
  margin: 0;
  font-size: 1.2rem;
}

.dashboard-title .hint {
  margin: 2px 0 0;
}

.refresh-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.refresh-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.refresh-control select {
  width: auto;
  padding: 6px 10px;
  border-radius: 8px;
}

.health-bar {
  margin-bottom: 12px;
}

.health-bar h3 {
  margin: 0 0 10px;
}

.auto-ingest-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.auto-ingest-toggle-row strong {
  font-size: 0.95rem;
}

.auto-ingest-toggle-row .hint {
  margin-top: 2px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: 0.25s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.25s;
}

.switch input:checked + .slider {
  background: var(--brand);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.system-status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.88rem;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator.ok {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.status-indicator.warn {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.status-indicator.error {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.status-item .status-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.status-item .status-value {
  font-weight: 600;
  font-size: 0.88rem;
}

.status-item .status-value.error-text {
  color: var(--danger);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: white;
  padding: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  border-left: 4px solid var(--brand);
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(31, 41, 55, 0.1);
}

.stat.stat-pending {
  border-left-color: #f59e0b;
}

.stat.stat-scheduled {
  border-left-color: #3b82f6;
}

.stat.stat-today {
  border-left-color: #22c55e;
}

.stat.stat-failed {
  border-left-color: #ef4444;
}

.stat.stat-tomorrow {
  border-left-color: #8b5cf6;
}

.stat.stat-total {
  border-left-color: #6b7280;
}

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

.stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 6px;
}

.stat .sub {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

.dashboard-grid {
  margin-bottom: 12px;
}

.dashboard-grid .card {
  min-height: 0;
}

.next-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.next-item:last-child {
  border-bottom: none;
}

.next-item .time {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  min-width: 52px;
}

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

.next-item .info .title {
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.next-item .info .meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.site-mini-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  padding: 10px;
  margin-bottom: 8px;
}

.site-mini-card:last-child {
  margin-bottom: 0;
}

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

.site-mini-card .site-header h4 {
  margin: 0;
  font-size: 0.95rem;
}

.site-mini-card .site-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.site-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  border: 1px solid var(--border);
  background: #fff;
}

.site-count.pending {
  border-color: #fcd34d;
  color: #92400e;
}

.site-count.scheduled {
  border-color: #93c5fd;
  color: #1e40af;
}

.site-count.posted {
  border-color: #86efac;
  color: #14532d;
}

.site-count.failed {
  border-color: #fca5a5;
  color: #7f1d1d;
}

.site-mini-card .site-last {
  color: var(--muted);
  font-size: 0.78rem;
}

.site-bindings-box {
  margin-top: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fefbf5;
}

.site-bindings-title {
  margin: 0 0 6px;
  font-size: 0.85rem;
}

.binding-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.binding-badge {
  background: var(--brand-soft);
  border-color: #74d6c6;
  font-weight: 600;
}

.add-binding-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.add-binding-row select,
.add-binding-row input {
  flex: 1;
  min-width: 140px;
  padding: 7px 9px;
  border-radius: 8px;
}

.add-binding-row .btn {
  white-space: nowrap;
  padding: 7px 10px;
  font-size: 0.85rem;
}

.template-toggle-list {
  display: grid;
  gap: 6px;
}

.template-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  padding: 8px 10px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
  margin: 0;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 0.78rem;
  border-radius: 8px;
}

.rotation-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.rotation-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
  margin: 0;
}

.activity-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 110px;
  padding-top: 10px;
}

.activity-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.activity-bar {
  flex: 1;
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--brand-soft);
  min-height: 2px;
  transition: background 0.2s;
}

.activity-bar.has-error {
  background: linear-gradient(to top, #ef4444 0%, var(--brand-soft) 100%);
}

.activity-bar-total {
  background: #ef4444;
  border-radius: 999px;
  font-size: 0.7rem;
  color: white;
  padding: 1px 5px;
  line-height: 1.3;
}

.activity-chart-label {
  font-size: 0.7rem;
  color: var(--muted);
  transform: rotate(-60deg);
  transform-origin: top left;
  white-space: nowrap;
  position: absolute;
  bottom: 0;
  left: -4px;
}

.activity-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-posted {
  background: var(--brand);
}

.dot-error {
  background: #ef4444;
}

.action-result {
  margin-top: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  min-height: 40px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.action-result.success {
  border-color: #86efac;
  background: #f0fdf4;
  color: #14532d;
}

.action-result.error {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #7f1d1d;
}

.action-result .detail {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: pre-wrap;
}

.job-search {
  margin: 8px 0 10px;
}

.list {
  display: grid;
  gap: 8px;
}

.item {
  border: 1px solid var(--border);
  background: white;
  border-radius: 12px;
  padding: 10px;
}

.item h4 {
  margin: 0 0 5px;
}

.item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.item .actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.inline-fields {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
}

.inline-fields.compact {
  grid-template-columns: 1fr;
}

.inline-fields label {
  font-size: 0.82rem;
  color: var(--muted);
}

.inline-fields input {
  margin-top: 4px;
}

.preview-box {
  margin-top: 8px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 220px 1fr;
  align-items: start;
}

.preview-image {
  width: 100%;
  max-width: 220px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.item .danger {
  border-color: #ef9a9a;
  color: var(--danger);
}

.hint {
  color: var(--muted);
  font-size: 0.86rem;
}

.hidden {
  display: none;
}

.actions-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
}

.filter-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.filter-btn.active {
  background: var(--brand-soft);
  border-color: #74d6c6;
}

.result {
  margin-top: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  min-height: 120px;
  white-space: pre-wrap;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  background: #fff;
}

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

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

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

  .grid-form button,
  .grid-form input:last-child {
    grid-column: auto;
  }

  .inline-fields {
    grid-template-columns: 1fr;
  }

  .preview-box {
    grid-template-columns: 1fr;
  }

  .preview-image {
    max-width: 100%;
  }
}
