/* Arrival Project Dashboard */

:root {
  --bg: #F6F5F9;
  --surface: #FFFFFF;
  --surface-2: #FAF9FC;
  --ink: #15111F;
  --muted: #5B5568;
  --faint: #8A8496;
  --border: #E6E2EE;
  --border-strong: #D3CDDF;
  --brand: #3E2A8C;
  --brand-hover: #33227A;
  --brand-text: #4A35A6;
  --brand-soft: #EEEAFB;
  --accent: #D6237F;
  --focus: #7A5CFA;
  --grad: linear-gradient(100deg, #3E2A8C 0%, #D6237F 42%, #F2924A 78%, #FBC272 100%);

  --ok: #17734A;      --ok-bg: #E4F5EB;
  --warn: #8F5400;    --warn-bg: #FFF1D6;
  --danger: #BE2843;  --danger-bg: #FDEBEE;
  --info: #2A58C4;    --info-bg: #E8EFFE;
  --teal: #0C7479;    --teal-bg: #E0F3F3;
  --pink: #B81D6C;    --pink-bg: #FCE7F1;
  --neutral: #5B5568; --neutral-bg: #EFEDF3;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(21, 17, 31, 0.05), 0 6px 20px rgba(21, 17, 31, 0.04);
  --shadow-lg: 0 20px 60px rgba(21, 17, 31, 0.22);
  --font-head: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F0D14;
    --surface: #18151F;
    --surface-2: #1D1A25;
    --ink: #F1EEF7;
    --muted: #B3ADBF;
    --faint: #878192;
    --border: #2A2634;
    --border-strong: #3A3546;
    --brand: #6A50E6;
    --brand-hover: #7A62EE;
    --brand-text: #AC9CFF;
    --brand-soft: #241D40;
    --accent: #F0609F;
    --focus: #A28CFF;
    --ok: #6DD39A;      --ok-bg: #12301F;
    --warn: #F2B65A;    --warn-bg: #33270C;
    --danger: #FF8297;  --danger-bg: #3A1620;
    --info: #8AB0FF;    --info-bg: #16233F;
    --teal: #5CCFD2;    --teal-bg: #0F2E2F;
    --pink: #F27DB7;    --pink-bg: #3A1730;
    --neutral: #B3ADBF; --neutral-bg: #26232E;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F0D14;
  --surface: #18151F;
  --surface-2: #1D1A25;
  --ink: #F1EEF7;
  --muted: #B3ADBF;
  --faint: #878192;
  --border: #2A2634;
  --border-strong: #3A3546;
  --brand: #6A50E6;
  --brand-hover: #7A62EE;
  --brand-text: #AC9CFF;
  --brand-soft: #241D40;
  --accent: #F0609F;
  --focus: #A28CFF;
  --ok: #6DD39A;      --ok-bg: #12301F;
  --warn: #F2B65A;    --warn-bg: #33270C;
  --danger: #FF8297;  --danger-bg: #3A1620;
  --info: #8AB0FF;    --info-bg: #16233F;
  --teal: #5CCFD2;    --teal-bg: #0F2E2F;
  --pink: #F27DB7;    --pink-bg: #3A1730;
  --neutral: #B3ADBF; --neutral-bg: #26232E;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.25; }
h2 { font-size: 1.05rem; }
a { color: var(--brand-text); }
code, pre { font-family: var(--font-mono); font-size: 0.86em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--faint); }
.small { font-size: 0.82rem; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- Top bar --- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar::before { content: ''; display: block; height: 3px; background: var(--grad); }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { display: block; height: 18px; width: auto; }
.brand-label {
  font-family: var(--font-head); font-weight: 600; font-size: 0.95rem; color: var(--muted);
  padding-left: 10px; border-left: 1px solid var(--border-strong);
}
.topnav { display: flex; gap: 4px; margin-right: auto; }
.topnav a {
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 0.9rem;
  padding: 6px 10px; border-radius: var(--radius-sm);
}
.topnav a:hover { color: var(--ink); background: var(--surface-2); }
.topnav a.active { color: var(--brand-text); background: var(--brand-soft); }

.user { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; min-width: 0; }
.user:empty { display: none; }
.avatar {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 0.72rem; letter-spacing: 0.02em;
}
.avatar.none { background: var(--neutral-bg); color: var(--muted); }
.group-head .avatar { width: 34px; height: 34px; font-size: 0.8rem; }
.avatar.xs { width: 20px; height: 20px; font-size: 0.6rem; }
.person-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.84rem; }
.user-name { color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.user-menu summary { display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px; border-radius: 999px; cursor: pointer; list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .user-menu[open] summary { background: var(--surface-2); }
.dropdown.user-menu .menu { left: auto; right: 0; min-width: 220px; max-width: calc(100vw - 32px); }
.user-menu .menu-hint { overflow-wrap: anywhere; }
.menu-name { margin: 6px 8px 0; font-weight: 600; }
.menu-link { display: block; padding: 7px 8px; border-radius: 6px; color: var(--ink); text-decoration: none; border-top: 1px solid var(--border); margin-top: 4px; }
.menu-link:hover { background: var(--surface-2); color: var(--brand-text); }

main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 64px; outline: none; }

/* --- Buttons --- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: 500 0.9rem/1 var(--font-body); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; padding: 0 8px; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 0.84rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--faint); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand-text); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* --- Pills, chips, dots --- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-planning { color: var(--info); background: var(--info-bg); }
.status-in-progress { color: var(--brand-text); background: var(--brand-soft); }
.status-live { color: var(--ok); background: var(--ok-bg); }
.status-on-hold { color: var(--warn); background: var(--warn-bg); }
.status-complete { color: var(--neutral); background: var(--neutral-bg); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 0.76rem; font-weight: 500; white-space: nowrap;
}

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.t-update { background: var(--brand-text); }
.dot.t-milestone { background: var(--accent); }
.dot.t-meeting { background: var(--info); }
.dot.t-decision { background: var(--teal); }
.dot.t-issue { background: var(--danger); }
.dot.t-deployment { background: var(--ok); }
.dot.t-commit { background: var(--faint); }
.dot.t-task { background: var(--ok); }
.dot.t-status { background: var(--warn); }

/* --- Dashboard --- */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.sub { margin: 4px 0 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-family: var(--font-head); font-size: 1.8rem; font-weight: 600; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 0.82rem; color: var(--faint); }
.stat.warn .stat-value { color: var(--warn); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.filters .search { flex: 1 1 260px; }
input, select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--brand); flex: none; }
input:disabled { color: var(--faint); background: var(--surface-2); }
.field-inline select { width: auto; max-width: 240px; }
.select-like {
  display: flex; align-items: center; min-height: 38px; padding: 7px 30px 7px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; list-style: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select-like::-webkit-details-marker { display: none; }
.dropdown { position: relative; }
.dropdown .menu {
  position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; min-width: 230px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 340px; overflow: auto;
}
.menu-hint { margin: 4px 8px 6px; font-size: 0.8rem; color: var(--faint); }
.check { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check span:first-of-type { flex: 1; }
.check-hint { display: block; font-size: 0.74rem; color: var(--faint); overflow: hidden; text-overflow: ellipsis; }

.result-count { display: flex; gap: 10px; align-items: center; min-height: 22px; margin: 0 0 8px; font-size: 0.85rem; color: var(--muted); }
.expand-all { display: inline-flex; gap: 14px; margin-left: auto; }
.group-toggle { margin-left: auto; }
.group-toggle button { padding: 8px 12px; }

/* Projects grouped by user */
.group { margin-bottom: 10px; }
.group-head {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--ink); font: inherit; cursor: pointer;
}
.group-head:hover { border-color: var(--border-strong); background: var(--surface-2); }
.group:not(.collapsed) .group-head, .group-head[aria-expanded="true"] { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.group-head[aria-expanded="false"] { border-radius: var(--radius); }
.chevron { width: 10px; height: 10px; flex: none; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(-45deg); transition: transform 0.15s; margin: 0 2px; }
.group-head[aria-expanded="true"] .chevron { transform: rotate(45deg); }
.group-title { display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; }
.group-name { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 600; font-size: 1rem; }
.group-email { font-size: 0.8rem; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you { font: 600 0.7rem var(--font-body); color: var(--brand-text); background: var(--brand-soft); padding: 1px 7px; border-radius: 999px; }
.group-meta { display: flex; gap: 16px; margin-left: auto; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.group-meta strong { color: var(--ink); font-weight: 600; }
.group-body .project-list { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.group-body[hidden] { display: none; }
.row-users { font-size: 0.78rem; color: var(--faint); }

/* Private projects */
.private-tag {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; vertical-align: 2px;
  padding: 1px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn);
  font: 600 0.72rem var(--font-body); white-space: nowrap;
}
.private-tag .icon { width: 12px; height: 12px; }
.title-block .private-tag { margin-left: 0; font-size: 0.78rem; padding: 2px 10px; }
.avatar.lock { background: var(--warn-bg); color: var(--warn); }
.avatar.lock .icon { width: 16px; height: 16px; }
.group.private .group-head { border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.private-check { margin-top: 8px; padding: 10px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); align-items: flex-start; }
.private-check input { margin-top: 2px; }
.private-check .icon { width: 14px; height: 14px; vertical-align: -2px; }

.project-list {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: minmax(0, 2.6fr) minmax(0, 1.1fr) minmax(0, 1.3fr) 110px minmax(0, 1.7fr) minmax(0, 1.3fr);
  gap: 16px; align-items: start; padding: 14px 18px;
  border-top: 1px solid var(--border); color: inherit; text-decoration: none;
}
.row:first-child { border-top: 0; }
a.row:hover { background: var(--surface-2); }
a.row:hover .name { color: var(--brand-text); }
.row.head {
  padding-top: 10px; padding-bottom: 10px; background: var(--surface-2);
  font-size: 0.74rem; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em;
}
.c-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.name { font-weight: 600; font-size: 0.98rem; }
.desc {
  color: var(--muted); font-size: 0.85rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.c-customer { font-size: 0.9rem; }
.c-last, .c-tasks { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 0.85rem; }
.when { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.82rem; color: var(--muted); }
.when.quiet { color: var(--warn); }
.what { color: var(--ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-count { font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mini-flag { font-size: 0.72rem; font-weight: 600; color: var(--danger); background: var(--danger-bg); padding: 0 6px; border-radius: 4px; }
.bar { display: block; height: 4px; border-radius: 2px; background: var(--neutral-bg); overflow: hidden; max-width: 160px; }
.bar span { display: block; height: 100%; background: var(--ok); border-radius: 2px; }
.next { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-label { display: none; }

.empty { color: var(--faint); padding: 18px; margin: 0; }
.empty-state { text-align: center; padding: 56px 16px; }
.empty-state p { color: var(--muted); }

/* --- Project page --- */

.back { display: inline-block; margin-bottom: 14px; color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.back:hover { color: var(--brand-text); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.project-head { margin-bottom: 14px; }
.title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.title-block { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.title-block h1 { overflow-wrap: anywhere; }
.description { margin: 10px 0 16px; max-width: 78ch; color: var(--ink); white-space: pre-wrap; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
.facts-wide { grid-column: span 2; }
.facts dt { font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
.facts dd { margin: 2px 0 0; font-size: 0.92rem; }
.links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.link { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; font-size: 0.9rem; text-decoration: none; }
.link:hover { text-decoration: underline; }
.sync { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sync code { background: var(--surface-2); border: 1px solid var(--border); padding: 2px 6px; border-radius: 5px; color: var(--muted); }
.sync-error { color: var(--danger); font-size: 0.82rem; }

.highlights { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.highlight { padding: 16px 20px; }
.highlight-title { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; margin-top: 6px; overflow-wrap: anywhere; }
.highlight-title .big { font-size: 1.8rem; line-height: 1; }
.highlight-meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 4px; color: var(--muted); font-size: 0.85rem; }
.highlight-meta .dot { margin-right: 3px; }
.highlight-sub { margin-top: 8px; font-size: 0.85rem; color: var(--muted); }
.highlight-sub strong { color: var(--ink); font-weight: 600; }

.project-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.section-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin-right: auto; }
.count-badge { font-weight: 600; font-size: 0.8rem; background: var(--brand-soft); color: var(--brand-text); border-radius: 999px; padding: 1px 9px; }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button {
  border: 0; background: var(--surface); color: var(--muted); font: 500 0.82rem var(--font-body);
  padding: 6px 10px; cursor: pointer; border-left: 1px solid var(--border-strong);
}
.segmented button:first-child { border-left: 0; }
.segmented button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-text); }

/* Timeline */
.month + .month { margin-top: 18px; }
.month-label { font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin-bottom: 6px; font-family: var(--font-body); }
.events { list-style: none; margin: 0; padding: 0; position: relative; }
.events::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); border-radius: 1px; }
.ev { position: relative; display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 12px; padding: 8px 0; }
.ev > .dot { width: 12px; height: 12px; margin-top: 4px; position: relative; box-shadow: 0 0 0 3px var(--surface); }
.ev.t-commit > .dot { width: 8px; height: 8px; margin: 6px 2px 0; }
.ev-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; font-size: 0.78rem; color: var(--faint); }
.ev-type { font-weight: 600; color: var(--muted); }
.ev.t-milestone .ev-type { color: var(--accent); }
.ev.t-issue .ev-type { color: var(--danger); }
.ev.t-deployment .ev-type, .ev.t-task .ev-type { color: var(--ok); }
.ev-title { font-weight: 500; margin-top: 1px; overflow-wrap: anywhere; }
.ev.t-commit .ev-title { font-weight: 400; font-size: 0.92rem; }
.ev.t-milestone .ev-title { font-weight: 600; }
.ev-details { margin-top: 4px; color: var(--muted); font-size: 0.87rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.ev-details.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ev-details.folded { display: none; }
.ev.t-commit .ev-details { font-size: 0.82rem; }
.run-list { list-style: none; margin: 4px 0 2px; padding: 0; }
.run-list[hidden] { display: none; }
.run-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 3px 0; font-size: 0.9rem; }
.run-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-list time { font-size: 0.76rem; color: var(--faint); white-space: nowrap; }
.hash { font-family: var(--font-mono); font-size: 0.76rem; color: var(--faint); }
a.hash:hover { color: var(--brand-text); }
.ev-actions { opacity: 0; transition: opacity 0.15s; }
.ev:hover .ev-actions, .ev:focus-within .ev-actions { opacity: 1; }
.btn.more { margin-top: 12px; width: 100%; }

/* Tasks */
.task-add { display: flex; gap: 8px; margin-bottom: 12px; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--border); }
.task:first-child { border-top: 0; }
.task input[type="checkbox"] { margin-top: 3px; cursor: pointer; }
.task-body { min-width: 0; flex: 1; }
.task-title {
  display: block; width: 100%; text-align: left; border: 0; padding: 0; background: none; color: var(--ink);
  font: inherit; cursor: pointer; overflow-wrap: anywhere;
}
.task-title:hover { color: var(--brand-text); }
.task.is-done .task-title { color: var(--faint); text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; font-size: 0.78rem; color: var(--faint); }
.task-notes { margin-top: 3px; font-size: 0.82rem; color: var(--muted); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; padding: 0 6px; border-radius: 4px; background: var(--neutral-bg); color: var(--neutral); }
.tag .icon { width: 11px; height: 11px; }
.tag-doing { background: var(--brand-soft); color: var(--brand-text); }
.tag-blocked { background: var(--warn-bg); color: var(--warn); }
.tag-high { background: var(--danger-bg); color: var(--danger); }
.overdue { color: var(--danger); font-weight: 600; }
.done-tasks { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.done-tasks summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; font-weight: 500; }
.done-tasks .task-list { margin-top: 6px; }

/* --- Dialog --- */

dialog {
  width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(15, 12, 24, 0.5); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 8px; }
.dialog-body { padding: 8px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--border); margin-top: 8px; }
.spacer { flex: 1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field-label { font-size: 0.84rem; font-weight: 600; color: var(--muted); padding: 0; }
.hint { font-size: 0.78rem; color: var(--faint); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; background: var(--surface-2);
}
.ai-grid .check { font-size: 0.88rem; }
.add-other { display: flex; gap: 8px; margin-top: 6px; }
.form-error { color: var(--danger); margin: 0 20px; font-size: 0.88rem; }
.form-error:empty { display: none; }

/* --- API page --- */

.prose { max-width: 900px; }
.prose h2 { margin: 22px 0 8px; }
.prose h2:first-child { margin-top: 0; }
.prose p { margin: 0 0 10px; max-width: 75ch; color: var(--muted); }
.code { position: relative; margin: 8px 0 12px; }
.code pre {
  margin: 0; padding: 14px 44px 14px 14px; overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); line-height: 1.5;
}
.code .copy { position: absolute; top: 6px; right: 6px; }
.endpoints { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; }
.endpoint { display: grid; grid-template-columns: 64px minmax(180px, 260px) minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 10px 12px; border-top: 1px solid var(--border); }
.endpoint:first-child { border-top: 0; }
.endpoint p { margin: 0; font-size: 0.88rem; }
.method { font: 700 0.72rem var(--font-mono); padding: 2px 6px; border-radius: 4px; text-align: center; }
.m-get { color: var(--info); background: var(--info-bg); }
.m-post { color: var(--ok); background: var(--ok-bg); }
.m-put { color: var(--warn); background: var(--warn-bg); }

.prose + .prose { margin-top: 14px; }
.token-add { display: flex; gap: 8px; margin: 12px 0; max-width: 640px; }
.token-reveal { border: 1px solid var(--border-strong); background: var(--warn-bg); border-radius: var(--radius-sm); padding: 12px 14px 2px; margin-bottom: 12px; }
.token-reveal[hidden] { display: none; }
.token-reveal p { color: var(--ink); }
.token-reveal .code pre { background: var(--surface); word-break: break-all; white-space: pre-wrap; }
.tokens { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.token-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.3fr) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.token-main { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.token-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Sign-in page --- */

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-body::before { content: ''; position: fixed; inset: 0 0 auto; height: 3px; background: var(--grad); }
.login-card {
  width: min(400px, 100%); padding: 32px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-card img { height: 24px; width: auto; }
.login-card h1 { margin-top: 18px; font-size: 1.35rem; }
.login-card .sub { margin: 6px 0 20px; }
.login-msg { margin: 0 0 16px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--neutral-bg); color: var(--ink); font-size: 0.88rem; text-align: left; }
.login-msg.error { background: var(--danger-bg); color: var(--danger); }
.ms-btn { width: 100%; min-height: 42px; gap: 10px; font-size: 0.95rem; }

/* --- Toast --- */

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 0.9rem; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }

/* --- Narrow screens --- */

@media (max-width: 1080px) {
  .row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 110px minmax(0, 1.5fr) minmax(0, 1.2fr); }
  .row .c-ai, .row.head > :nth-child(3) { display: none; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts-wide { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-grid, .highlights { grid-template-columns: minmax(0, 1fr); }
  .row.head { display: none; }
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name status" "customer customer" "ai ai" "last tasks";
    gap: 10px 16px;
  }
  .row .c-ai { display: block; }
  .c-name { grid-area: name; }
  .c-status { grid-area: status; }
  .c-customer { grid-area: customer; }
  .c-ai { grid-area: ai; }
  .c-last { grid-area: last; }
  .c-tasks { grid-area: tasks; }
  .cell-label { display: block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
  .c-customer { display: flex; gap: 8px; align-items: baseline; }
  .endpoint { grid-template-columns: 56px minmax(0, 1fr); }
  .endpoint p { grid-column: 1 / -1; }
  .user-name { display: none; }
  .token-row { grid-template-columns: minmax(0, 1fr) auto; }
  .token-row .muted { grid-column: 1; }
  .token-row .btn { grid-column: 2; grid-row: 1; }
}

@media (max-width: 560px) {
  h1 { font-size: 1.35rem; }
  .topbar-inner { gap: 8px; }
  .brand img { height: 15px; }
  .brand-label { display: none; }
  .topnav a { padding: 6px 8px; }
  #new-project { padding: 0 10px; }
  #new-project .label { display: none; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat-label { font-size: 0.7rem; }
  .stat-value { font-size: 1.5rem; }
  .stat-sub { font-size: 0.74rem; line-height: 1.35; }
  .run-list li { grid-template-columns: auto minmax(0, 1fr); }
  .run-list time { display: none; }
  .group-head { flex-wrap: wrap; row-gap: 6px; padding: 12px; }
  .group-meta { width: 100%; margin-left: 58px; gap: 12px; }
  .group-latest { display: none; }
  .group-toggle { margin-left: 0; }
  .group-toggle button { flex: 1; }
  .expand-all { margin-left: 0; }
  .filters > * { flex: 1 1 100%; }
  .field-inline select, .select-like { width: 100%; max-width: none; }
  .row { grid-template-areas: "name status" "customer customer" "ai ai" "last last" "tasks tasks"; }
  .card { padding: 16px; }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .two, .ai-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ev-actions { opacity: 1; }
}
