:root {
  --bg: #f6f3e7;
  --surface: #fffdf7;
  --surface-2: #faf8ef;
  --line: #e7e2cf;
  --ink: #2c3624;
  --ink-2: #4d5643;
  --muted: #858a77;
  --matcha: #6f8f4e;
  --matcha-deep: #4f6c36;
  --matcha-soft: #e3ebd2;
  --matcha-tint: #f0f4e5;
  --amber: #c08a2e;
  --amber-soft: #f7ecd3;
  --red: #bd5a43;
  --red-soft: #f7e2da;
  --blue: #5a7d8c;
  --blue-soft: #e1ecef;
  --violet: #7d6a96;
  --violet-soft: #ece6f3;
  --shadow: 0 1px 2px rgba(60, 70, 40, .05), 0 6px 22px rgba(60, 70, 40, .06);
  --shadow-lg: 0 18px 50px rgba(50, 60, 30, .18);
  --r: 16px;
  --r-sm: 11px;
  --ease: cubic-bezier(.22, .8, .3, 1);
  --sidebar: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--matcha-deep); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.tiny { font-size: .75rem; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 14px; }
.stack-sm { display: grid; gap: 8px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* ───────── Layout ───────── */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 14px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; }
.brand img { width: 38px; height: 38px; border-radius: 11px; }
.brand b { display: block; font-size: 1.02rem; }
.brand span { font-size: .78rem; color: var(--muted); }
.nav { display: grid; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--ink-2); font-weight: 500; transition: background .2s var(--ease), color .2s;
}
.nav a:hover { background: var(--matcha-tint); }
.nav a.active { background: var(--matcha-soft); color: var(--matcha-deep); font-weight: 600; }
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 8px; }
.nav .badge-count { margin-left: auto; }
.sidebar .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }

