:root {
  --ink: #0f2a3a; --ink-2: #3a5565; --muted: #6b8392; --line: #dde5ea; --line-2: #eef2f5; --bg: #f4f7f9; --panel: #fff;
  --side: #0f2a3a; --accent: #f2a33a; --blue: #3b82a0; --red: #c0392b; --green: #1f8a5b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--blue); text-decoration: none; } a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); } .small { font-size: 12px; } .num { font-variant-numeric: tabular-nums; } .r { text-align: right; } .c { text-align: center; }
.big { font-size: 18px; } .late { color: var(--red); } .grow { flex: 1; } .prewrap { white-space: pre-wrap; margin: 12px 0 0; } .linkish { text-transform: none; letter-spacing: 0; }

input, select, textarea, button { font: inherit; }
input, select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: #fff; color: var(--ink); min-width: 0; }
textarea { min-height: 70px; resize: vertical; width: 100%; }
input[type=checkbox] { accent-color: var(--ink); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f2f6f8; text-decoration: none; } .btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 4px 8px; font-size: 12px; } .btn.ghost { border-color: transparent; background: none; } .btn.ghost:hover { background: var(--line-2); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); } .btn.primary:hover { background: #17415a; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #2a1a00; font-weight: 600; } .btn.accent:hover { background: #f5b455; }
.btn.danger { color: var(--red); } .btn.won { background: var(--green); color: #fff; border-color: var(--green); } .btn.lost { background: var(--red); color: #fff; border-color: var(--red); }

/* shell */
.shell { display: grid; grid-template-columns: 210px 1fr; height: 100vh; height: 100dvh; }
.side { background: var(--side); color: #cfe0ea; display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; }
.brand { color: #fff; font-weight: 700; font-size: 17px; padding: 6px 10px 18px; display: flex; align-items: center; gap: 8px; }
.brand small { font-weight: 400; color: #8fb0c2; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav a { display: flex; align-items: center; gap: 10px; color: #cfe0ea; padding: 9px 10px; border-radius: 6px; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; } .nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.me { margin-top: auto; padding: 10px; font-size: 13px; color: #cfe0ea; } .me b { color: #fff; display: block; }
.me button { background: none; border: 0; color: var(--accent); padding: 6px 0 0; cursor: pointer; }
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.top { display: flex; align-items: center; gap: 10px; padding: 12px 22px; background: #fff; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 18px; white-space: nowrap; }
.search { width: 280px; }
.content { padding: 18px 22px 40px; overflow: auto; flex: 1; }

/* panels & tables */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; }
.pad { padding: 14px 16px; } .stack { display: grid; gap: 14px; align-content: start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; } .grid3 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 14px 16px; } .kpi .label { font-size: 12px; color: var(--muted); } .kpi .value { font-size: 26px; font-weight: 650; margin: 4px 0 2px; } .kpi .sub { font-size: 12px; color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; } .list th[data-sort] { cursor: pointer; }
.list th.r { text-align: right; }
.list td { padding: 9px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; } .list tr:last-child td { border-bottom: 0; }
.list tr.click { cursor: pointer; } .list tr.click:hover td { background: #f7fafb; }
.small-table { font-size: 12px; background: #fff; } .empty { padding: 22px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; border-top: 1px solid var(--line-2); color: var(--muted); font-size: 12px; }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); }
.pill.open { background: #e3eef5; color: #17506c; } .pill.won { background: #dcf1e7; color: #146342; } .pill.lost { background: #f7e0dd; color: #8e2a1e; } .pill.overdue { background: #f7e0dd; color: #8e2a1e; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 6px 11px; cursor: pointer; color: var(--ink-2); } .seg button.on { background: var(--ink); color: #fff; }

/* charts */
.bars .row { display: grid; grid-template-columns: 130px 1fr 80px; gap: 10px; align-items: center; margin: 8px 0; } .bars .row.narrow { grid-template-columns: 90px 1fr 80px; }
.bars .track { background: var(--line-2); height: 14px; border-radius: 4px; position: relative; } .bars .fill { background: var(--blue); height: 100%; border-radius: 4px; position: absolute; left: 0; top: 0; }
.bars .fill.w { background: var(--accent); height: 5px; top: auto; bottom: 0; border-radius: 0 0 4px 4px; } .bars .amt { text-align: right; font-variant-numeric: tabular-nums; }
.legend { display: inline-flex; gap: 12px; text-transform: none; letter-spacing: 0; } .legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; }
.cols { display: flex; align-items: flex-end; gap: 10px; height: 160px; } .cols .c { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.cols .v { font-size: 11px; color: var(--ink-2); margin-bottom: 3px; } .cols .b { background: var(--accent); width: 100%; border-radius: 4px 4px 0 0; min-height: 2px; } .cols .m { font-size: 11px; color: var(--muted); margin-top: 5px; }

/* board */
.board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 12px; }
.col { flex: 0 0 270px; background: #e9eff3; border-radius: 8px; padding: 8px; max-height: calc(100vh - 210px); display: flex; flex-direction: column; }
.col.drop { outline: 2px dashed var(--accent); } .col header { padding: 4px 6px 8px; } .cards { overflow-y: auto; display: grid; gap: 8px; align-content: start; min-height: 40px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; cursor: pointer; } .card:hover { border-color: var(--blue); } .card.drag { opacity: .4; }
.card .t { font-weight: 600; margin-bottom: 2px; } .card .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; } .card .val { color: var(--ink); font-weight: 600; }

/* record pages */
.rec { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.rec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; } .rec-head h2 { font-size: 22px; }
.stagebar { display: flex; margin-bottom: 14px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.stagebar button { flex: 1; border: 0; border-right: 1px solid var(--line); background: #fff; padding: 9px 6px; cursor: pointer; color: var(--muted); } .stagebar button:last-child { border-right: 0; }
.stagebar button.done { background: #e3eef5; color: #17506c; } .stagebar button.on { background: var(--ink); color: #fff; } .stagebar button:disabled { cursor: default; }
dl.fields { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; margin: 0; } dl.fields dt { color: var(--muted); } dl.fields dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; } .timeline li { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.timeline .ic { width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--line-2); display: grid; place-items: center; font-size: 13px; }
.timeline .ic.call { background: #e8f1f6; } .timeline .ic.email { background: #fdf1df; } .timeline .ic.meeting { background: #e3f3ea; }
.timeline > li > div:last-child { flex: 1; min-width: 0; } .timeline .h { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; } .timeline .h b { color: var(--ink); font-weight: 500; } .timeline .b { white-space: pre-wrap; margin-top: 2px; }
.composer { padding: 12px 16px; border-bottom: 1px solid var(--line-2); display: grid; gap: 8px; } .composer .row { display: flex; gap: 8px; align-items: center; }
.task-composer { grid-template-columns: 1fr auto auto auto; align-items: center; }
.tasklist { list-style: none; margin: 0; padding: 0; } .tasklist li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 16px; border-bottom: 1px solid var(--line-2); }
.tasklist li.done .tt { text-decoration: line-through; color: var(--muted); } .tasklist input[type=checkbox] { margin-top: 3px; width: 15px; height: 15px; } .tasklist .tt { flex: 1; min-width: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; white-space: nowrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; } .tabs button.on { color: var(--ink); border-color: var(--accent); font-weight: 500; }
.edit-table { width: 100%; border-collapse: collapse; } .edit-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 4px; } .edit-table td { padding: 4px; } .edit-table input:not([type=checkbox]), .edit-table select { width: 100%; }
.narrow { max-width: 520px; } .row-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; } .check { display: flex; gap: 6px; align-items: center; margin-top: 14px; font-size: 13px; }

/* modal & forms */
.overlay { position: fixed; inset: 0; background: rgba(15,42,58,.4); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 10px; width: min(640px, 100%); max-height: 90vh; max-height: 90dvh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 16px 18px; } .modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fafbfc; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; } .form.one { grid-template-columns: 1fr; } .form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); align-content: start; } .form label.full { grid-column: 1 / -1; }
.form input, .form select, .form textarea { width: 100%; font-size: 14px; }
.err { color: var(--red); font-size: 13px; margin-top: 8px; }
.report { font-size: 13px; background: #fafbfc; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-top: 10px; } .report div { margin: 3px 0; } .report-head { font-size: 14px; margin-bottom: 6px; } .report.err { color: var(--red); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; background: var(--side); padding: 16px; }
.auth .box { background: #fff; padding: 28px; border-radius: 12px; width: min(380px, 100%); }
.auth h1 { margin: 0 0 4px; font-size: 20px; display: flex; align-items: center; gap: 10px; } .auth p { margin: 0 0 18px; color: var(--muted); }
.auth label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 12px; } .auth input { width: 100%; padding: 9px 10px; } .auth .btn { width: 100%; justify-content: center; padding: 9px; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } .grid2, .grid3, .rec { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .main { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .side { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); flex-direction: row; box-shadow: 0 -2px 10px rgba(15,42,58,.15); overflow: visible; }
  .side .brand, .side .me { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { flex: 1; flex-direction: column; gap: 3px; padding: 6px 2px; margin: 0; font-size: 10.5px; text-align: center; min-width: 0; } .nav a.on { box-shadow: inset 0 3px 0 var(--accent); border-radius: 0; }
  .top { flex-wrap: wrap; padding: 10px 14px; gap: 8px; } .top h1 { font-size: 16px; white-space: normal; flex: 1; min-width: 0; } .top .grow { display: none; } .search { width: 100%; order: 10; }
  .content { padding: 14px 12px 24px; } .form { grid-template-columns: 1fr; } .kpi .value { font-size: 20px; } .panel { overflow-x: auto; }
  .bars .row { grid-template-columns: 96px 1fr 76px; } .rec-head h2 { font-size: 19px; width: 100%; }
  .stagebar { overflow-x: auto; } .stagebar button { flex: 0 0 auto; padding: 7px 10px; }
  .col { flex-basis: 82vw; max-height: none; } .board { scroll-snap-type: x mandatory; } .col { scroll-snap-align: start; }
  .task-composer { grid-template-columns: 1fr 1fr; } .task-composer #ttitle { grid-column: 1 / -1; }
  .modal { max-height: 100dvh; } .overlay { padding: 8px; } .filters input[type=search] { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* sign-in: Google */
.btn.google { width: 100%; justify-content: center; padding: 9px; gap: 10px; font-weight: 500; }
.auth .or { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 12px; }
.auth .or::before, .auth .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-error { background: #fbeceb; border: 1px solid #f0c9c5; border-radius: 6px; padding: 8px 10px; margin: 0 0 14px; margin-top: 0; }

/* feedback button + dialog */
.nowrap { white-space: nowrap; }
.fb-btn { position: fixed; right: 18px; bottom: 18px; z-index: 40; display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 99px; padding: 10px 16px; cursor: pointer;
  background: var(--ink); color: #fff; box-shadow: 0 4px 14px rgba(15,42,58,.35); font-weight: 500; }
.fb-btn:hover { background: #17415a; }
.fb-form .seg { justify-self: start; }
.fb-drop { border: 2px dashed var(--line); border-radius: 8px; padding: 18px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.fb-drop.over, .fb-drop:focus-visible { border-color: var(--accent); background: #fff8ee; }
.fb-pick { color: var(--blue); cursor: pointer; text-decoration: underline; display: inline; }
.fb-preview { display: flex; align-items: flex-start; gap: 10px; } .fb-preview img { max-width: 220px; max-height: 140px; border: 1px solid var(--line); border-radius: 6px; }
.fb-ctx { font-size: 12px; color: var(--muted); } .fb-ctx ul { margin: 6px 0 0; padding-left: 18px; word-break: break-all; }
.fb-title { margin: 0 0 8px; font-size: 16px; } .fb-shot-img { max-width: 100%; max-height: 320px; border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 760px) {
  .fb-btn { bottom: calc(74px + env(safe-area-inset-bottom)); right: 12px; padding: 12px; }
  .fb-btn .fb-label { display: none; }
}

/* The `hidden` attribute must win over any display rule below (e.g. .fb-preview { display: flex }). */
[hidden] { display: none !important; }
