:root {
  --bg: #ffffff; --panel: #fff; --ink: #1c1d21; --muted: #71717a; --line: #ebebeb; --soft: #f7f7f7;
  --accent: #ff7a45; --accent-ink: #fff; --danger: #c93a3a;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; height: 56px; padding: 0 28px; background: var(--soft); border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.top .links { display: flex; gap: 4px; height: 100%; overflow-x: auto; }
.top .links a { display: flex; align-items: center; padding: 0 12px; color: #71717a; text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.top .links a:hover { color: var(--ink); }
.top .links a.active { color: var(--ink); border-bottom-color: var(--accent); }
.usermenu { margin-left: auto; position: relative; }
.usermenu summary { list-style: none; cursor: pointer; font-size: 13px; color: #71717a; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; white-space: nowrap; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary::after { content: " ▾"; }
.usermenu .dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-width: 160px; box-shadow: 0 8px 24px rgba(0,0,0,.08); display: flex; flex-direction: column; }
.usermenu .dropdown a { padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.usermenu .dropdown a:hover, .usermenu .dropdown a.active { background: var(--soft); }
main { padding: 24px 28px; max-width: 1600px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h1 { margin: 0 auto 0 0; }
.toolbar h1:has(+ .tabs) { margin-right: 12px; }
input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
textarea { min-height: 80px; resize: vertical; }
.toolbar input[type=search] { width: 240px; }
button { font: inherit; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
button.primary { background: #18181b; color: #fff; border-color: #18181b; font-weight: 600; }
button.primary:hover { background: #27272a; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--soft); font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fff8f4; }
.muted { color: var(--muted); }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; width: auto; flex: 1 1 0; min-width: 190px; padding: 10px; min-height: 120px; }
.col.over { outline: 2px dashed var(--accent); }
.col h3 { font-size: 13px; margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.card { background: #fff; border-radius: 8px; padding: 10px; margin-bottom: 8px; border: 1px solid var(--line); cursor: grab; }
.card:hover { border-color: #d4d4d8; }
.card .t { font-weight: 600; }
.card .s { font-size: 12px; color: var(--muted); margin-top: 3px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 16px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field.wide { grid-column: 1 / -1; }
.panel { background: var(--panel); border-radius: 10px; padding: 18px; border: 1px solid var(--line); margin-bottom: 16px; }
.note { border-bottom: 1px solid var(--line); padding: 10px 0; white-space: pre-wrap; }
.note .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
dialog { border: none; border-radius: 12px; padding: 0; width: min(640px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog form { padding: 20px; }
dialog h2 { margin-top: 0; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; background: #eee; font-size: 12px; }
.err { background: #fde8e8; color: var(--danger); padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.key { font-family: ui-monospace, monospace; background: var(--soft); padding: 10px; border-radius: 8px; word-break: break-all; border: 1px solid var(--line); }
@media (max-width: 760px) {
  .top { gap: 12px; padding: 0 12px; }
  .top .brand { display: none; }
  main { padding: 16px; }
}

.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; text-align: center; margin-left: 4px; }
.badge:empty { display: none; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fff; }
.task:last-child { border-bottom: none; }
.task input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 auto; cursor: pointer; }
.task .body { flex: 1; min-width: 0; }
.task .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.task.done .ttl { text-decoration: line-through; color: var(--muted); }
.task .over { color: var(--danger); font-weight: 600; }
.tasklist { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 8px; }
.addtask { display: grid; grid-template-columns: 1fr 120px 150px 110px 170px auto; gap: 8px; margin-bottom: 12px; }
@media (max-width: 760px) { .addtask { grid-template-columns: 1fr; } }

.dash { display: grid; grid-template-columns: 3fr 6fr 3fr; gap: 20px; align-items: start; }
.dash .panel { padding: 16px; }
.dash h2.dh { margin: 0 0 10px; font-size: 20px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dash h2.dh svg { width: 20px; height: 20px; flex: 0 0 auto; }
.dash h2.dh .act-link { margin-left: auto; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; }
.dash h2.dh .act-link:hover { color: var(--accent); }
.dash section { margin-bottom: 24px; }
.kpis { display: flex; gap: 24px; margin-bottom: 8px; flex-wrap: wrap; }
.kpi .v { font-size: 20px; font-weight: 700; }
.kpi .l { font-size: 12px; color: var(--muted); }
.person { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.person:last-child { border-bottom: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; font-size: 13px; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.person .s, .act .s { font-size: 13px; color: var(--muted); }
.person .n { font-weight: 500; }
.act { padding: 10px 0; border-bottom: 1px solid var(--line); }
.act:last-child { border-bottom: none; }
.act .b { white-space: pre-wrap; margin-top: 3px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.dash .task { padding: 8px 0; }
@media (max-width: 1100px) { .dash { grid-template-columns: 1fr; } }

tbody tr:last-child td { border-bottom: none; }

main a { color: var(--ink); text-decoration-color: #c4c4c8; text-underline-offset: 2px; }
main a:hover { color: var(--accent); text-decoration-color: currentColor; }

.col.closed { width: 96px; min-width: 96px; flex: 0 0 96px; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; background: #fff; border-style: dashed; }
.col.closed .cname { font-size: 13px; font-weight: 600; }
.col.closed .cnum { font-size: 22px; font-weight: 700; }
.col.closed.won { border-color: #3fb39a; } .col.closed.won .cnum, .col.closed.won .cname { color: #2a8f79; }
.col.closed.lost { border-color: #e25c3b; } .col.closed.lost .cnum, .col.closed.lost .cname { color: #c4462a; }
.col.closed.over { background: #fff8f4; }
.closed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.closed-grid h2.dh { font-size: 20px; font-weight: 600; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; }
.closed-grid h2.dh span { font-size: 14px; color: var(--muted); font-weight: 500; }
.closed-grid h2.won { color: #2a8f79; } .closed-grid h2.lost { color: #c4462a; }
.tabs { display: flex; gap: 4px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.tabs a { padding: 5px 12px; border-radius: 6px; text-decoration: none; color: var(--muted); font-weight: 500; }
.tabs a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
@media (max-width: 900px) { .closed-grid { grid-template-columns: 1fr; } }

@media (max-width: 760px) { .col.closed.later { border-color: #a1a1aa; } .col.closed.later .cnum, .col.closed.later .cname { color: #52525b; } }
.hist { padding: 8px 0; border-bottom: 1px solid var(--line); }
.hist:last-child { border-bottom: none; }
.hist .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* deal card signals (activity, rotting, owner) */
.card .meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11.5px; }
.card .meta .avatar { margin-left: auto; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.act-ic { font-weight: 600; white-space: nowrap; }
.act-ic.warn { color: #b45309; }
.act-ic.late { color: #dc2626; }
.act-ic.today { color: #16a34a; }
.act-ic.plan { color: var(--muted); }
.days { color: var(--muted); }
.days.rot { color: #dc2626; font-weight: 700; }
.card.rotting { border-color: #fca5a5; background: #fff7f7; }
.owner-filter { width: auto; margin-left: 4px; padding: 6px 10px; font-size: 13px; }
.closed-grid td:last-child { white-space: nowrap; }

/* column quick add */
.col h3 .col-add { margin-left: 6px; padding: 0 7px; line-height: 18px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 14px; cursor: pointer; }
.col h3 .col-add:hover { color: var(--ink); border-color: #d4d4d8; }

/* search */
.searchbtn { margin-left: auto; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 13px; cursor: pointer; min-width: 180px; justify-content: space-between; }
.searchbtn kbd { font-family: inherit; font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.searchbtn + .usermenu { margin-left: 8px; }
dialog.search { width: min(620px, 94vw); padding: 0; margin-top: 12vh; }
dialog.search::backdrop { background: rgba(0,0,0,.25); }
dialog.search #sq { width: 100%; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 18px; font-size: 16px; outline: none; }
.sr { max-height: 420px; overflow-y: auto; padding: 6px; }
.sr p { padding: 10px 12px; margin: 0; }
.sr-g { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px 4px; }
.sr-i { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--ink); text-decoration: none; }
.sr-i .muted { font-size: 12px; text-align: right; }
.sr-i.on { background: var(--soft); }

/* activity timeline */
.tl-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.tl-filters a { cursor: pointer; }
.tl-list { margin-top: 14px; }
.tl { padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl:last-child { border-bottom: none; }
.tl-h { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; }
.tl-h svg { width: 15px; height: 15px; color: var(--muted); flex: 0 0 auto; }
.tl-h .s { font-size: 12px; color: var(--muted); }
.tl-b { margin: 6px 0 0 21px; white-space: pre-wrap; }
.tl.email details { margin: 6px 0 0 21px; }
.tl.email summary { cursor: pointer; list-style: none; }
.tl.email summary::-webkit-details-marker { display: none; }
.tl.email.in .tl-h svg { color: #2563eb; }
.mailbody { white-space: pre-wrap; font-family: inherit; font-size: 13px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 8px 0 0; max-height: 420px; overflow: auto; }
@media (max-width: 760px) { .searchbtn { min-width: 0; } .searchbtn kbd { display: none; } }
.col h3 { gap: 6px; }
.col h3 > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.col h3 > span:last-child { white-space: nowrap; flex: 0 0 auto; }
.tl.email details[open] summary .muted { display: none; }
.col h3 { align-items: flex-start; }
.col h3 .csub { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.ttype { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; margin-right: 6px; background: var(--soft); color: var(--muted); border: 1px solid var(--line); vertical-align: 1px; }
.ttype.call { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.ttype.meeting { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.ttype.email { background: #faf5ff; color: #7e22ce; border-color: #e9d5ff; }
.ttype.follow-up { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.addtask select, .addtask input { width: 100%; min-width: 0; }
.claude-panel .steps { padding-left: 18px; line-height: 1.7; }
.claude-panel code { font-size: 12px; background: var(--soft); padding: 2px 6px; border-radius: 5px; word-break: break-all; }