.main { margin-left: var(--sidebar); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: rgba(246, 243, 231, .86); backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .title { font-weight: 650; font-size: 1.1rem; }
.topbar .mobile-brand { display: none; }
.content { padding: 8px 28px 60px; max-width: 1180px; }
.view { animation: viewIn .38s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.bottom-nav { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar .mobile-brand { display: flex; align-items: center; gap: 9px; }
  .topbar .mobile-brand img { width: 30px; height: 30px; border-radius: 9px; }
  .topbar .title.desktop { display: none; }
  .content { padding: 6px 16px calc(96px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(255, 253, 247, .95); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px;
    font-size: .7rem; color: var(--muted); font-weight: 500; position: relative; transition: color .2s;
  }
  .bottom-nav a svg { width: 22px; height: 22px; transition: transform .25s var(--ease); }
  .bottom-nav a.active { color: var(--matcha-deep); }
  .bottom-nav a.active svg { transform: translateY(-2px); }
  .bottom-nav a .badge-count { position: absolute; top: 0; right: 22%; }
}

/* ───────── Cards / grid ───────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .grid-main, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid.stats3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .grid.grid-4 { gap: 10px; }
  .card { padding: 15px; }
  .stat { padding: 12px 13px; }
  .stat .value { font-size: 1.45rem; }
  .stat .label { font-size: .76rem; }
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 10px 0 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.stat .value { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.stat .sub { font-size: .8rem; color: var(--muted); }
.stat.green .value { color: var(--matcha-deep); }
.stat.red .value { color: var(--red); }
.stat.amber .value { color: var(--amber); }
.stat.blue .value { color: var(--blue); }

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: 12px; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: transform .15s var(--ease), background .2s, box-shadow .2s, border-color .2s, opacity .2s;
}
.btn:hover { background: var(--surface-2); border-color: #d9d3bd; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--matcha); border-color: var(--matcha); color: #fff; box-shadow: 0 4px 14px rgba(111, 143, 78, .3); }
.btn.primary:hover { background: var(--matcha-deep); }
.btn.soft { background: var(--matcha-soft); border-color: transparent; color: var(--matcha-deep); }
.btn.soft:hover { background: #d7e3c0; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: #ebc5b8; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--matcha-tint); }
.btn.sm { padding: 6px 11px; font-size: .85rem; border-radius: 10px; }
.btn.lg { padding: 13px 22px; font-size: 1.02rem; border-radius: 14px; }
.btn.block { width: 100%; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px;
  border: none; background: transparent; cursor: pointer; position: relative; transition: background .2s;
}
.icon-btn:hover { background: var(--matcha-tint); }
.icon-btn svg { width: 21px; height: 21px; }

/* ───────── Forms ───────── */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: .83rem; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--matcha); box-shadow: 0 0 0 4px rgba(111, 143, 78, .14); }
textarea.input { resize: vertical; min-height: 84px; }
.input.sm { padding: 7px 10px; font-size: .88rem; border-radius: 10px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--matcha); }
.seg { display: inline-flex; background: var(--matcha-tint); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  border: none; background: transparent; padding: 7px 13px; border-radius: 10px; cursor: pointer;
  font-weight: 550; font-size: .87rem; color: var(--ink-2); transition: background .2s, color .2s, box-shadow .2s;
}
.seg button.on { background: var(--surface); color: var(--matcha-deep); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.daypick { display: flex; gap: 6px; flex-wrap: wrap; }
.daypick label { cursor: pointer; }
.daypick input { display: none; }
.daypick span {
  display: grid; place-items: center; min-width: 40px; height: 36px; padding: 0 8px; border-radius: 10px;
  border: 1px solid var(--line); font-size: .85rem; font-weight: 550; transition: all .2s;
}
.daypick input:checked + span { background: var(--matcha); color: #fff; border-color: var(--matcha); }

/* ───────── Chips / badges ───────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap;
}
.chip.todo { background: #f1efe6; color: #6c6a5d; border-color: transparent; }
.chip.doing { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.chip.submitted { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.chip.done { background: var(--matcha-soft); color: var(--matcha-deep); border-color: transparent; }
.chip.rejected { background: var(--amber-soft); color: #9a6b1a; border-color: transparent; }
.chip.cancelled { background: #eeeeea; color: #8a8a80; border-color: transparent; text-decoration: line-through; }
.chip.overdue { background: var(--red-soft); color: var(--red); border-color: transparent; }
.chip.urgent { background: var(--red); color: #fff; border-color: transparent; }
.chip.high { background: var(--amber-soft); color: #9a6b1a; border-color: transparent; }
.chip.low { background: transparent; color: var(--muted); }
.badge-count {
  min-width: 19px; height: 19px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: .7rem; font-weight: 700; display: inline-grid; place-items: center;
}
.icon-btn .badge-count { position: absolute; top: 3px; right: 2px; transform: scale(.9); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 650; font-size: .8rem; color: #fff; background: var(--matcha);
}
.avatar.sm { width: 26px; height: 26px; font-size: .68rem; }
.avatar.lg { width: 46px; height: 46px; font-size: 1rem; }

/* ───────── Progress ───────── */
.progress { height: 8px; background: var(--matcha-tint); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #8fac6c, var(--matcha)); border-radius: 999px; transition: width .7s var(--ease); }
.progress.red > i { background: linear-gradient(90deg, #d88d74, var(--red)); }
.progress.amber > i { background: linear-gradient(90deg, #dcb367, var(--amber)); }
.ring { --p: 0; --c: var(--matcha); width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--matcha-tint) 0); flex: none; transition: --p .8s; }
.ring::before { content: ''; grid-area: 1 / 1; width: 50px; height: 50px; border-radius: 50%; background: var(--surface); }
.ring b { grid-area: 1 / 1; font-size: .9rem; z-index: 1; }

/* ───────── Task list ───────── */
.task-list { display: grid; gap: 10px; }
.task-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 15px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; cursor: pointer; position: relative;
  transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
  animation: itemIn .35s var(--ease) both;
}
.task-item:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: #dcd6c0; }
.task-item::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: transparent; }
.task-item.p-urgent::before { background: var(--red); }
.task-item.p-high::before { background: var(--amber); }
.task-item.is-done { opacity: .78; }
.task-item.is-done .t-title { text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, .25); }
.task-item .t-title { font-weight: 600; line-height: 1.35; }
.task-item .t-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; font-size: .8rem; color: var(--muted); align-items: center; }
.task-item .t-meta .late { color: var(--red); font-weight: 600; }
.task-item .t-meta .soon { color: var(--amber); font-weight: 600; }
.task-item .mini-progress { width: 70px; height: 5px; }
.task-item .t-side { display: grid; justify-items: end; gap: 6px; flex: none; }
@keyframes itemIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.group-title { display: flex; align-items: center; gap: 8px; margin: 18px 2px 10px; font-size: .86rem; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.group-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--matcha); }
.group-title .dot.red { background: var(--red); }
.group-title .dot.amber { background: var(--amber); }
.group-title .dot.violet { background: var(--violet); }
.group-title .dot.gray { background: #bdbaa8; }

/* ───────── Steps checklist ───────── */
.steps { display: grid; gap: 4px; }
.step {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 10px; border-radius: 12px;
  transition: background .2s; position: relative;
}
.step:hover { background: var(--surface-2); }
.step .tick {
  width: 26px; height: 26px; border-radius: 9px; border: 2px solid #cfd6bf; background: #fff; flex: none;
  display: grid; place-items: center; cursor: pointer; transition: all .25s var(--ease); margin-top: 1px;
}
.step .tick svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3.2; fill: none; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .35s var(--ease) .05s; }
.step.done .tick { background: var(--matcha); border-color: var(--matcha); transform: scale(1.04); }
.step.done .tick svg { stroke-dashoffset: 0; }
.step .tick:active { transform: scale(.88); }
.step .s-body { flex: 1; min-width: 0; }
.step .s-text { transition: color .25s; word-break: break-word; }
.step.done .s-text { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, .2); }
.step .s-meta { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.step .s-num { font-size: .75rem; color: var(--muted); font-weight: 600; width: 18px; text-align: right; margin-top: 4px; flex: none; }
.step .s-actions { opacity: 0; transition: opacity .2s; display: flex; gap: 2px; }
.step:hover .s-actions { opacity: 1; }
@media (hover: none) { .step .s-actions { opacity: 1; } }
.step.locked .tick { cursor: default; }

/* ───────── Timeline ───────── */
.timeline { position: relative; display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 10px; position: relative; padding-bottom: 14px; }
.tl-item::before { content: ''; position: absolute; left: 10px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--matcha-soft); color: var(--matcha-deep); z-index: 1; }
.tl-dot svg { width: 12px; height: 12px; }
.tl-dot.red { background: var(--red-soft); color: var(--red); }
.tl-dot.amber { background: var(--amber-soft); color: var(--amber); }
.tl-dot.violet { background: var(--violet-soft); color: var(--violet); }
.tl-dot.blue { background: var(--blue-soft); color: var(--blue); }
.tl-body { font-size: .88rem; padding-top: 1px; }
.tl-body .when { font-size: .75rem; color: var(--muted); }
.day-head { position: sticky; top: 62px; z-index: 2; background: var(--bg); padding: 8px 2px; font-weight: 650; font-size: .9rem; color: var(--ink-2); }

