/* ============================================================================
   AAP Portal — Design System
   A refined, enterprise-grade dark theme for an agentic AI QA platform.
   Signature: an indigo→cyan "agentic" gradient, used with restraint.
   ========================================================================== */

:root {
  /* Surfaces — light & bright */
  --bg:            #F5F7FC;
  --bg-grid:       #EEF1F9;
  --surface:       #FFFFFF;
  --surface-2:     #F4F6FC;
  --surface-3:     #EAEEF7;
  --border:        #E4E8F1;
  --border-strong: #D2D9E7;

  /* Text — deep slate on light */
  --text:   #161A25;
  --text-2: #5A6274;
  --text-3: #98A0B2;

  /* Brand + signature gradient (indigo → cyan) */
  --brand:   #5B4FE6;
  --brand-2: #0EA5C4;
  --brand-soft: rgba(91, 79, 230, 0.09);
  --grad:    linear-gradient(135deg, #6D5DF6 0%, #7C6BF9 42%, #22D3EE 100%);
  --grad-text: linear-gradient(120deg, #5B4FE6 0%, #0BA5C4 100%);

  /* Status — tuned for light backgrounds */
  --success: #12B981;  --success-soft: rgba(18, 185, 129, 0.11);
  --warning: #E08706;  --warning-soft: rgba(224, 135, 6, 0.12);
  --danger:  #E5484D;  --danger-soft:  rgba(229, 72, 77, 0.10);
  --info:    #2E90FA;  --info-soft:    rgba(46, 144, 250, 0.10);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 12px 28px -14px rgba(16,24,40,.16);
  --shadow-lg: 0 28px 64px -24px rgba(16,24,40,.26);
  --sidebar-w: 250px;

  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', var(--font-body);
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Ambient background: soft colour wash + faint grid */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(1100px 520px at 82% -10%, rgba(109,93,246,.10), transparent 60%),
    radial-gradient(900px 520px at 2% 110%, rgba(14,165,196,.08), transparent 55%),
    var(--bg);
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -1; opacity: .6;
  background-image:
    linear-gradient(rgba(20,30,60,.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20,30,60,.028) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent);
          mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent);
}

h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.015em; margin: 0; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(91,79,230,.18); }

