:root {
  --bg: #F4F4F4;
  --border: #D9D9D9;
  --ink: #212121;
  --accent: #ED6A12;
  --accent-dark: #c9590d;
  --gray: #6b6b6b;
  --card: #ffffff;
  --status-not-started: #b3b3b3;
  --status-in-progress: #d9a441;
  --status-waiting: #6b8fb3;
  --status-submitted: #7a5fc0;
  --status-approved: #325928;
  --status-done: #1f3d17;
  --status-rejected: #c0392b;
}

* { box-sizing: border-box; }

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: 'Helvetica Neue LT Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

h1, h2, h3, .brand-heading, button, .tab, .phase-badge, .status-badge {
  font-family: 'Helvetica Neue LT Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 700;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

header.topbar {
  background: white;
  border-bottom: 3px solid var(--border);
  padding: 8px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 12px;
}
.topbar-row1 {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}
#logo-home {
  height: 32px;
  cursor: pointer;
  flex-shrink: 0;
}
.app-title-img {
  height: 24px;
  cursor: pointer;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
  filter: grayscale(100%);
  line-height: 1;
}
.topbar-user {
  font-size: 12px;
  color: var(--gray);
}
.topbar-user-link {
  font-size: 12px;
  color: var(--ink);
}

@media (min-width: 480px) {
  #logo-home { height: 42px; }
  .app-title-img { height: 30px; }
}

main { flex: 1; padding: 12px; padding-bottom: 80px; max-width: 1100px; margin: 0 auto; width: 100%; }

/* Bottom tab bar (mobile-first primary nav) */
nav.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: white;
  border-top: 1px solid var(--border);
  z-index: 20;
}
nav.tabbar button {
  flex: 1;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  padding: 8px 4px 5px;
  font-size: 11px;
  color: var(--gray);
  cursor: pointer;
}
nav.tabbar button.active {
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
  font-weight: 700;
}
nav.tabbar .icon { display: block; font-size: 20px; margin-bottom: 2px; }

/* Quick list (mobile-first) */
.quick-list { display: flex; flex-direction: column; gap: 10px; }
.quick-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.quick-item:active { background: var(--bg); }
.quick-item .addr { font-weight: 700; font-size: 15px; }
.quick-item .scope { color: var(--gray); font-size: 13px; margin-top: 2px; }

