/* ===========================================================================
   FIELD OFFICE — the theme.

   This one is deliberately not a website.

   A Tahasil office runs Windows, the operator has been doing data entry for
   eleven years, and the fastest interface they have ever used is a grey box
   with keyboard shortcuts. Every instinct a web designer has - generous
   whitespace, big rounded cards, a hero - makes that person slower. So this
   looks like a native desktop application, because that is what the work is:

   - System grey chrome, 1px borders, square corners. No shadows except the
     one under a real modal.
   - Segoe UI at 13px. Dense rows, 26px tall, because a register clerk wants
     forty rows on screen and not twelve.
   - Every action has a function key and the status bar says so. The mouse is
     an option, not the plan.
   - Underlined access keys in the menu, because that is the muscle memory.
   - Colour appears three times: the title bar, the sync state, and a conflict.
     Nowhere else.

   It should feel like software that was installed, not visited.
   =========================================================================== */
:root{
  --chrome:#F0F0F0;
  --chrome-d:#E1E1E1;
  --face:#FFFFFF;
  --ink:#1B1B1B;
  --ink-2:#444;
  --mut:#6C6C6C;
  --line:#C8C8C8;
  --line-2:#A0A0A0;
  --title:#1F3864;        /* the classic dark-blue title bar */
  --title-2:#2B4F8C;
  --sel:#CDE3FB;
  --sel-line:#5B9BD5;
  --ok:#0E6B34;
  --warn:#8A5200;
  --bad:#A4262C;
  --queue:#7A3E00;
  /* THE THIRD DELIBERATE EXCEPTION to the house type system, for the same
     reason as -apple-system on the iOS app and Roboto on the Android one:
     this is a Windows desktop replica and on Windows the correct typeface IS
     Segoe UI. Substituting Archivo would make it look like a web page dressed
     as an application, which is precisely what it is built to argue we do not
     do. Written down so nobody "corrects" it later. */
  --ui:"Segoe UI",Tahoma,"Archivo","Helvetica Neue",Arial,sans-serif;
  --mono:var(--f-data);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;height:100vh;display:flex;flex-direction:column;overflow:hidden;
  background:var(--chrome);color:var(--ink);
  font:13px/1.35 var(--ui);
  -webkit-font-smoothing:auto;               /* crisp, not smoothed: native */
}
button,input,select,textarea{font:inherit;color:inherit}

#app{flex:1;min-height:0;display:flex;flex-direction:column;
  border:1px solid var(--line-2);border-top:0;background:var(--chrome)}

