:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #d9dee8;
  --text: #1f2937;
  --muted: #687385;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #15803d;
  --danger: #b91c1c;
  --warning: #b45309;
  --pending: #4b5563;
  --running: #7c3aed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: #aeb8ca;
}

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

button.primary:hover {
  background: var(--primary-dark);
}

button.danger {
  border-color: #fecaca;
  color: var(--danger);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 250px;
}

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

.brand span,
.statusbar {
  color: var(--muted);
  font-size: 13px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.controls input {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: white;
}

.main {
  padding: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.gantt-wrapper {
  overflow: auto;
  max-height: calc(100vh - 138px);
}

.gantt-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: max-content;
  width: 100%;
  table-layout: fixed;
}

.gantt-table th,
.gantt-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  height: 58px;
  vertical-align: top;
  background: white;
}

.gantt-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 44px;
  padding: 8px;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.fixed-col,
.fixed-col-2 {
  position: sticky;
  z-index: 4;
  background: white;
}

th.fixed-col,
th.fixed-col-2 {
  z-index: 6;
  background: #f8fafc;
}

.fixed-col {
  left: 0;
  width: 180px;
  min-width: 180px;
}

.fixed-col-2 {
  left: 180px;
  width: 220px;
  min-width: 220px;
  box-shadow: 4px 0 8px rgba(15, 23, 42, 0.06);
}

.date-cell {
  width: 136px;
  min-width: 136px;
  padding: 6px;
  cursor: pointer;
}

.date-cell:hover {
  background: #f8fafc;
}

.account-cell {
  padding: 8px 10px;
}

.account-name {
  font-weight: 700;
  margin-bottom: 5px;
}

.account-tools {
  display: flex;
  gap: 6px;
}

.account-tools button {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.token-text {
  max-width: 210px;
  padding: 8px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.task-card {
  display: block;
  width: 100%;
  margin-bottom: 5px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--pending);
  border-radius: 6px;
  padding: 5px 6px;
  background: #fbfdff;
  text-align: left;
}

.task-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.task-card span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.task-card.success {
  border-left-color: var(--success);
}

.task-card.failed {
  border-left-color: var(--danger);
}

.task-card.canceled {
  border-left-color: var(--warning);
}

.task-card.running {
  border-left-color: var(--running);
}

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

dialog {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-height: calc(100vh - 24px);
  padding: 18px;
  overflow: auto;
}

.dialog-form.wide {
  width: 100%;
}

.dialog-form h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

label.checkbox {
  flex-direction: row;
  align-items: center;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: white;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 6px 0 0;
  padding: 0;
}

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

.logs {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.log-item {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

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

.log-item pre {
  overflow: auto;
  margin: 8px 0 0;
  white-space: pre-wrap;
  color: var(--muted);
}

@media (max-width: 760px) {
  .toolbar,
  .brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    position: static;
  }

  .controls {
    width: 100%;
  }

  .controls button,
  .controls input {
    flex: 1 1 118px;
  }

  .main {
    padding: 10px;
  }

  .fixed-col {
    width: 150px;
    min-width: 150px;
  }

  .fixed-col-2 {
    left: 150px;
    width: 170px;
    min-width: 170px;
  }

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

  dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .dialog-form {
    max-height: calc(100vh - 16px);
    padding: 16px;
  }
}