.mono { font-family: var(--font-mono); }
.grad-text {
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.eyebrow {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600;
}

/* ---- App shell ----------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed; inset: 0 auto 0 0;
  background: linear-gradient(180deg, #FFFFFF, #FBFCFE);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 40;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 20px 18px;
}
.brandmark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--grad);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; color: #fff;
  box-shadow: 0 6px 18px -6px rgba(109,93,246,.7), inset 0 1px 0 rgba(255,255,255,.25);
  letter-spacing: -.02em;
}
.sidebar__brand .name { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.1; }
.sidebar__brand .sub { font-size: 10.5px; color: var(--text-3); letter-spacing: .04em; }

.nav { padding: 6px 12px; flex: 1; overflow-y: auto; }
.nav__label { padding: 16px 10px 8px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; margin: 2px 0; border-radius: 10px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  position: relative; transition: background .15s, color .15s;
}
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav__item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--grad);
}
.nav__item.is-locked { opacity: .4; pointer-events: none; }
.nav__idx {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-3);
  margin-left: auto; letter-spacing: .05em;
}
.nav__icon { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }

.sidebar__user {
  border-top: 1px solid var(--border);
  padding: 12px; display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  display: grid; place-items: center; font-weight: 600; font-size: 12px; color: var(--text);
}
.sidebar__user .u-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.sidebar__user .u-role { font-size: 11px; color: var(--text-3); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 60px; display: flex; align-items: center; gap: 14px;
  padding: 0 26px;
  background: rgba(255,255,255,.78); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .crumbs { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.topbar .crumbs b { color: var(--text); font-weight: 600; }
.topbar .sep { color: var(--text-3); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.env-badge {
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--border-strong);
  display: inline-flex; align-items: center; gap: 6px; color: var(--text-2);
}
.env-badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.env-badge.env-development .dot { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.env-badge.env-production  .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }

.content { padding: 30px 26px 56px; max-width: 1280px; width: 100%; margin: 0 auto; }

.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 25px; }
.page-head p { color: var(--text-2); margin: 6px 0 0; font-size: 14px; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-family: var(--font-body); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap; line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--grad); color: #fff;
  box-shadow: 0 8px 22px -10px rgba(109,93,246,.85), inset 0 1px 0 rgba(255,255,255,.22);
}
.btn-primary:hover { box-shadow: 0 12px 30px -10px rgba(109,93,246,.95), inset 0 1px 0 rgba(255,255,255,.3); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-3); border-color: #3c465e; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(251,110,110,.4); }
.btn-danger:hover { background: rgba(251,110,110,.2); }
.btn-success { background: var(--success); color: #05261d; }
.btn-success:hover { filter: brightness(1.06); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---- Cards --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }
.card-hover { transition: border-color .18s, transform .18s, box-shadow .18s; }
.card-hover:hover { border-color: var(--border-strong); transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- KPI ----------------------------------------------------------------- */
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .k-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.kpi .k-value { font-family: var(--font-display); font-size: 32px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.kpi .k-icon {
  position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.kpi .k-icon svg { width: 18px; height: 18px; }
.kpi .k-foot { font-size: 11.5px; color: var(--text-3); margin-top: 8px; }

/* ---- Badges & pills ------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent; letter-spacing: .01em;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-neutral { background: var(--surface-3); color: var(--text-2); border-color: var(--border-strong); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: rgba(18,185,129,.30); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(224,135,6,.30); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: rgba(229,72,77,.30); }
.badge-info    { background: var(--info-soft);    color: var(--info);    border-color: rgba(46,144,250,.30); }
.badge-brand   { background: var(--brand-soft);   color: var(--brand);   border-color: rgba(91,79,230,.30); }

/* ---- Forms --------------------------------------------------------------- */
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.form-input {
  width: 100%; padding: 10px 13px; font-size: 13.5px; font-family: var(--font-body);
  background: var(--bg-grid); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.form-input::placeholder { color: var(--text-3); }
.form-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
select.form-input { appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2399A1B7' stroke-width='2'%3E%3Cpath d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.form-row { margin-bottom: 16px; }
.form-hint { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }

/* file input */
input[type=file].form-input { padding: 8px 12px; }
input[type=file]::file-selector-button {
  margin-right: 12px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface-3); color: var(--text); font-weight: 600; font-size: 12px; cursor: pointer;
}

/* ---- Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
  text-align: left; padding: 12px 16px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600; background: var(--surface); border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { background: var(--surface); transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }

/* ---- Pipeline rail (signature) ------------------------------------------ */
.pipeline { position: relative; }
.pipeline__track {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; position: relative;
}
.pipeline__line {
  position: absolute; left: 8%; right: 8%; top: 26px; height: 2px;
  background: linear-gradient(90deg, var(--border-strong), var(--border-strong));
  z-index: 0;
}
.pipeline__line-fill {
  position: absolute; left: 8%; top: 26px; height: 2px; background: var(--grad);
  z-index: 1; box-shadow: 0 0 12px rgba(109,93,246,.6); transition: width .5s;
}
.stage { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 10px; }
.stage__node {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--text-2);
  transition: all .2s;
}
.stage.is-done .stage__node { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 10px 26px -10px rgba(109,93,246,.8); }
.stage.is-done .stage__node svg { width: 22px; height: 22px; }
.stage__name { font-weight: 600; font-size: 13px; margin-top: 12px; }
.stage__role { font-size: 11px; color: var(--brand); margin-top: 2px; }
.stage__desc { font-size: 11.5px; color: var(--text-3); margin-top: 6px; line-height: 1.4; max-width: 190px; }

/* stage list (vertical, on project page) */
.stage-list { display: flex; flex-direction: column; gap: 12px; }
.stage-row {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  transition: border-color .16s, transform .16s;
}
.stage-row:hover { border-color: var(--border-strong); transform: translateX(3px); }
.stage-row__idx {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 600; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2);
}
.stage-row.is-done .stage-row__idx { background: var(--grad); color: #fff; border-color: transparent; }

/* ---- Progress bar -------------------------------------------------------- */
.progress { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; background: var(--grad); border-radius: 999px; transition: width .5s; }

/* ---- Donut (SVG chart) --------------------------------------------------- */
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut { transform: rotate(-90deg); }
.donut__center { font-family: var(--font-display); font-weight: 600; }

/* ---- Empty state --------------------------------------------------------- */
.empty {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 46px 24px; text-align: center; background: var(--surface);
}
.empty__icon { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--text-3); }
.empty h3 { font-size: 16px; margin-bottom: 6px; }
.empty p { color: var(--text-2); font-size: 13px; margin: 0 auto 18px; max-width: 380px; }

/* ---- Messages / toasts --------------------------------------------------- */
.toasts { position: fixed; top: 74px; right: 24px; z-index: 60; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast {
  display: flex; align-items: flex-start; gap: 11px; padding: 13px 15px;
  border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface-2);
  box-shadow: var(--shadow-lg); font-size: 13px; animation: toastin .35s cubic-bezier(.2,.8,.2,1);
}
@keyframes toastin { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.toast__bar { width: 3px; align-self: stretch; border-radius: 3px; }
.toast.success .toast__bar { background: var(--success); }
.toast.error .toast__bar { background: var(--danger); }
.toast.info .toast__bar, .toast.debug .toast__bar { background: var(--info); }
.toast.warning .toast__bar { background: var(--warning); }
.toast__close { margin-left: auto; color: var(--text-3); cursor: pointer; background: none; border: none; font-size: 16px; }

/* ---- Modal --------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 70; background: rgba(23,27,42,.42); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 24px; }
.modal h3 { font-size: 18px; margin-bottom: 8px; }

/* ---- Code block ---------------------------------------------------------- */
.code {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
  background: var(--bg-grid); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; color: #2B3346; white-space: pre; overflow-x: auto;
}
.gherkin .kw { color: var(--brand); font-weight: 600; }

/* ---- Misc ---------------------------------------------------------------- */
.divider { height: 1px; background: var(--border); margin: 22px 0; }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.link { color: var(--brand); font-weight: 600; }
.link:hover { text-decoration: underline; }
.meta { font-size: 12px; color: var(--text-3); }
.stack { display: flex; flex-direction: column; }
.hstack { display: flex; align-items: center; }
.spread { display: flex; align-items: center; justify-content: space-between; }
.gap-6{gap:6px}.gap-8{gap:8px}.gap-10{gap:10px}.gap-12{gap:12px}.gap-16{gap:16px}.gap-20{gap:20px}
.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mt-6{margin-top:24px}
.mb-2{margin-top:0;margin-bottom:8px}.mb-4{margin-bottom:16px}.mb-6{margin-bottom:24px}
.wrap { flex-wrap: wrap; }

.menu-btn { display: none; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); }
  .pipeline__track { grid-template-columns: 1fr; gap: 14px; }
  .pipeline__line, .pipeline__line-fill { display: none; }
  .stage { flex-direction: row; text-align: left; gap: 14px; }
  .stage__desc { max-width: none; }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
