/* BStreet Asset Tracker — production app styles
   Palette echoes the demo: BStreet blue on a light slate ground. */
:root {
  --blue: #1d4ed8;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }
.spacer { flex: 1; }

/* ---------- Login ---------- */
.auth-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px 30px;
}
.auth-card img.logo { display: block; width: 190px; max-width: 70%; margin: 4px auto 18px; }
.auth-card h1 { font-size: 18px; margin: 0 0 4px; text-align: center; }
.auth-card p.sub { margin: 0 0 20px; text-align: center; color: var(--muted); font-size: 14px; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin: 14px 0 6px; }
input[type=email], input[type=password], input[type=text] {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus { outline: 2px solid var(--blue-600); outline-offset: 1px; border-color: var(--blue-600); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  margin-top: 18px;
  padding: 12px 16px;
  font-size: 15px; font-weight: 600;
  color: #fff; background: var(--blue-700);
  border: none; border-radius: 10px; cursor: pointer;
}
.btn:hover { background: var(--blue); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: #f8fafc; }
.btn.inline { width: auto; margin-top: 0; padding: 8px 14px; font-size: 14px; }

/* ---------- App shell (placeholder until screens are ported) ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.topbar img.logo { height: 30px; }
.topbar .who { font-size: 14px; }
.topbar .who b { display: block; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .3px;
  text-transform: uppercase; padding: 3px 8px; border-radius: 999px;
  background: #dbeafe; color: var(--blue-700);
}
.content { padding: 28px 22px; max-width: 900px; margin: 0 auto; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; margin-bottom: 18px;
}
.card h2 { margin: 0 0 10px; font-size: 17px; }
.content.wide { max-width: 1100px; }

select, textarea {
  width: 100%; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 76px; resize: vertical; }
select:focus, textarea:focus { outline: 2px solid var(--blue-600); outline-offset: 1px; border-color: var(--blue-600); }

/* ---------- Top nav ---------- */
.nav { display: flex; gap: 2px; margin-left: 8px; flex-wrap: wrap; }
.nav-item {
  border: none; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600; padding: 8px 12px; border-radius: 9px; cursor: pointer;
}
.nav-item:hover { background: #f1f5f9; color: var(--ink); }
.nav-item.active { background: #dbeafe; color: var(--blue-700); }
.nav-item .soon {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: #94a3b8; background: #f1f5f9; padding: 1px 5px; border-radius: 6px; margin-left: 4px;
}

/* ---------- Page head + toolbar ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head p { margin: 2px 0 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.toolbar input[type=text] { flex: 1 1 240px; min-width: 200px; }
.toolbar select { flex: 0 1 auto; width: auto; min-width: 150px; }

/* ---------- Equipment grid ---------- */
.eq-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.eq-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; box-shadow: var(--shadow);
}
.eq-card[data-open] { cursor: pointer; }
.eq-card[data-open]:hover { border-color: #cbd5e1; }
.eq-icon {
  width: 60px; height: 60px; flex: none; border-radius: 13px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 27px; color: #fff;
}
.eq-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.eq-main { flex: 1; min-width: 0; }
.eq-name { font-weight: 700; font-size: 15px; }
.eq-sub { font-size: 13px; }
.eq-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--muted); }
.chip { background: #f1f5f9; border-radius: 999px; padding: 2px 9px; font-weight: 600; color: #475569; }
.eq-status { flex: none; }
.eq-actions { display: flex; gap: 12px; flex: none; }

/* Equipment-list card. Desktop: icon | details | right-hand block (status over
   actions). Phone: the status+actions block drops to its own full-width row so
   the name/details get the whole width instead of being squeezed and wrapping. */
.eq-card.list {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "icon main foot";
  align-items: center; column-gap: 14px;
}
.eq-card.list .eq-icon { grid-area: icon; }
.eq-card.list .eq-main { grid-area: main; }
.eq-card.list .eq-foot {
  grid-area: foot; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.linkbtn { border: none; background: none; color: var(--blue-700); font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--danger); }

.badge2 { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge2.ok { background: #dcfce7; color: #15803d; }
.badge2.warn { background: #fef9c3; color: #a16207; }
.badge2.down { background: #fee2e2; color: #b91c1c; }

.empty { text-align: center; color: var(--muted); padding: 40px 24px; }
.empty .big { font-size: 34px; margin-bottom: 8px; }

.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(2, 6, 23, .35);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-head .x { border: none; background: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); }
.field { margin-bottom: 14px; }
.field label { margin: 0 0 6px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---------- Toast ---------- */
#toastHost { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 8px;
  background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(2, 6, 23, .35); opacity: 0; transform: translateY(8px); transition: .22s;
}
.toast.show { opacity: 1; transform: translateY(0); }

.content.narrow { max-width: 620px; }
.eq-card.plain { box-shadow: none; border: none; padding: 0; }
.eq-icon.sm { width: 38px; height: 38px; font-size: 18px; border-radius: 9px; }

/* urgency selector (report form) */
.urg { display: flex; gap: 8px; }
.urg-btn { flex: 1; padding: 10px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-weight: 600; cursor: pointer; color: var(--muted); }
.urg-btn.active { border-color: var(--blue-600); background: #eff6ff; color: var(--blue-700); }

/* worklist tabs */
.tabs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 999px; cursor: pointer; }
.tab.active { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.tabs .mine { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* task rows */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task { display: flex; align-items: center; gap: 13px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); }
.task.is-done { opacity: .62; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; }
.eq-open { cursor: pointer; }
b.eq-open:hover { text-decoration: underline; color: var(--blue-700); }
.eq-icon.eq-open:hover { outline: 2px solid var(--blue-600); outline-offset: 1px; }
.task.is-done .task-title { text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 3px; font-size: 12px; color: var(--muted); }
.task-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.task-actions select.assign { width: auto; min-width: 130px; padding: 7px 10px; font-size: 13px; }
.urg { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .3px; }
.urg.high { background: #fee2e2; color: #b91c1c; }
.urg.med { background: #fef9c3; color: #a16207; }
.urg.low { background: #e2e8f0; color: #475569; }

/* Settings */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 16px; }
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.row-item:first-of-type { border-top: none; }
.row-actions { display: flex; gap: 12px; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.chip.big { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 10px; }
.chip-x { border: none; background: none; color: #94a3b8; font-size: 16px; line-height: 1; cursor: pointer; padding: 0; }
.chip-x:hover { color: var(--danger); }
.add-inline { display: flex; gap: 8px; max-width: 420px; }
.add-inline input { flex: 1; }

/* Equipment detail */
.eq-icon.lg { width: 64px; height: 64px; font-size: 30px; border-radius: 14px; }
.detail-head { display: flex; align-items: center; gap: 18px; margin-top: 12px; }
.detail-head .badge2 { margin-right: 6px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.detail-grid .card { margin-bottom: 0; }
.kv { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.kv > div { min-width: 0; }
.kv dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; }
.history-mini { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.tl-item:first-child { border-top: none; }
.tl-icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; background: #f1f5f9; border-radius: 8px; font-size: 14px; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #f1f5f9; }
.photo img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; }
.photo-del { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border-radius: 50%; border: none; background: rgba(15,23,42,.6); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.photo-del:hover { background: var(--danger); }
/* staged photo previews in the report form */
.photo-stage { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.photo-stage:empty { display: none; }
.photo-stage .photo { width: 84px; height: 84px; }
/* report photos shown on a worklist task */
.task-photos { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.task-photos img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }

.qr-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.qr-card h3 { margin: 0; }
.qr-box { flex: none; width: 180px; height: 180px; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.qr-box img { display: block; }

@media (max-width: 700px) {
  .detail-grid { grid-template-columns: 1fr; }
  .qr-card { flex-direction: column; align-items: flex-start; }
  .qr-box { align-self: center; }
}

/* Calendar */
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav b { min-width: 150px; text-align: center; }
.cal-legend { display: flex; gap: 18px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.cal-legend i.dot, i.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.dot.c-maint { background: #2563eb; } .dot.c-insp { background: #7c3aed; } .dot.c-request { background: #d97706; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; padding-bottom: 4px; }
.cal-cell { background: var(--card); border: 1px solid var(--line); border-radius: 10px; min-height: 96px; padding: 6px; overflow: hidden; }
.cal-cell.empty { background: transparent; border: none; }
.cal-cell.today { border-color: var(--blue-600); box-shadow: inset 0 0 0 1px var(--blue-600); }
.cal-cell[data-day] { cursor: pointer; }
.cal-cell[data-day]:hover { border-color: #cbd5e1; }
.cal-num { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.cal-chip { font-size: 11px; padding: 2px 5px; border-radius: 5px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.cal-chip.c-maint { background: #2563eb; } .cal-chip.c-insp { background: #7c3aed; } .cal-chip.c-request { background: #d97706; }
.cal-chip.done { opacity: .5; text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--muted); font-weight: 600; }

/* Reports */
.rep-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.rep-controls .btn { margin-left: auto; }
.rep-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rep-table th, .rep-table td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rep-table th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); position: sticky; top: 0; }

@media (max-width: 640px) {
  .cal-cell { min-height: 70px; }
  .cal-chip { font-size: 9px; }
  .rep-controls .btn { margin-left: 0; }
}

/* User management table */
.utable { display: flex; flex-direction: column; }
.urow { display: grid; grid-template-columns: 1.4fr 1.8fr 1.2fr .8fr 1.4fr; gap: 12px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 14px; }
.urow.uhead { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; border-top: none; }
.urow-actions { display: flex; gap: 12px; justify-content: flex-end; }
select.mini { padding: 6px 8px; font-size: 13px; width: auto; }
.pill { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700; cursor: pointer; }
.pill.on { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.pill.off { background: #f1f5f9; color: #64748b; }
.tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; background: #dbeafe; color: var(--blue-700); padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.tag.warn { background: #fef9c3; color: #a16207; }
.creds { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.creds > div { display: flex; align-items: center; gap: 10px; }
.creds span { width: 74px; font-size: 12px; color: var(--muted); font-weight: 600; }
.creds code { font-family: ui-monospace, Menlo, monospace; font-size: 14px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.notify-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; font-size: 14px; cursor: pointer; }
.notify-row input { width: 18px; height: 18px; flex: none; }
.notify-list { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.notify-list .notify-row input:disabled + * , .notify-row input:disabled { opacity: .5; }

@media (max-width: 700px) {
  .urow { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .urow.uhead { display: none; }
  .urow-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .grid2 { grid-template-columns: 1fr; }
  /* phone: details take the full width (row 1); status + actions share row 2 */
  .eq-card.list {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "icon main"
      "foot foot";
    align-items: center; row-gap: 10px;
  }
  .eq-card.list .eq-foot {
    flex-direction: row; align-items: center; justify-content: space-between; width: 100%;
  }
  .task { flex-wrap: wrap; }
  .task-actions { width: 100%; justify-content: flex-end; }
}
