:root {
  --ink: #182321; --muted: #586D61; --soft: #3F5249; --bg: #F1F7F2; --card: #FFFFFF;
  --line: #D4E2D8; --line2: #E6EEE8; --tint: #E4EFE7; --green: #60D23B; --deep: #185D3A; --won: #20824D;
  --amber: #C2531F; --warn: #A8461A; --lost: #8A8E95; --mint: #DEF3E2;
  --r: 10px; --pad: 20px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%; padding-bottom: env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--deep); }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
[hidden] { display: none !important; }
.loading { padding: 60px 20px; text-align: center; color: var(--muted); }

/* Buttons */
.btn { min-height: 44px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card);
  font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.go { background: var(--green); border-color: var(--green); color: var(--ink); }
.btn.danger { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.danger-line { color: var(--warn); border-color: var(--line); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* Sign in */
.signin { max-width: 420px; margin: 0 auto; padding: 64px 20px; display: flex; flex-direction: column; gap: 16px; }
.signin h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; line-height: 1.1; }
.signin p { margin: 0; color: var(--soft); }
.brand { font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--deep); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field input, .field select, .field textarea { min-height: 48px; border: 1px solid #A8BEB0; border-radius: 6px; padding: 0 12px;
  font-size: 16px; background: #fff; width: 100%; }
.field textarea { padding: 10px 12px; min-height: 96px; resize: vertical; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 14px var(--pad); display: flex; align-items: center; gap: 12px; }
.top .biz { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .biz small { font-weight: 500; color: var(--muted); margin-left: 8px; font-size: 14px; }
.top select { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: #fff; }

main { max-width: 1240px; margin: 0 auto; padding: 20px var(--pad) 120px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; line-height: 1.1; }
.head .sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
.head .sub b { color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: var(--r); background: var(--tint); }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; font-weight: 700; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Groups and rows */
.group { margin-top: 22px; }
.group-h { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 10px; background: none; border: 0; padding: 0; text-align: left; }
.group-h .t { white-space: nowrap; }
.group-h .t { font-size: 12px; font-weight: 800; letter-spacing: .14em; color: var(--deep); }
.group-h .n { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--tint); font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; }
.group-h .n.hot { background: var(--amber); color: #fff; }
.group-h .h { font-size: 14px; color: var(--muted); }
.rows { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row + .row { border-top: 1px solid var(--line2); }
.row > button.sum { width: 100%; text-align: left; background: none; border: 0; padding: 14px 18px; display: grid; gap: 12px; align-items: center;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, .9fr) minmax(0, 1.3fr) minmax(0, 1fr) 24px; min-height: 64px; }
.row.open { background: #F7FBF8; }
.name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta { font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; min-height: 20px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--amber);
  color: var(--warn); font-size: 11px; font-weight: 700; }
.strip { display: flex; gap: 3px; margin-bottom: 4px; }
.strip i { width: 22px; height: 5px; border-radius: 3px; background: var(--line); display: block; }
.strip i.on { background: var(--deep); } .strip.won i.on { background: var(--won); } .strip.lost i { background: #C9CCD1; }
.stage { font-size: 13px; font-weight: 700; color: var(--soft); }
.next { font-weight: 700; font-size: 14px; }
.due { font-size: 13px; font-weight: 700; color: var(--muted); }
.due.over { color: var(--warn); } .due.today { color: var(--ink); }
.chev { font-size: 22px; color: var(--muted); text-align: center; }
.detail { padding: 0 18px 18px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.contact { display: flex; flex-direction: column; gap: 10px; }
.contact .line { font-size: 14px; } .contact .line b { display: inline-block; min-width: 72px; }
.msg { white-space: pre-wrap; background: var(--bg); border-radius: 10px; padding: 12px 14px; font-size: 14px; color: var(--soft); max-height: 260px; overflow: auto; }
.do { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; grid-column: 1 / -1; padding-top: 4px; }
.do label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 700; color: var(--muted); }
.do select { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: #fff; font-size: 14px; }
.empty { padding: 18px; color: var(--muted); font-size: 14px; }

/* Board view */
.board { display: grid; grid-template-columns: repeat(var(--cols), minmax(200px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #E6EFE8; border-radius: 12px; padding: 10px; min-height: 300px; display: flex; flex-direction: column; gap: 8px; border: 2px solid transparent; }
.col.over { background: var(--mint); border: 2px dashed var(--won); }
.col h3 { margin: 0 0 4px; font-size: 13px; display: flex; justify-content: space-between; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: grab; text-align: left; width: 100%; }
.card .name { font-size: 14px; }

/* Dialogs */
.scrim { position: fixed; inset: 0; background: rgba(24, 35, 33, .45); z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; }
.scrim.top { z-index: 30; background: rgba(24, 35, 33, .55); }
.dialog { background: #fff; border-radius: 16px; padding: 26px; width: 100%; max-width: 540px; max-height: 88vh; overflow: auto;
  display: flex; flex-direction: column; gap: 14px; }
.dialog.small { max-width: 420px; }
.dialog h2 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }
.dialog .lede { font-size: 14px; color: var(--muted); margin: -6px 0 0; }
.dialog .foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.dialog .x { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.item { border-top: 1px solid var(--line2); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.item .top-line { display: flex; justify-content: space-between; gap: 12px; }
.why { font-size: 12px; font-weight: 700; color: var(--warn); }
.kicker { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--muted); }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line2); }
.switch { flex-shrink: 0; width: 52px; height: 30px; border: 0; border-radius: 999px; background: #C9D6CD; position: relative; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 999px; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--won); }
.switch[aria-checked="true"]::after { left: 25px; }
.err { color: var(--warn); font-size: 13px; font-weight: 600; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 8px; font-weight: 600; font-size: 14px; max-width: calc(100vw - 32px); }

/* Phone */
@media (max-width: 760px) {
  :root { --pad: 16px; }
  .head h1 { font-size: 26px; }
  .row > button.sum { grid-template-columns: minmax(0, 1fr) 24px; gap: 4px; padding: 12px 16px; }
  .row > button.sum .c-stage, .row > button.sum .c-src { display: none; }
  .row > button.sum .c-next { grid-column: 1; grid-row: 2; }
  .row > button.sum .chev { grid-row: 1 / span 2; grid-column: 2; }
  .detail { grid-template-columns: 1fr; padding: 0 16px 16px; }
  .scrim:not(.top) { align-items: flex-end; padding: 0; }
  .scrim:not(.top) .dialog { border-radius: 16px 16px 0 0; max-width: none; max-height: 90vh; padding: 22px 18px calc(24px + env(safe-area-inset-bottom)); }
  .actions .btn { flex: 1 1 auto; }
  .hide-phone { display: none !important; }
}
@media (min-width: 761px) { .hide-desk { display: none !important; } }
