@import url('fonts.css');

:root {
  --bg: #f3f0ea;
  --surface: #fbfaf7;
  --surface-2: #efeae3;
  --surface-3: #e7e0d8;
  --border: #ddd5ce;
  --border-strong: #c9bfb8;
  --text: #2b272a;
  --muted: #676166;
  --faint: #8f888d;
  --accent: #6e4e64;
  --accent-hover: #5c4053;
  --accent-soft: #ece2e8;
  --accent-ink: #fff;
  --silver: #8a8a8d;
  --warn: #8a5519;
  --warn-soft: #f5ead9;
  --ok: #3d6a4d;
  --ok-soft: #e3eee6;
  --danger: #9a3a3a;
  --danger-soft: #f5e3e1;
  --shadow: 0 1px 2px rgba(43, 39, 42, .06), 0 4px 16px rgba(43, 39, 42, .05);
  --radius: 10px;
  --radius-sm: 6px;
  --font-display: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', serif;
  --font-body: 'Work Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --text-xs: .75rem;
  --text-sm: .8125rem;
  --text-base: .9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #1b191b;
  --surface: #232023;
  --surface-2: #2b272a;
  --surface-3: #342f33;
  --border: #3b3539;
  --border-strong: #4d464b;
  --text: #ece7ea;
  --muted: #aaa1a7;
  --faint: #857d83;
  --accent: #c9a6bc;
  --accent-hover: #d8bacc;
  --accent-soft: #3a2e36;
  --accent-ink: #1b191b;
  --warn: #e0b073;
  --warn-soft: #3a2f22;
  --ok: #8fc3a0;
  --ok-soft: #22322a;
  --danger: #e59a92;
  --danger-soft: #3b2525;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; }
.display { font-family: var(--font-display); letter-spacing: .005em; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; text-decoration: none; color: var(--text); }
.brand img { width: 46px; height: 46px; border-radius: 50%; box-shadow: 0 0 0 1px var(--border); }
.brand .name { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--accent); }
.brand .tag { font-size: var(--text-xs); color: var(--muted); letter-spacing: .04em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-size: var(--text-sm); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 17px; height: 17px; flex: none; }
.nav .count { margin-left: auto; background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; font-weight: 600; }
.nav .count.warn { background: var(--warn); color: var(--surface); }
.sidebar .spacer { flex: 1; }
.userbox { border-top: 1px solid var(--border); padding: 12px 8px 0; font-size: var(--text-sm); }
.userbox .who { font-weight: 600; }
.userbox .role { color: var(--muted); font-size: var(--text-xs); }
.userbox .links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: var(--text-xs); font-weight: 500; }
.linkbtn:hover { text-decoration: underline; }

main { min-width: 0; padding: 28px 36px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-display); font-size: 2rem; font-weight: 600; line-height: 1.1; }
.page-head .sub { color: var(--muted); font-size: var(--text-sm); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: var(--text-sm); font-weight: 500;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; font-size: var(--text-xs); }
.btn svg { width: 15px; height: 15px; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: var(--text-xs); color: var(--muted); font-weight: 500; }
input[type=text], input[type=password], input[type=date], input[type=search], input[type=number], input[type=time], input[type=email], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-size: var(--text-sm);
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px; }
label.check { display: inline-flex; gap: 7px; align-items: center; font-size: var(--text-sm); cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; }

.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px 20px; }
.card h2 { font-size: var(--text-lg); font-family: var(--font-display); font-weight: 700; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.mono { font-family: var(--font-mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hr { height: 1px; background: var(--border); margin: 14px 0; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); white-space: nowrap;
}
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 12.5px;
}
.chip.primary { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--faint); padding: 0 4px; border-radius: 999px; line-height: 1; font-size: 15px; }
.chip button:hover { color: var(--text); background: var(--surface-3); }
.chip.add { cursor: pointer; padding-right: 10px; border-style: dashed; background: transparent; }
.chip.add:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-size: var(--text-xs); color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow: auto; border-radius: var(--radius); }

