/* CCT Work Orders: app styles layered on the design kit's tokens.css */
html{-webkit-text-size-adjust:100%}
body{min-height:100vh;min-height:100dvh}
.boot{display:grid;place-items:center;height:100vh;opacity:.6}
.icon{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round;flex:none}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
a{color:var(--signal)}
button{display:inline-flex;align-items:center;justify-content:center;gap:8px}
button.small{min-height:36px;padding:6px 12px;font-size:13px}
button.link{border:0;background:none;padding:0;min-height:0;color:var(--signal);text-decoration:underline}
button.danger.solid{background:var(--danger);border-color:var(--danger);color:#fff}
[data-theme=dark] button.danger.solid{color:#060c1a}
button.primary:disabled:hover{background:var(--brand)}
input[type=date]{min-width:150px}
textarea{width:100%;min-height:88px;resize:vertical}
label.field input,label.field select,label.field textarea{width:100%}
label.field>span.lbl{font-weight:500}
.field-error{color:var(--danger);font-size:13px}
.hint{color:var(--muted);font-size:12px}
.req::after{content:' *';color:var(--danger)}

/* Shell */
.shell{min-height:100vh;min-height:100dvh}
.sidebar{position:sticky;top:0;height:100vh;height:100dvh;display:flex;flex-direction:column}
.sidebar nav button{justify-content:flex-start;width:100%}
.sidebar .foot{margin-top:auto;color:var(--muted);font-size:12px;padding-top:24px}
.main{min-width:0;display:flex;flex-direction:column}
.mainheader{position:sticky;top:0;z-index:5;padding-top:max(16px,env(safe-area-inset-top))}
.mainheader .who{display:flex;align-items:center;gap:10px}
.crumbs{color:var(--muted);display:flex;gap:6px;align-items:center;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.crumbs a{color:var(--muted);text-decoration:none}
.content{width:100%}
.role{font-size:12px;padding:3px 10px;border-radius:999px;background:var(--surface-alt);color:var(--muted);font-weight:600}
.role.admin{color:var(--blue)}
.role.engineer{color:var(--teal)}
@media(max-width:900px){
  .sidebar{position:static;height:auto;flex-direction:row;align-items:center;gap:12px;flex-wrap:wrap}
  .sidebar nav{flex:1 1 100%;margin:0}
  .sidebar nav button{width:auto;white-space:nowrap}
  .sidebar .foot{display:none}
  .mainheader{position:static}
  .hide-sm{display:none!important}
}
@media(min-width:901px){.show-sm{display:none!important}}

/* Page header */
.pagehead{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;flex-wrap:wrap;margin-bottom:8px}
.pagehead .actions{display:flex;gap:8px;flex-wrap:wrap}
.back{margin-bottom:8px}

/* Filters */
.tools{border:1px solid var(--border);border-radius:12px;margin-top:16px}
.tools label{display:inline-flex;align-items:center;gap:8px}
.tools input[type=search]{width:220px}
.tools select{max-width:220px}
@media(max-width:540px){.tools input[type=search],.tools select{width:100%;max-width:none}.tools>label{width:100%}.tools>label>select,.tools>label>input{flex:1}}
.chips{display:flex;gap:8px;flex-wrap:wrap;align-items:center;padding:12px 0 0}
.chip{display:inline-flex;align-items:center;gap:4px;min-height:32px;padding:2px 4px 2px 10px;border-radius:999px;font-size:12px;font-weight:600;border:1px solid var(--border);background:var(--surface)}
.chip button{min-height:28px;width:28px;padding:0;border:0;background:none;border-radius:999px}
.popwrap{position:relative;display:inline-block}
.popover{position:absolute;z-index:30;top:calc(100% + 6px);left:0;min-width:240px;max-height:min(420px,70vh);overflow:auto;background:var(--surface);border:1px solid var(--border);border-radius:12px;box-shadow:0 12px 32px #0003;padding:8px}
.popover label.check{display:flex;width:100%;padding:0 8px;border-radius:8px}
.popover label.check:hover{background:var(--surface-alt)}
.popover hr{border:0;border-top:1px solid var(--border);margin:6px 0}
.counter{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:12px;flex-wrap:wrap}

/* Bulk bar */
.bulkbar{position:sticky;top:76px;z-index:4;display:flex;gap:10px;align-items:center;flex-wrap:wrap;padding:10px 12px;margin-top:12px;border:1px solid var(--blue);border-radius:12px;background:color-mix(in srgb,var(--blue) 8%,var(--surface))}
@media(max-width:900px){.bulkbar{position:fixed;left:12px;right:12px;top:auto;bottom:max(12px,env(safe-area-inset-bottom));box-shadow:0 8px 24px #0003;background:var(--surface)}}

/* Table */
.tablewrap{max-height:none}
th button.sort{min-height:32px;padding:0;border:0;background:none;color:inherit;font-weight:600;gap:4px}
th.num,td.num{text-align:right}
tbody tr{cursor:pointer}
tbody tr:hover{background:color-mix(in srgb,var(--surface-alt) 60%,var(--surface))}
tbody tr.selected:hover{background:color-mix(in srgb,var(--blue) 12%,var(--surface))}
td .wo{font-weight:700}
td.desc{max-width:340px}
.dots{display:flex;gap:4px;margin-top:6px;align-items:center}
.dots i{width:8px;height:8px;border-radius:50%;background:var(--c,var(--slate));opacity:.75}
.dots i:last-child{outline:2px solid color-mix(in srgb,var(--c,var(--slate)) 40%,transparent);outline-offset:1px;opacity:1}
.dots .more{font-size:11px;color:var(--muted);margin-left:2px}
.wo-card.selected{border-color:var(--blue);background:color-mix(in srgb,var(--blue) 7%,var(--surface))}
.wo-card .meta{color:var(--muted);font-size:13px}
.pill.outline{background:transparent;border:1px solid color-mix(in srgb,var(--c) 45%,transparent)}
.pill.big{font-size:14px;padding:6px 14px}
.empty{text-align:center;padding:40px 16px}
.empty h2{margin-top:0}

/* Detail */
.summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:16px;margin-top:16px}
.kv span{display:block;color:var(--muted);font-size:12px;margin-bottom:4px}
.kv strong,.kv div{font-size:15px}
.timeline{margin-top:8px}
.timeline article .row{gap:8px}
.timeline article:before{background:var(--c,var(--blue))}
.timeline .who{color:var(--muted);font-size:12px}
.timeline .comment{margin:6px 0 0;white-space:pre-wrap}
.dur{display:grid;grid-template-columns:minmax(120px,200px) 1fr 56px;gap:12px;align-items:center;margin:10px 0;font-size:13px}
.dur .bar{height:12px}
.progress{display:flex;align-items:center;gap:10px}
.progress .bar{flex:1;min-width:80px}
.section-title{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}
.section-title h2{margin:0}
.panel+.panel,.grid+.panel,.panel+.grid{margin-top:20px}
.grid>.panel+.panel{margin-top:0}

/* Dialog */
dialog{padding:0}
dialog form,dialog .dlg{padding:24px 28px}
dialog .dlg-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:12px}
dialog .dlg-head h2{margin:0}
dialog .dlg-foot{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap;margin-top:8px;position:sticky;bottom:0;background:var(--surface);padding:12px 0 0}
dialog.wide{width:min(860px,calc(100% - 32px))}
.checks{display:flex;flex-wrap:wrap;gap:4px 16px}
.callout{padding:12px 14px;border-radius:10px;background:var(--surface-alt);font-size:13px;margin-bottom:16px}
.callout.warn{background:color-mix(in srgb,var(--amber) 12%,var(--surface));color:var(--text)}
.callout.bad{background:color-mix(in srgb,var(--red) 10%,var(--surface))}
.err{color:var(--danger);min-height:20px;margin:4px 0 0}
@media(max-width:540px){dialog form,dialog .dlg{padding:20px 16px}}

/* Toast */
.toast{bottom:max(24px,env(safe-area-inset-bottom));box-shadow:var(--shadow);max-width:calc(100% - 48px)}
.toast.bad{border-color:var(--danger)}

/* Login */
.auth{min-height:100vh;min-height:100dvh;display:grid;place-items:center;padding:24px 16px;background:radial-gradient(1000px 500px at 50% -10%,color-mix(in srgb,var(--brand) 18%,transparent),transparent),var(--bg)}
.auth .panel{width:min(420px,100%)}
.auth .lockup{margin-bottom:24px}
.auth .lockup img{width:48px}
.auth button.primary{width:100%;margin-top:8px}

/* Tabs */
.tabs{display:flex;gap:4px;overflow:auto;border-bottom:1px solid var(--border);margin:16px 0 20px}
.tabs button{border:0;border-bottom:3px solid transparent;border-radius:0;background:none;white-space:nowrap;color:var(--muted)}
.tabs button.active{color:var(--text);border-bottom-color:var(--brand);font-weight:600}
[data-theme=dark] .tabs button.active{border-bottom-color:var(--signal)}

/* Misc */
.stat{cursor:pointer;text-align:left}
.stats .panel{padding:20px}
.listrow.click{cursor:pointer}
.listrow.click:hover{background:var(--surface-alt);margin:0 -12px;padding-left:12px;padding-right:12px;border-radius:8px}
.metric button{width:100%}
.swatch{display:inline-block;width:16px;height:16px;border-radius:50%;background:var(--c);vertical-align:middle}
.diff{font-family:ui-monospace,Menlo,monospace;font-size:12px;white-space:pre-wrap;word-break:break-word;margin:0}
.diff .del{color:var(--red)}.diff .add{color:var(--green)}
.inline-form{display:flex;gap:8px;flex-wrap:wrap;align-items:flex-end}
.inline-form label.field{margin:0}
.copy{display:flex;gap:8px}.copy input{flex:1}
.spinner{width:18px;height:18px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.offline{background:var(--amber);color:#17243e;text-align:center;font-size:13px;padding:6px}

/* ---- fixes after visual QA ---- */
.stat{display:block;width:100%}
.stat strong{margin-top:8px}
.kv>span{display:block}
.kv span.pill,.kv span.age{display:inline-flex;margin:0 4px 4px 0}
.kv .progress{margin-top:4px}
th button.sort{white-space:nowrap}
td:nth-last-child(-n+2) .age,td a{white-space:nowrap}
@media(max-width:900px){
  .shell{grid-template-columns:minmax(0,1fr)}
  .sidebar nav{min-width:0;max-width:100%}
  .sidebar .lockup br{display:none}
}
.tools .filters-toggle{display:none}
@media(max-width:540px){
  .tools>label:not(.check){width:100%}
  .tools>label.check{width:auto}
  .tools>label>input[type=checkbox]{flex:none}
  .tools .filters-toggle{display:inline-flex}
  .tools:not(.open)>*:not(.filters-toggle):not(label:first-child):not(.keep){display:none}
  .tools .popwrap,.tools .popwrap>button{width:100%}
  .popover{left:0;right:0;min-width:0}
}
td>.row{flex-wrap:nowrap}
