:root {
  --ink: #1a1d21; --ink-2: #4b5259; --ink-3: #7b838b; --line: #dfe3e7; --line-2: #eef0f2;
  --bg: #f6f7f8; --panel: #ffffff; --accent: #1f3a5f; --accent-2: #e8eef6; --warn: #b4531a; --warn-bg: #fbeee4;
  --ok: #2b7a4b; --ok-bg: #e6f3ea; --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font: 400 26px/1.2 var(--serif); margin: 0 0 4px; } h2 { font: 400 18px/1.25 var(--serif); margin: 0 0 8px; }
h3 { font: 600 12px/1.3 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px; }
.muted { color: var(--ink-3); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }

/* layout */
#app { display: grid; grid-template-columns: 196px 1fr; min-height: 100vh; }
nav.rail { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
nav.rail .brand { font: 600 20px/1 var(--serif); color: var(--accent); padding: 4px 10px 14px; letter-spacing: .01em; }
nav.rail a { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 6px; color: var(--ink-2); }
nav.rail a:hover { background: var(--line-2); text-decoration: none; } nav.rail a.active { background: var(--accent-2); color: var(--accent); font-weight: 600; }
nav.rail .spacer { flex: 1; } nav.rail .who { padding: 8px 10px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); }
nav.rail .search-hint { margin: 4px 0 12px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink-3); background: var(--bg); display: flex; justify-content: space-between; cursor: text; }
nav.rail kbd { font: 11px var(--mono); color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; background: #fff; }
main { padding: 22px 28px 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.head .sub { color: var(--ink-3); }

/* panels & grid */
.grid { display: grid; gap: 14px; } .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.main-side { grid-template-columns: minmax(0, 1fr) 320px; }
@media (max-width: 1000px) { .grid.two, .grid.three, .grid.main-side { grid-template-columns: 1fr; } #app { grid-template-columns: 1fr; } nav.rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } nav.rail .spacer, nav.rail .who, nav.rail .search-hint { display: none; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; min-width: 0; }
.panel + .panel { margin-top: 14px; }
.panel h3 { display: flex; justify-content: space-between; align-items: baseline; }
.panel h3 .act { text-transform: none; letter-spacing: 0; font-weight: 500; }
.stat { display: flex; flex-direction: column; } .stat .n { font: 400 26px/1.1 var(--serif); } .stat .l { color: var(--ink-3); font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 14px; } @media (max-width: 1000px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* tables */
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; white-space: nowrap; }
th.sort { cursor: pointer; } th.sort:hover { color: var(--ink); }
tr.row { cursor: pointer; } tr.row:hover td { background: #fafbfc; }
td .sub { color: var(--ink-3); font-size: 12px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--ink-3); font-size: 12px; }

/* forms & controls */
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
input[type=text], input[type=search], input[type=date], input[type=number], select, textarea { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
input[type=search] { min-width: 260px; } textarea { width: 100%; min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
.btn { padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
.btn:hover { background: var(--line-2); } .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: #17304f; }
.btn.small { padding: 3px 8px; font-size: 12px; } .btn.danger { color: var(--warn); border-color: #f0d3c4; } .btn.link { border: none; background: none; color: var(--accent); padding: 2px 4px; }
.form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; } .form.one { grid-template-columns: 1fr; } .form .full { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-3); } .form label > * { font-size: 14px; color: var(--ink); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* tags & pills */
.pill { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.t1 { background: #fde8e8; color: #8b1e1e; } .pill.t2 { background: #fdf1dc; color: #7a4b00; } .pill.t3 { background: var(--line-2); }
.pill.kind-note { background: var(--accent-2); color: var(--accent); } .pill.kind-email { background: #eef7ee; color: var(--ok); } .pill.kind-call { background: #fdf1dc; color: #7a4b00; } .pill.kind-meeting, .pill.kind-tour { background: #f1e8fb; color: #5b2f8f; }
.pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.ok { background: var(--ok-bg); color: var(--ok); }
.stage { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--accent-2); color: var(--accent); font-size: 12px; }

/* detail */
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; } .dl dt { color: var(--ink-3); font-size: 12px; padding-top: 2px; } .dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline .item { padding: 10px 0; border-bottom: 1px solid var(--line-2); } .timeline .item:last-child { border-bottom: none; }
.timeline .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-3); margin-bottom: 3px; flex-wrap: wrap; }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; } .timeline .subject { font-weight: 600; }
.timeline .body.clamp { max-height: 6.5em; overflow: hidden; position: relative; } .timeline .more { font-size: 12px; }
.note-box { display: grid; gap: 8px; } .note-box .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.list { list-style: none; margin: 0; padding: 0; } .list li { padding: 6px 0; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; gap: 8px; align-items: baseline; } .list li:last-child { border-bottom: none; }
.task.done { text-decoration: line-through; color: var(--ink-3); } .task input { margin-right: 6px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--line-2); border-radius: 8px; padding: 8px; min-height: 120px; } .col h4 { margin: 0 4px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); display: flex; justify-content: space-between; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; } .card:hover { border-color: var(--accent); } .card .amt { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }

/* palette */
#palette { position: fixed; inset: 0; background: rgba(20, 24, 30, .35); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 50; }
#palette .box { width: min(720px, 92vw); background: #fff; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); overflow: hidden; }
#palette input { width: 100%; padding: 14px 16px; border: none; border-bottom: 1px solid var(--line); font-size: 16px; outline: none; }
#palette .results { max-height: 60vh; overflow: auto; padding: 6px 0; }
#palette .group { padding: 6px 16px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
#palette .hit { padding: 7px 16px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; } #palette .hit.sel, #palette .hit:hover { background: var(--accent-2); }
#palette .hit .sub { color: var(--ink-3); font-size: 12px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 6px; font-size: 13px; z-index: 60; }
.login { max-width: 360px; margin: 14vh auto; } .login .panel { padding: 24px; }
.empty { color: var(--ink-3); padding: 14px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; } .chip { padding: 2px 8px; border: 1px solid var(--line); border-radius: 12px; font-size: 12px; background: #fff; cursor: pointer; } .chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pick { position: relative; } .pick .menu { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 20; max-height: 240px; overflow: auto; }
.pick .menu div { padding: 6px 10px; cursor: pointer; } .pick .menu div:hover { background: var(--accent-2); }
