/* ============================================================
   Obra Control — construction project record
   Palette: drafting blue on cool paper. Mono for every document number.
   ============================================================ */

:root{
  --bg:#EDEFF2;
  --surface:#FFFFFF;
  --surface-2:#F6F7F9;
  --surface-3:#E4E7EC;
  --line:#D6D9DF;
  --line-2:#BEC3CC;
  --text:#121722;
  --text-2:#4C5462;
  --text-3:#78808E;
  --accent:#1B3A66;
  --accent-2:#122A4D;
  --accent-soft:#E3E8F1;
  --accent-line:#B3C0D6;
  --ok:#1A6B4B; --ok-soft:#E2EFE9; --ok-line:#A9D2BF;
  --warn:#8A5A12; --warn-soft:#F6EBD9; --warn-line:#DFC79A;
  --crit:#9E3128; --crit-soft:#F6E2DF; --crit-line:#E1B0AA;
  --mute:#5A6472; --mute-soft:#E9EBEE; --mute-line:#C9CED6;
  --shadow-1:0 1px 2px rgba(18,23,34,.07);
  --shadow-2:0 2px 4px rgba(18,23,34,.06), 0 12px 28px -14px rgba(18,23,34,.28);
  --shadow-3:0 24px 60px -20px rgba(18,23,34,.42);
  --r-sm:4px; --r-md:7px; --r-lg:12px;
  --sans:"IBM Plex Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  --disp:"Archivo","IBM Plex Sans",-apple-system,"Segoe UI",sans-serif;
  --mono:"IBM Plex Mono",ui-monospace,SFMono-Regular,Menlo,monospace;
  --sidebar-w:244px;
  color-scheme:light;
}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#0A0E16;
    --surface:#121722;
    --surface-2:#181E2B;
    --surface-3:#212838;
    --line:#242B3A;
    --line-2:#374056;
    --text:#E6E9EF;
    --text-2:#A3ABBA;
    --text-3:#7D8697;
    --accent:#7FA2D6;
    --accent-2:#9CBAE6;
    --accent-soft:#162034;
    --accent-line:#2C3E62;
    --ok:#57C296; --ok-soft:#0F2620; --ok-line:#215240;
    --warn:#D5A45A; --warn-soft:#2A2116; --warn-line:#564322;
    --crit:#DE8378; --crit-soft:#2C1917; --crit-line:#59302B;
    --mute:#93A0B3; --mute-soft:#1A2030; --mute-line:#2E3749;
    --shadow-1:0 1px 2px rgba(0,0,0,.4);
    --shadow-2:0 2px 4px rgba(0,0,0,.35), 0 12px 28px -14px rgba(0,0,0,.7);
    --shadow-3:0 24px 60px -20px rgba(0,0,0,.8);
    color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --bg:#0A0E16;
  --surface:#121722;
  --surface-2:#181E2B;
  --surface-3:#212838;
  --line:#242B3A;
  --line-2:#374056;
  --text:#E6E9EF;
  --text-2:#A3ABBA;
  --text-3:#7D8697;
  --accent:#7FA2D6;
  --accent-2:#9CBAE6;
  --accent-soft:#162034;
  --accent-line:#2C3E62;
  --ok:#57C296; --ok-soft:#0F2620; --ok-line:#215240;
  --warn:#D5A45A; --warn-soft:#2A2116; --warn-line:#564322;
  --crit:#DE8378; --crit-soft:#2C1917; --crit-line:#59302B;
  --mute:#93A0B3; --mute-soft:#1A2030; --mute-line:#2E3749;
  --shadow-1:0 1px 2px rgba(0,0,0,.4);
  --shadow-2:0 2px 4px rgba(0,0,0,.35), 0 12px 28px -14px rgba(0,0,0,.7);
  --shadow-3:0 24px 60px -20px rgba(0,0,0,.8);
  color-scheme:dark;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:var(--sans); font-size:14px; line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4{font-family:var(--disp); margin:0; text-wrap:balance; letter-spacing:-.01em}
a{color:var(--accent); text-decoration:none}
a:hover{text-decoration:underline}
button,input,select,textarea{font:inherit; color:inherit}
/* every icon is 16px unless a component says otherwise */
svg{width:16px; height:16px; flex:none}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:3px}
.mono{font-family:var(--mono); font-variant-numeric:tabular-nums}
.num{font-family:var(--mono); font-variant-numeric:tabular-nums}
.muted{color:var(--text-2)}
.dim{color:var(--text-3)}
.tiny{font-size:11.5px}
.sm{font-size:12.5px}
.nowrap{white-space:nowrap}
.right{text-align:right}
.center{text-align:center}
.grow{flex:1}
.hide{display:none !important}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* ---------- shell ---------- */
.shell{display:grid; grid-template-columns:var(--sidebar-w) 1fr; height:100%; overflow:hidden}
.main{display:flex; flex-direction:column; min-width:0; height:100%; overflow:hidden}
.view{flex:1; overflow-y:auto; overflow-x:hidden; padding:20px 22px 64px; scroll-behavior:smooth}
.view:focus{outline:none}
.wrap{max-width:1360px; margin:0 auto}