.status-badge, .phase-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  color: white;
  white-space: nowrap;
}
.status-not_started, .status-not-started { background: var(--status-not-started); }
.status-in_progress { background: var(--status-in-progress); }
.status-waiting_on_third_party { background: var(--status-waiting); }
.status-submitted { background: var(--status-submitted); }
.status-approved { background: var(--status-approved); }
.status-done { background: var(--status-done); }
.status-rejected { background: var(--status-rejected); }
.phase-pre_planning { background: #a0a0a0; }
.phase-in_submission { background: #d9a441; }
.phase-on_hold { background: #b3542e; }
.phase-in_construction { background: #6b8fb3; }
.phase-closeout { background: #7a5fc0; }
.phase-done { background: #325928; }

/* Detail / requirement view */
.req-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}
.req-row .desc { font-weight: 700; margin-bottom: 6px; }
.big-btn {
  display: block;
  width: 100%;
  max-width: 220px;
  background: white;
  color: var(--accent-dark);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 400;
  margin-top: 6px;
  cursor: pointer;
}
.big-btn:hover { border-color: var(--accent); }
.big-btn:active { background: var(--bg); }
textarea, input, select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Helvetica Neue LT Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  margin-top: 6px;
}
label { font-size: 12px; color: var(--gray); margin-top: 10px; display: block; }

.notes-log { margin-top: 8px; }
.note-entry { font-size: 13px; padding: 6px 0; border-top: 1px dashed var(--border); }
.note-entry .meta { color: var(--gray); font-size: 11px; }

/* Desktop operations dashboard */
.dashboard-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.dashboard-grid .permit-card {
  flex: 1 1 190px;
  max-width: 260px;
}
.permit-card {
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: transform 0.1s ease;
}
.permit-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.permit-card .addr { font-size: 15px; font-weight: 700; }
.permit-card .scope { color: var(--gray); font-size: 13px; margin: 4px 0 0; }
.permit-card.hot-card {
  position: relative;
  overflow: hidden;
  padding-right: 74px;
}
.permit-card.hot-card::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 25%;
  background: repeating-linear-gradient(45deg, var(--accent) 0 6px, transparent 6px 12px);
  opacity: 0.85;
  pointer-events: none;
}
.permit-card.phase-border-pre_planning { border-color: #a0a0a0; }
.permit-card.phase-border-in_submission { border-color: #d9a441; }
.permit-card.phase-border-scheduled_hearing { border-color: #4a7fc9; }
.permit-card.phase-border-on_hold { border-color: #b3542e; }
.permit-card.phase-border-in_construction { border-color: #6b8fb3; }
.permit-card.phase-border-closeout { border-color: #7a5fc0; }
.permit-card.phase-border-done { border-color: #325928; }
.permit-card.phase-border-dead { border-color: #4a4a4a; }

.section-title { color: var(--ink); font-size: 15px; margin: 16px 0 10px; letter-spacing: 0.5px; }
.back-link { color: var(--ink); background: none; border: none; font-size: 13px; padding: 0; margin-bottom: 10px; cursor: pointer; }

@media (min-width: 900px) {
  nav.tabbar { position: static; border-top: none; border-bottom: 1px solid var(--border); }
  main { padding-bottom: 24px; }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-box {
  background: white;
  border-radius: 14px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-box h3 { color: var(--ink); margin: 0 0 14px; font-size: 17px; }
.modal-field { margin-bottom: 10px; }
.modal-field label { display: block; font-size: 12px; color: var(--gray); margin-bottom: 3px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .big-btn { max-width: none; flex: 1; margin-top: 0; }
.modal-cancel-btn { background: white; color: var(--ink); border: 1px solid var(--ink); }

/* ---------- TV display (office monitor board) ---------- */
body.tv-mode { overflow: hidden; }
body.tv-mode #app { min-height: 100vh; }

.tv-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; font-size: 24px; color: var(--gray); background: var(--bg);
}

.tv-board {
  height: 100vh;
  width: 100vw;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 14px 24px;
  box-sizing: border-box;
  overflow: hidden;
}

.tv-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.tv-clock-wrap { justify-self: start; display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.tv-clock {
  position: relative;
  width: 105px;
  height: 105px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid var(--ink);
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.tv-clock-tick-wrap {
  position: absolute;
  inset: 0;
}
.tv-clock-tick {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 3px;
  height: 8px;
  background: var(--ink);
  transform: translateX(-50%);
}
.tv-clock-hand {
  position: absolute;
  left: 50%; bottom: 50%;
  transform-origin: bottom center;
  background: var(--ink);
  border-radius: 3px;
}
.tv-hand-hour { width: 5px; height: 26px; margin-left: -2.5px; }
.tv-hand-minute { width: 3.5px; height: 39px; margin-left: -1.75px; }
.tv-hand-second { width: 2.5px; height: 42px; margin-left: -1.25px; background: var(--accent); }
.tv-clock-center {
  position: absolute; top: 50%; left: 50%;
  width: 9px; height: 9px; margin: -4.5px;
  background: var(--accent);
  border-radius: 50%;
}

.tv-title { display: flex; flex-direction: column; align-items: center; gap: 3px; justify-self: center; }
.tv-logo { height: 24px; }
.tv-wordmark { height: 15px; }

.tv-date { font-size: 16px; color: var(--ink); font-weight: 700; line-height: 1.25; max-width: 140px; }

.tv-columns {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  min-height: 0;
}
@media (max-width: 1900px) {
  .tv-columns { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .tv-columns { grid-template-columns: repeat(1, 1fr); }
}

.tv-column { display: flex; flex-direction: column; min-height: 0; }
.tv-column-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 3px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink);
  flex-shrink: 0;
}
.tv-column-count { font-size: 15px; }
.tv-column-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: none;
}
.tv-column-body::-webkit-scrollbar { display: none; }
.tv-column-empty { color: var(--gray); font-size: 12px; text-align: center; margin-top: 20px; }

.tv-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-left-width: 5px;
  border-radius: 7px;
  padding: 6px 9px;
  flex-shrink: 0;
}
.tv-card.tv-hot {
  position: relative;
  overflow: hidden;
  padding-right: 56px;
}
.tv-card.tv-hot::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 44px;
  background: repeating-linear-gradient(45deg, var(--accent) 0 5px, transparent 5px 10px);
  opacity: 0.85;
  pointer-events: none;
}
.tv-card-addr { font-size: 13px; font-weight: 700; line-height: 1.2; }
.tv-card-scope { font-size: 11px; color: var(--gray); margin-top: 2px; }
.tv-card.phase-border-pre_planning { border-left-color: #a0a0a0; }
.tv-card.phase-border-in_submission { border-left-color: #d9a441; }
.tv-card.phase-border-scheduled_hearing { border-left-color: #4a7fc9; }
.tv-card.phase-border-on_hold { border-left-color: #b3542e; }
.tv-card.phase-border-in_construction { border-left-color: #6b8fb3; }
.tv-card.phase-border-closeout { border-left-color: #7a5fc0; }
