:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d1f20;
  --muted: #6b7177;
  --line: #e6e8eb;
  --orange: #f6821f;
  --orange-ink: #b45f0a;
  --tint: #fff6ec;
  --ok: #0a8a45;
  --warn: #b45309;
  --radius: 12px;
}
* { box-sizing: border-box; }
/* `hidden` must always win over the display:grid on .login/.shell below. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.muted { color: var(--muted); }
.err { color: #c02626; font-size: 13px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.01em; }
.logo {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--orange); color: #fff; font-weight: 800; font-size: 13px;
}
button {
  font: inherit; cursor: pointer; border: 1px solid var(--orange); background: var(--orange);
  color: #fff; padding: 8px 14px; border-radius: 9px; font-weight: 600;
}
button.ghost { background: #fff; color: var(--ink); border-color: var(--line); font-weight: 500; }
button.link { background: none; border: none; color: var(--orange-ink); padding: 0; font-weight: 500; }
button.danger { background: #fff; color: #c02626; border-color: #f0caca; }
button:disabled { opacity: 0.5; cursor: default; }
input, select, textarea {
  font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; color: var(--ink);
}
textarea { min-height: 72px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.field { margin: 0 0 12px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; width: 340px; display: grid; gap: 12px;
}

/* Shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--panel); border-right: 1px solid var(--line); padding: 20px 16px;
  display: flex; flex-direction: column; gap: 18px;
}
.side nav { display: grid; gap: 2px; }
.side nav button {
  background: none; border: none; color: var(--ink); text-align: left; padding: 9px 11px;
  border-radius: 8px; font-weight: 500;
}
.side nav button:hover { background: var(--bg); }
.side nav button.active { background: var(--tint); color: var(--orange-ink); font-weight: 600; }
.side-foot { margin-top: auto; display: grid; gap: 6px; font-size: 13px; }
.main { padding: 26px 30px; overflow-x: auto; }

.head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 18px; gap: 16px; }
.head h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } .shell { grid-template-columns: 1fr; } .side { flex-direction: row; flex-wrap: wrap; align-items: center; } .side nav { grid-auto-flow: column; } .side-foot { margin: 0; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: none; }
.row .t { font-weight: 600; }
.row .s { font-size: 12.5px; color: var(--muted); }

.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.pill.ok { background: #e7f6ee; color: var(--ok); }
.pill.warn { background: #fdf0e0; color: var(--warn); }
.pill.draft { background: #eef1f4; color: #5a6472; }

.list-item { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.list-item + .list-item { margin-top: 8px; }
.list-item.sel { border-color: var(--orange); background: var(--tint); }

.empty { color: var(--muted); font-size: 14px; padding: 18px 0; text-align: center; }
.inline { display: flex; gap: 8px; align-items: center; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.flags { display: grid; gap: 6px; }
.flag { background: #fdf0e0; border: 1px solid #f6dcbb; color: var(--warn); padding: 8px 10px; border-radius: 8px; font-size: 13px; }

/* Project-centric shell */
.small { font-size: 13px; padding: 6px 10px; }
.side-section { display: grid; gap: 6px; }
.side-head { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.project-list { display: grid; gap: 2px; }
.project-item { display: flex; align-items: center; gap: 8px; background: none; border: none; color: var(--ink); text-align: left; padding: 8px 10px; border-radius: 8px; font-weight: 500; }
.project-item:hover { background: var(--bg); }
.project-item.sel { background: var(--tint); color: var(--orange-ink); font-weight: 600; }
.pdot { width: 7px; height: 7px; border-radius: 50%; background: #c8ccd0; flex: none; }
.project-item.sel .pdot { background: var(--orange); }
.side-link { background: none; border: none; color: var(--ink); text-align: left; padding: 8px 10px; border-radius: 8px; font-weight: 500; width: 100%; }
.side-link:hover { background: var(--bg); }
.side-link.active { background: var(--tint); color: var(--orange-ink); font-weight: 600; }

.ws-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 16px; }
.ws-head h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.ws-head .s { color: var(--muted); font-size: 13px; }
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 12px; border-radius: 0; font-weight: 600; text-transform: capitalize; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--orange-ink); border-bottom-color: var(--orange); }
.metrics { display: flex; gap: 22px; }
.metrics .k { font-size: 22px; font-weight: 700; }
.metrics .s { color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #fff; border: 1px solid var(--line); color: var(--muted); padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; }
.chip.on { background: var(--tint); border-color: var(--orange); color: var(--orange-ink); font-weight: 600; }
.linkish { background: none; border: none; text-align: left; padding: 0; flex: 1; cursor: pointer; color: var(--ink); min-width: 0; }
.linkish:hover .t, .linkish:hover .acct-name { color: var(--orange-ink); }
.chatlog { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.bubble { padding: 8px 12px; border-radius: 12px; max-width: 80%; white-space: pre-wrap; font-size: 14px; }
.bubble.user { align-self: flex-end; background: var(--tint); border: 1px solid #f7dcbf; }
.bubble.agent { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
/* list rows (GoLogin-style) */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 11px 6px; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: none; }
.list-row .lead { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; background: none; border: none; text-align: left; cursor: pointer; color: var(--ink); padding: 0; }
.list-row button.lead:hover .row-title { color: var(--orange-ink); }
.grow { min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.acct-av { width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px; }
.acct-av.sm { width: 34px; height: 34px; font-size: 14px; border-radius: 9px; }
.meta { display: flex; gap: 6px; align-items: center; flex: none; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--bg); color: var(--muted); font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.badge.cur { background: #eef3ff; color: #3557b7; }
.badge.mgr { background: #fdf0e0; color: var(--warn); }

/* context menu */
.menu-wrap { position: relative; flex: none; }
.menu-btn { background: none; border: 1px solid transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 8px; }
.menu-btn:hover { background: var(--bg); color: var(--ink); }
.menu { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(20, 24, 28, 0.14); min-width: 168px; padding: 5px; z-index: 60; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--ink); padding: 8px 10px; border-radius: 7px; font-weight: 500; font-size: 14px; }
.menu button:hover { background: var(--bg); }
.menu button.danger { color: #c02626; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(20, 24, 28, 0.4); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 16px; padding: 22px; max-width: 440px; width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.detail { display: grid; gap: 2px; }
.drow { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--line); }
.drow:first-child { border-top: none; }
.dk { color: var(--muted); font-size: 13.5px; }
.dv { font-weight: 600; text-align: right; word-break: break-word; }

/* mobile */
@media (max-width: 640px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 14px; border-right: none; border-bottom: 1px solid var(--line); }
  .side-section { display: block; }
  .side-head { margin-bottom: 4px; }
  .project-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
  .project-item { flex: none; }
  #newProject { margin-top: 6px; }
  .side nav, .side-section:last-of-type { display: flex; gap: 6px; flex-wrap: wrap; }
  .side-foot { margin-top: 4px; flex-direction: row; align-items: center; gap: 12px; }
  .main { padding: 18px 14px; overflow-x: hidden; }
  .meta-hide { display: none; }
  .card { padding: 14px; }
  .grid2 { grid-template-columns: 1fr; }
  .ws-head h1 { font-size: 19px; }
  .inline { flex-wrap: wrap; }
  input, select, textarea { width: 100%; }
  .drow { flex-direction: column; gap: 2px; }
  .dv { text-align: left; }
  .modal { padding: 18px; border-radius: 14px; }
  .menu { min-width: 150px; }
}
