/* ---------- tokens ---------- */
:root {
  --bg: #f3f5f9; --card: #ffffff; --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --line: #e2e8f0; --line-2: #cbd5e1;
  --brand: #2563eb; --brand-2: #1d4ed8; --brand-soft: #dbeafe;
  --ok: #15803d; --ok-soft: #dcfce7; --bad: #b91c1c; --bad-soft: #fee2e2; --warn: #b45309; --warn-soft: #fef3c7; --info: #0369a1; --info-soft: #e0f2fe;
  --side: #0b1220; --side-2: #121b2f; --side-ink: #cbd5e1;
  --r: 12px; --r-sm: 8px; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.06); --shadow-lg: 0 10px 30px rgba(15,23,42,.14);
  --sidebar-w: 248px; --t: .18s cubic-bezier(.2,.7,.3,1);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; } body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0; } h2 { font-size: 15px; font-weight: 700; margin: 0; } h3 { font-size: 15px; margin: 0; }
code { font: 12.5px ui-monospace, SFMono-Regular, Consolas, monospace; background: #eef2f7; padding: 1px 6px; border-radius: 5px; color: var(--ink-2); }
.muted { color: var(--muted); } small { color: var(--muted); font-weight: 400; } .link { font-weight: 500; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: linear-gradient(180deg, var(--side), var(--side-2)); color: var(--side-ink); display: flex; flex-direction: column; position: fixed; left: 0; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; transition: transform var(--t); z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.logo, .auth-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 17px; box-shadow: 0 4px 12px rgba(37,99,235,.4); }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: var(--side-ink); font-weight: 500; transition: background var(--t), color var(--t), transform var(--t); }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; transform: translateX(2px); }
.nav a.on { background: rgba(37,99,235,.22); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav svg { opacity: .85; }
.side-foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; gap: 10px; align-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #1e293b; color: #fff; display: grid; place-items: center; font-weight: 700; }
.side-user { display: flex; flex-direction: column; line-height: 1.25; } .side-user b { color: #fff; font-size: 13px; } .side-user a { color: #94a3b8; font-size: 12px; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar { height: 54px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: rgba(255,255,255,.75); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.crumbs { color: var(--ink-2); font-weight: 500; } .crumbs span { color: var(--line-2); margin: 0 6px; }
.menu-btn { display: none; }
.content > main { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 20; }

/* ---------- page head / cards ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.grid { display: grid; gap: 18px; } .grid > *, .card, .content, main { min-width: 0; } @media (max-width: 960px) { .grid { grid-template-columns: 1fr !important; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; color: inherit; box-shadow: var(--shadow); transition: transform var(--t), box-shadow var(--t); }
.tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tile b { display: block; font-size: 26px; line-height: 1.1; } .tile span { color: var(--muted); font-size: 13px; }
.tile-ico { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; }
.t-blue { background: var(--brand-soft); color: var(--brand); } .t-green { background: var(--ok-soft); color: var(--ok); } .t-amber { background: var(--warn-soft); color: var(--warn); } .t-purple { background: #ede9fe; color: #6d28d9; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.pcard { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; color: inherit; box-shadow: var(--shadow); transition: transform var(--t), box-shadow var(--t), border-color var(--t); }
.pcard:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--line-2); }
.pcard-head { display: flex; justify-content: space-between; align-items: center; } .pcard p { margin: 6px 0 12px; min-height: 1.5em; }
.pcard-meta { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 34px 10px; color: var(--muted); } .empty svg { width: 36px; height: 36px; opacity: .4; margin-bottom: 6px; } .empty p { margin: 6px 0 12px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr { transition: background var(--t); } tbody tr:hover { background: #f8fafc; } tbody tr:last-child td { border-bottom: 0; }
tr.rowlink { cursor: pointer; }
td.actions { text-align: right; } td.actions form { display: inline; margin-left: 4px; }
table.editable td input, table.editable td select { padding: 5px 8px; min-width: 10em; } .w5 { width: 5.5em; min-width: 5.5em !important; } .w9 { width: 9.5em; min-width: 9.5em !important; }

/* ---------- forms ---------- */
label { display: block; font-weight: 500; color: var(--ink-2); font-size: 13px; }
label > input, label > select, label > textarea { margin-top: 5px; }
.stack > * + * { margin-top: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } @media (max-width: 600px) { .row2 { grid-template-columns: 1fr; } }
input, select, textarea { font: inherit; color: var(--ink); width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; transition: border-color var(--t), box-shadow var(--t); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; resize: vertical; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; } label.inline input { margin: 0; width: auto; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.alert { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 12px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 400; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { width: 38px; height: 22px; border-radius: 11px; background: var(--line-2); position: relative; transition: background var(--t); flex: 0 0 auto; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--t); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); } .switch input:checked + span::after { transform: translateX(16px); }
.switch.sm span { width: 30px; height: 18px; } .switch.sm span::after { width: 12px; height: 12px; } .switch.sm input:checked + span::after { transform: translateX(12px); }

/* ---------- buttons ---------- */
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: #fff; color: var(--ink); cursor: pointer; transition: background var(--t), transform var(--t), box-shadow var(--t), border-color var(--t); white-space: nowrap; }
.btn:hover { background: #f8fafc; text-decoration: none; } .btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); } .btn.primary:hover { background: var(--brand-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; } .btn.danger:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); } .btn.ghost:hover { background: #eef2f7; }
.btn.ghost.danger { color: var(--bad); } .btn.ghost.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; } .btn.block { width: 100%; }
.icon-btn { background: transparent; border: 0; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; cursor: pointer; font-size: 14px; transition: background var(--t), color var(--t); }
.icon-btn:hover { background: #eef2f7; color: var(--ink); } .icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad); }

/* ---------- pills / status ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.soft { background: var(--info-soft); color: var(--info); } .pill.soft.warn { background: var(--warn-soft); color: var(--warn); } .pill.soft.ok { background: var(--ok-soft); color: var(--ok); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: #eef2f7; color: var(--ink-2); font-size: 12px; margin-right: 4px; }
.st { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e2e8f0; color: var(--ink-2); vertical-align: middle; }
.st.lg { font-size: 13px; padding: 4px 12px; }
.st i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-ok { background: var(--ok-soft); color: var(--ok); } .st-failed { background: var(--bad-soft); color: var(--bad); }
.st-running { background: var(--brand-soft); color: var(--brand); } .st-running i { animation: pulse 1s ease-in-out infinite; }
.st-pending { background: var(--warn-soft); color: var(--warn); } .st-cancelled { background: #e2e8f0; color: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); display: inline-block; } .dot.ok { background: var(--ok); }

/* ---------- project members ---------- */
.members { display: flex; flex-direction: column; gap: 12px; }
.member { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; transition: border-color var(--t), box-shadow var(--t); }
.member:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.member-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.member-id { display: flex; align-items: center; gap: 8px; } .member-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.chip-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-check span { display: inline-block; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; font-weight: 500; font-size: 13px; cursor: pointer; user-select: none; transition: all var(--t); }
.chip-check span:hover { border-color: var(--brand); color: var(--brand); }
.chip-check input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.chip-check input:focus-visible + span { box-shadow: 0 0 0 3px rgba(37,99,235,.25); }
details.sub summary { cursor: pointer; color: var(--muted); font-size: 13px; list-style: none; } details.sub summary::-webkit-details-marker { display: none; }
details.sub summary::before { content: "▸ "; } details.sub[open] summary::before { content: "▾ "; }
details.sub textarea, details.sub pre { margin-top: 8px; }

/* ---------- dialog ---------- */
.dlg { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--ink); }
.dlg::backdrop { background: rgba(15,23,42,.5); backdrop-filter: blur(2px); }
.dlg[open] { animation: pop .2s ease; } @keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.dlg form { padding: 18px 20px 16px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- terminal / log ---------- */
.term { background: #0b1020; border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-lg); margin-bottom: 18px; }
.term-bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: #121a33; color: #94a3b8; font-size: 12.5px; }
.term-bar .switch { margin-left: auto; color: #cbd5e1; } .term-bar .switch span { background: #334155; }
.term-dots { display: inline-flex; gap: 6px; } .term-dots i { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; } .term-dots i:nth-child(2) { background: #f59e0b; } .term-dots i:nth-child(3) { background: #22c55e; }
pre.log { margin: 0; padding: 14px 16px; color: #d9e1f2; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-height: 68vh; overflow: auto; min-height: 120px; }
pre.code { margin: 0; background: #0b1020; color: #d9e1f2; padding: 12px 14px; border-radius: var(--r-sm); font: 12.5px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow: auto; }
pre.recap { background: #f8fafc; color: var(--ink); border: 1px solid var(--line); }

/* ---------- toast ---------- */
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; z-index: 50; animation: toast-in .3s ease; max-width: 360px; }
.toast.hide { opacity: 0; transform: translateY(8px); transition: all .3s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- auth ---------- */
body.auth { background: radial-gradient(1200px 600px at 20% -10%, #dbeafe 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #e0e7ff 0%, transparent 60%), var(--bg); }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); text-align: center; animation: pop .3s ease; }
.auth-card h1 { margin: 12px 0 2px; } .auth-card p { margin: 0 0 16px; } .auth-card form { text-align: left; } .auth-logo { margin: 0 auto; width: 44px; height: 44px; font-size: 20px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); } .content { margin-left: 0; }
  body.nav-open .sidebar { transform: none; } body.nav-open .backdrop { display: block; }
  .menu-btn { display: inline-grid; } main { padding: 16px; } .topbar { padding: 0 12px; }
  .page-head { flex-direction: column; } .btns { width: 100%; } .btns .btn { flex: 1; }
}