/* ---------- family page ---------- */
.fam-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; }
.fam-label { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--accent); font-weight: 600; letter-spacing: .02em; }
.fam-title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 600; line-height: 1.15; margin-top: 2px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 20px; margin-top: 14px; }
.meta div > span { display: block; font-size: var(--text-xs); color: var(--muted); }
.meta div > b { font-weight: 500; font-size: var(--text-sm); white-space: pre-wrap; }

.pending-panel { border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); border-radius: var(--radius); padding: 16px 18px; }
.pending-panel h2 { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; color: var(--warn); }
.pedit { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.diff { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 6px 12px; font-size: var(--text-sm); margin-top: 8px; }
.diff .h { font-size: var(--text-xs); color: var(--muted); font-weight: 600; }
.diff .old { background: var(--danger-soft); border-radius: 4px; padding: 4px 8px; white-space: pre-wrap; max-height: 220px; overflow: auto; }
.diff .new { background: var(--ok-soft); border-radius: 4px; padding: 4px 8px; white-space: pre-wrap; max-height: 220px; overflow: auto; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 11px; font-size: var(--text-xs); font-weight: 500; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tgroup { position: relative; margin-bottom: 22px; }
.tgroup::before { content: ''; position: absolute; left: -24px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tgroup-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.tgroup-head .d { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; line-height: 1.1; }
.tgroup-head .src { font-size: var(--text-sm); color: var(--muted); }
.dates { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--text-xs); color: var(--muted); }
.dates b { color: var(--text); font-weight: 600; }
.entry { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.entry.has-pending { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.entry-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.entry-body { white-space: pre-wrap; font-size: var(--text-sm); line-height: 1.55; overflow-wrap: anywhere; }
.entry-body.clamp { max-height: 190px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.entry-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.entry-actions { margin-left: auto; display: flex; gap: 6px; }

/* ---------- upload & review ---------- */
.drop { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 40px 20px; text-align: center; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop h2 { font-family: var(--font-display); font-size: 1.4rem; }
.item { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }
.item.off { opacity: .55; }
.item.off .item-body { display: none; }
.item-top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.plan { font-size: var(--text-xs); font-weight: 600; }
.warnbox { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 8px 12px; font-size: var(--text-sm); margin-top: 10px; }
.errbox { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); padding: 8px 12px; font-size: var(--text-sm); }
.infobox { background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-sm); padding: 10px 14px; font-size: var(--text-sm); }
.sub-entry { display: grid; grid-template-columns: 26px 170px 1fr; gap: 8px; align-items: start; margin-top: 8px; }
.sticky-bar { position: sticky; bottom: 0; margin: 20px -36px -80px; padding: 12px 36px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; z-index: 5; }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(27, 25, 27, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25); width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 22px 24px; }
.modal.wide { width: min(820px, 100%); }
.modal h2 { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; margin-bottom: 8px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: var(--text-sm); box-shadow: var(--shadow); max-width: 380px; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--accent-soft) 70%, transparent), transparent 60%), var(--bg); }
.login .card { width: min(380px, 100%); padding: 30px 28px; text-align: center; }
.login img { width: 150px; height: 150px; border-radius: 50%; margin: 0 auto 8px; display: block; box-shadow: 0 0 0 1px var(--border), var(--shadow); }
.login h1 { font-family: var(--font-display); font-size: 2rem; color: var(--accent); }
.login form { text-align: left; margin-top: 18px; display: grid; gap: 12px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h2 { font-family: var(--font-display); color: var(--text); font-size: 1.4rem; margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; }
.stat .v { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; line-height: 1; }
.stat .l { font-size: var(--text-xs); color: var(--muted); margin-top: 4px; }

.menu-pop { position: absolute; z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; min-width: 210px; }
.menu-pop button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 5px; cursor: pointer; font-size: var(--text-sm); }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop button.danger { color: var(--danger); }

.mobile-top { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .2s; z-index: 40; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20; }
  .mobile-top img { width: 32px; height: 32px; border-radius: 50%; }
  main { padding: 20px 16px 80px; }
  .g2, .g3, .g4, .stats { grid-template-columns: 1fr 1fr; }
  .sub-entry { grid-template-columns: 26px 1fr; }
  .sub-entry textarea { grid-column: 1 / -1; }
  .diff { grid-template-columns: 1fr; }
  .fam-head { grid-template-columns: 1fr; }
  .sticky-bar { margin: 20px -16px -80px; padding: 12px 16px; }
  .hide-sm { display: none; }
}
@media (max-width: 520px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .stats { gap: 8px; } }

