/* T2ES Ops. Mobile first: engineers open this on a phone at a site gate, so
   everything stacks, touch targets are big, and the office layout only
   spreads out on a wide screen. */

:root {
  --navy: #12263a;
  --navy-soft: #1d3855;
  --ink: #16202b;
  --body: #3d4d5c;
  --muted: #6b7c8d;
  --line: #dde4ea;
  --page: #f4f6f8;
  --card: #ffffff;
  --accent: #0b6bcb;
  --accent-soft: #e7f0fb;
  --amber: #f2b632;
  --good: #17795e;
  --good-soft: #e3f4ef;
  --warn: #9a6100;
  --warn-soft: #fdf1dc;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(18, 38, 58, .08), 0 4px 12px rgba(18, 38, 58, .06);
  --tap: 46px;
  --tabbar: 62px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--page); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.strong { font-weight: 600; }
.pre { white-space: pre-wrap; word-break: break-word; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.app-loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------------ shell */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  background: var(--navy); color: #fff;
  padding: .55rem .9rem; padding-top: max(.55rem, env(safe-area-inset-top));
  display: flex; align-items: center; gap: .6rem;
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: .45rem; text-decoration: none; color: #fff; }
.topbar .brand .bolt { width: 22px; height: 22px; }
.topbar .spacer { flex: 1; }
.topbar .title { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back {
  background: none; border: 0; color: #fff; font-size: 1.4rem; line-height: 1;
  padding: .2rem .5rem .2rem 0; min-width: var(--tap); min-height: var(--tap); cursor: pointer;
}
.topbar .who { font-size: .78rem; opacity: .85; text-align: right; line-height: 1.2; color: #fff; text-decoration: none; }

main.content { flex: 1; padding: .9rem; padding-bottom: calc(var(--tabbar) + 1.2rem + env(safe-area-inset-bottom)); max-width: 1100px; width: 100%; margin: 0 auto; }
@media (min-width: 900px) { main.content { padding: 1.4rem 1.6rem; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .72rem; position: relative;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--accent); }
.tabbar .dot {
  position: absolute; top: 8px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* sheet from the More tab */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(18, 38, 58, .45); z-index: 30; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: #fff; border-radius: 18px 18px 0 0; padding: .6rem .9rem calc(1rem + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
}
.sheet .handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto .6rem; }
.sheet a, .sheet button.link {
  display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left;
  padding: .8rem .4rem; min-height: var(--tap); border: 0; background: none; cursor: pointer;
  color: var(--ink); text-decoration: none; font-size: 1rem; border-bottom: 1px solid var(--line);
}
.sheet a:last-child, .sheet button.link:last-child { border-bottom: 0; }
.sheet svg { width: 22px; height: 22px; color: var(--muted); }

/* ------------------------------------------------------------------ cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; margin-bottom: .9rem; }
.card.tight { padding: .6rem .8rem; }
.card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.card-head h2, .card-head h3 { flex: 1; }
.section-title { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 1.2rem 0 .5rem; }
.section-title:first-child { margin-top: 0; }
.grid { display: grid; gap: .9rem; }
@media (min-width: 720px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }

.kv { display: grid; grid-template-columns: minmax(90px, 32%) 1fr; gap: .3rem .8rem; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); padding: .7rem 0; }
.list li:first-child { border-top: 0; padding-top: 0; }
.list li:last-child { padding-bottom: 0; }

/* a tappable row that leads to a page */
.rowlink {
  display: flex; align-items: center; gap: .8rem; text-decoration: none; color: inherit;
  padding: .75rem .9rem; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: .6rem; min-height: var(--tap);
}
.rowlink .body { flex: 1; min-width: 0; }
.rowlink .chev { color: var(--muted); font-size: 1.3rem; }
.rowlink .name { font-weight: 600; }
.rowlink .sub { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------- home / hero */
.hero { padding: .4rem 0 .8rem; }
.hero h1 { font-size: 1.6rem; }
.hero .date { color: var(--muted); }
.jobcard {
  display: block; text-decoration: none; color: inherit;
  background: var(--navy); color: #fff; border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: .8rem;
  box-shadow: var(--shadow);
}
.jobcard .eyebrow { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; opacity: .7; }
.jobcard .site { font-size: 1.35rem; font-weight: 700; margin: .15rem 0; }
.jobcard .time { font-size: 1.05rem; }
.jobcard .team { opacity: .85; margin-top: .4rem; font-size: .95rem; }
.jobcard .open { display: inline-block; margin-top: .8rem; background: var(--amber); color: var(--navy); font-weight: 700; padding: .55rem 1rem; border-radius: 8px; }
.jobcard.quiet { background: #fff; color: var(--ink); }
.jobcard.quiet .eyebrow { color: var(--muted); opacity: 1; }
.jobcard.quiet .open { background: var(--accent-soft); color: var(--accent); }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .7rem .8rem; text-decoration: none; color: inherit; }
.tile .n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: .8rem; }
.tile.warn .n { color: var(--warn); }
.tile.bad .n { color: var(--bad); }
.tile.good .n { color: var(--good); }

/* ------------------------------------------------------------- badges */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: #eef1f4; color: var(--body); white-space: nowrap; vertical-align: middle; }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--good-soft); color: var(--good); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--bad-soft); color: var(--bad); }
.badge.navy { background: var(--navy); color: #fff; }

.progress { height: 8px; border-radius: 4px; background: #e6ebf0; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--good); }
.progress.mid > span { background: var(--accent); }
.progress.low > span { background: var(--amber); }

.alert { padding: .7rem .9rem; border-radius: 10px; margin-bottom: .8rem; font-size: .95rem; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--accent-soft); color: var(--accent); }
.alert.good { background: var(--good-soft); color: var(--good); }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.amber { background: var(--amber); border-color: var(--amber); color: var(--navy); }
.btn.danger { background: var(--bad-soft); border-color: var(--bad-soft); color: var(--bad); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.block { display: flex; width: 100%; }
.btn.sm { min-height: 36px; padding: .3rem .7rem; font-size: .88rem; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .8rem; }
.btn-row .btn { flex: 1; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: .8rem 0; }
.actions .btn { flex-direction: column; gap: .2rem; padding: .7rem .4rem; font-size: .85rem; }
.actions .btn svg { width: 24px; height: 24px; }

/* ---------------------------------------------------------------- tabs */
.tabs { display: flex; gap: .2rem; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.9rem .9rem; padding: 0 .9rem; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: 0 0 auto; padding: .6rem .7rem; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem; border-bottom: 3px solid transparent; white-space: nowrap; min-height: var(--tap); display: flex; align-items: center; gap: .3rem; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { background: #eef1f4; border-radius: 999px; padding: 0 .4rem; font-size: .72rem; }
.pills { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.pills a, .pills button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .35rem .8rem; font-size: .88rem; font-weight: 600; color: var(--body); text-decoration: none; cursor: pointer; min-height: 36px; }
.pills .active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* --------------------------------------------------------------- forms */
.field { display: block; margin-bottom: .9rem; }
.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--body); margin-bottom: .3rem; }
.field .hint { font-weight: 400; color: var(--muted); }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.range-wrap { display: flex; align-items: center; gap: .8rem; }
.range-wrap input[type=range] { flex: 1; min-height: var(--tap); }
.range-wrap output { font-size: 1.4rem; font-weight: 700; min-width: 3.2rem; text-align: right; }
.check { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); }
.check input { width: 22px; height: 22px; }
.lines .line { display: grid; grid-template-columns: 4.5rem 4.5rem 1fr 2.4rem; gap: .4rem; margin-bottom: .5rem; align-items: center; }
.lines .line input { min-width: 0; }
.lines .line button { min-height: var(--tap); border: 0; background: none; color: var(--bad); font-size: 1.3rem; cursor: pointer; }
.team-pick .person { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-top: 1px solid var(--line); }
.team-pick .person:first-child { border-top: 0; }
.team-pick .person .name { flex: 1; }
.team-pick .person select { width: auto; min-height: 38px; padding: .3rem .5rem; }
.form-error { color: var(--bad); margin: .4rem 0; }

/* -------------------------------------------------------------- photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.photo-grid a { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #e6ebf0; position: relative; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .cap { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: .7rem; padding: .2rem .35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumbs { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.thumbs a { width: 64px; height: 64px; border-radius: 6px; overflow: hidden; display: block; background: #e6ebf0; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 50; display: flex; flex-direction: column; }
.lightbox img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.lightbox .bar { color: #fff; padding: .7rem .9rem; padding-top: max(.7rem, env(safe-area-inset-top)); display: flex; gap: .8rem; align-items: center; }
.lightbox .bar .cap { flex: 1; font-size: .9rem; }
.lightbox .bar button { background: rgba(255, 255, 255, .15); color: #fff; border: 0; border-radius: 8px; min-height: 40px; padding: 0 .8rem; cursor: pointer; }

/* --------------------------------------------------------------- table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1rem; padding: 0 1rem; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .4rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t a { text-decoration: none; }

/* --------------------------------------------------------------- misc */
.update { border-top: 1px solid var(--line); padding: .8rem 0; }
.update:first-child { border-top: 0; padding-top: 0; }
.update .head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .3rem; }
.update .head .when { font-weight: 700; }
.update .pct { font-weight: 700; color: var(--good); }
.update .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin-top: .4rem; }
.problem { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: .5rem .7rem; margin-top: .4rem; }
.problem.resolved { background: var(--good-soft); color: var(--good); }
.note { border-top: 1px solid var(--line); padding: .6rem 0; }
.note:first-child { border-top: 0; }
.note .by { font-size: .8rem; color: var(--muted); }
.money { font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 1.6rem .5rem; }
.spinner { text-align: center; color: var(--muted); padding: 2rem; }
.login { max-width: 400px; margin: 8vh auto; padding: 1rem; }
.login .logo { text-align: center; margin-bottom: 1.4rem; }
.login .logo svg { width: 72px; height: 72px; }
.login h1 { text-align: center; margin-bottom: 1.2rem; }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: .4rem; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: .6rem 1rem; border-radius: 999px; box-shadow: var(--shadow); font-size: .92rem; max-width: 92vw; }
.toast.bad { background: var(--bad); }
.toast.good { background: var(--good); }

.inbox-item { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem .9rem; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: .55rem; text-decoration: none; color: inherit; }
.inbox-item.unread { border-left: 4px solid var(--accent); }
.inbox-item .ico { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.inbox-item .ico.red { background: var(--bad-soft); color: var(--bad); }
.inbox-item .ico.amber { background: var(--warn-soft); color: var(--warn); }
.inbox-item .ico.green { background: var(--good-soft); color: var(--good); }
.inbox-item .ico svg { width: 18px; height: 18px; }
.inbox-item .t { font-weight: 600; }
.inbox-item .b { color: var(--body); font-size: .9rem; }
.inbox-item .w { color: var(--muted); font-size: .78rem; margin-top: .2rem; }

@media print { .topbar, .tabbar, .btn, .actions { display: none !important; } main.content { padding: 0; } }
