:root {
  --canvas: oklch(0.975 0.004 250);
  --surface: oklch(1 0 0);
  --surface-muted: oklch(0.945 0.008 250);
  --ink: oklch(0.22 0.018 250);
  --ink-muted: oklch(0.44 0.018 250);
  --line: oklch(0.86 0.012 250);
  --accent: oklch(0.52 0.17 250);
  --accent-dark: oklch(0.43 0.16 250);
  --success: oklch(0.48 0.13 150);
  --success-bg: oklch(0.94 0.04 150);
  --warning: oklch(0.55 0.12 75);
  --warning-bg: oklch(0.95 0.045 85);
  --danger: oklch(0.5 0.18 25);
  --danger-bg: oklch(0.95 0.035 25);
  --focus: oklch(0.66 0.17 250);
  --radius: 10px;
  --sidebar-width: 236px;
  --transition: 180ms cubic-bezier(0.25, 1, 0.5, 1);
}

* { box-sizing: border-box; }

html { font-size: 15px; min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-underline-offset: 3px; }
a:hover { color: var(--accent); }

button, input, select { font: inherit; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 24px 16px 16px;
  background: oklch(0.23 0.025 250);
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-size: 1rem;
  text-decoration: none;
}

.brand:hover { color: white; }

.brand span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: .78rem;
  font-weight: 800;
}

.sidebar nav {
  display: grid;
  gap: 4px;
  margin-top: 34px;
}

.sidebar nav a {
  padding: 10px 12px;
  border-radius: 8px;
  color: oklch(0.86 0.012 250);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.sidebar nav a:hover,
.sidebar nav a[aria-current="page"] {
  background: oklch(0.32 0.035 250);
  color: white;
}

.sidebar-account {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid oklch(0.4 0.025 250);
}

.sidebar-account ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sidebar-account a, .sidebar-account button {
  color: oklch(0.88 0.01 250) !important;
  font-size: .86rem;
}

.app-main {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 38px clamp(24px, 4vw, 64px) 64px;
}

.mobile-header { display: none; }

.page-heading,
.section-heading,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-heading { margin-bottom: 28px; }
.page-heading h1 { margin: 0 0 5px; font-size: 1.8rem; letter-spacing: -.025em; }
.page-heading p { margin: 0; color: var(--ink-muted); }

h2 { margin: 0; font-size: 1.12rem; }
h3 { font-size: 1rem; }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  margin-bottom: 28px;
  border-block: 1px solid var(--line);
  background: var(--surface);
}

.metric {
  display: flex;
  min-height: 98px;
  flex-direction: column;
  justify-content: center;
  padding: 18px 22px;
}

.metric + .metric { border-left: 1px solid var(--line); }
.metric span { color: var(--ink-muted); font-size: .84rem; }
.metric strong { margin-top: 4px; font-size: 1.7rem; line-height: 1; }
.metric-danger strong { color: var(--danger); }

.data-section,
.form-section {
  border-radius: var(--radius);
  background: var(--surface);
}

.data-section { overflow: hidden; }
.data-section > h2, .data-section > .section-heading { padding: 20px 22px; }
.section-heading { border-bottom: 1px solid var(--line); }
.section-heading a { font-size: .88rem; font-weight: 600; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  padding: 11px 18px;
  background: var(--surface-muted);
  color: var(--ink-muted);
  font-size: .76rem;
  font-weight: 700;
  text-align: left;
}
td { padding: 14px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: oklch(0.985 0.004 250); }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--ink-muted); }

.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .86em; }
.muted { color: var(--ink-muted); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--surface-muted);
  color: var(--ink-muted);
  font-size: .76rem;
  font-weight: 700;
}

.status::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.status-installed { background: var(--success-bg); color: var(--success); }
.status-failed { background: var(--danger-bg); color: var(--danger); }
.status-queued, .status-dispatched, .status-downloading, .status-installing { background: oklch(0.94 0.035 250); color: var(--accent-dark); }
.status-canceled { color: var(--ink-muted); }

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.button:hover { border-color: var(--ink-muted); background: var(--surface-muted); color: var(--ink); }
.button-primary { border-color: var(--accent); background: var(--accent); color: white; }
.button-primary:hover { border-color: var(--accent-dark); background: var(--accent-dark); color: white; }
.button-danger { border-color: var(--danger); background: var(--danger); color: white; }
.button-danger:hover { border-color: var(--danger); background: oklch(0.48 0.18 25); color: white; }
.button-small { min-height: 32px; padding: 5px 10px; font-size: .84rem; }
.inline-form { display: inline-block; margin: 0 8px 0 0; }

.empty-state {
  max-width: 620px;
  padding: 44px 22px;
}
.empty-state h2, .empty-state h3 { margin: 0 0 8px; }
.empty-state p { max-width: 58ch; margin: 0 0 18px; color: var(--ink-muted); }
.empty-state.compact { padding: 26px 22px; }

.split-layout { display: grid; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); gap: 24px; align-items: start; }
.form-section { padding: 22px; }
.form-section.narrow { max-width: 620px; }
.form-section h2 { margin-bottom: 20px; }
.form-section form { display: grid; gap: 8px; }
.form-section label { margin-top: 8px; font-size: .84rem; font-weight: 700; }
.form-section input, .form-section select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
}
.form-section input::placeholder { color: oklch(0.48 0.018 250); opacity: 1; }
.form-section input:focus, .form-section select:focus { border-color: var(--focus); outline: 3px solid oklch(0.9 0.05 250); }
.form-section .button { margin-top: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row > div { display: grid; gap: 8px; }

.validation { color: var(--danger); font-size: .82rem; }
.alert { margin-bottom: 20px; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.alert-success { border-color: oklch(0.76 0.09 150); background: var(--success-bg); color: oklch(0.35 0.1 150); }
.alert-warning { margin-top: 14px; border-color: oklch(0.79 0.09 75); background: var(--warning-bg); color: oklch(0.39 0.08 75); }

.artifact-list { display: grid; }
.artifact-list article { padding: 18px 22px; border-top: 1px solid var(--line); }
.artifact-list article:first-child { border-top: 0; }
.artifact-list article > div { display: flex; justify-content: space-between; gap: 16px; }
.artifact-list dl { display: flex; gap: 24px; margin: 14px 0 8px; }
.artifact-list dl div { display: flex; gap: 6px; }
.artifact-list dt { color: var(--ink-muted); font-weight: 500; }
.artifact-list dd { margin: 0; font-weight: 700; }
.checksum { display: block; overflow: hidden; color: var(--ink-muted); text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 840px) {
  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    height: 58px;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: oklch(0.23 0.025 250);
  }
  .menu-toggle { border: 1px solid oklch(0.5 0.02 250); border-radius: 7px; padding: 7px 10px; background: transparent; color: white; }
  .sidebar { top: 58px; width: min(280px, 88vw); transform: translateX(-100%); transition: transform var(--transition); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar > .brand { display: none; }
  .sidebar nav { margin-top: 0; }
  .app-main { margin-left: 0; padding: 24px 16px 48px; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .metric:nth-child(4) { border-top: 1px solid var(--line); }
  .split-layout { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .field-row { grid-template-columns: 1fr; }
  .artifact-list article > div { flex-direction: column; }
  .metric { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
