/* Mangan + Grech wedding tracker — coastal / Cape Cod palette */
:root {
  --navy: #1f3a5f;
  --navy-deep: #152b47;
  --azure: #2f6fed;
  --azure-soft: #e8f0ff;
  --sky: #7dd3fc;
  --sand: #f6f1e7;
  --bg: #eef3f9;
  --surface: #ffffff;
  --ink: #1b2733;
  --muted: #6b7a8d;
  --line: #e2e8f1;
  --line-strong: #cbd6e4;
  --green: #1f9d6b;
  --amber: #d9870a;
  --red: #d6453d;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(20,40,70,.06), 0 1px 3px rgba(20,40,70,.08);
  --shadow-md: 0 6px 24px rgba(20,40,70,.12);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
/* The `hidden` attribute must win even over flex/grid display rules below. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--azure); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--navy); margin: 0; }
code { font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace; font-size: .85em; }
.muted { color: var(--muted); font-size: 13px; }

/* ---- Topbar ---- */
.topbar {
  background: linear-gradient(120deg, var(--navy-deep), var(--navy));
  color: #fff;
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 28px;
  padding: 0 22px; height: 58px;
}
.brand { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand-rings { font-size: 20px; }
.mainnav { display: flex; gap: 4px; margin-right: auto; }
.mainnav a {
  color: #cfe0f5; padding: 7px 13px; border-radius: 8px; font-weight: 500;
}
.mainnav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.mainnav a.active { background: rgba(255,255,255,.18); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.countdown {
  background: rgba(125,211,252,.18); color: #d7ecff; padding: 5px 11px;
  border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.signout { color: #aac4e4; font-size: 13px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex: 0 0 auto;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; vertical-align: middle; }

/* ---- Layout ---- */
.page, .board-page { max-width: 1400px; margin: 0 auto; padding: 22px; }
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.toolbar-left { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title { font-size: 22px; }

/* ---- Inputs / buttons ---- */
.input, select.input {
  font: inherit; padding: 8px 11px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: #fff; color: var(--ink); min-height: 36px;
}
.input:focus { outline: none; border-color: var(--azure); box-shadow: 0 0 0 3px var(--azure-soft); }
/* Native <select> arrows jam against the right edge and differ per OS. Swap in
   one thin chevron with consistent breathing room (14px), and reserve room on
   the right so a long value never slides under it. */
select.input, .modal-body select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-color: #fff; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%236b7a8d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px 8px;
}
/* Park the native date-picker glyph at the same 14px inset as the select chevron
   so the stacked drawer fields (status / priority / category / due date) share one
   clean right edge. */
input[type=date].input, .modal-body input[type=date] { padding-right: 14px; }
.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  border-radius: 8px; padding: 8px 14px; min-height: 36px; transition: .15s;
}
.btn-primary { background: var(--azure); color: #fff; }
.btn-primary:hover { background: #245fd1; }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: #f4f7fb; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; min-height: 30px; font-size: 13px; }
.btn-danger { background: #fff; border-color: #f1c9c6; color: var(--red); }
.btn-danger:hover { background: #fdf2f1; }
.icon-btn {
  background: transparent; border: none; cursor: pointer; font-size: 16px;
  color: var(--muted); padding: 6px 8px; border-radius: 8px;
}
.icon-btn:hover { background: #eef2f8; color: var(--ink); }

/* ---- Flash ---- */
#flash-zone { max-width: 1400px; margin: 0 auto; padding: 0 22px; }
.flash { padding: 11px 15px; border-radius: 8px; margin-top: 12px; font-size: 14px; }
.flash-error { background: #fdecea; color: #a3322b; border: 1px solid #f3c6c1; }
.flash-info { background: var(--azure-soft); color: #1d4ea8; border: 1px solid #c7daff; }

/* ---- Login ---- */
.login-bg { background: linear-gradient(160deg, #1f3a5f 0%, #2f6fed 55%, #7dd3fc 130%); }
.login-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 22px; }
.login-card {
  background: #fff; border-radius: 18px; padding: 40px 36px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(10,25,50,.35); text-align: center;
}
.login-rings { font-size: 40px; }
.login-card h1 { font-size: 26px; margin: 8px 0 4px; letter-spacing: .3px; }
.login-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 22px; }
.login-form { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.login-form label { font-size: 13px; font-weight: 600; color: var(--navy); display: flex; flex-direction: column; gap: 5px; }
.login-form input[type=email], .login-form input[type=password] {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px;
}
.login-form input:focus { outline: none; border-color: var(--azure); box-shadow: 0 0 0 3px var(--azure-soft); }
.remember { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 500 !important; color: var(--muted) !important; }

/* ---- Board ---- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
.column { background: #e9eef6; border-radius: var(--radius); display: flex; flex-direction: column; min-height: 200px; }
.column-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; font-weight: 700; color: var(--navy);
  border-bottom: 3px solid var(--line-strong); border-radius: var(--radius) var(--radius) 0 0;
}
.column-head.status-todo { border-color: #94a3b8; }
.column-head.status-in_progress { border-color: var(--azure); }
.column-head.status-blocked { border-color: var(--amber); }
.column-head.status-done { border-color: var(--green); }
.column-count {
  background: rgba(31,58,95,.1); color: var(--navy); font-size: 12px;
  padding: 1px 9px; border-radius: 12px; font-weight: 700;
}
.column-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; flex: 1; }
.column-body.drag-over { background: #dde7f4; border-radius: 8px; outline: 2px dashed var(--azure); outline-offset: -4px; }

.card {
  background: #fff; border-radius: 10px; padding: 12px; box-shadow: var(--shadow-sm);
  cursor: pointer; border-left: 4px solid var(--azure); position: relative; transition: .12s;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card.dragging { opacity: .45; }
.card-cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 5px; }
.card-title { font-weight: 600; color: var(--ink); line-height: 1.35; }
.card.is-done .card-title { text-decoration: line-through; color: var(--muted); }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.card-spacer { flex: 1; }
.assignees { display: flex; }
.assignees .avatar { margin-left: -6px; border: 2px solid #fff; }
.assignees .avatar:first-child { margin-left: 0; }

.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 12px; white-space: nowrap; }
.pill-due { background: #eef2f8; color: var(--muted); }
.pill-due.soon { background: #fff3df; color: var(--amber); }
.pill-due.overdue { background: #fdecea; color: var(--red); }
.pill-prio { text-transform: capitalize; }
.pill-prio.urgent { background: #fdecea; color: var(--red); }
.pill-prio.high { background: #fff3df; color: var(--amber); }
.pill-prio.medium { background: var(--azure-soft); color: #2657b8; }
.pill-prio.low { background: #eef2f8; color: var(--muted); }
.comment-chip { font-size: 11px; color: var(--muted); }

/* ---- Drawer (card detail) ---- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(20,35,60,.4); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; height: 100dvh; width: 480px; max-width: 94vw;
  background: #fff; box-shadow: -10px 0 40px rgba(10,25,50,.25); z-index: 61;
  display: flex; flex-direction: column; animation: slidein .18s ease;
}
@keyframes slidein { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.drawer-saved { color: var(--green); font-size: 12.5px; font-weight: 700; opacity: 0; transition: opacity .2s; }
.drawer-saved.show { opacity: 1; }
.drawer-actions { display: flex; gap: 4px; }
.drawer-body { padding: 22px 24px; overflow-y: auto; }
.drawer-title-input {
  font-size: 19px; font-weight: 700; color: var(--navy); border: none; width: 100%;
  font-family: inherit; resize: none; line-height: 1.3;
}
.drawer-title-input:focus { outline: none; background: #f4f7fb; border-radius: 6px; }
.field-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: center; margin: 18px 0; }
.field-grid label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.assignee-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.assignee-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--line-strong); border-radius: 20px; cursor: pointer; font-size: 12.5px; background: #fff;
}
.assignee-toggle.on { background: var(--azure-soft); border-color: var(--azure); color: #1d4ea8; font-weight: 600; }
.drawer-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; margin: 22px 0 10px; }
.desc-area {
  width: 100%; min-height: 80px; font: inherit; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 9px; resize: vertical; line-height: 1.5;
}
.desc-area:focus { outline: none; border-color: var(--azure); box-shadow: 0 0 0 3px var(--azure-soft); }

/* ---- Thread (comments + activity) ---- */
.thread { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.thread-item { display: flex; gap: 10px; font-size: 13px; }
.thread-item .avatar { width: 26px; height: 26px; font-size: 10px; }
.thread-comment .bubble { background: #f1f5fb; border-radius: 10px; padding: 8px 11px; flex: 1; }
.thread-comment .bubble .who { font-weight: 700; color: var(--navy); font-size: 12.5px; }
.thread-comment .bubble .body { white-space: pre-wrap; margin-top: 2px; }
.thread-activity { color: var(--muted); align-items: center; }
.thread-activity .dot { width: 26px; display: flex; justify-content: center; }
.thread-activity .dot span { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.thread-time { color: var(--muted); font-size: 11px; margin-top: 2px; }
.comment-form { display: flex; gap: 8px; margin-top: 14px; }
.comment-form textarea { flex: 1; min-height: 38px; font: inherit; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 9px; resize: vertical; }
.comment-form textarea:focus { outline: none; border-color: var(--azure); box-shadow: 0 0 0 3px var(--azure-soft); }
.source-tag { font-size: 11px; color: var(--muted); }

/* ---- Modal (new task) ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,35,60,.45); z-index: 70; display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; }
.modal { background: #fff; border-radius: 14px; width: 520px; max-width: 94vw; box-shadow: var(--shadow-md); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { font-size: 12px; font-weight: 600; color: var(--navy); display: flex; flex-direction: column; gap: 5px; }
.modal-body input, .modal-body select, .modal-body textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 9px; }
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Timeline / calendar ---- */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--line-strong); }
.tl-month { margin: 26px 0 12px; font-size: 13px; font-weight: 800; color: var(--azure); text-transform: uppercase; letter-spacing: .6px; }
.tl-day { position: relative; margin-bottom: 14px; }
.tl-day::before { content: ''; position: absolute; left: -18px; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--azure); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--azure); }
.tl-day.overdue::before { background: var(--red); box-shadow: 0 0 0 2px var(--red); }
.tl-day.done::before { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.tl-date { font-weight: 700; color: var(--navy); font-size: 13.5px; }
.tl-date .rel { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 8px; }
.tl-cards { margin-top: 6px; display: flex; flex-direction: column; gap: 8px; }
.tl-card { background: #fff; border-radius: 9px; padding: 9px 12px; box-shadow: var(--shadow-sm); border-left: 4px solid var(--azure); display: flex; align-items: center; gap: 10px; cursor: pointer; }
.tl-card:hover { box-shadow: var(--shadow-md); }
.tl-card.done .tl-title { text-decoration: line-through; color: var(--muted); }
.tl-card.payment { border-left-color: var(--amber); background: #fffaf2; }
.tl-card.payment .pay-badge { background: #fff3df; color: var(--amber); }
.tl-title { font-weight: 600; flex: 1; }
.wedding-marker { background: linear-gradient(120deg,#2f6fed,#7dd3fc); color: #fff; padding: 12px 16px; border-radius: 10px; font-weight: 700; margin: 20px 0; }

/* ---- Vendors ---- */
.vendor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.vendor-card { background: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px; }
.vendor-card h3 { font-size: 15.5px; }
.vendor-cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--azure); }
.vendor-meta { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink); }
.vendor-money { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.vendor-money b { color: var(--ink); }
.vendor-links { display: flex; gap: 12px; margin-top: 4px; font-size: 12.5px; }
.vendor-notes { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; white-space: pre-wrap; }
.vendor-pay { font-size: 12px; color: var(--amber); font-weight: 600; }

/* money rollup banner (vendors) */
.vendor-rollup { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 18px; }
.vendor-rollup:empty { display: none; }
.roll-stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 10px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 130px; }
.roll-label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; }
.roll-val { font-size: 18px; font-weight: 800; color: var(--navy); }
.roll-stat.warn .roll-val { color: var(--amber); }
.roll-stat.amber .roll-val { font-size: 15px; color: var(--amber); }

/* This Week triage page */
.tw-section { margin-bottom: 24px; }
.tw-h { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--azure); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.tw-count { background: #eef2f8; color: var(--muted); font-size: 12px; font-weight: 700; border-radius: 10px; padding: 1px 8px; }
.tw-card { background: #fff; border-radius: 9px; padding: 10px 13px; box-shadow: var(--shadow-sm); border-left: 4px solid var(--azure); display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tw-card:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.tw-title { font-weight: 600; flex: 1; color: var(--ink); }
.tw-on { font-size: 12px; color: var(--muted); }
.tw-card.tw-q { border-left-color: var(--amber); background: #fffaf2; }
.tw-blocked { background: #fdecea; color: var(--red); }

/* status badges (vendors + generic) */
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 12px; background: #eef2f8; color: var(--muted); text-transform: capitalize; }
.badge-muted { background: #eef2f8; color: var(--muted); }
.status-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 12px; }
.status-booked { background: #e3f6ee; color: var(--green); }
.status-pending { background: #fff3df; color: var(--amber); }
.status-open { background: #fdecea; color: var(--red); }

/* ---- Activity feed ---- */
.activity-feed { display: flex; flex-direction: column; gap: 2px; max-width: 760px; }
.act-row { display: flex; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.act-row .avatar { width: 30px; height: 30px; font-size: 11px; }
.act-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--azure-soft); display: flex; align-items: center; justify-content: center; font-size: 14px; }
.act-text { flex: 1; font-size: 13.5px; }
.act-text .who { font-weight: 700; color: var(--navy); }
.act-text .tasklink { color: var(--azure); font-weight: 600; }
.act-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---- Panels / tables (settings) ---- */
.card-panel { background: #fff; border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm); margin-bottom: 18px; max-width: 920px; }
.card-panel h2 { font-size: 16px; margin-bottom: 6px; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13.5px; }
.data-table th { text-align: left; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; padding: 6px 10px; border-bottom: 2px solid var(--line); }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr.revoked { opacity: .5; }
.inline-form { display: flex; gap: 10px; margin: 12px 0; }
.inline-form .input { min-width: 280px; }
.token-reveal { background: #e3f6ee; border: 1px solid #a8e0c6; border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; max-width: 920px; }
.token-code { display: block; margin-top: 8px; background: #0f2238; color: #7dd3fc; padding: 10px 12px; border-radius: 8px; word-break: break-all; }
.code-block { background: #0f2238; color: #cfe3ff; padding: 16px; border-radius: 10px; overflow-x: auto; font-size: 12px; line-height: 1.7; }
.code-block .api-host { color: #7dd3fc; }

.loading { padding: 40px 0; text-align: center; }
.empty-col { color: var(--muted); font-size: 12.5px; text-align: center; padding: 12px 0; }

/* ============================================================= *
 *  App shell — left sidebar (Amazon-Quick style)                *
 * ============================================================= */
body.app { display: flex; min-height: 100vh; min-height: 100dvh; background: #eef1f6; }
.nav-toggle { position: absolute; }

.sidebar {
  width: 250px; flex: 0 0 250px; position: fixed; inset: 0 auto 0 0; height: 100vh; height: 100dvh;
  background: #fbfcfe; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 12px; z-index: 40;
}
.sidebar-top { padding: 6px 8px 12px; }
.sidebar-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--navy); font-size: 15.5px; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand .brand-rings { font-size: 18px; }
.sidebar-top .countdown {
  display: inline-block; margin-top: 10px; background: var(--azure-soft); color: #1d4ea8;
  padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
}
.sync-status { font-size: 11px; color: var(--muted); letter-spacing: .2px; }
.sync-status.stale { color: var(--amber); }
.sidebar-top .sync-status { display: block; margin-top: 8px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px;
  color: var(--ink); font-weight: 600; font-size: 14px;
}
.side-nav a:hover { background: #eef2f8; text-decoration: none; }
.side-nav a.active { background: var(--azure); color: #fff; }
.side-nav a.active .ico { filter: grayscale(0); }
.side-nav .ico { font-size: 15px; width: 18px; text-align: center; }

.side-section { margin-top: 16px; }
.side-heading { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 0 11px 6px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 8px 11px; border-radius: 9px; color: var(--ink); font-weight: 600; font-size: 13.5px; }
.side-link:hover { background: #eef2f8; text-decoration: none; }
.side-link .ico { width: 18px; text-align: center; }
.side-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 11px; padding: 1px 7px; }

.side-tags { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tag-scroll { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding-right: 2px; }
.tag-link { display: flex; align-items: center; gap: 8px; padding: 5px 11px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.tag-link:hover { background: #eef2f8; color: var(--ink); text-decoration: none; }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.tag-count { margin-left: auto; font-size: 11px; color: var(--muted); }

.sidebar-foot { display: flex; align-items: center; gap: 9px; padding: 12px 8px 4px; border-top: 1px solid var(--line); margin-top: 8px; }
.foot-name { font-size: 13px; font-weight: 600; color: var(--ink); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .signout { color: var(--muted); font-size: 17px; }

.main-area { margin-left: 250px; flex: 1; min-width: 0; }
.mobile-bar { display: none; }
.hamburger { display: none; }

/* ============================================================= *
 *  Activity feed                                                *
 * ============================================================= */
.feed-page { max-width: 880px; margin: 0 auto; padding: 26px 24px 60px; }
.feed-head { margin-bottom: 16px; }
.feed-title { font-size: 24px; display: flex; align-items: center; gap: 8px; }
.feed-title .sparkle { font-size: 20px; }
.feed-sub { margin: 4px 0 0; }
.feed-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.feed-toolbar .input { flex: 1; }
.feed-all { white-space: nowrap; }

.feed-pills { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 20px; }
.pill-btn {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); background: #fff; color: var(--muted);
  border-radius: 18px; padding: 5px 12px; display: inline-flex; align-items: center; gap: 6px;
}
.pill-btn:hover { border-color: var(--azure); color: var(--ink); }
.pill-btn.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.pill-btn.tag.on { background: var(--tag, var(--azure)); border-color: var(--tag, var(--azure)); color: #fff; }
.pill-btn.tag.on .tag-dot { background: #fff !important; }

.feed-section-h { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 8px 2px 10px; }
.feed-section-h:not(:first-child) { margin-top: 24px; }

/* feed view tabs */
.feed-tabs { display: inline-flex; background: #e7ecf3; border-radius: 10px; padding: 3px; gap: 2px; margin-bottom: 14px; }
.ftab { font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; border: none; background: transparent; color: var(--muted); padding: 7px 16px; border-radius: 8px; }
.ftab:hover { color: var(--ink); }
.ftab.on { background: #fff; color: var(--navy); box-shadow: var(--shadow-sm); }

/* resolved states */
.chip-resolved { background: #e3f6ee; color: var(--green); }
.feed-card.resolved { opacity: .82; }
.feed-card.resolved .fc-title { color: var(--muted); }
.resolved-note { margin: 8px 0 0 45px; font-size: 12.5px; color: var(--green); font-weight: 600; background: #f0faf5; border-radius: 8px; padding: 6px 10px; }

/* inline replies on a feed card */
.fc-replies { margin: 12px 0 0 45px; display: flex; flex-direction: column; gap: 8px; border-left: 2px solid var(--line); padding-left: 12px; }
.reply { display: flex; gap: 8px; }
.reply .avatar { width: 24px; height: 24px; font-size: 10px; }
.reply-b { background: #f4f7fb; border-radius: 9px; padding: 6px 10px; font-size: 13px; flex: 1; }
.reply-who { font-weight: 700; color: var(--navy); }
.reply-t { color: var(--muted); font-size: 11px; }
.fc-resolvebox, .fc-reopenbox { margin: 10px 0 0 45px; display: flex; gap: 8px; }
.fc-resolvebox .input, .fc-reopenbox .input { flex: 1; }

/* open-tasks list */
.task-row { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow-sm); margin-bottom: 9px; color: var(--ink); }
.task-row:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.tr-status { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 8px; white-space: nowrap; flex: 0 0 92px; text-align: center; }
.tr-status.st-todo { background: #eef2f8; color: #475569; }
.tr-status.st-in_progress { background: var(--azure-soft); color: #2657b8; }
.tr-status.st-blocked { background: #fff3df; color: var(--amber); }
.tr-status.st-done { background: #e3f6ee; color: var(--green); }
.tr-main { flex: 1; min-width: 0; }
.tr-title { font-weight: 600; color: var(--ink); }
.tr-sub { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-latest { color: var(--ink); }
.tr-tags { margin-top: 5px; display: flex; gap: 4px; flex-wrap: wrap; }
.tr-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

/* nested replies in the board drawer thread */
.thread-q { align-items: flex-start; }
.thread-q-body { flex: 1; background: #f8fafd; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.thread-q.attn .thread-q-body { border-left: 3px solid var(--amber); }
.tq-head { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.tq-title { font-weight: 700; color: var(--navy); margin-top: 3px; font-size: 13.5px; }
.tq-text { font-size: 13px; margin-top: 4px; white-space: pre-wrap; }
.thread-replies { margin-top: 9px; padding-left: 10px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 7px; }

.feed { display: flex; flex-direction: column; gap: 12px; }
.feed-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
  box-shadow: var(--shadow-sm); transition: box-shadow .12s; cursor: default;
}
.feed-card:hover { box-shadow: var(--shadow-md); }
.feed-card.attn { border-left: 4px solid var(--amber); background: #fffdf8; }
.fc-top { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; }
.fc-top .avatar, .fc-top .act-ico { width: 34px; height: 34px; flex: 0 0 auto; }
.act-ico { border-radius: 50%; background: var(--azure-soft); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.fc-headwrap { flex: 1; min-width: 0; }
.fc-title { font-weight: 700; color: var(--navy); font-size: 15px; line-height: 1.35; }
.fc-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.fc-meta .fc-actor { font-weight: 600; color: var(--ink); }
.fc-body { margin: 10px 0 0 45px; color: var(--ink); font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; cursor: pointer; }

/* Rendered Markdown (bold / lists / code / links) in activity + comment bodies.
   The container's pre-wrap is dropped here because mdToHtml emits real block
   elements (no literal newlines), and tight margins keep cards compact. */
.fc-body.md, .tq-text.md, .thread-comment .bubble .body.md, .reply-b .md { white-space: normal; }
.md p { margin: 0 0 8px; }
.md > :last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 1.3em; }
.md li { margin: 2px 0; }
.md li::marker { color: var(--muted); }
.md strong { font-weight: 700; color: var(--navy); }
.md a { text-decoration: underline; }
.md code { background: #eef2f8; padding: 1px 5px; border-radius: 5px; font-size: .92em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.fc-foot { display: flex; align-items: center; gap: 8px; margin: 12px 0 0 45px; flex-wrap: wrap; }
.fc-spacer { flex: 1; }
.feed-tasklink { font-size: 12.5px; font-weight: 600; color: var(--azure); background: var(--azure-soft); padding: 3px 9px; border-radius: 7px; }
.feed-tasklink:hover { text-decoration: none; background: #d9e6ff; }

.chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 12px; white-space: nowrap; }
.chip-attn { background: #fff0d6; color: var(--amber); }
.chip-update { background: var(--azure-soft); color: #2657b8; }
.chip-muted { background: #eef2f8; color: var(--muted); }
.tag-chip { background: #eef2f8; color: var(--muted); font-weight: 600; }
.tag-chip:hover { background: #e2e8f1; text-decoration: none; color: var(--ink); }

.fc-actions { display: flex; gap: 16px; margin: 12px 0 0 45px; padding-top: 10px; border-top: 1px solid var(--line); }
.link-btn { background: none; border: none; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--azure); padding: 0; }
.link-btn:hover { text-decoration: underline; }
.fc-reply { margin: 10px 0 0 45px; display: flex; gap: 8px; }
.fc-reply textarea { flex: 1; min-height: 38px; font: inherit; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 9px; resize: vertical; }
.fc-reply textarea:focus { outline: none; border-color: var(--azure); box-shadow: 0 0 0 3px var(--azure-soft); }

.feed-line { display: flex; align-items: center; gap: 11px; padding: 9px 6px; }
.feed-line .avatar, .feed-line .act-ico { width: 28px; height: 28px; font-size: 11px; }
.line-text { flex: 1; font-size: 13px; color: var(--ink); }
.line-text b { color: var(--navy); }
.line-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty-feed { text-align: center; padding: 50px 0; }

/* tag chips (board cards, task rows) — colored + clickable to filter */
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.mini-tag { font-size: 10.5px; font-weight: 600; color: var(--muted); background: #eef2f8; padding: 1px 7px; border-radius: 10px; white-space: nowrap; display: inline-block; }
.mini-tag.clickable { cursor: pointer; }
.mini-tag.clickable:hover { filter: brightness(0.94); }

@media (max-width: 1000px) {
  .board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-md);
  }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .main-area { margin-left: 0; }
  .mobile-bar {
    display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 14px;
    background: linear-gradient(120deg, var(--navy-deep), var(--navy)); color: #fff; position: sticky; top: 0; z-index: 30;
  }
  .hamburger { display: inline-block; font-size: 22px; cursor: pointer; color: #fff; }
  .mobile-brand { font-weight: 700; }
  .mobile-bar .sync-status { margin-left: auto; color: rgba(255,255,255,.82); white-space: nowrap; }
  .mobile-bar .sync-status.stale { color: #ffd27a; }
}
@media (max-width: 620px) {
  .board { grid-template-columns: 1fr; }
  .fc-body, .fc-foot, .fc-actions, .fc-reply,
  .fc-replies, .resolved-note, .fc-resolvebox, .fc-reopenbox { margin-left: 0; }
}

/* ============================================================= *
 *  Mobile polish (mobile-UX pass)                               *
 *  - 16px form fonts stop iOS focus-zoom (harmless on desktop)  *
 *  - dvh + safe-area + a tap-to-close scrim for the nav drawer  *
 *  - one consolidated phone (<=430px) block                     *
 * ============================================================= */

/* iOS auto-zooms a focused field whose font-size < 16px. */
.input, select.input, .desc-area, .comment-form textarea,
.modal-body input, .modal-body select, .modal-body textarea,
.login-form input[type=email], .login-form input[type=password],
.fc-reply textarea, .fc-resolvebox .input, .fc-reopenbox .input,
.resolve-reason, .reopen-reason, #feed-search { font-size: 16px; }

/* Lock the page behind the open nav drawer. */
body.nav-open { overflow: hidden; }

/* Scrim is hidden until the off-canvas drawer is open (see 820px block). */
.nav-scrim { display: none; }

/* Wide tables (settings) scroll inside their panel instead of widening the page. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll .data-table { min-width: 520px; }

@media (max-width: 820px) {
  .nav-scrim { position: fixed; inset: 0; background: rgba(20,35,60,.45); z-index: 35; }
  #nav-toggle:checked ~ .nav-scrim { display: block; }
  .mobile-bar {
    padding-top: env(safe-area-inset-top);
    padding-left: max(14px, env(safe-area-inset-left));
    height: calc(52px + env(safe-area-inset-top));
  }
  .mobile-brand { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar {
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  /* tighter shell padding reclaims ~30-48px of width */
  .page, .board-page { padding: 14px; }
  .feed-page { padding: 16px 14px 48px; }
  .card-panel { padding: 16px 14px; }
  .feed-card { padding: 14px; }
  #flash-zone { padding: 0 14px; }  /* match the 14px content inset (base is 22px) */
  .page-title { font-size: 19px; }
  .feed-title { font-size: 21px; }
  .toolbar { justify-content: flex-start; gap: 10px; }

  /* ---- 44px touch targets ---- */
  .hamburger { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: -8px; font-size: 22px; line-height: 1; }
  .icon-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .drawer-actions { gap: 8px; }
  .input, select.input { min-height: 44px; }
  .chk { min-height: 44px; }
  .chk input[type=checkbox] { width: 20px; height: 20px; }
  .btn-sm { min-height: 40px; padding: 8px 14px; }
  .assignee-toggle { min-height: 40px; padding: 6px 12px 6px 6px; }
  /* nav-drawer rows + sign-out are touch targets too (already flex, so min-height centers) */
  .side-nav a, .side-link { min-height: 44px; }
  .tag-link { min-height: 40px; padding-top: 8px; padding-bottom: 8px; }
  .sidebar-foot .signout {
    min-width: 44px; min-height: 44px; display: inline-flex;
    align-items: center; justify-content: center; margin: -6px -6px -6px 0;
  }

  /* ---- feed tabs: full-width segmented control ---- */
  .feed-tabs { display: flex; width: 100%; }
  .ftab { flex: 1; min-height: 44px; }

  /* ---- feed toolbar: search full width, checkbox drops below ---- */
  .feed-toolbar { flex-wrap: wrap; }
  .feed-toolbar .input { flex: 1 1 100%; }
  .feed-all { flex: 0 0 auto; }

  /* ---- THE reported fix: filter pills => one-row horizontal scroll strip ---- */
  /* First pill aligns with the page content (left:0/padding:0); the right-edge
     fade is the "swipe for more" cue. Scroll position is managed in activity.js
     so the default "All" state stays pinned to the start (no left drift). */
  .feed-pills {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; margin: 0 0 16px; padding: 2px 0 8px;
    scroll-snap-type: x proximity; scroll-padding-left: 0;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  }
  .feed-pills::-webkit-scrollbar { display: none; }
  .feed-pills .pill-btn { flex: 0 0 auto; scroll-snap-align: start; min-height: 36px; padding: 8px 14px; font-size: 13px; }

  /* ---- open-task rows stack so the title gets full width ---- */
  .task-row { flex-wrap: wrap; gap: 8px 10px; padding: 12px 14px; }
  .tr-status { flex: 0 0 auto; }
  .tr-main { flex: 1 1 100%; order: 3; }
  .tr-right { flex: 0 0 auto; margin-left: auto; }
  .tr-tags { gap: 6px; }
  .mini-tag.clickable { padding: 6px 10px; font-size: 11.5px; }

  /* ---- feed card actions / reply rows ---- */
  .fc-actions { gap: 8px; flex-wrap: wrap; }
  .fc-actions .link-btn { min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px; }
  .fc-reply, .fc-resolvebox, .fc-reopenbox { flex-direction: column; align-items: stretch; }
  .fc-reply .act-send { align-self: flex-end; }
  .fc-reply textarea { min-height: 44px; }
  /* Long email-sourced tokens (URLs, message-ids, addresses) break instead of
     pushing the card past the viewport. */
  .fc-title, .fc-body { overflow-wrap: anywhere; word-break: break-word; }
  .feed-tasklink { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }

  /* ---- board toolbar: search + button full width, selects two-up ---- */
  .toolbar-right { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar-right .input { width: 100%; }
  #filter-search, #new-task-btn, #vendor-search { grid-column: 1 / -1; }
  #new-task-btn { width: 100%; min-height: 44px; }

  /* ---- card drawer => full-width sheet ---- */
  .drawer { width: 100%; max-width: 100%; }
  .drawer-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .field-grid { grid-template-columns: 1fr; gap: 4px 0; margin: 14px 0; }
  .field-grid label { margin-top: 8px; }
  .comment-form { flex-direction: column; align-items: stretch; }
  .comment-form .btn { width: 100%; }
  /* Keep long tokens inside the full-width sheet (min-width:0 lets flex bodies shrink). */
  .card-title { overflow-wrap: anywhere; word-break: break-word; }
  .thread-comment .bubble, .thread-q-body { min-width: 0; }
  .thread-comment .bubble .body, .tq-title, .tq-text { overflow-wrap: anywhere; word-break: break-word; }
  .source-tag, .source-tag code { overflow-wrap: anywhere; word-break: break-word; }

  /* ---- modals => mobile sheet (beats the reopen modal's inline width) ---- */
  .modal-overlay { padding: 0; align-items: flex-start; overflow-y: auto; }
  .modal { width: 100% !important; max-width: 100% !important; max-height: 100dvh; border-radius: 0; display: flex; flex-direction: column; }
  .modal-body { overflow-y: auto; flex: 1; overscroll-behavior: contain; }
  .modal-row { grid-template-columns: 1fr; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }

  /* ---- settings: stacked create-token form, smaller code block ---- */
  .inline-form { flex-wrap: wrap; }
  .inline-form .input { min-width: 0; flex: 1 1 100%; }
  .inline-form .btn { width: 100%; }
  .code-block { font-size: 11px; padding: 12px; }
  .card-panel .muted code, #api-base { overflow-wrap: anywhere; word-break: break-word; }

  /* ---- vendors ---- */
  .vendor-grid { grid-template-columns: 1fr; gap: 12px; }
  .vendor-card { overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
  .vendor-card a, .vendor-notes { overflow-wrap: anywhere; }
  .vendor-links { flex-wrap: wrap; gap: 10px 14px; }
  .vendor-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
  .vendor-meta, .vendor-money, .vendor-notes, .vendor-pay, .vendor-links { font-size: 13.5px; }
  .vendor-meta a { display: inline-flex; align-items: center; min-height: 44px; }

  /* ---- timeline ---- */
  .tl-card { flex-wrap: wrap; align-items: flex-start; min-height: 44px; }
  .tl-title { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
  .tl-card .assignees { margin-left: auto; }
  .tl-card .badge { align-self: center; }  /* center the badge against the taller wrapped avatars */

  /* ---- login ---- */
  .login-card { padding: 28px 22px; }
  .login-card h1 { font-size: 22px; }
  .login-wrap { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
  .login-form .remember { min-height: 44px; }
  .login-form .remember input[type=checkbox] { width: 20px; height: 20px; }
  .login-form .btn-block { min-height: 48px; padding-top: 12px; padding-bottom: 12px; }
}