.clabel { color: var(--accent); font-weight: 650; }

/* deliverables */
.deliv { display: grid; grid-template-columns: 118px minmax(0, 1fr) auto; gap: 16px; align-items: start; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius); padding: 14px 16px; }
.deliv.overdue { border-left-color: var(--danger); }
.deliv.done { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); border-left-color: var(--ok); }
.deliv.done .deliv-main > .row b { color: var(--ok); }
.deliv-when { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.deliv-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.deliv-body { white-space: pre-wrap; color: var(--muted); max-height: 4.8em; overflow: hidden; margin-top: 2px; }
.deliv-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 260px; }
.section-h { font-family: var(--font-display); font-size: var(--text-lg); margin: 22px 0 10px; color: var(--muted); }
.deliv-toggle { margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
@media (max-width: 760px) { .deliv { grid-template-columns: 1fr; } .deliv-actions { justify-content: flex-start; max-width: none; } }

/* person responsible */
.resp-line b { font-weight: 600; }
.resp-pick select { max-width: 100%; }

/* calendar (month / week / day) */
.cal-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.cal-title { font-family: var(--font-display); font-size: 1.45rem; font-weight: 600; margin: 0 4px; min-width: 0; }
.cal-nav { font-size: 1.15rem; line-height: 1; padding: 3px 10px; }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend .lg { width: 10px; height: 10px; border-radius: 3px; background: var(--surface-3); border-left: 3px solid var(--border-strong); display: inline-block; }
.cal-month { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cal-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-dow div { padding: 6px 8px; font-size: var(--text-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(108px, auto); }
.cal-cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px 4px 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.wkend { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.cal-cell.out { background: var(--surface-2); }
.cal-cell.out .cal-dn { color: var(--faint); }
.cal-dn { align-self: flex-start; border: 0; background: transparent; font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--text); padding: 1px 7px; border-radius: 999px; cursor: pointer; }
.cal-dn:hover { background: var(--surface-3); }
.cal-cell.today .cal-dn { background: var(--accent); color: var(--accent-ink); }
.cal-ev { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-width: 0; text-align: left; border: 0; border-left: 3px solid var(--border-strong); background: var(--surface-3); color: var(--text); border-radius: 4px; padding: 2px 6px; cursor: pointer; font: inherit; font-size: var(--text-xs); line-height: 1.3; }
.cal-ev:hover { filter: brightness(.96); }
.cal-ev .t { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-ev .s { font-weight: 600; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev .w { width: 100%; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev.soon, .cal-legend .lg.soon { background: var(--warn-soft); border-left-color: var(--warn); }
.cal-ev.overdue, .cal-legend .lg.overdue { background: var(--danger-soft); border-left-color: var(--danger); }
.cal-ev.done, .cal-legend .lg.done { background: var(--ok-soft); border-left-color: var(--ok); }
.cal-ev.done .s { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ok) 60%, transparent); }
.cal-ev.anniv, .cal-legend .lg.anniv { background: var(--accent-soft); border-left-color: var(--accent); border-left-style: dashed; }
.cal-more { border: 0; background: transparent; color: var(--accent); font: inherit; font-size: var(--text-xs); font-weight: 600; text-align: left; padding: 1px 6px; cursor: pointer; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); min-height: 420px; }
.cal-wcol { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.cal-wcol:last-child { border-right: 0; }
.cal-wcol.wkend { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.cal-whead { display: flex; align-items: baseline; gap: 6px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface-2); padding: 8px 10px; font: inherit; color: var(--muted); cursor: pointer; text-align: left; }
.cal-whead span { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.cal-whead b { font-size: 1.15rem; color: var(--text); }
.cal-wcol.today .cal-whead { background: var(--accent-soft); }
.cal-wcol.today .cal-whead b { color: var(--accent); }
.cal-wbody { padding: 6px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.cal-wbody .cal-ev { padding: 5px 7px; }
.cal-wbody .cal-ev .s { white-space: normal; }
@media (max-width: 900px) {
  .cal-week { grid-template-columns: 1fr; min-height: 0; }
  .cal-wcol { border-right: 0; border-bottom: 1px solid var(--border); }
  .cal-grid { grid-auto-rows: minmax(76px, auto); }
  .cal-ev .w, .cal-ev .t { display: none; }
}
@media (max-width: 560px) {
  .cal-dow div { padding: 4px 2px; text-align: center; font-size: 10px; }
  .cal-cell { padding: 2px; }
  .cal-ev { padding: 1px 3px; font-size: 10px; }
}
.resp-pick .chip { font-family: var(--font-body); }
[hidden] { display: none !important; }

/* my deliverables */
.my-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.my-stat { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.my-stat b { font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.my-stat span { font-size: var(--text-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.my-stat.danger { border-left-color: var(--danger); } .my-stat.danger b { color: var(--danger); }
.my-stat.warn { border-left-color: var(--warn); } .my-stat.warn b { color: var(--warn); }
.my-stat.ok { border-left-color: var(--ok); } .my-stat.ok b { color: var(--ok); }
.my-sec { margin-bottom: 22px; }
.my-sec h2 { font-size: 1.15rem; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.my-sec.danger h2 { color: var(--danger); }
.count-pill { font-family: var(--font-body); font-size: var(--text-xs); font-weight: 700; background: var(--surface-3); color: var(--text); border-radius: 999px; padding: 1px 8px; }
.my-empty { padding: 10px 14px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.completion { margin: 4px 0; padding: 6px 10px; background: var(--ok-soft); border-radius: 6px; }
@media (max-width: 700px) { .my-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Competitor Watch */
.cw-meta { margin: -8px 0 10px; }
.cw-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cw-chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 10px 4px 8px; font-size: var(--text-xs); color: var(--text); cursor: pointer; max-width: 100%; }
.cw-chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.cw-chip i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.cw-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.cw-chip b { color: var(--muted); font-weight: 600; }
.cw-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.cw-card { padding: 14px 16px 12px; cursor: zoom-in; transition: border-color .15s, box-shadow .15s; }
.cw-card:hover, .cw-card:focus-visible { border-color: var(--accent); outline: none; }
.cw-card h2 { font-size: var(--text-lg); }
.cw-canvas { position: relative; height: 260px; margin-top: 8px; }
.cw-full { padding: 0; place-items: stretch; background: rgba(27, 25, 27, .55); }
.cw-full-box { background: var(--surface); margin: 2vh 2vw; border-radius: 12px; padding: 18px 22px 22px; display: flex; flex-direction: column; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.cw-full-head { gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.cw-full-head h2 { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; }
.cw-full-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cw-big { position: relative; flex: 1; min-height: 360px; }
.cw-year-chart { position: relative; height: 46vh; min-height: 260px; flex: none; }
.cw-h3 { font-size: var(--text-base); font-weight: 600; margin: 18px 0 8px; }
.as-list { border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 380px; overflow: auto; }
.as-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.as-row:last-child { border-bottom: 0; }
.as-row:hover { background: var(--surface-2); }
.as-row.on { background: var(--accent-soft); }
.as-name { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-sm); }
.as-merge { margin: 0 0 4px 18px; font-size: var(--text-sm); }
.alias-ask { align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.alias-ask input { margin-top: 3px; }
.owner-link { color: inherit; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
.owner-link:hover { color: var(--accent); text-decoration-color: currentColor; }
@media (max-width: 900px) { .cw-grid { grid-template-columns: 1fr; } .cw-full-box { margin: 0; border-radius: 0; padding: 14px; } }
@media (max-width: 520px) { .as-row { grid-template-columns: auto 1fr auto; row-gap: 2px; } .as-row > a.xs { grid-column: 2 / 4; } .cw-canvas { height: 220px; } .cw-year-chart { height: 38vh; } }
.as-row.ro { grid-template-columns: 1fr auto auto; cursor: default; }
@media (max-width: 520px) { .as-row.ro { grid-template-columns: 1fr auto; } .as-row.ro > a.xs { grid-column: 1 / 3; } }
