/* Call Hub - design tokens */
:root {
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #f8f9fb; --border: #e6e8ee; --border-strong: #d5d9e2;
  --text: #0e1220; --muted: #667085; --faint: #98a2b3;
  --brand: #4f46e5; --brand-soft: #eef0ff; --brand-ink: #3730a3;
  --ok: #12945a; --ok-soft: #e4f6ec; --bad: #d92d20; --bad-soft: #fdecea; --warn: #b54708; --warn-soft: #fff1dc;
  --shadow: 0 1px 2px #10182808, 0 4px 14px #1018280a;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0c11; --surface: #12151c; --surface-2: #171b24; --border: #232836; --border-strong: #303749;
    --text: #eceef4; --muted: #98a1b5; --faint: #667085;
    --brand: #818cf8; --brand-soft: #1d2140; --brand-ink: #c7cbff;
    --ok: #3ddc97; --ok-soft: #10281e; --bad: #ff6b60; --bad-soft: #2d1513; --warn: #ffb454; --warn-soft: #2c2010;
    --shadow: 0 1px 2px #0006;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; }
.ic { flex: none; display: block; }
.num, .time, .tnum { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px;
  border-radius: 12px; font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap;
  background: var(--text); color: var(--bg); transition: transform .06s, opacity .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.call { background: var(--ok); color: #fff; }
.btn.brand { background: var(--brand); color: #fff; }
.btn.ghost { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.btn.block { width: 100%; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.login .mark { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 6px; }
.login h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.login p { margin: -6px 0 6px; color: var(--muted); }
.field {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border-strong); transition: border-color .15s, box-shadow .15s;
}
textarea.field { height: auto; min-height: 120px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.field:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.err { color: var(--bad); min-height: 1.3em; font-size: 14px; }

.mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--brand); color: #fff; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); height: 100dvh; }
.pane-list { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--border); background: var(--bg); }
.pane-detail { overflow: auto; min-width: 0; background: var(--surface); }
.empty-detail { height: 100%; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--faint); text-align: center; padding: 24px; }
.empty-detail .ring { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--surface-2); color: var(--faint); }

.top { display: flex; align-items: center; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 16px 10px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand b { font-size: 17px; letter-spacing: -.01em; }
.duty { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 10px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-strong); font-size: 13px; font-weight: 600; }
.duty i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.duty.on i { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.avatar-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; font-size: 13px; display: grid; place-items: center; }

.menu { position: fixed; z-index: 50; right: 12px; top: calc(54px + env(safe-area-inset-top)); width: 240px; padding: 6px; border-radius: 14px; background: var(--surface); box-shadow: 0 12px 40px #0003, 0 0 0 1px var(--border); }
.menu .who { padding: 10px 12px 8px; }
.menu .who b { display: block; }
.menu .who span { color: var(--muted); font-size: 13px; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu button .ic { color: var(--muted); }

.notice { margin: 0 16px 10px; padding: 10px 12px 10px 14px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-ink); font-size: 13.5px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.notice button { height: 32px; padding: 0 12px; border-radius: 9px; background: var(--brand); color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; flex: none; }

.summary { margin: 0 16px 10px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow), 0 0 0 1px var(--border); display: grid; grid-template-columns: repeat(3, 1fr); }
.sum { padding: 12px 16px; }
.sum + .sum { border-left: 1px solid var(--border); }
.sum b { display: block; font-size: 24px; letter-spacing: -.02em; line-height: 1.1; }
.sum span { font-size: 12px; color: var(--muted); }
.todo { margin: 0 16px 10px; width: calc(100% - 32px); display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); text-align: left; background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.todo span { flex: 1; }
.todo small { font-weight: 500; opacity: .85; display: block; font-size: 12.5px; }
.todo.clear { background: var(--surface); color: var(--muted); box-shadow: 0 0 0 1px var(--border); cursor: default; }
.team { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 16px 10px; font-size: 12.5px; color: var(--muted); }
.team b { color: var(--text); }
.team .off { opacity: .5; }

.seg { display: flex; gap: 4px; margin: 0 16px 10px; padding: 3px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; height: 34px; padding: 0 12px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 13.5px; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow), 0 0 0 1px var(--border); }
.seg .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

.searchbox { position: relative; margin: 0 16px 8px; }
.searchbox .ic { position: absolute; left: 13px; top: 13px; color: var(--faint); }
.searchbox .field { padding-left: 40px; }

/* ---------- list ---------- */
.list { flex: 1; min-height: 0; overflow: auto; padding: 0 16px 28px; }
.daylabel { position: sticky; top: 0; z-index: 1; padding: 14px 4px 6px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); background: linear-gradient(var(--bg) 70%, transparent); }
.group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow), 0 0 0 1px var(--border); overflow: hidden; }
.row { width: 100%; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 12px 14px; text-align: left; position: relative; align-items: start; }
.row + .row { border-top: 1px solid var(--border); }
.row:hover { background: var(--surface-2); }
.row.sel { background: var(--brand-soft); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.avatar.ok { background: var(--ok-soft); color: var(--ok); }
.avatar.bad { background: var(--bad-soft); color: var(--bad); }
.avatar.warn { background: var(--warn-soft); color: var(--warn); }
.avatar.warn .ic { animation: ring 1s ease-in-out infinite; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(14deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(8deg); } }
.row .top1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row .num { font-weight: 650; font-size: 16px; letter-spacing: .005em; }
.row .time { font-size: 12.5px; color: var(--faint); white-space: nowrap; }
.row .sub { font-size: 13.5px; color: var(--muted); }
.row .sub.bad { color: var(--bad); font-weight: 600; }
.row .extra { display: flex; gap: 8px; align-items: center; margin-top: 6px; min-width: 0; }
.row .note { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tag { flex: none; height: 22px; padding: 0 9px; border-radius: 7px; background: var(--brand-soft); color: var(--brand-ink); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; }
.more { display: flex; width: fit-content; margin: 14px auto 0; }
.empty { text-align: center; color: var(--muted); padding: 56px 24px; display: grid; justify-items: center; gap: 8px; }
.empty .ring { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--surface); color: var(--faint); box-shadow: 0 0 0 1px var(--border); }
.empty b { color: var(--text); }

/* ---------- detail ---------- */
.detail { max-width: 640px; margin: 0 auto; padding: 28px 24px 0; display: grid; gap: 18px; }
.dbar { display: none; }
.dhead { display: grid; gap: 10px; }
.dhead h2 { margin: 0; font-size: 32px; letter-spacing: -.025em; line-height: 1.1; }
.dhead .meta { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.pill { height: 26px; padding: 0 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.muted { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.cta { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--border); padding: 16px; display: grid; gap: 16px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin: 0; }
.facts dt { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 600; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 36px; padding: 0 14px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-strong); color: var(--text); font-size: 14px; font-weight: 500; transition: background .12s, color .12s, box-shadow .12s; }
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed=true] { background: var(--brand); color: #fff; box-shadow: none; font-weight: 600; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-weight: 600; cursor: pointer; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--border-strong); position: relative; flex: none; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0004; transition: transform .15s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(18px); }
.savebar { position: sticky; bottom: 0; margin: 0 -24px; padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--surface) 28%); }
.hist { display: grid; gap: 0; }
.hist .h { padding: 12px 0; border-top: 1px solid var(--border); display: grid; gap: 2px; font-size: 14px; }
.hist .h small { color: var(--muted); font-size: 13px; }

