/* ====== Global ====== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg-body: #f5f5f8;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-topbar: #ffffff;
  --border-subtle: #e5e7eb;
  --border-strong: #d1d5db;
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius-lg: 12px;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.08);
  --font-main: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body {
  margin: 0;
  font-family: var(--font-main);
  background: radial-gradient(circle at top, #e5edff 0, #f5f5f8 50%);
  color: var(--text-main);
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ====== Shell layout ====== */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-pill {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.topbar-title {
  font-weight: 600;
  font-size: 1rem;
}

.topbar-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.topbar-right {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Layout: sidebar + main */
.app-body {
  display: flex;
  min-height: calc(100vh - 56px);
}

.sidebar {
  width: 220px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  padding: 1rem 0.75rem;
}

.sidebar-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0.25rem 0.5rem;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav li + li {
  margin-top: 0.25rem;
}

.sidebar-link {
  display: block;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}

.sidebar-link:hover {
  background: #f3f4f6;
  color: var(--text-main);
}

.sidebar-link.active {
  background: var(--accent);
  color: #ffffff;
}

/* Main area */
.main {
  flex: 1;
  padding: 1.25rem 1.75rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* ====== Cards & basic components ====== */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 1rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.text-muted {
  color: var(--text-muted);
}

/* Buttons & selects */

button,
select,
input[type="text"],
input[type="email"],
input[type="password"] {
  font-family: inherit;
  font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 0.75rem;
  background: #ffffff;
  color: var(--text-main);
  outline: none;
}

button:focus,
select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
}

button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 500;
}

button.secondary {
  background: var(--warning);
  border-color: var(--warning);
  color: #ffffff;
  font-weight: 500;
}

button.ghost {
  background: #ffffff;
}

button.small {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
}

/* Pills / status */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  font-size: 0.7rem;
}

.pill.small {
  font-size: 0.68rem;
}

.pill.success {
  border-color: rgba(22, 163, 74, 0.2);
  color: var(--success);
  background: #ecfdf3;
}

.pill.failed {
  border-color: rgba(220, 38, 38, 0.2);
  color: var(--danger);
  background: #fef2f2;
}

.pill.pending {
  border-color: rgba(217, 119, 6, 0.2);
  color: var(--warning);
  background: #fffbeb;
}

.pill.running {
  border-color: rgba(37, 99, 235, 0.2);
  color: var(--accent);
  background: #eff6ff;
}

/* Toolbar / filters */

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.filters label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tag {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

/* Summary grid */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.summary-item {
  padding: 0.6rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-subtle);
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.summary-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.summary-value {
  font-size: 0.95rem;
  font-weight: 600;
}

.summary-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Table */

.table-wrapper {
  margin-top: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

thead {
  background: #f9fafb;
}

th,
td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #eef0f4;
  text-align: left;
  white-space: nowrap;
}

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

tbody tr:hover {
  background: #f9fafb;
}

.text-right {
  text-align: right;
}

.runtime-chip {
  font-variant-numeric: tabular-nums;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: #f3f4f6;
  font-size: 0.72rem;
}

/* Pagination */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
}

.modal {
  background: #ffffff;
  border-radius: 1rem;
  border: 1px solid var(--border-subtle);
  max-width: 900px;
  width: calc(100% - 2rem);
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.modal-header {
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-body {
  padding: 0.75rem 1rem;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 0.75rem;
}

.modal-section {
  border-radius: 0.75rem;
  border: 1px solid var(--border-subtle);
  padding: 0.5rem 0.75rem;
  background: #f9fafb;
  font-size: 0.78rem;
}

.modal-section h3 {
  margin: 0 0 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.code-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.72rem;
  background: #ffffff;
  border-radius: 0.5rem;
  padding: 0.4rem 0.5rem;
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  white-space: pre;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  max-height: 220px;
  overflow: auto;
}

.log-item {
  padding: 0.35rem 0.45rem;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
}

.log-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
  margin-bottom: 0.15rem;
}

.log-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.log-level {
  font-size: 0.7rem;
  font-weight: 500;
}

/* Login page */

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: #ffffff;
  border-radius: 1rem;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 1.5rem 1.75rem;
  width: 100%;
  max-width: 380px;
}

.login-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 0.75rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.form-footer {
  margin-top: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}

/* Responsive */

@media (max-width: 900px) {
  .app-body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .sidebar-title {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 1rem 1rem 1.5rem;
  }

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

  .modal-body {
    grid-template-columns: minmax(0, 1fr);
  }
}
.modal-body,
.modal-section {
  min-width: 0;
}

/* Code blocks: readable JSON + controlled height + better wrapping */
.code-block {
  white-space: pre-wrap;          /* wrap long lines */
  word-break: break-word;         /* break long tokens */
  overflow-wrap: anywhere;        /* allow wrap even for long ids */
  max-height: 305px;              /* prevent huge blocks */
  overflow: auto;                 /* both directions if needed */
  line-height: 1.35;
}

/* Make code blocks feel less "boxed" when inside modal sections */
.modal-section .code-block {
  background: #fcfcfd;
}

/* Logs area: a bit more breathing room + smoother scroll */
.log-list {
  max-height: 450px;              /* was 220px */
  padding-right: 6px;             /* room for scrollbar */
  overscroll-behavior: contain;
}

/* Log item polish */
.log-item {
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.log-item:hover {
  background: #f9fafb;
  border-color: #dbe1ea;
  transform: translateY(-1px);
}

/* Log message can be long; let it wrap nicely */
.log-message {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

/* Optional: make modal a touch wider on large screens */
@media (min-width: 1100px) {
  .modal {
    max-width: 980px;
  }
}

/* Optional: reduce modal padding on very small screens */
@media (max-width: 420px) {
  .modal-header {
    padding: 0.6rem 0.75rem;
  }
  .modal-body {
    padding: 0.6rem 0.75rem;
  }
}