/* ------------------------------------------------------------- title bar */
.tbar{
  flex:none;display:flex;align-items:center;gap:9px;height:30px;padding:0 4px 0 9px;
  background:linear-gradient(180deg,var(--title-2),var(--title));color:#fff;
  font-size:12.5px;
}
.tbar .ic{width:15px;height:15px;flex:none}
.tbar .tt{font-weight:600;letter-spacing:.01em}
.tbar .doc{opacity:.78}
.tbar .wbtn{margin-left:auto;display:flex}
.tbar .wbtn span{
  width:42px;height:30px;display:grid;place-items:center;font-size:11px;
  color:#E8EEF8;
}
.tbar .wbtn span:last-child:hover{background:#C42B1C}
.tbar .wbtn span:hover{background:rgba(255,255,255,.14)}

/* ------------------------------------------------------------- menu bar */
.mbar{
  flex:none;display:flex;align-items:stretch;height:25px;
  background:var(--chrome);border-bottom:1px solid var(--chrome-d);
}
.mbar button{
  border:0;background:transparent;padding:0 10px;font-size:12.5px;cursor:default;
  color:var(--ink);
}
.mbar button:hover{background:#D6E4F7}
.mbar u{text-decoration:underline}

/* -------------------------------------------------------------- toolbar */
.tool{
  flex:none;display:flex;align-items:center;gap:3px;padding:4px 6px;
  background:var(--chrome);border-bottom:1px solid var(--line);
}
.tool button{
  display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 9px;
  border:1px solid transparent;background:transparent;cursor:pointer;
  font-size:12.5px;border-radius:2px;white-space:nowrap;
}
.tool button:hover:not(:disabled){background:#D6E4F7;border-color:#9EC3EC}
.tool button:active:not(:disabled){background:#BFD8F5}
.tool button:disabled{color:#A6A6A6;cursor:default}
.tool button svg{width:14px;height:14px;flex:none;fill:none;stroke:currentColor;
  stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.tool button kbd{
  font:600 10.5px var(--ui);color:var(--mut);background:var(--chrome-d);
  border:1px solid var(--line);border-radius:2px;padding:0 3px;margin-left:2px;
}
.tool .sep{width:1px;height:20px;background:var(--line);margin:0 4px}
.tool .grow{flex:1}
.tool .find{
  display:flex;align-items:center;gap:5px;border:1px solid var(--line-2);
  background:#fff;height:24px;padding:0 6px;min-width:210px;
}
.tool .find input{border:0;outline:0;flex:1;min-width:0;font-size:12.5px;background:none}
.tool .find svg{width:13px;height:13px;stroke:var(--mut)}

/* ------------------------------------------------------------ the split */
.split{flex:1;min-height:0;display:grid;grid-template-columns:1fr 372px}
.left{min-width:0;display:flex;flex-direction:column;border-right:1px solid var(--line)}
.right{min-width:0;display:flex;flex-direction:column;background:var(--chrome);
  overflow-y:auto}

/* -------------------------------------------------------------- the grid
   A real data grid: fixed header, 26px rows, a focus ring you can drive with
   the arrow keys, and column alignment that follows the data type. */
.gwrap{flex:1;min-height:0;overflow:auto;background:var(--face)}
table.grid{border-collapse:separate;border-spacing:0;width:100%;font-size:12.5px}
table.grid th{
  position:sticky;top:0;z-index:2;background:var(--chrome);text-align:left;
  font-weight:600;font-size:12px;color:var(--ink-2);padding:0 8px;height:25px;
  border-bottom:1px solid var(--line);border-right:1px solid var(--chrome-d);
  white-space:nowrap;cursor:pointer;user-select:none;
}
table.grid th:hover{background:#E3ECF7}
table.grid th .ar{color:var(--sel-line);font-size:10px;margin-left:3px}
table.grid td{
  padding:0 8px;height:26px;border-bottom:1px solid #EFEFEF;white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis;max-width:260px;
}
table.grid td.n{text-align:right;font-variant-numeric:tabular-nums;font-family:var(--mono);
  font-size:12px}
table.grid tbody tr{cursor:default}
table.grid tbody tr:nth-child(even){background:#FAFAFA}
table.grid tbody tr:hover{background:#EFF5FD}
table.grid tbody tr.on{background:var(--sel)}
table.grid tbody tr.on td{border-bottom-color:#B7D4F2}
table.grid tbody tr:focus{outline:1px dotted #333;outline-offset:-2px}
/* an unsynced row is marked in the gutter, not recoloured: the operator has
   to be able to read the row, and "this has not gone to the server yet" is a
   property of the row's journey, not of its content */
table.grid td.g{width:20px;padding:0 0 0 6px;text-align:center}
.gq{color:var(--queue);font-weight:700}
.gc{color:var(--bad);font-weight:700}
.gs{color:var(--ok)}
.pill{
  display:inline-block;font-size:11px;padding:0 6px;border:1px solid;
  border-radius:2px;line-height:16px;font-weight:600;
}
.p-new{color:var(--mut);border-color:var(--line-2);background:#F6F6F6}
.p-ver{color:var(--warn);border-color:#D9B48A;background:#FFF6E8}
.p-ok{color:var(--ok);border-color:#9BC7AC;background:#EDF7F1}
.p-rej{color:var(--bad);border-color:#DBAAAD;background:#FCF0F1}

/* --------------------------------------------------------------- the form */
.grp{border:1px solid var(--line);margin:9px;background:var(--face)}
.grp>h3{
  margin:0;padding:6px 9px;font-size:12px;font-weight:600;color:var(--ink-2);
  background:var(--chrome);border-bottom:1px solid var(--line);
  display:flex;align-items:center;gap:7px;
}
.grp>h3 .rt{margin-left:auto;font-weight:400;color:var(--mut);font-size:11.5px}
.grp .in{padding:9px}
.frow{display:grid;grid-template-columns:118px 1fr;gap:5px 9px;align-items:center;
  margin-bottom:6px}
.frow:last-child{margin-bottom:0}
.frow label{font-size:12.5px;color:var(--ink-2);text-align:right}
.frow .v{font-size:12.5px;min-width:0}
.frow input,.frow select,.frow textarea{
  width:100%;height:23px;border:1px solid var(--line-2);background:#fff;padding:0 5px;
  font-size:12.5px;border-radius:0;
}
.frow textarea{height:52px;padding:4px 5px;resize:vertical;line-height:1.4}
.frow input:focus,.frow select:focus,.frow textarea:focus{
  outline:0;border-color:var(--sel-line);box-shadow:inset 0 0 0 1px var(--sel-line)}
.frow input:read-only{background:var(--chrome);color:var(--ink-2)}
.frow .hint{grid-column:2;font-size:11.5px;color:var(--mut);margin-top:-2px}
.frow.wide{grid-template-columns:1fr}
.frow.wide label{text-align:left}

.btnrow{display:flex;gap:6px;padding:9px;flex-wrap:wrap}
.btn{
  height:25px;min-width:82px;padding:0 11px;border:1px solid var(--line-2);
  background:linear-gradient(180deg,#FDFDFD,#EFEFEF);cursor:pointer;font-size:12.5px;
  border-radius:2px;
}
.btn:hover:not(:disabled){background:linear-gradient(180deg,#F2F8FE,#DCEAF9);
  border-color:#7FA9D6}
.btn:active:not(:disabled){background:#CFE0F3}
.btn:disabled{color:#A6A6A6;cursor:default;background:var(--chrome)}
.btn.def{border-color:#3A6EA5;box-shadow:inset 0 0 0 1px #A8C6E5;font-weight:600}
.btn.wide{flex:1}

/* ------------------------------------------------------------ sync panel
   The whole point of the application, so it gets the only colour on screen
   that is not the title bar. */
.sync{border:1px solid var(--line);margin:9px;background:var(--face)}
.sync .st{display:flex;align-items:center;gap:9px;padding:9px}
.sync .lamp{width:11px;height:11px;border-radius:50%;flex:none;border:1px solid rgba(0,0,0,.28)}
.lamp.on{background:#16A34A}
.lamp.off{background:#B9B9B9}
.lamp.busy{background:#D97706}
.sync .stx{font-size:12.5px;line-height:1.4}
.sync .stx b{display:block}
.sync .stx span{color:var(--mut)}
.bar{height:6px;background:var(--chrome-d);border:1px solid var(--line);margin:0 9px}
.bar i{display:block;height:100%;background:#2B7BD1;width:0;transition:width .25s}
.qlist{margin:9px;border:1px solid var(--line);max-height:168px;overflow-y:auto;
  background:#fff}
.qlist .qr{display:flex;gap:8px;padding:5px 8px;border-bottom:1px solid #EFEFEF;
  font-size:12px;align-items:baseline}
.qlist .qr:last-child{border-bottom:0}
.qlist .qr .op{font-family:var(--mono);font-size:11px;color:var(--queue);flex:none;
  font-weight:700}
.qlist .qr .ds{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap}
.qlist .qr .tm{color:var(--mut);font-size:11px;flex:none;font-variant-numeric:tabular-nums}
.qlist .none{padding:11px;color:var(--mut);font-size:12px;text-align:center}

/* --------------------------------------------------------------- conflict */
.scrim{position:fixed;inset:0;background:rgba(0,0,0,.34);display:grid;
  place-items:center;z-index:400;padding:18px}
.dlg{
  width:min(660px,100%);max-height:88vh;overflow:auto;background:var(--chrome);
  border:1px solid #555;box-shadow:0 10px 40px rgba(0,0,0,.4);
}
.dlg .dt{
  display:flex;align-items:center;gap:9px;height:29px;padding:0 9px;color:#fff;
  background:linear-gradient(180deg,var(--title-2),var(--title));font-size:12.5px;
  font-weight:600;
}
.dlg .db{padding:13px}
.dlg .msg{display:flex;gap:11px;margin-bottom:12px}
.dlg .msg svg{width:30px;height:30px;flex:none;stroke:var(--warn);fill:none;stroke-width:1.7}
.dlg .msg p{margin:0;font-size:12.5px;line-height:1.55}
.dlg .msg b{display:block;margin-bottom:3px;font-size:13px}
.cmp{display:grid;grid-template-columns:1fr 1fr;gap:1px;background:var(--line);
  border:1px solid var(--line)}
.cmp>div{background:#fff;padding:9px}
.cmp h4{margin:0 0 7px;font-size:11.5px;text-transform:uppercase;letter-spacing:.07em;
  color:var(--mut)}
.cmp dl{margin:0;display:grid;grid-template-columns:auto 1fr;gap:3px 9px;font-size:12px}
.cmp dt{color:var(--mut)}
.cmp dd{margin:0}
.cmp .df{background:#FFF6E8;font-weight:600}
.cmp .pick{margin-top:9px;width:100%}

/* ------------------------------------------------------------ status bar */
.sbar{
  flex:none;display:flex;align-items:center;gap:0;height:23px;
  background:var(--chrome);border-top:1px solid var(--line);font-size:11.5px;
  color:var(--ink-2);
}
.sbar .c{padding:0 9px;border-right:1px solid var(--chrome-d);height:100%;
  display:flex;align-items:center;gap:6px;white-space:nowrap}
.sbar .c:last-child{border-right:0}
.sbar .grow{flex:1;min-width:0;overflow:hidden}
.sbar .keys{margin-left:auto;display:flex;gap:0}
.sbar kbd{
  font:600 10.5px var(--ui);background:var(--chrome-d);border:1px solid var(--line);
  border-radius:2px;padding:0 3px;
}
.sbar .warnx{color:var(--queue);font-weight:600}
.sbar .okx{color:var(--ok);font-weight:600}

/* ------------------------------------------------------------ print sheet
   The statute wants a paper register. This is what comes off the printer,
   and it is monochrome because an office photocopier is. */
.sheet{background:#fff;color:#000;padding:26px 30px;font-family:var(--ui)}
.sheet h2{margin:0 0 2px;font-size:15px;text-align:center;letter-spacing:.02em}
.sheet .sub{text-align:center;font-size:11.5px;margin-bottom:14px;color:#333}
.sheet table{width:100%;border-collapse:collapse;font-size:11px}
.sheet th,.sheet td{border:1px solid #000;padding:4px 5px;text-align:left;
  vertical-align:top}
.sheet th{background:#EEE;font-size:10.5px;text-transform:uppercase;letter-spacing:.04em}
.sheet .sign{display:flex;justify-content:space-between;margin-top:34px;font-size:11px}
.sheet .sign div{text-align:center}
.sheet .sign b{display:block;border-top:1px solid #000;padding-top:4px;min-width:150px;
  font-weight:500}
@media print{
  body>*:not(#printhost){display:none!important}
  #printhost{display:block!important}
  .sheet{padding:0}
}
#printhost{display:none}

/* ----------------------------------------------------------------- narrow
   A desktop application on a laptop screen and, at a push, on a phone in the
   field. The grid is the thing that has to survive, so below 1080px the form
   moves under it rather than squeezing both. */
/* Below 860px the toolbar's right-aligned case counter is what pushes the
   PAGE sideways, not the register. The table is already contained: .gwrap
   scrolls it (768px wide, 796px of content). The counter sits after a
   flex spacer, so it is pushed past the edge instead of shrinking, and a
   27px span at x=772 was making the whole document 799px wide.

   It is dropped rather than wrapped, because a Windows toolbar does not
   wrap and a wrapped one stops reading as native. Nothing is lost: the same
   figure is in the status bar at the bottom of the window ("64 cases, 0
   changes this session"), which is where a clerk reads it anyway. */
@media(max-width:860px){
  .tool #gct{display:none}
  /* And the function-key legend in the status bar, which was the larger half
     of the overflow at 419px wide. Dropping it below 860px is not a
     compromise: a tablet has no F2, F3 or F9, so the legend is telling a
     touch user about keys their device does not have. The shortcuts keep
     working for anyone with a keyboard at any width; only the printed
     reminder goes. */
  /* `.sbar .keys`, not `.keys`. The base rule at line 270 is
     `.sbar .keys{display:flex}` at specificity 0,2,0, so a bare
     `.keys{display:none}` loses on specificity no matter where it
     sits in the file. Matching the parent is what makes it apply. */
  .sbar .keys{display:none}
}

@media(max-width:1080px){
  .split{grid-template-columns:1fr}
  .left{border-right:0;border-bottom:1px solid var(--line)}
  .gwrap{max-height:46vh}
  .right{max-height:none;overflow:visible}
  body{height:auto;overflow:auto}
  #app{border:0}
}
@media(max-width:700px){
  .tool{flex-wrap:wrap;gap:4px}
  .tool .find{min-width:0;flex:1 1 100%;order:9}
  .tool button kbd{display:none}
  .mbar{overflow-x:auto}
  .sbar{height:auto;flex-wrap:wrap;padding:3px 0}
  .sbar .c{height:22px}
  .sbar .keys{margin-left:0;flex:1 1 100%;overflow-x:auto}
  .frow{grid-template-columns:1fr;gap:3px}
  .frow label{text-align:left;font-weight:600}
  .cmp{grid-template-columns:1fr}
  .tbar .doc{display:none}
}

/* ------------------------------------------------------- touch, on a phone
   This is a Windows application and its 24px menu bar is the point of it. But
   a desktop application opened on a phone should still be operable, and by
   620px the chrome has already stacked, so the argument survives. */
@media(max-width:700px) and (pointer:coarse){
  .mbar{height:auto}
  .mbar button{min-height:44px;padding:0 14px}
  .tool button{min-height:44px}
  .tool .find{height:44px}
  .btn{height:44px}
  .sel,.frow input,.frow select,.frow textarea,.tool .find input{min-height:44px}
  table.grid td{height:44px}
  table.grid th{height:38px}
}