/* ---------- sidebar ---------- */
.sidebar{
  background:var(--surface); border-right:1px solid var(--line);
  display:flex; flex-direction:column; height:100%; overflow:hidden; z-index:40;
}
.brand{display:flex; align-items:center; gap:10px; padding:16px 16px 14px; border-bottom:1px solid var(--line)}
.brand-mark{
  width:32px;height:32px;border-radius:var(--r-sm); background:var(--accent); color:#fff;
  display:grid;place-items:center; font-family:var(--disp); font-weight:700; font-size:13px; letter-spacing:.02em;
  flex:none;
}
.brand-name{font-family:var(--disp); font-weight:700; font-size:14.5px; line-height:1.1}
.brand-sub{font-size:10.5px; letter-spacing:.09em; text-transform:uppercase; color:var(--text-3); font-weight:600}
.nav{flex:1; overflow-y:auto; padding:10px 10px 20px}
.nav-label{
  font-size:10px; letter-spacing:.1em; text-transform:uppercase; color:var(--text-3);
  font-weight:700; padding:14px 8px 6px;
}
.nav-item{
  display:flex; align-items:center; gap:10px; width:100%; text-align:left;
  padding:7px 9px; border-radius:var(--r-md); border:0; background:transparent;
  color:var(--text-2); cursor:pointer; font-size:13.5px; font-weight:500; margin-bottom:1px;
}
.nav-item:hover{background:var(--surface-2); color:var(--text); text-decoration:none}
.nav-item.active{background:var(--accent-soft); color:var(--accent); font-weight:600}
.nav-item.active svg{color:var(--accent)}
.nav-item svg{width:16px;height:16px;flex:none;color:var(--text-3)}
.nav-count{
  margin-left:auto; font-family:var(--mono); font-size:11px; color:var(--text-3);
  background:var(--surface-3); border-radius:20px; padding:1px 7px; font-weight:500;
}
.nav-item.active .nav-count{background:var(--surface); color:var(--accent)}
.sidebar-foot{border-top:1px solid var(--line); padding:10px}
.proj-switch{
  width:100%; display:flex; align-items:center; gap:8px; padding:8px 10px; border:1px solid var(--line);
  background:var(--surface-2); border-radius:var(--r-md); cursor:pointer; text-align:left;
}
.proj-switch:hover{border-color:var(--line-2)}
.proj-switch .grow{min-width:0}
.proj-switch .pk{display:block; font-family:var(--mono); font-size:10.5px; color:var(--text-3); line-height:1.3}
.proj-switch .pn{display:block; font-size:12.5px; font-weight:600; line-height:1.25; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}

/* ---------- topbar ---------- */
.topbar{
  display:flex; align-items:center; gap:10px; padding:10px 22px;
  border-bottom:1px solid var(--line); background:var(--surface);
  position:sticky; top:env(safe-area-inset-top,0px); z-index:30; flex:none;
}
.icon-btn{
  width:34px;height:34px;display:grid;place-items:center; border:1px solid transparent;
  background:transparent; border-radius:var(--r-md); cursor:pointer; color:var(--text-2); position:relative; flex:none;
}
.icon-btn:hover{background:var(--surface-2); color:var(--text); border-color:var(--line)}
.icon-btn svg{width:17px;height:17px}
.icon-btn .dot{
  position:absolute; top:5px; right:5px; min-width:15px; height:15px; padding:0 3px; border-radius:9px;
  background:var(--crit); color:#fff; font-size:9.5px; font-weight:700; display:grid; place-items:center;
  font-family:var(--mono); border:2px solid var(--surface);
}
.search{position:relative; flex:1; max-width:480px}
.search input{
  width:100%; padding:8px 12px 8px 34px; border:1px solid var(--line); border-radius:var(--r-md);
  background:var(--surface-2); font-size:13px;
}
.search input:focus{background:var(--surface); border-color:var(--accent-line); outline:none}
.search svg{position:absolute; left:10px; top:9px; width:15px;height:15px; color:var(--text-3)}
.search kbd{
  position:absolute; right:8px; top:7px; font-family:var(--mono); font-size:10px; color:var(--text-3);
  border:1px solid var(--line); border-radius:3px; padding:1px 5px; background:var(--surface);
}
.who{display:flex; align-items:center; gap:8px; padding:4px 8px 4px 4px; border-radius:20px; border:1px solid var(--line); background:var(--surface-2); cursor:pointer}
.who:hover{border-color:var(--line-2)}
.who img{width:24px;height:24px;border-radius:50%; flex:none}
.who .wn{display:block; font-size:12.5px; font-weight:600; line-height:1.15; max-width:130px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.who .wr{display:block; font-size:10px; letter-spacing:.06em; text-transform:uppercase; color:var(--text-3); font-weight:700; line-height:1.2}
.menu-btn{display:none}

/* ---------- page header ---------- */
.page-head{display:flex; align-items:flex-end; gap:16px; flex-wrap:wrap; margin-bottom:18px}
.page-head h1{font-size:22px; font-weight:700}
.page-head .sub{color:var(--text-2); font-size:13px; margin-top:3px}
.head-actions{margin-left:auto; display:flex; gap:8px; flex-wrap:wrap}

/* ---------- buttons ---------- */
.btn{
  display:inline-flex; align-items:center; gap:7px; padding:7px 13px; border-radius:var(--r-md);
  border:1px solid var(--line); background:var(--surface); color:var(--text); font-size:13px;
  font-weight:500; cursor:pointer; white-space:nowrap;
}
.btn:hover{background:var(--surface-2); border-color:var(--line-2); text-decoration:none}
.btn svg{width:15px;height:15px}
.btn.primary{background:var(--accent); border-color:var(--accent); color:#fff}
.btn.primary:hover{background:var(--accent-2); border-color:var(--accent-2)}
.btn.ghost{border-color:transparent; background:transparent; color:var(--text-2)}
.btn.ghost:hover{background:var(--surface-2); color:var(--text)}
.btn.danger{color:var(--crit); border-color:var(--crit-line); background:var(--crit-soft)}
.btn.danger:hover{background:var(--crit-soft); border-color:var(--crit)}
.btn.sm{padding:4px 9px; font-size:12px}
.btn[disabled]{opacity:.45; cursor:not-allowed}
.btn-row{display:flex; gap:8px; flex-wrap:wrap}

/* ---------- pills ---------- */
.pill{
  display:inline-flex; align-items:center; gap:5px; padding:2px 9px; border-radius:20px;
  font-size:11.5px; font-weight:600; border:1px solid var(--mute-line); background:var(--mute-soft); color:var(--mute);
  white-space:nowrap; line-height:1.55;
}
.pill.ok{color:var(--ok); background:var(--ok-soft); border-color:var(--ok-line)}
.pill.warn{color:var(--warn); background:var(--warn-soft); border-color:var(--warn-line)}
.pill.crit{color:var(--crit); background:var(--crit-soft); border-color:var(--crit-line)}
.pill.info{color:var(--accent); background:var(--accent-soft); border-color:var(--accent-line)}
.pill.plain{background:transparent}
.pill .pdot{width:6px;height:6px;border-radius:50%;background:currentColor;flex:none}
.tag{
  display:inline-block; font-size:10.5px; font-weight:600; letter-spacing:.05em; text-transform:uppercase;
  color:var(--text-3); border:1px solid var(--line); border-radius:3px; padding:1px 5px;
}

/* ---------- cards / panels ---------- */
.card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg)}
.card-h{display:flex; align-items:center; gap:10px; padding:13px 16px; border-bottom:1px solid var(--line)}
.card-h h3{font-size:13.5px; font-weight:700}
.card-h .more{margin-left:auto; font-size:12px}
.card-b{padding:16px}
.card-b.flush{padding:0}
.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))}
.g-main{grid-template-columns:minmax(0,2fr) minmax(0,1fr)}

