:root {
  --ink: #172026;
  --muted: #64727c;
  --line: #dce3e7;
  --soft-line: #edf1f3;
  --page: #f6f8f9;
  --surface: #ffffff;
  --sidebar: #0d1720;
  --sidebar-2: #132331;
  --teal: #008d84;
  --teal-2: #00a99d;
  --green: #1b8f4d;
  --amber: #b87600;
  --red: #c43d3d;
  --shadow: 0 10px 30px rgba(21, 36, 44, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  min-width: 320px;
  overflow-x: hidden;
}

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

button,
.button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

button:hover,
.button:hover {
  border-color: #b8c5ca;
}

button svg,
.button svg,
.nav-item svg,
.brand-mark svg,
.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

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

.primary:hover {
  background: #007c74;
  border-color: #007c74;
}

.ghost {
  margin-left: auto;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: radial-gradient(circle at 20% 0%, #183246 0%, var(--sidebar) 34%, #091119 100%);
  color: white;
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  font-size: 17px;
  font-weight: 760;
}

.brand-mark {
  width: 32px;
  height: 32px;
  color: var(--teal-2);
  display: grid;
  place-items: center;
}

.brand-mark svg {
  width: 32px;
  height: 32px;
  stroke-width: 1.8;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.09);
  color: #6ff4ea;
}

.usage-panel {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.usage-panel strong,
.usage-panel span {
  display: block;
}

.usage-panel strong {
  font-size: 13px;
}

.usage-panel span {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.68);
}

.account-dot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 18px 18px;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(82px, 1fr));
  gap: 8px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 90px;
}

.metric span,
.queue-stats span,
label span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 650;
}

.metric strong,
.queue-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 1;
}

.warning strong {
  color: var(--amber);
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(390px, 1.1fr) minmax(350px, 1fr);
  gap: 14px;
  min-width: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.campaign-panel,
.queue-panel,
.log-panel {
  padding: 18px;
}

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

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

.campaign-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.tab-button {
  min-height: 36px;
  background: #f4f7f8;
  color: #46545d;
}

.tab-button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.campaign-pane[hidden] {
  display: none;
}

.forever-intro {
  display: grid;
  gap: 4px;
  border: 1px solid #a6dcd8;
  background: #eefafa;
  border-radius: 6px;
  padding: 11px 12px;
  margin-bottom: 14px;
}

.forever-intro strong,
.forever-export-head strong {
  font-size: 13px;
}

.forever-intro span,
.forever-export-head span,
.forever-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.status-pill {
  border-radius: 999px;
  min-height: 26px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  color: #075f38;
  border: 1px solid #b9dec9;
  background: #edf9f1;
  font-size: 12px;
  font-weight: 750;
  text-transform: capitalize;
}

.status-pill.paused {
  color: #7a4b00;
  border-color: #f1d99c;
  background: #fff8e8;
}

.status-pill.stopped,
.status-pill.idle {
  color: #52616a;
  border-color: var(--line);
  background: #f4f6f7;
}

label {
  display: block;
  margin-bottom: 14px;
}

textarea,
select,
input {
  width: 100%;
  border: 1px solid #cfd9de;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
  font-size: 13px;
}

textarea {
  margin-top: 7px;
  min-height: 116px;
  resize: vertical;
  padding: 10px;
  line-height: 1.45;
}

input,
select {
  margin-top: 7px;
  height: 38px;
  padding: 0 10px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 141, 132, 0.12);
}

.field-row {
  display: grid;
  grid-template-columns: 1.4fr 0.65fr 0.65fr 0.75fr;
  gap: 12px;
  align-items: end;
}

.forever-fields {
  grid-template-columns: 1.25fr 1fr 0.45fr 1fr;
}

.forever-settings {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.forever-timers {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
}

.folder-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.folder-row label {
  margin-bottom: 0;
}

.forever-options {
  grid-template-columns: minmax(0, 1fr) 210px;
  align-items: center;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.button-row button,
.button-row .button {
  flex: 0 1 auto;
}

.toggle-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 14px;
}

.check-control {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbfcfc;
}

.check-control input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.check-control span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.export-template {
  width: 136px;
  margin: 0;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.progress-wrap {
  margin-top: 4px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.progress-track {
  height: 9px;
  border-radius: 999px;
  background: #e7ecef;
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal-2));
  transition: width 180ms ease;
}

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

.queue-stats div {
  border-left: 1px solid var(--line);
  padding-left: 12px;
}

.queue-stats div:first-child {
  border-left: 0;
  padding-left: 0;
}

.current-item {
  border: 1px solid #a6dcd8;
  background: #eefafa;
  border-radius: 6px;
  padding: 11px 12px;
  font-size: 13px;
  min-height: 42px;
}

.queue-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 202px;
  overflow: auto;
  padding-right: 4px;
}

.queue-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(120px, 1fr) 90px 80px;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--soft-line);
  padding-bottom: 8px;
  font-size: 13px;
}

.queue-row span {
  color: var(--muted);
}

.forever-list,
.forever-export-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.forever-tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
  margin-top: 14px;
}

.forever-tool-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  min-width: 0;
}

.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.mini-head strong {
  font-size: 14px;
}

.mini-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-head span.running {
  color: var(--green);
}

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

.mini-metrics div {
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  padding: 8px;
}

.mini-metrics span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.mini-metrics strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.forever-job-list {
  display: grid;
  gap: 8px;
  max-height: 184px;
  overflow: auto;
  padding-right: 4px;
}

.forever-job-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 78px;
  gap: 8px;
  align-items: start;
  border-bottom: 1px solid var(--soft-line);
  padding-bottom: 8px;
}

