/* --- cards --- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
}
.card h3 { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--sp-3); }
.card-sub { color: var(--text-3); font-size: var(--fs-xs); }

.stat { display: flex; flex-direction: column; gap: var(--sp-1); }
.stat .value { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--text-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- badges & dots --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--bg3);
  color: var(--text-2);
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.dot-green { background: var(--status-done); }
.dot-red { background: var(--status-failed); }
.dot-blue { background: var(--status-running); }
.dot-gray { background: var(--status-cancelled); }
.dot-pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --- tables --- */
.table-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-header { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.table-header h3 { font-size: var(--fs-md); font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: var(--sp-2) var(--sp-4); font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable:hover { background: var(--bg3); cursor: pointer; }

/* --- buttons & inputs --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-1);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
  font-family: var(--font);
}
.btn:hover { filter: brightness(1.2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: transparent; border-color: var(--status-failed); color: var(--status-failed); }
.btn-sm { padding: 3px 9px; font-size: var(--fs-xs); }

input, select, textarea {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  padding: 7px 10px;
  font-size: var(--fs-sm);
  font-family: var(--font);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; font-family: var(--mono); }
label { font-size: var(--fs-xs); color: var(--text-3); display: block; margin-bottom: 3px; }
.field { margin-bottom: var(--sp-3); }
.row { display: flex; gap: var(--sp-3); align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.row > .fit { flex: 0 0 auto; min-width: 0; }

/* --- kanban --- */
.kanban { display: flex; gap: var(--sp-3); overflow-x: auto; align-items: flex-start; padding-bottom: var(--sp-4); }
.kanban-column {
  min-width: 240px;
  width: 240px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-shrink: 0;
}
.kanban-column-header {
  padding: var(--sp-2) var(--sp-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.kanban-cards { padding: var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-2); min-height: 60px; }
.kanban-column.drag-over .kanban-cards { background: var(--accent-soft); border-radius: var(--radius-sm); }

.task-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-3);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  cursor: grab;
  font-size: var(--fs-sm);
}
.task-card:hover { border-color: var(--accent); }
.task-card.p2 { border-left-color: var(--status-failed); }
.task-card.p1 { border-left-color: var(--status-blocked); }
.task-card.p0 { border-left-color: var(--text-3); }
.task-card.synthetic { opacity: 0.65; cursor: default; border-style: dashed; }
.task-card.no-drag { cursor: default; }
.task-card .title { font-weight: 500; margin-bottom: 4px; word-break: break-word; }
.task-card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: var(--fs-xs); color: var(--text-3); }

/* --- pipeline graph --- */
.stage-graph { display: flex; align-items: center; gap: 0; flex-wrap: wrap; padding: var(--sp-3) 0; }
.stage-node {
  border: 2px solid var(--text-3);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3);
  min-width: 110px;
  text-align: center;
  background: var(--bg2);
  cursor: pointer;
  font-size: var(--fs-xs);
}
.stage-node .type { font-weight: 700; font-size: var(--fs-sm); }
.stage-node .profile { color: var(--text-3); }
.stage-node.running { border-color: var(--status-running); animation: pulse 1.4s infinite; }
.stage-node.succeeded { border-color: var(--status-done); }
.stage-node.failed { border-color: var(--status-failed); }
.stage-node.blocked { border-color: var(--status-blocked); }
.stage-node.waiting_for_review { border-color: var(--status-review); }
.stage-node.cancelled { border-color: var(--status-cancelled); opacity: 0.6; }
.stage-arrow { color: var(--text-3); padding: 0 var(--sp-2); font-size: 16px; }

/* --- drawer --- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 50;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(720px, 92vw);
  background: var(--bg1);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 51;
  display: flex;
  flex-direction: column;
  animation: slide-in 0.18s ease-out;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3);
}
.drawer-body { padding: var(--sp-4) var(--sp-5); overflow-y: auto; flex: 1; }
.drawer-close { background: none; border: none; color: var(--text-3); font-size: 22px; cursor: pointer; line-height: 1; }

/* --- modal --- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 60; display: flex; align-items: center; justify-content: center; padding: var(--sp-5); }
.modal { background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius); width: min(760px, 94vw); max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-header { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: var(--sp-4) var(--sp-5); overflow-y: auto; }
.modal-footer { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-2); }

/* --- timeline --- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px dashed var(--border); font-size: var(--fs-sm); }
.timeline-item .time { color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; min-width: 70px; }
.timeline-item .type { font-family: var(--mono); font-size: var(--fs-xs); min-width: 150px; }
.timeline-item .payload { color: var(--text-2); word-break: break-word; font-size: var(--fs-xs); }

/* --- misc --- */
.empty { color: var(--text-3); text-align: center; padding: var(--sp-6); font-size: var(--fs-sm); }
.pre {
  background: var(--bg0); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--sp-3); font-family: var(--mono); font-size: var(--fs-xs);
  white-space: pre-wrap; word-break: break-word; max-height: 380px; overflow-y: auto;
}
.section { margin-bottom: var(--sp-5); }
.section > h4 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); margin-bottom: var(--sp-3); }
.tree { font-size: var(--fs-sm); }
.tree ul { list-style: none; padding-left: var(--sp-5); }
.tree li { padding: 3px 0; }

#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: var(--sp-2); }
.toast {
  background: var(--bg3); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm); font-size: var(--fs-sm);
  box-shadow: var(--shadow); max-width: 380px; animation: slide-in 0.15s ease-out;
}
.toast.error { border-left-color: var(--status-failed); }
.toast.success { border-left-color: var(--status-done); }

.progress { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 3px; }