/* ---------- stat strip ---------- */
.stats{display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:1px; background:var(--line);
  border:1px solid var(--line); border-radius:var(--r-lg); overflow:hidden; margin-bottom:16px}
.stat{background:var(--surface); padding:13px 15px; cursor:pointer; text-align:left; border:0; display:block; width:100%;
  color:var(--text); text-decoration:none}
a.stat:hover, a.pcard:hover, a.fitem:hover, a.tl-item:hover, a.photo:hover{text-decoration:none}
a.stat, a.pcard, a.fitem, a.tl-item, a.photo{color:var(--text)}
.fav svg{width:14px;height:14px}
.stat:hover{background:var(--surface-2)}
.stat .sl{font-size:10.5px; letter-spacing:.08em; text-transform:uppercase; color:var(--text-3); font-weight:700}
.stat .sv{font-family:var(--mono); font-size:24px; font-weight:500; line-height:1.15; margin-top:5px; font-variant-numeric:tabular-nums}
.stat .sn{font-size:11.5px; color:var(--text-2); margin-top:2px}
.stat .sv.alert{color:var(--crit)}
.stat .sv.warn{color:var(--warn)}
.stat .sv.good{color:var(--ok)}

/* ---------- tables ---------- */
.tbl-wrap{overflow-x:auto; -webkit-overflow-scrolling:touch}
table.tbl{width:100%; border-collapse:collapse; font-size:13px; min-width:640px}
table.tbl th{
  text-align:left; font-family:var(--disp); font-size:10.5px; letter-spacing:.07em; text-transform:uppercase;
  color:var(--text-3); font-weight:700; padding:9px 12px; border-bottom:1px solid var(--line);
  background:var(--surface-2); position:sticky; top:0; z-index:1; white-space:nowrap;
}
table.tbl th.sortable{cursor:pointer; user-select:none}
table.tbl th.sortable:hover{color:var(--text)}
table.tbl td{padding:10px 12px; border-bottom:1px solid var(--line); vertical-align:middle}
table.tbl tbody tr{cursor:pointer}
table.tbl tbody tr:hover{background:var(--surface-2)}
table.tbl tbody tr:last-child td{border-bottom:0}
table.tbl .c-id{font-family:var(--mono); font-size:12px; font-weight:500; color:var(--accent); white-space:nowrap}
table.tbl .c-title{font-weight:500}
table.tbl .c-num{font-family:var(--mono); font-variant-numeric:tabular-nums; text-align:right; white-space:nowrap}
tr.od td{background:var(--crit-soft)}
.rowsub{font-size:11.5px; color:var(--text-3); margin-top:1px}

/* ---------- filter bar ---------- */
.filters{display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:12px}
.filters select, .filters input[type="search"], .filters input[type="date"]{
  padding:6px 9px; border:1px solid var(--line); border-radius:var(--r-md); background:var(--surface); font-size:12.5px;
}
.filters .fchip{display:flex; align-items:center; gap:6px}
.filters .fchip label{font-size:11px; color:var(--text-3); font-weight:600; text-transform:uppercase; letter-spacing:.05em}
.result-count{margin-left:auto; font-size:12px; color:var(--text-3); font-family:var(--mono)}

