/* dashboard/public/styles.css */
:root {
  --bg: #f5f6f8;
  --fg: #1a1d23;
  --muted: #5b6472;
  --card: #ffffff;
  --border: #e2e6ec;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.45;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.title { display: flex; align-items: center; gap: 12px; }
.title h1 { font-size: 18px; margin: 0; }
.title .logo { font-size: 24px; }

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-pill {
  background: #eef2ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
}

main { padding: 28px; max-width: 1200px; margin: 0 auto; }

.empty {
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  color: var(--muted);
}
.empty code { background: #eef0f4; padding: 2px 6px; border-radius: 4px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
  position: relative;
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.card .icon {
  font-size: 44px;
  line-height: 1;
}
.card .name {
  font-weight: 600;
  font-size: 15px;
  margin: 0;
  word-break: break-word;
}
.card .desc {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  flex: 1;
  word-break: break-word;
}
.card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}
.card .last-status {
  font-size: 12px;
  color: var(--muted);
}
.card .last-status.pass { color: var(--success); }
.card .last-status.fail { color: var(--danger); }
.card .last-status.error { color: var(--warning); }

.card .delete {
  position: absolute;
  top: 8px; right: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
}
.card .delete:hover { background: #f0f1f5; color: var(--danger); }
.card .history-link {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
}
.card .history-link:hover {
  background: #eef2ff;
  text-decoration: underline;
}

/* Buttons */
.btn {
  background: #f0f1f5;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}
.btn:hover { background: #e6e8ee; }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn.danger:hover { background: #b91c1c; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Modals */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal.hidden { display: none; }
.hidden { display: none !important; }

.modal-card {
  background: var(--card);
  border-radius: 14px;
  width: min(520px, 92vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-card.wide { width: min(820px, 96vw); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.modal-header h2 { margin: 0; font-size: 16px; }
.btn-close {
  background: none; border: none; cursor: pointer;
  font-size: 24px; line-height: 1; color: var(--muted);
  padding: 0 4px;
}
.btn-close:hover { color: var(--fg); }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.tab {
  flex: 1;
  padding: 12px 16px;
  background: transparent; border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-panel {
  display: none;
  padding: 20px;
}
.tab-panel.active { display: block; }

.tab-panel label {
  display: block;
  margin-bottom: 12px;
}
.tab-panel label > span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--muted);
}
.tab-panel input,
.tab-panel select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.tab-panel input:focus,
.tab-panel select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.hint {
  background: #f0f7ff;
  border: 1px solid #cee0fa;
  color: #1e3a8a;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin: 0 0 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}
.tab-panel .modal-actions {
  border-top: none;
  background: transparent;
  padding: 4px 0 0;
}

.log {
  background: #0f1115;
  color: #e6e6e6;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 14px 16px;
  margin: 0;
  flex: 1;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
}
.log .pass-line { color: #4ade80; }
.log .fail-line { color: #f87171; }
.log .warn-line { color: #fbbf24; }

.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  margin-right: auto;
  margin-left: 12px;
}
.status-running { background: #dbeafe; color: #1d4ed8; }
.status-pass    { background: #dcfce7; color: #166534; }
.status-fail    { background: #fee2e2; color: #991b1b; }
.status-error   { background: #fef3c7; color: #92400e; }
.status-stopped { background: #f3f4f6; color: #4b5563; }

/* History panel */
.history-panel {
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  background: #fafbfc;
  max-height: 360px;
  overflow: auto;
}
.history-panel h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-row {
  display: grid;
  grid-template-columns: 64px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
}
.history-row:hover { background: #f9fafb; }
.history-row .pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}
.history-row .when { color: var(--muted); }
.history-row .dur { color: var(--muted); font-variant-numeric: tabular-nums; }
.history-row .params {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-row.no-runs {
  grid-template-columns: 1fr;
  text-align: center;
  color: var(--muted);
  cursor: default;
}