/* ───────── Comments ───────── */
.comment { display: flex; gap: 10px; }
.comment .bubble { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 9px 12px; flex: 1; min-width: 0; }
.comment.mine { flex-direction: row-reverse; }
.comment.mine .bubble { background: var(--matcha-tint); border-color: #dbe5c6; border-radius: 14px 4px 14px 14px; }
.comment img, .result-img { border-radius: 10px; margin-top: 6px; max-height: 260px; object-fit: cover; cursor: zoom-in; }

/* ───────── Table ───────── */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.click { cursor: pointer; transition: background .15s; }
.table tr.click:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ───────── Charts ───────── */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 10px; }
.bars .bar { flex: 1; display: grid; align-content: end; height: 100%; position: relative; min-width: 4px; }
.bars .bar i { display: block; background: var(--matcha-soft); border-radius: 5px 5px 2px 2px; position: relative; transition: height .7s var(--ease); }
.bars .bar i b { position: absolute; left: 0; right: 0; bottom: 0; background: var(--matcha); border-radius: 5px 5px 2px 2px; transition: height .7s var(--ease); }
.bars .bar:hover i { filter: brightness(.96); }
.bars-x { display: flex; gap: 4px; font-size: .66rem; color: var(--muted); margin-top: 6px; }
.bars-x span { flex: 1; text-align: center; overflow: hidden; }
.legend { display: flex; gap: 14px; font-size: .78rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ───────── Voice assign ───────── */
.voice-card { background: linear-gradient(160deg, #fffdf7, #f1f5e7); }
.mic-wrap { display: grid; justify-items: center; gap: 10px; padding: 8px 0 4px; }
.mic {
  width: 92px; height: 92px; border-radius: 50%; border: none; cursor: pointer; position: relative;
  background: radial-gradient(circle at 35% 30%, #8aab67, var(--matcha-deep)); color: #fff;
  box-shadow: 0 10px 30px rgba(79, 108, 54, .35); transition: transform .2s var(--ease), box-shadow .3s;
  display: grid; place-items: center;
}
.mic svg { width: 38px; height: 38px; }
.mic:active { transform: scale(.94); }
.mic.on { background: radial-gradient(circle at 35% 30%, #d77a62, var(--red)); box-shadow: 0 10px 30px rgba(189, 90, 67, .4); }
.mic.on::before, .mic.on::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--red); animation: ripple 1.8s ease-out infinite;
}
.mic.on::after { animation-delay: .9s; }
@keyframes ripple { from { transform: scale(1); opacity: .7; } to { transform: scale(1.75); opacity: 0; } }
.mic-hint { font-size: .85rem; color: var(--muted); text-align: center; }
.interim { color: var(--muted); font-style: italic; min-height: 1.4em; font-size: .9rem; }
.draft {
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 14px; display: grid; gap: 12px;
  animation: itemIn .35s var(--ease) both;
}
.draft .draft-head { display: flex; gap: 10px; align-items: center; }
.draft .draft-head .n { width: 26px; height: 26px; border-radius: 8px; background: var(--matcha-soft); color: var(--matcha-deep); display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.people label { cursor: pointer; }
.people input { display: none; }
.people span {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px 5px 5px; border-radius: 999px; border: 1px solid var(--line);
  font-size: .84rem; font-weight: 500; background: #fff; transition: all .2s var(--ease);
}
.people span .avatar { width: 22px; height: 22px; font-size: .6rem; }
.people input:checked + span { background: var(--matcha); border-color: var(--matcha); color: #fff; }
.step-edit { display: grid; gap: 6px; }
.step-edit .se-row { display: flex; gap: 6px; align-items: center; }
.step-edit .se-row .n { width: 20px; text-align: right; font-size: .78rem; color: var(--muted); flex: none; }

/* ───────── Modal / sheet ───────── */
.overlay {
  position: fixed; inset: 0; background: rgba(40, 48, 30, .34); backdrop-filter: blur(3px); z-index: 100;
  display: grid; place-items: center; padding: 20px; animation: fadeIn .25s ease;
}
.overlay.closing { animation: fadeOut .2s ease forwards; }
.modal {
  background: var(--surface); border-radius: 20px; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  box-shadow: var(--shadow-lg); animation: popIn .32s var(--ease);
}
.modal.wide { width: min(760px, 100%); }
.overlay.closing .modal { animation: popOut .2s ease forwards; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-body { padding: 12px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 20px; flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes popOut { to { opacity: 0; transform: translateY(10px) scale(.98); } }
@media (max-width: 640px) {
  .overlay { place-items: end stretch; padding: 0; }
  .modal { border-radius: 22px 22px 0 0; max-height: 92vh; width: 100%; animation: sheetIn .38s var(--ease); padding-bottom: env(safe-area-inset-bottom); }
  .modal::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 4px; background: #d8d4c2; margin: 9px auto 0; }
  .overlay.closing .modal { animation: sheetOut .22s ease forwards; }
}
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }

/* ───────── Notifications panel ───────── */
.notif-panel {
  position: fixed; top: 64px; right: 20px; width: min(390px, calc(100vw - 24px)); max-height: min(560px, 75vh); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); z-index: 90;
  animation: popIn .25s var(--ease); transform-origin: top right;
}
.notif-panel .n-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 8px; position: sticky; top: 0; background: var(--surface); }
.notif-item { display: flex; gap: 10px; padding: 11px 16px; cursor: pointer; transition: background .15s; border-top: 1px solid var(--line); }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--matcha-tint); }
.notif-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--matcha); margin-top: 7px; flex: none; }
.notif-item:not(.unread) .dot { background: transparent; }
@media (max-width: 640px) { .notif-panel { right: 12px; left: 12px; width: auto; top: 58px; } }

/* ───────── Toast ───────── */
.toasts { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
@media (max-width: 900px) { .toasts { bottom: calc(90px + env(safe-area-inset-bottom)); } }
.toast {
  background: #2f3a26; color: #fff; padding: 11px 18px; border-radius: 14px; font-size: .9rem; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toastIn .35s var(--ease); max-width: 92vw;
}
.toast.err { background: var(--red); }
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ───────── Misc ───────── */
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .em { font-size: 2.2rem; margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, #efecdf 25%, #f7f5ec 50%, #efecdf 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.fab {
  position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 25; width: 58px; height: 58px; border-radius: 50%;
  background: var(--matcha); color: #fff; border: none; box-shadow: 0 10px 26px rgba(79, 108, 54, .4); display: none; place-items: center; cursor: pointer;
  transition: transform .2s var(--ease);
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.92); }
@media (max-width: 900px) { .fab.show { display: grid; } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.callout { border-radius: 14px; padding: 12px 14px; font-size: .9rem; display: flex; gap: 10px; align-items: flex-start; }
.callout > svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.callout.green { background: var(--matcha-tint); color: var(--matcha-deep); }
.callout.amber { background: var(--amber-soft); color: #87601a; }
.callout.red { background: var(--red-soft); color: #94432f; }
.callout.violet { background: var(--violet-soft); color: #5f4f75; }
.divider { height: 1px; background: var(--line); margin: 6px 0; }
.lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(20, 24, 16, .88); display: grid; place-items: center; padding: 20px; animation: fadeIn .2s; cursor: zoom-out; }
.lightbox img { max-height: 92vh; border-radius: 12px; }
.person-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.person-row:last-child { border-bottom: none; }
.countdown { font-variant-numeric: tabular-nums; }

/* ───────── Login ───────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, #e3ebd2 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #ebe4cc 0, transparent 55%), var(--bg); }
.login-card { width: min(400px, 100%); animation: popIn .5s var(--ease); }
.login-card .logo { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px; box-shadow: 0 10px 26px rgba(79, 108, 54, .3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