/* ---------- project header ---------- */
.proj-head{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); overflow:hidden; margin-bottom:16px}
.proj-head-top{padding:16px 18px; display:flex; gap:18px; flex-wrap:wrap; align-items:flex-start}
.proj-title h1{font-size:20px; line-height:1.2}
.proj-title .pnum{font-family:var(--mono); font-size:12px; color:var(--text-3); margin-top:4px}
.proj-prog{margin-left:auto; min-width:210px}
.prog-top{display:flex; justify-content:space-between; align-items:baseline; font-size:11.5px; color:var(--text-3); font-weight:600; text-transform:uppercase; letter-spacing:.06em}
.prog-top b{font-family:var(--mono); font-size:19px; color:var(--text); font-weight:500; letter-spacing:0; text-transform:none}
.bar{height:7px; background:var(--surface-3); border-radius:6px; overflow:hidden; margin-top:6px}
.bar span{display:block; height:100%; background:var(--accent); border-radius:6px}
.bar.mini{height:5px; margin-top:4px}
.proj-meta{display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); border-top:1px solid var(--line)}
.pm{padding:10px 18px; border-right:1px solid var(--line)}
.pm:last-child{border-right:0}
.pm dt{font-size:10px; letter-spacing:.08em; text-transform:uppercase; color:var(--text-3); font-weight:700}
.pm dd{margin:3px 0 0; font-size:13px; font-weight:500}
.tabs{display:flex; gap:2px; overflow-x:auto; border-bottom:1px solid var(--line); margin-bottom:16px; scrollbar-width:thin}
.tab{
  padding:8px 12px; border:0; background:transparent; cursor:pointer; font-size:13px; font-weight:600;
  color:var(--text-2); border-bottom:2px solid transparent; white-space:nowrap; font-family:var(--disp);
}
.tab:hover{color:var(--text)}
.tab.active{color:var(--accent); border-bottom-color:var(--accent)}
.tab .tc{font-family:var(--mono); font-size:10.5px; color:var(--text-3); margin-left:5px; font-weight:500}

/* ---------- project cards ---------- */
.pcards{display:grid; grid-template-columns:repeat(auto-fill,minmax(310px,1fr)); gap:14px}
.pcard{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:15px; cursor:pointer; display:block; text-align:left; width:100%}
.pcard:hover{border-color:var(--accent-line); box-shadow:var(--shadow-2); text-decoration:none}
.pcard h3{font-size:15px; margin-bottom:3px}
.pcard .pnum{font-family:var(--mono); font-size:11px; color:var(--text-3)}
.pcard .prow{display:flex; gap:10px; font-size:12px; color:var(--text-2); margin-top:10px; flex-wrap:wrap}
.pcard .pstats{display:flex; gap:14px; margin-top:12px; padding-top:11px; border-top:1px solid var(--line)}
.pcard .pstat{font-size:11px; color:var(--text-3)}
.pcard .pstat b{display:block; font-family:var(--mono); font-size:15px; color:var(--text); font-weight:500}

/* ---------- activity feed ---------- */
.feed{display:flex; flex-direction:column}
.fitem{display:flex; gap:11px; padding:10px 16px; border-bottom:1px solid var(--line); align-items:flex-start}
.fitem:last-child{border-bottom:0}
.fitem:hover{background:var(--surface-2)}
.fav{width:26px;height:26px;border-radius:50%; flex:none; background:var(--surface-3); display:grid; place-items:center; font-size:10px; font-weight:700; color:var(--text-2); overflow:hidden}
.fav img{width:100%;height:100%;object-fit:cover}
.ftext{flex:1; min-width:0; font-size:13px; line-height:1.45}
.ftext b{font-weight:600}
.ftime{font-family:var(--mono); font-size:11px; color:var(--text-3); white-space:nowrap; padding-top:2px}
.fact{display:block; font-size:11px; color:var(--text-3); margin-top:1px}

/* ---------- timeline ---------- */
.tl{position:relative; padding-left:26px}
.tl::before{content:""; position:absolute; left:8px; top:4px; bottom:4px; width:2px; background:var(--line)}
.tl-day{position:relative; margin-bottom:6px}
.tl-day-h{font-family:var(--mono); font-size:11.5px; font-weight:600; color:var(--text-3); margin:16px 0 8px; letter-spacing:.03em}
.tl-item{position:relative; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-md); padding:10px 13px; margin-bottom:8px; cursor:pointer}
.tl-item:hover{border-color:var(--accent-line)}
.tl-item::before{content:""; position:absolute; left:-22px; top:14px; width:9px;height:9px; border-radius:50%; background:var(--surface); border:2px solid var(--line-2)}
.tl-item.k-approve::before{border-color:var(--ok)}
.tl-item.k-create::before{border-color:var(--accent)}
.tl-item.k-delete::before{border-color:var(--crit)}
.tl-item.k-revise::before{border-color:var(--warn)}

/* ---------- forms ---------- */
.form{display:grid; gap:14px}
.frow{display:grid; gap:14px; grid-template-columns:repeat(2,minmax(0,1fr))}
.frow.f3{grid-template-columns:repeat(3,minmax(0,1fr))}
.field label{display:block; font-size:11px; letter-spacing:.06em; text-transform:uppercase; color:var(--text-3); font-weight:700; margin-bottom:5px}
.field label .req{color:var(--crit)}
.field input, .field select, .field textarea{
  width:100%; padding:8px 10px; border:1px solid var(--line); border-radius:var(--r-md);
  background:var(--surface); font-size:13.5px;
}
.field textarea{min-height:88px; resize:vertical; line-height:1.5}
.field input:focus, .field select:focus, .field textarea:focus{border-color:var(--accent); outline:none; box-shadow:0 0 0 3px var(--accent-soft)}
.field .hint{font-size:11.5px; color:var(--text-3); margin-top:4px}
.field .err{font-size:11.5px; color:var(--crit); margin-top:4px; font-weight:500}
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"]{border-color:var(--crit)}
.checkline{display:flex; align-items:center; gap:8px; font-size:13px}
.checkline input{width:auto}
.fieldset{border:1px solid var(--line); border-radius:var(--r-md); padding:13px; }
.fieldset legend{font-size:10.5px; letter-spacing:.07em; text-transform:uppercase; color:var(--text-3); font-weight:700; padding:0 6px}