/* ---------- overlay, toast ---------- */
.overlay { position: fixed; inset: 0; background: #0008; display: grid; place-items: center; padding: 16px; z-index: 60; backdrop-filter: blur(2px); }
.dialog { background: var(--surface); border-radius: 18px; padding: 22px; width: 100%; max-width: 400px; display: grid; gap: 14px; box-shadow: 0 20px 60px #0006; }
.dialog h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.dialog label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.dialog .row2 { display: flex; gap: 10px; }
.dialog .row2 .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 8px; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px #0004; max-width: 90vw; animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- mobile ---------- */
@media (max-width: 800px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .pane-list { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .list { overflow: visible; padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
  .daylabel { position: static; background: none; }
  .pane-detail { position: fixed; inset: 0; z-index: 10; transform: translateX(100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
  .app.show-detail .pane-detail { transform: none; }
  .empty-detail { display: none; }
  .dbar { display: flex; align-items: center; position: sticky; top: 0; z-index: 2; margin: 0 -24px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .dbar button { display: inline-flex; align-items: center; gap: 2px; height: 40px; padding: 0 10px 0 4px; color: var(--brand); font-weight: 600; font-size: 16px; border-radius: 10px; }
  .detail { padding-top: 0; gap: 16px; }
  .dhead h2 { font-size: 30px; padding-top: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
