:root {
  --bg: #f4f1ec; --bg2: #ffffff; --bg3: #ebe6de; --ink: #1b2a38; --ink2: #4b5a69; --muted: #5c6874; --line: #d9d2c6;
  --rust: #C2551F; --rust2: #a3451a; --navy: #1b2a38; --sand: #e8e2d6; --green: #2e7d4f; --amber: #b7791f; --red: #b3261e; --blue: #2a5d8f; --purple: #6b4fa1;
  --radius: 10px; --shadow: 0 1px 2px rgba(27,42,56,.06), 0 4px 16px rgba(27,42,56,.06);
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif; --serif: "Source Serif 4", Georgia, serif;
}
:root[data-theme="dark"] { --bg: #141a21; --bg2: #1c242d; --bg3: #232d38; --ink: #ecebe6; --ink2: #c3c8cf; --muted: #8b96a2; --line: #2f3a46; --sand: #2a333d; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--rust); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-family: var(--serif); font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg3); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.boot { padding: 60px; text-align: center; color: var(--muted); }
.small { font-size: 12px; } .muted { color: var(--muted); } .right { text-align: right; } .nowrap { white-space: nowrap; } .mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.hide { display: none !important; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #e2c9b6 0%, var(--bg) 55%); }
.login .card { width: 360px; max-width: 100%; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 32px; height: 32px; border-radius: 8px; background: var(--navy); position: relative; flex: none; }
.brand .mark::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 7px; height: 11px; background: var(--rust); }
.brand .mark::before { content: ""; position: absolute; left: 9px; right: 9px; top: 8px; height: 4px; background: #e8e2d6; }
.brand b { font-family: var(--serif); font-size: 17px; } .brand span { display: block; font-size: 11px; color: var(--muted); }

/* ---------- layout ---------- */
.app { min-height: 100vh; }
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #d9dee4; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.side .brand b, .side .brand span { color: #fff; } .side .brand span { color: #9fb0c2; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: #c9d2db; padding: 8px 10px; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; } .nav a.active { background: var(--rust); color: #fff; }
.nav .sec { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #7f8fa0; padding: 10px 10px 2px; }
.nav .pill { background: rgba(255,255,255,.15); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; }
.nav a.active .pill { background: rgba(0,0,0,.2); }
.side .foot { margin-top: auto; font-size: 11px; color: #9fb0c2; display: flex; flex-direction: column; gap: 6px; }
.side .foot button { background: transparent; border: 1px solid rgba(255,255,255,.2); color: #c9d2db; border-radius: 6px; padding: 5px 8px; cursor: pointer; }
.main { padding: 22px 26px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-btn { display: none; }

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: 14px; } .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(--bg2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card .hd { padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .bd { padding: 12px 14px; } .card .bd.tight { padding: 0; }
.stat { padding: 14px; } .stat .v { font-size: 26px; font-weight: 700; line-height: 1.1; font-family: var(--serif); } .stat .l { font-size: 12px; color: var(--muted); margin-top: 4px; } .stat .sub { font-size: 12px; color: var(--ink2); margin-top: 6px; }
.stat.warn .v { color: var(--rust); }

/* ---------- forms / buttons ---------- */
.btn { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--ink2); } .btn.primary { background: var(--rust); border-color: var(--rust); color: #fff; } .btn.primary:hover { background: var(--rust2); }
.btn.danger { color: var(--red); } .btn.sm { padding: 4px 9px; font-size: 12px; } .btn.ghost { border-color: transparent; background: transparent; } .btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; } .field label { font-size: 12px; color: var(--ink2); font-weight: 500; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=email], input[type=password], input[type=search], select, textarea { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(194,85,31,.35); border-color: var(--rust); }
textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row > * { min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 14px; } .form-grid .span2 { grid-column: span 2; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; } .filters select, .filters input { width: auto; min-width: 140px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; } th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; white-space: nowrap; }
th.sorted::after { content: " ↕"; color: var(--rust); } tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--bg3); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; background: var(--bg3); color: var(--ink2); }
.badge.stage-0 { background: #e9eef3; color: #3b4a59; } .badge.stage-1 { background: #e3ecf6; color: #2a5d8f; } .badge.stage-2 { background: #e5eef9; color: #1f4f80; } .badge.stage-3 { background: #ece7f7; color: #5a3f99; }
.badge.stage-4 { background: #f8e8d9; color: #a3451a; } .badge.stage-5 { background: #fbe0cf; color: #8a3a12; } .badge.stage-6 { background: #e3f1e8; color: #2e7d4f; } .badge.stage-7 { background: #d6ead9; color: #246b40; } .badge.stage-8 { background: #2e7d4f; color: #fff; }
.badge.parked { background: #eee; color: #777; } .badge.lost { background: #f3dedd; color: #b3261e; }
.badge.type { background: var(--sand); color: var(--ink2); } .badge.warn { background: #fbe9c6; color: #8a5a0e; } .badge.ok { background: #e3f1e8; color: #2e7d4f; } .badge.danger { background: #f3dedd; color: #b3261e; } .badge.info { background: #e3ecf6; color: #2a5d8f; }
:root[data-theme="dark"] .badge.stage-0 { background: #2a3540; color: #c3c8cf; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ---------- stage stepper ---------- */
.stepper { display: flex; gap: 4px; flex-wrap: wrap; } .stepper .st { flex: 1 1 90px; padding: 6px 8px; border-radius: 6px; background: var(--bg3); font-size: 11px; text-align: center; color: var(--muted); border: 1px solid transparent; cursor: pointer; }
.stepper .st.done { background: #e3f1e8; color: #2e7d4f; } .stepper .st.cur { background: var(--rust); color: #fff; font-weight: 600; } .stepper .st:hover { border-color: var(--ink2); }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.col { background: var(--bg3); border-radius: var(--radius); padding: 8px; min-height: 200px; }
.col .ch { font-size: 12px; font-weight: 600; padding: 4px 6px 8px; display: flex; justify-content: space-between; color: var(--ink2); }
.col.over { outline: 2px dashed var(--rust); }
.kcard { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.kcard b { display: block; } .kcard .m { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.kcard.stale { border-left: 3px solid var(--rust); }

/* ---------- drawer ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(27,42,56,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 760px; max-width: 100%; background: var(--bg); z-index: 41; overflow: auto; box-shadow: -8px 0 30px rgba(0,0,0,.2); padding: 18px 22px 60px; }
.drawer .dh { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; position: sticky; top: -18px; background: var(--bg); padding: 6px 0 10px; z-index: 2; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 12px 0; overflow: auto; } .tabs button { background: none; border: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; } .tabs button.active { color: var(--rust); border-bottom-color: var(--rust); font-weight: 600; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 10px; font-size: 13px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; } .timeline li { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); } .timeline .d { font-size: 12px; color: var(--muted); white-space: nowrap; } .timeline .x { font-size: 12px; color: var(--ink2); margin-top: 3px; white-space: pre-wrap; }
.timeline .in { border-left: 3px solid var(--blue); padding-left: 8px; } .timeline .out { border-left: 3px solid var(--rust); padding-left: 8px; }
.note { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--bg2); } .note .nh { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; } .note p { margin: 4px 0 0; white-space: pre-wrap; }

/* ---------- misc ---------- */
.funnel { display: flex; flex-direction: column; gap: 5px; } .funnel .fr { display: grid; grid-template-columns: 170px 1fr 70px; align-items: center; gap: 8px; font-size: 12px; } .funnel .bar { height: 14px; background: var(--sand); border-radius: 4px; overflow: hidden; } .funnel .bar i { display: block; height: 100%; background: var(--rust); }
.list { list-style: none; margin: 0; padding: 0; } .list li { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; align-items: baseline; } .list li:last-child { border-bottom: none; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 60; font-size: 13px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.suitegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.suite { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--bg2); cursor: pointer; font-size: 12px; } .suite b { display: block; font-size: 13px; } .suite .sf { color: var(--muted); }
.suite.available { border-left: 4px solid var(--green); } .suite.prospect { border-left: 4px solid var(--blue); } .suite.negotiating { border-left: 4px solid var(--purple); } .suite.loi { border-left: 4px solid var(--amber); } .suite.leased { border-left: 4px solid var(--rust); background: #fbe0cf; color: #3a2416; } .suite.programmed { border-left: 4px solid #999; } .suite.common, .suite.boh { opacity: .55; border-left: 4px solid #ccc; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink2); margin-bottom: 10px; }
.checkbox { display: flex; align-items: center; gap: 6px; } .checkbox input { width: auto; }
.bulkbar { position: sticky; bottom: 10px; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; } .bulkbar select { width: auto; }
.fc { position: relative; } .fc-grid { stroke: var(--line); stroke-width: 1; } .fc-ax { font-size: 11px; fill: var(--muted); } .fc-lbl { font-size: 11px; fill: var(--ink2); }
.fc-line { fill: none; stroke-width: 2; stroke-linejoin: round; } .fc-cross { stroke: var(--ink2); stroke-width: 1; stroke-dasharray: 3 3; }
.fc-tip { position: absolute; top: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); pointer-events: none; min-width: 200px; }
:root { --s1: #eb6834; --s2: #2a78d6; --s3: #1baf7a; } :root[data-theme="dark"] { --s1: #d95926; --s2: #3987e5; --s3: #199e70; }
.fc-line.s1 { stroke: var(--s1); } .fc-line.s2 { stroke: var(--s2); } .fc-line.s3 { stroke: var(--s3); stroke-dasharray: 6 4; } .dot.s1 { background: var(--s1); } .dot.s2 { background: var(--s2); } .dot.s3 { background: var(--s3); }
.login .alt { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; } .login .or { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0; }
.side-brand { display: flex; flex-direction: column; gap: 6px; } .side-brand .kc-logo { width: 170px; max-width: 100%; height: auto; display: block; }
.side-brand .app-name { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #9fb0c2; }
.project-mark { margin-top: 8px; background: #f4f1ec; border-radius: 8px; padding: 8px 10px; min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
.project-mark img { max-width: 100%; max-height: 64px; object-fit: contain; display: block; margin: 0 auto; }
.project-mark .project-name { font-family: var(--serif); font-size: 17px; color: #1b2a38; line-height: 1.2; } .project-mark .project-sub { font-size: 11px; color: #4b5a69; }
.proj-switch { margin-top: 6px; background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 6px; padding: 5px 8px; font-size: 12px; }
.proj-switch option { color: #1b2a38; }
.login-brand { text-align: center; margin-bottom: 16px; } .login-brand .kc-logo { width: 220px; max-width: 100%; height: auto; } .login-brand .app-name { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.logo-preview { max-width: 220px; max-height: 80px; object-fit: contain; background: #f4f1ec; border-radius: 6px; padding: 6px; }
.feat-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 2px 10px; }
.capture textarea { min-height: 140px; font-size: 16px; } .capture input, .capture select { font-size: 16px; }
#bt-tbl input, #bt-tbl select { padding: 4px 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.side .foot .foot-link { color: #c9d2db; } .qr img { width: 200px; height: 200px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }
@media print { .side, .topbar .actions, .btn, .filters { display: none !important; } .shell { grid-template-columns: 1fr; } .main { padding: 0; } .card { box-shadow: none; break-inside: avoid; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; } .side { position: fixed; left: -260px; width: 240px; transition: left .2s; z-index: 30; } .side.open { left: 0; }
  .menu-btn { display: inline-block; } .main { padding: 14px; } .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; } .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: span 1; } .drawer { width: 100%; } .kv { grid-template-columns: 1fr; }
}
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* ---------- v5: accessibility, palette, gantt, undo toast, import ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -40px; z-index: 100; background: var(--navy); color: #fff; padding: 8px 12px; border-radius: 6px; text-decoration: none; }
.skip-link:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }
td.row-open:focus-visible, .kcard:focus-visible, .suite:focus-visible { outline: 2px solid var(--rust); outline-offset: -2px; }
.main:focus { outline: none; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.toast-action { display: flex; align-items: center; gap: 10px; bottom: 64px; }
.toast-action .btn { background: #fff; color: var(--navy); border-color: #fff; }
.palette-bg { position: fixed; inset: 0; background: rgba(10, 16, 24, .45); z-index: 80; display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.palette { width: min(640px, 100%); background: var(--bg2); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--line); }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; font-size: 16px; padding: 14px 16px; width: 100%; background: var(--bg2); color: var(--ink); }
.palette ul { list-style: none; margin: 0; padding: 6px 0; max-height: 52vh; overflow: auto; }
.palette li { padding: 8px 16px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.palette li.on { background: var(--bg3); }
.pal-foot { padding: 8px 16px; border-top: 1px solid var(--line); }
.views-bar { margin-bottom: 8px; align-items: center; }
.gantt { display: grid; gap: 2px; min-width: 640px; } .card .bd:has(> .gantt) { overflow-x: auto; }
.g-row { display: grid; grid-template-columns: 240px 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.g-head { font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line); }
.g-track { position: relative; height: 22px; background: linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), var(--line) 100%); }
.g-head .g-track { height: 16px; } .g-month { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.g-bar { position: absolute; top: 7px; height: 8px; border-radius: 4px; background: var(--s2); }
.g-bar.anchor { background: var(--s1); }
.g-open { position: absolute; top: 3px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--navy); border: 2px solid var(--bg2); }
.g-open.bad { background: var(--red, #b3261e); }
.fc-tip { position: absolute; top: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); pointer-events: none; min-width: 180px; }
.hide { display: none !important; }
@media (max-width: 720px) { .g-row { grid-template-columns: 130px 1fr; } }
/* closed off-canvas menu is not reachable by keyboard or screen readers */
@media (max-width: 900px) { .side:not(.open) { visibility: hidden; transition: left .2s, visibility 0s .2s; } .side.open { visibility: visible; transition: left .2s; } }
/* long unbroken values (addresses, sign-in links, emails) never widen the page; bare tables scroll inside their card */
.kv > * { min-width: 0; overflow-wrap: anywhere; }
.card .bd:has(> table), .card .bd:has(> form > table) { overflow-x: auto; }
.main { min-width: 0; }

/* last-updated stamp in the top bar */
.last-upd { font-size: 12px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.badge.info { background: var(--accent-soft, #e6eff6); color: var(--blue); }