/* ---------- modal / drawer ---------- */
.overlay-root{position:fixed; inset:0; pointer-events:none; z-index:100}
.backdrop{position:fixed; inset:0; background:rgba(9,20,27,.46); pointer-events:auto; animation:fade .15s ease}
@keyframes fade{from{opacity:0}to{opacity:1}}
.modal{
  position:fixed; left:50%; top:50%; transform:translate(-50%,-50%);
  width:min(760px, calc(100vw - 32px)); max-height:min(88vh, 900px); display:flex; flex-direction:column;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); box-shadow:var(--shadow-3);
  pointer-events:auto; animation:pop .16s ease;
}
.modal.wide{width:min(1020px, calc(100vw - 32px))}
.modal.narrow{width:min(470px, calc(100vw - 32px))}
@keyframes pop{from{opacity:0; transform:translate(-50%,-48%) scale(.985)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}
.drawer{
  position:fixed; top:0; right:0; bottom:0; width:min(620px,100vw); display:flex; flex-direction:column;
  background:var(--surface); border-left:1px solid var(--line); box-shadow:var(--shadow-3);
  pointer-events:auto; animation:slide .18s ease;
}
@keyframes slide{from{transform:translateX(18px); opacity:.6}to{transform:none;opacity:1}}
.m-head{display:flex; align-items:flex-start; gap:12px; padding:14px 18px; border-bottom:1px solid var(--line); flex:none}
.m-head h2{font-size:16px; line-height:1.25}
.m-head .msub{font-size:12px; color:var(--text-3); margin-top:3px; font-family:var(--mono)}
.m-body{padding:18px; overflow-y:auto; flex:1}
.m-body.flush{padding:0}
.m-foot{display:flex; gap:8px; justify-content:flex-end; padding:12px 18px; border-top:1px solid var(--line); flex:none; background:var(--surface-2); flex-wrap:wrap}
.m-foot .left{margin-right:auto}

/* ---------- detail record ---------- */
.dl{display:grid; grid-template-columns:minmax(120px,auto) 1fr; gap:8px 16px; font-size:13px; align-items:baseline}
.dl dt{font-size:10.5px; letter-spacing:.07em; text-transform:uppercase; color:var(--text-3); font-weight:700; padding-top:2px}
.dl dd{margin:0}
.sec{margin-top:20px}
.sec:first-child{margin-top:0}
.sec-h{font-family:var(--disp); font-size:11px; letter-spacing:.09em; text-transform:uppercase; color:var(--text-3);
  font-weight:700; padding-bottom:6px; border-bottom:1px solid var(--line); margin-bottom:11px; display:flex; align-items:center; gap:8px}
.sec-h .n{font-family:var(--mono); letter-spacing:0; color:var(--text-3)}
.sec-h .act{margin-left:auto}
.prose{font-size:13.5px; line-height:1.6; white-space:pre-wrap; word-wrap:break-word}
.answer-box{background:var(--ok-soft); border:1px solid var(--ok-line); border-radius:var(--r-md); padding:12px 14px}
.answer-box .ah{font-size:10.5px; letter-spacing:.07em; text-transform:uppercase; font-weight:700; color:var(--ok); margin-bottom:6px}
.note-box{background:var(--surface-2); border:1px solid var(--line); border-radius:var(--r-md); padding:11px 13px}
.warn-box{background:var(--warn-soft); border:1px solid var(--warn-line); color:var(--warn); border-radius:var(--r-md); padding:10px 13px; font-size:12.5px; font-weight:500}
.crit-box{background:var(--crit-soft); border:1px solid var(--crit-line); color:var(--crit); border-radius:var(--r-md); padding:10px 13px; font-size:12.5px; font-weight:500}

/* ---------- attachments / files ---------- */
.files{display:flex; flex-direction:column; gap:6px}
.file{display:flex; align-items:center; gap:10px; padding:8px 11px; border:1px solid var(--line); border-radius:var(--r-md); background:var(--surface-2)}
.file .fi{width:30px;height:30px; border-radius:var(--r-sm); display:grid; place-items:center; flex:none;
  font-family:var(--mono); font-size:9px; font-weight:600; background:var(--surface-3); color:var(--text-2); text-transform:uppercase}
.file .fi.pdf{background:var(--crit-soft); color:var(--crit)}
.file .fi.img{background:var(--accent-soft); color:var(--accent)}
.file .fi.xls{background:var(--ok-soft); color:var(--ok)}
.file .fi.doc{background:var(--accent-soft); color:var(--accent)}
.file .fn{flex:1; min-width:0; font-size:12.5px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.file .fm{font-size:11px; color:var(--text-3); font-family:var(--mono)}
.file .fb{display:flex; gap:2px}
.drop{
  border:1.5px dashed var(--line-2); border-radius:var(--r-md); padding:18px; text-align:center;
  color:var(--text-3); font-size:12.5px; cursor:pointer; background:var(--surface-2);
}
.drop:hover, .drop.over{border-color:var(--accent); color:var(--accent); background:var(--accent-soft)}
.drop b{display:block; color:var(--text); font-size:13px; margin-bottom:2px}
.upbar{height:3px; background:var(--surface-3); border-radius:3px; overflow:hidden; margin-top:8px}
.upbar span{display:block; height:100%; background:var(--accent); width:40%; animation:ind 1.1s ease-in-out infinite}
@keyframes ind{0%{margin-left:-40%}100%{margin-left:100%}}

/* ---------- versions ---------- */
.vers{display:flex; flex-direction:column; gap:0; border:1px solid var(--line); border-radius:var(--r-md); overflow:hidden}
.ver{display:flex; align-items:center; gap:11px; padding:9px 12px; border-bottom:1px solid var(--line); background:var(--surface)}
.ver:last-child{border-bottom:0}
.ver.current{background:var(--accent-soft)}
.ver .vb{
  font-family:var(--mono); font-size:11px; font-weight:600; border:1px solid var(--line-2); border-radius:3px;
  padding:1px 6px; color:var(--text-2); background:var(--surface); flex:none;
}
.ver.current .vb{border-color:var(--accent); color:var(--accent); background:var(--surface)}
.ver .vmain{flex:1; min-width:0}
.ver .vn{font-size:12.5px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.ver .vm{font-size:11px; color:var(--text-3); margin-top:1px}

/* ---------- comments ---------- */
.cmt{display:flex; gap:10px; padding:11px 0; border-bottom:1px solid var(--line)}
.cmt:last-of-type{border-bottom:0}
.cmt .ch{display:flex; align-items:baseline; gap:8px; margin-bottom:3px; flex-wrap:wrap}
.cmt .cn{font-size:12.5px; font-weight:600}
.cmt .ct{font-family:var(--mono); font-size:11px; color:var(--text-3)}
.cmt .cb{font-size:13px; line-height:1.5; white-space:pre-wrap; word-wrap:break-word}
.mention{color:var(--accent); font-weight:600; background:var(--accent-soft); border-radius:3px; padding:0 3px}
.cmt-form{display:flex; gap:8px; align-items:flex-end; margin-top:12px; position:relative}
.cmt-form textarea{flex:1; min-height:64px}
.mention-menu{
  position:absolute; bottom:100%; left:0; margin-bottom:4px; background:var(--surface); border:1px solid var(--line);
  border-radius:var(--r-md); box-shadow:var(--shadow-2); min-width:220px; max-height:210px; overflow-y:auto; z-index:5;
}
.mention-menu button{display:flex; gap:8px; align-items:center; width:100%; text-align:left; padding:7px 10px; border:0; background:transparent; cursor:pointer; font-size:12.5px}
.mention-menu button:hover, .mention-menu button.sel{background:var(--accent-soft)}

/* ---------- thread ---------- */
.thread{display:flex; flex-direction:column; gap:12px}
.msg{border:1px solid var(--line); border-radius:var(--r-md); overflow:hidden}
.msg-h{display:flex; align-items:center; gap:9px; padding:8px 12px; background:var(--surface-2); border-bottom:1px solid var(--line); flex-wrap:wrap}
.msg-h .mn{font-size:12.5px; font-weight:600}
.msg-h .mt{font-family:var(--mono); font-size:11px; color:var(--text-3); margin-left:auto}
.msg-b{padding:12px; font-size:13.5px; line-height:1.55; white-space:pre-wrap}
.route{display:flex; align-items:center; gap:6px; font-size:11.5px; color:var(--text-2); flex-wrap:wrap}
.route svg{width:12px;height:12px;color:var(--text-3)}

/* ---------- photos ---------- */
.photos{display:grid; grid-template-columns:repeat(auto-fill,minmax(168px,1fr)); gap:12px}
.photo{border:1px solid var(--line); border-radius:var(--r-md); overflow:hidden; background:var(--surface); cursor:pointer; position:relative; text-align:left; padding:0; width:100%}
.photo:hover{border-color:var(--accent-line); box-shadow:var(--shadow-2)}
.photo .pimg{aspect-ratio:4/3; background:var(--surface-3); display:block; width:100%; object-fit:cover}
.photo .pmeta{padding:8px 10px}
.photo .pcap{font-size:12px; font-weight:500; line-height:1.35; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden}
.photo .pd{font-family:var(--mono); font-size:10.5px; color:var(--text-3); margin-top:3px}
.photo .pcat{position:absolute; top:7px; left:7px}
.photo .psel{position:absolute; top:7px; right:7px; width:20px;height:20px; border-radius:4px; border:1.5px solid #fff; background:rgba(9,20,27,.4); display:grid; place-items:center}
.photo.sel{border-color:var(--accent); box-shadow:0 0 0 2px var(--accent-soft)}
.photo.sel .psel{background:var(--accent)}
.lightbox img{max-width:100%; max-height:66vh; display:block; margin:0 auto; border-radius:var(--r-md); background:var(--surface-3)}

/* ---------- calendar ---------- */
.cal{border:1px solid var(--line); border-radius:var(--r-lg); overflow:hidden; background:var(--surface)}
.cal-h{display:grid; grid-template-columns:repeat(7,1fr); background:var(--surface-2); border-bottom:1px solid var(--line)}
.cal-h div{padding:7px 8px; font-size:10.5px; letter-spacing:.07em; text-transform:uppercase; color:var(--text-3); font-weight:700; text-align:center}
.cal-g{display:grid; grid-template-columns:repeat(7,1fr)}
.cal-d{min-height:96px; border-right:1px solid var(--line); border-bottom:1px solid var(--line); padding:5px 6px; position:relative}
.cal-d:nth-child(7n){border-right:0}
.cal-d.out{background:var(--surface-2)}
.cal-d.today{background:var(--accent-soft)}
.cal-d .dn{font-family:var(--mono); font-size:11.5px; color:var(--text-3); font-weight:500}
.cal-d.today .dn{color:var(--accent); font-weight:700}
.cev{display:block; width:100%; text-align:left; font-size:11px; padding:2px 5px; border-radius:3px; margin-top:3px;
  background:var(--accent-soft); color:var(--accent); border:0; cursor:pointer; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:500}
.cev.t-inspection{background:var(--warn-soft); color:var(--warn)}
.cev.t-milestone{background:var(--ok-soft); color:var(--ok)}
.cev.t-deadline{background:var(--crit-soft); color:var(--crit)}
.cev.t-meeting{background:var(--mute-soft); color:var(--mute)}

/* ---------- misc ---------- */
.empty{text-align:center; padding:40px 20px; color:var(--text-3)}
.empty svg{width:30px;height:30px; margin-bottom:10px; color:var(--line-2)}
.empty h3{font-size:14.5px; color:var(--text-2); margin-bottom:4px}
.empty p{font-size:12.5px; margin:0 0 14px}
.toasts{position:fixed; bottom:16px; left:50%; transform:translateX(-50%); z-index:300; display:flex; flex-direction:column; gap:8px; align-items:center; pointer-events:none; padding:0 16px; width:100%; max-width:520px}
.toast{background:var(--text); color:var(--bg); padding:9px 15px; border-radius:20px; font-size:13px; font-weight:500; box-shadow:var(--shadow-2); animation:up .18s ease; pointer-events:auto}
.toast.bad{background:var(--crit); color:#fff}
.toast.good{background:var(--ok); color:#fff}
@keyframes up{from{opacity:0; transform:translateY(8px)}to{opacity:1;transform:none}}
.scrim{position:fixed; inset:0; background:rgba(9,20,27,.45); z-index:35}
.boot{position:fixed; inset:0; background:var(--bg); display:grid; place-items:center; z-index:500}
.boot-card{text-align:center; width:min(300px,86vw)}
.boot-mark{width:44px;height:44px;border-radius:8px;background:var(--accent);color:#fff;display:grid;place-items:center;
  font-family:var(--disp);font-weight:700;font-size:16px;margin:0 auto 14px}
.boot-text{font-size:13px;color:var(--text-2); margin-bottom:12px}
.boot-bar{height:3px;background:var(--surface-3);border-radius:3px;overflow:hidden}
.boot-bar span{display:block;height:100%;width:38%;background:var(--accent);animation:ind 1.1s ease-in-out infinite}
.banner{display:flex; align-items:center; gap:10px; padding:9px 14px; border-radius:var(--r-md); font-size:12.5px; margin-bottom:14px; font-weight:500}
.banner.warn{background:var(--warn-soft); border:1px solid var(--warn-line); color:var(--warn)}
.banner.info{background:var(--accent-soft); border:1px solid var(--accent-line); color:var(--accent)}
.banner .btn{margin-left:auto}
.notif{display:flex; gap:10px; padding:10px 14px; border-bottom:1px solid var(--line); cursor:pointer; align-items:flex-start; width:100%; text-align:left; background:transparent; border-left:0; border-right:0; border-top:0}
.notif:hover{background:var(--surface-2)}
.notif.unread{background:var(--accent-soft)}
.notif.unread:hover{background:var(--accent-soft)}
.notif .nd{flex:1; min-width:0}
.notif .nt{font-size:12.5px; line-height:1.4}
.notif .nm{font-family:var(--mono); font-size:10.5px; color:var(--text-3); margin-top:2px}
.kv{display:flex; gap:8px; font-size:12.5px; padding:4px 0}
.kv .k{color:var(--text-3); min-width:132px; font-size:11px; letter-spacing:.06em; text-transform:uppercase; font-weight:700; padding-top:2px}
.kv .v{flex:1}
.diff{font-family:var(--mono); font-size:11.5px; border:1px solid var(--line); border-radius:var(--r-sm); overflow:hidden}
.diff div{padding:4px 8px; border-bottom:1px solid var(--line); display:flex; gap:8px}
.diff div:last-child{border-bottom:0}
.diff .df{color:var(--text-3); min-width:120px}
.diff .db{color:var(--crit); text-decoration:line-through; opacity:.75}
.diff .da{color:var(--ok)}
.perm-tbl td{text-align:center}
.perm-tbl td:first-child{text-align:left; font-weight:500}
.perm-tbl input{width:15px;height:15px; cursor:pointer}
.chips{display:flex; gap:6px; flex-wrap:wrap}
.chip{display:inline-flex; align-items:center; gap:5px; padding:3px 8px; border-radius:20px; background:var(--surface-3);
  font-size:11.5px; font-weight:500; border:1px solid var(--line)}
.chip button{border:0;background:transparent;cursor:pointer;color:var(--text-3);padding:0;line-height:1;font-size:14px}
.seg{display:inline-flex; border:1px solid var(--line); border-radius:var(--r-md); overflow:hidden; background:var(--surface)}
.seg button{border:0; background:transparent; padding:5px 11px; font-size:12.5px; cursor:pointer; color:var(--text-2); font-weight:500; border-right:1px solid var(--line)}
.seg button:last-child{border-right:0}
.seg button.on{background:var(--accent); color:#fff; font-weight:600}
.spark{display:flex; align-items:flex-end; gap:2px; height:34px}
.spark i{flex:1; background:var(--accent-soft); border-radius:1px 1px 0 0; min-height:2px; display:block}
.spark i.hi{background:var(--accent)}
.legend{display:flex; gap:12px; flex-wrap:wrap; font-size:11.5px; color:var(--text-2); margin-top:10px}
.legend span{display:flex; align-items:center; gap:5px}
.legend i{width:9px;height:9px;border-radius:2px;display:block}
.docs-tree{display:flex; gap:16px; align-items:flex-start}
.folders{width:200px; flex:none}
.folder{display:flex; align-items:center; gap:8px; width:100%; text-align:left; padding:6px 9px; border:0; background:transparent;
  border-radius:var(--r-md); cursor:pointer; font-size:12.5px; color:var(--text-2); font-weight:500}
.folder:hover{background:var(--surface-2); color:var(--text)}
.folder.on{background:var(--accent-soft); color:var(--accent); font-weight:600}
.folder .fc{margin-left:auto; font-family:var(--mono); font-size:10.5px; color:var(--text-3)}
.preview-frame{width:100%; height:min(66vh,620px); border:1px solid var(--line); border-radius:var(--r-md); background:var(--surface-2)}

/* ---------- responsive ---------- */
@media (max-width:1100px){
  .g-main{grid-template-columns:minmax(0,1fr)}
  .g4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .g3{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:900px){
  .shell{grid-template-columns:1fr}
  .sidebar{position:fixed; top:0; bottom:0; left:0; width:270px; transform:translateX(-100%); transition:transform .2s ease}
  .shell.nav-open .sidebar{transform:none}
  .menu-btn{display:grid}
  .view{padding:16px 16px 72px}
  .topbar{padding:9px 16px}
  .search kbd{display:none}
  .topbar .grow{display:none}
  .who .wn,.who .wr{display:none}
  .who{padding:3px; border:0; background:transparent}
  .docs-tree{flex-direction:column}
  .folders{width:100%; display:flex; gap:6px; overflow-x:auto; padding-bottom:4px}
  .folder{white-space:nowrap; width:auto; border:1px solid var(--line)}
  .drawer{width:100vw}
}
@media (max-width:700px){
  .g2,.g3,.g4{grid-template-columns:minmax(0,1fr)}
  .frow,.frow.f3{grid-template-columns:minmax(0,1fr)}
  .page-head h1{font-size:19px}
  .head-actions{margin-left:0; width:100%}
  .proj-prog{margin-left:0; width:100%}
  .pm{border-right:0; border-bottom:1px solid var(--line)}
  .cal-d{min-height:64px}
  .cal-d .cev{font-size:0; padding:0; height:5px; margin-top:2px}
  /* tables become stacked records */
  table.tbl{min-width:0; display:block}
  table.tbl thead{display:none}
  table.tbl tbody,table.tbl tr,table.tbl td{display:block; width:100%}
  table.tbl tr{border:1px solid var(--line); border-radius:var(--r-md); margin-bottom:9px; padding:4px 0; background:var(--surface)}
  table.tbl td{border-bottom:0; padding:5px 12px; display:flex; gap:12px; align-items:baseline}
  table.tbl td::before{
    content:attr(data-l); flex:none; width:96px; font-size:10px; letter-spacing:.07em; text-transform:uppercase;
    color:var(--text-3); font-weight:700; padding-top:2px;
  }
  table.tbl td.c-num{text-align:left; justify-content:flex-start}
  table.tbl td[data-l=""]::before{display:none}
  .result-count{margin-left:0}
  .m-foot{flex-direction:column-reverse; align-items:stretch}
  .m-foot .btn{justify-content:center}
  .m-foot .left{margin-right:0}
}
@media (prefers-reduced-motion:reduce){
  *{animation-duration:.001ms !important; transition-duration:.001ms !important}
  .view{scroll-behavior:auto}
}
@media print{
  .sidebar,.topbar,.head-actions,.filters{display:none}
  .view{overflow:visible; padding:0}
  body{background:#fff}
}

/* ============================================================
   Sign-in, password recovery and invitations
   ============================================================ */
body.auth-mode #app,
body.auth-mode #boot { display: none; }

.auth-root {
  position: fixed; inset: 0; z-index: 400;
  background: var(--bg);
  overflow-y: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.auth-wrap { width: 100%; max-width: 408px; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 30px 28px 26px;
  box-shadow: 0 1px 2px rgba(18, 23, 34, .05), 0 10px 30px rgba(18, 23, 34, .07);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.auth-mark { width: 30px; height: 30px; flex: none; fill: var(--accent); }
.auth-product { font-family: Archivo, system-ui, sans-serif; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.auth-org { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.auth-title {
  font-family: Archivo, system-ui, sans-serif;
  font-size: 21px; font-weight: 600; letter-spacing: -.015em;
  margin: 0 0 6px;
}
.auth-sub { font-size: 13px; color: var(--text-2); line-height: 1.5; margin: 0 0 20px; }
.auth-para { font-size: 13.5px; color: var(--text-2); line-height: 1.6; margin: 0 0 18px; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: block; }
.auth-field span {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-2); margin-bottom: 5px;
}
.auth-field input {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px;
  font: inherit; font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 6px;
}
.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.auth-go { width: 100%; justify-content: center; padding: 10px 14px; margin-top: 4px; }

.auth-msg {
  font-size: 12.5px; line-height: 1.5;
  padding: 10px 12px; border-radius: 6px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.auth-msg.bad { color: var(--crit); background: color-mix(in srgb, var(--crit) 9%, transparent); border-color: color-mix(in srgb, var(--crit) 28%, transparent); }
.auth-msg.ok  { color: var(--ok);   background: color-mix(in srgb, var(--ok) 10%, transparent);  border-color: color-mix(in srgb, var(--ok) 28%, transparent); }

.auth-foot {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
}
.auth-foot a { color: var(--accent); text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

.auth-legal {
  font-size: 11.5px; line-height: 1.55;
  color: var(--text-3);
  text-align: center;
  margin: 18px auto 0;
  max-width: 340px;
}

@media (max-width: 460px) {
  .auth-card { padding: 24px 20px 22px; }
  .auth-title { font-size: 19px; }
}