.forever-job-row div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.forever-job-row strong {
  font-size: 13px;
}

.forever-job-row span:not(.status-pill),
.forever-job-row time,
.forever-job-row em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.forever-job-row em {
  color: var(--red);
}

.forever-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
}

.forever-card-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.forever-card-main div {
  display: grid;
  gap: 4px;
}

.forever-card-main strong,
.forever-export-row strong {
  font-size: 14px;
}

.forever-card-main span:not(.status-pill),
.forever-export-row span {
  color: var(--muted);
  font-size: 12px;
}

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

.forever-card-stats div {
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #fff;
  padding: 8px;
}

.forever-card-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.forever-card-stats strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.forever-meta {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
  word-break: break-word;
}

.forever-actions {
  flex-wrap: wrap;
}

.forever-export-head {
  display: grid;
  gap: 3px;
  margin-top: 18px;
}

.forever-export-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--soft-line);
  padding-top: 10px;
}

.forever-export-row > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.diagnostics-panel .panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px 18px;
}

.diagnostic-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
  min-width: 0;
}

.diagnostic-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

.diagnostic-card strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.diagnostic-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.table-panel {
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar h2 {
  margin-bottom: 4px;
}

.table-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  min-width: 420px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.7fr 0.8fr 1.1fr;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.filter-grid label {
  margin: 0;
}

.filter-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 5px;
}

.filter-grid input,
.filter-grid select {
  margin: 0;
}

.table-scroll {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  padding: 11px 14px;
  font-size: 13px;
  vertical-align: middle;
}

th {
  background: #fbfcfc;
  color: #43515a;
  font-size: 12px;
  font-weight: 760;
}

td a {
  color: var(--teal);
  font-weight: 650;
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}

.status-select {
  min-width: 132px;
  height: 32px;
  margin: 0;
  font-size: 12px;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  height: 92px;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--soft-line);
}

.table-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.table-pagination > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.page-size {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.page-size select {
  width: 86px;
  margin: 0;
}

.log-panel {
  box-shadow: none;
}

.export-guide {
  padding: 18px;
  box-shadow: none;
}

.export-guide h2 {
  margin: 0;
}

.export-guide p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.export-guide ol {
  margin: 14px 0 0;
  padding-left: 22px;
  columns: 2;
  column-gap: 34px;
}

.export-guide li {
  break-inside: avoid;
  margin: 0 0 8px;
  color: #26343c;
  font-size: 13px;
  line-height: 1.45;
}

.export-guide .guide-note {
  margin-top: 8px;
  color: var(--teal);
  font-weight: 700;
}

.activity-log {
  display: grid;
  gap: 8px;
  max-height: 190px;
  overflow: auto;
}

.log-row {
  display: grid;
  grid-template-columns: 150px 70px 1fr;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--soft-line);
  font-size: 12px;
}

.log-row span {
  color: var(--muted);
}

.log-row strong {
  text-transform: uppercase;
  font-size: 11px;
  color: var(--teal);
}

.log-row.error strong {
  color: var(--red);
}

.log-row.warn strong {
  color: var(--amber);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #12202a;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 13px;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(9, 17, 25, 0.42);
}

.modal-backdrop.open {
  display: grid;
}

.modal {
  width: min(620px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(10, 22, 30, 0.22);
  padding: 20px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.modal h2 {
  margin: 0;
  font-size: 20px;
}

.modal p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.modal ol {
  margin: 16px 0 0;
  padding-left: 22px;
}

.modal li {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.45;
}

.modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.folder-modal {
  width: min(720px, 100%);
}

.folder-path-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 12px 0;
}

.folder-path-row input {
  margin: 0;
}

.folder-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.folder-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 360px;
  overflow: auto;
  background: #fbfcfc;
}

.folder-item {
  width: 100%;
  min-height: 38px;
  justify-content: flex-start;
  border: 0;
  border-bottom: 1px solid var(--soft-line);
  border-radius: 0;
  background: transparent;
}

.folder-item:last-child {
  border-bottom: 0;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 80px minmax(0, 1fr);
  }

  .brand span:last-child,
  .nav-item {
    font-size: 0;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .nav-item svg {
    width: 20px;
    height: 20px;
  }

  .usage-panel {
    display: none;
  }

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

  .diagnostics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    min-height: auto;
    padding: 10px;
    flex-direction: row;
    align-items: center;
  }

  .brand {
    padding: 0;
  }

  .nav-list {
    flex-direction: row;
    overflow: auto;
    margin-left: auto;
  }

  .nav-item {
    width: 42px;
    min-width: 42px;
  }

  .workspace {
    padding: 0 10px 12px;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 0;
  }

  .metric-row,
  .queue-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .field-row {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .forever-fields,
  .forever-settings,
  .forever-timers,
  .forever-tool-grid,
  .diagnostics-grid,
  .folder-row,
  .forever-options {
    grid-template-columns: 1fr;
  }

  .toolbar-actions,
  .table-toolbar,
  .filter-grid {
    min-width: 0;
  }

  .toolbar-actions,
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

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

  .export-guide ol {
    columns: 1;
  }

  .toggle-row {
    grid-template-columns: 1fr;
  }

  .forever-card-main,
  .forever-export-row {
    align-items: stretch;
    flex-direction: column;
  }

  .forever-card-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mini-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .forever-job-row {
    grid-template-columns: 1fr;
  }

  .ghost {
    margin-left: 0;
  }

  .button-row button,
  .button-row .button {
    flex: 1 1 145px;
  }
}
