:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #6b7785;
  --line: #e2e8ee;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #157347;
  --err: #b42318;
}
* { box-sizing: border-box; }
.session-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: #b91c1c; color: #fff; text-align: center;
  padding: 12px 16px; font-size: 14px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 8px 0 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.stat-num { font-size: 30px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dash-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.dash-card h3 { margin: 0 0 12px; }
.dash-card.dash-wide { grid-column: 1 / -1; }
@media (max-width: 820px) { .dash-grid { grid-template-columns: 1fr; } }
.pie-wrap { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.legend { font-size: 14px; }
.legend-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.legend-total { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.bar-row { display: grid; grid-template-columns: 140px 1fr 36px; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: #eef2f7; border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 6px; }
.bar-val { text-align: right; font-weight: 600; }
.sc-table th { cursor: default; }
.sc-ticket { text-decoration: underline; color: var(--accent); cursor: pointer; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.site-footer {
  margin-top: auto;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 16px 12px;
  border-top: 1px solid var(--line);
  background: var(--card);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.spacer { flex: 1; }

#topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 20px; position: sticky; top: 0; z-index: 10;
}
#brand { font-weight: 700; }
nav { display: flex; gap: 6px; }
.navbtn {
  background: transparent; border: none; padding: 8px 12px; border-radius: 8px;
  cursor: pointer; color: var(--ink); font-size: 14px;
}
.navbtn.active { background: #eef2ff; color: var(--accent); }
#whoami { font-size: 13px; color: var(--muted); }

main { max-width: 820px; margin: 0 auto; padding: 24px 20px 60px; }
/* The assets spreadsheet breaks out of the narrow reading width to use the window. */
#app.wide { max-width: 96vw; }
/* The ticket detail uses a wider, two-column layout on larger screens. */
#app.detail-wide { max-width: 1100px; }
#detailTitle { margin: 4px 0 16px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; align-items: stretch; margin-top: 6px; }
.detail-left { padding-right: 32px; border-right: 1px solid var(--line); }
.detail-right { padding-left: 32px; }
.detail-left h3, .detail-right h3 { margin-top: 0; }
.desc-label { margin-top: 14px; }
@media (max-width: 820px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-left { padding-right: 0; border-right: none; padding-bottom: 4px; }
  .detail-right { padding-left: 0; }
  .detail-right .reply { margin-top: 16px; }
  .detail-right h3 { margin-top: 24px; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.centered { max-width: 420px; margin: 8vh auto 0; }

/* Login logo (the uploaded graphic already carries the brand name) */
.login-logo { display: block; width: 230px; max-width: 72%; height: auto; margin: 4px auto 20px; }
/* The graphic already shows the brand, so the text heading is hidden on login.
   To show a text heading instead, set this to `display: block`. */
#loginBrand { display: none; }

h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 15px; color: var(--muted); margin: 24px 0 8px; text-transform: uppercase; letter-spacing: .04em; }

label { display: block; font-size: 13px; font-weight: 600; margin: 16px 0 6px; }
input, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 15px; font-family: inherit; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

button.primary {
  margin-top: 16px; width: 100%; background: var(--accent); color: var(--accent-ink);
  border: none; padding: 12px; border-radius: 9px; font-size: 15px; font-weight: 600; cursor: pointer;
}
button.primary:hover { filter: brightness(1.05); }
button.link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 14px; padding: 8px 0; }

.msg { font-size: 14px; margin-top: 10px; min-height: 18px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }

.list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.row {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  cursor: pointer; display: flex; flex-direction: column; gap: 4px;
}
.row:hover { border-color: var(--accent); }
.row .top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.row .title { font-weight: 600; }
.row .num { color: var(--muted); font-size: 13px; white-space: nowrap; }
.badge {
  display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px;
  background: #eef2ff; color: var(--accent); font-weight: 600;
}
.row .sub { font-size: 13px; color: var(--muted); }

.desc { white-space: pre-wrap; margin-top: 2px; font-size: 14px; line-height: 1.5; color: var(--ink); }
.desc a, .note .body a { color: var(--accent); word-break: break-word; }

.detail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#detailMeta { margin: 6px 0 4px; }
.meta-row { padding: 2px 0; font-size: 14px; }
.meta-label { font-weight: 600; color: var(--ink); }
.notes { display: flex; flex-direction: column; gap: 10px; }
.note { border-radius: 10px; padding: 12px 14px; background: #fff8e1; } /* technician replies */
.note.client { background: #ffffff; } /* client replies */
.note .meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.note .body { white-space: pre-wrap; font-size: 14px; }

.reply {
  margin: 0 0 18px;
  background: #dfe6ef;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px;
}
.reply-heading { font-weight: 700; font-size: 15px; }
.reply .reply-sub { margin: 2px 0 10px; font-size: 13px; color: var(--muted); }
.reply textarea { background: #fff; }
.reply label { margin-top: 0; }

.filters {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-top: 14px;
}
.filter { display: flex; flex-direction: column; }
.filter label { margin: 0 0 6px; }
.filter select, .filter input { padding: 9px 10px; min-width: 150px; }
.filter-actions { flex-direction: row; gap: 8px; align-items: center; margin-left: auto; }
button.primary.small { width: auto; margin-top: 0; padding: 9px 18px; }

/* Assets spreadsheet */
.assets-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.assets-tools { display: flex; gap: 8px; align-items: center; }
.btn-outline {
  background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 14px; font-size: 14px; cursor: pointer; color: var(--ink);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.coldropdown { position: relative; }
.colpanel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 8px; width: 260px;
  max-height: 320px; overflow-y: auto;
}
.colitem { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.colitem:hover { background: #f3f6fb; }
.colitem input { width: auto; }

.tablewrap { margin-top: 12px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
table.sheet { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
table.sheet th, table.sheet td { padding: 9px 12px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; }
table.sheet th { position: sticky; top: 0; background: #f6f8fb; font-weight: 600; cursor: pointer; user-select: none; }
table.sheet th .sort-ind { margin-left: 6px; color: var(--accent); font-size: 11px; }
table.sheet tbody tr.clickable { cursor: pointer; }
table.sheet th.dragging { opacity: .45; }
table.sheet th.drag-over { background: #e6efff; box-shadow: inset 3px 0 0 var(--accent); }
table.sheet tr:last-child td { border-bottom: none; }
table.sheet th:last-child, table.sheet td:last-child { border-right: none; }
table.sheet tbody tr:hover td { background: #f9fbfd; }

table { width: 100%; border-collapse: collapse; margin-top: 8px; }
