/* ============================================================
   Maintenance — shares Prop Spot brand
   ============================================================ */
:root {
  --brand:        #61B746;
  --brand-dark:   #52a03a;
  --brand-light:  #edf7e9;
  --surface:      #ffffff;
  --bg:           #f4f5f7;
  --text:         #111827;
  --text-muted:   #6b7280;
  --border:       #e5e7eb;
  --danger:       #ef4444;
  --amber:        #f59e0b;
  --success:      #22c55e;
  --radius:       12px;
  --shadow:       0 2px 12px rgba(0,0,0,.08);
  --nav-height:   64px;
  --header-height:56px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100dvh; padding-bottom: var(--nav-height);
}
a { color: var(--brand-dark); }

.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--brand); color: #fff;
  height: var(--header-height);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.app-header .logo {
  font-size: 1.25rem; font-weight: 800; letter-spacing: -.5px;
  color: #fff; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
}
.app-header .back-btn {
  background: none; border: none; color: #fff; font-size: 1.5rem;
  cursor: pointer; padding: 4px 8px 4px 0; line-height: 1;
}
.app-header .header-title {
  font-size: 1rem; font-weight: 600; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header .header-actions { display: flex; gap: 8px; margin-left: auto; }
.icon-btn {
  background: rgba(255,255,255,.2); border: none; border-radius: 8px;
  color: #fff; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem;
}
.icon-btn:hover { background: rgba(255,255,255,.3); }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 99;
  height: var(--nav-height); background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch; justify-content: space-around;
}
.nav-link {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; text-decoration: none;
  color: var(--text-muted); font-size: .72rem;
}
.nav-link .nav-icon { font-size: 1.4rem; line-height: 1; }
.nav-link.active { color: var(--brand); }
.nav-link:hover  { color: var(--brand); }
.nav-brand        { display: none; }
.nav-spacer       { display: none; }
.nav-signout      { display: none; }
.nav-collapse-btn { display: none; }

.page { padding: 16px; max-width: 720px; margin: 0 auto; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; }
.card-body { padding: 16px; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 8px; }
.section-title  { font-size: 1rem; font-weight: 700; }

/* Work order row */
.row-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex; gap: 12px; align-items: flex-start;
  text-decoration: none; color: var(--text);
  margin-bottom: 10px;
  transition: transform .15s;
  border-left: 4px solid var(--border);
}
.row-card:active { transform: scale(.98); }
.row-card.priority-urgent { border-left-color: var(--danger); }
.row-card.priority-high   { border-left-color: var(--amber); }
.row-card.priority-normal { border-left-color: var(--brand); }
.row-card.priority-low    { border-left-color: var(--text-muted); }
.row-card.status-completed,
.row-card.status-cancelled { opacity: .55; }

.row-card-icon  { font-size: 1.4rem; flex-shrink: 0; }
.row-card-body  { flex: 1; min-width: 0; }
.row-card-title { font-weight: 700; font-size: .98rem; }
.row-card-sub   { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.row-card-meta  { display: flex; gap: 10px; margin-top: 6px; font-size: .76rem; color: var(--text-muted); flex-wrap: wrap; }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; font-size: 1rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--brand); }
.form-textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; font-size: .95rem; font-weight: 600;
  border-radius: 8px; border: none; cursor: pointer;
  transition: transform .12s, background .12s; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: #eee; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-full      { width: 100%; }
.btn-sm        { padding: 6px 10px; font-size: .82rem; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--brand-light); color: var(--brand-dark); }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red   { background: #fee2e2; color: #b91c1c; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-grey  { background: #f3f4f6; color: #4b5563; }
.badge-blue  { background: #dbeafe; color: #1e40af; }
.badge-purple{ background: #ede9fe; color: #6b21a8; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pill {
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text-muted);
  padding: 6px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600;
  cursor: pointer;
}
.pill.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pill:hover  { border-color: var(--brand); }

.empty-state { padding: 32px 16px; text-align: center; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 8px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: none; align-items: flex-end; justify-content: center; z-index: 200;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); width: 100%; max-width: 640px;
  border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto;
  padding: 20px; box-shadow: 0 -2px 18px rgba(0,0,0,.18);
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-height) + 16px);
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: .88rem; box-shadow: 0 4px 16px rgba(0,0,0,.25);
  opacity: 0; transition: opacity .25s, transform .25s; z-index: 250; max-width: 90%;
}
.toast.toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: var(--danger); }

.login-wrap { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-sm  { font-size: .85rem; }
.text-xs  { font-size: .75rem; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; text-align: center; }
.stat-num   { font-size: 1.5rem; font-weight: 800; color: var(--brand); }
.stat-num.is-warn { color: var(--amber); }
.stat-num.is-bad  { color: var(--danger); }
.stat-label { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Status workflow buttons */
.status-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.status-btn {
  padding: 6px 10px; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-muted); border-radius: 6px; cursor: pointer; font-size: .82rem; font-weight: 600;
}
.status-btn.active { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-light); }
.status-btn:hover  { border-color: var(--brand); }

/* Updates thread */
.update-row {
  border-left: 3px solid var(--brand-light);
  padding: 8px 12px; margin: 8px 0;
  background: var(--bg);
  border-radius: 0 8px 8px 0;
}
.update-author { font-weight: 600; font-size: .82rem; }
.update-time   { font-size: .72rem; color: var(--text-muted); margin-left: 6px; }
.update-body   { font-size: .92rem; margin-top: 4px; white-space: pre-wrap; }

@media (min-width: 720px) {
  body { padding-bottom: 0; padding-left: 220px; }
  body.sidebar-collapsed,
  html.sidebar-collapsed body { padding-left: 64px; }
  .app-header { display: none; }
  .bottom-nav {
    top: 0; right: auto; bottom: 0; width: 220px; height: 100dvh;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    border-top: none; border-right: 1px solid var(--border);
    padding: 16px 8px;
  }
  .nav-brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 1.15rem; font-weight: 800; color: var(--brand);
    padding: 6px 12px; text-decoration: none; margin-bottom: 8px;
  }
  .nav-collapse-btn {
    display: block; background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 1.1rem;
    align-self: flex-end; padding: 4px 10px; margin-bottom: 8px;
  }
  .nav-link {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start;
    gap: 10px; padding: 10px 14px; border-radius: 10px; font-size: .92rem;
  }
  .nav-link.active { background: var(--brand-light); color: var(--brand-dark); }
  .nav-spacer { display: block; flex: 1; }
  .nav-signout {
    display: flex; align-items: center; gap: 10px;
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    padding: 10px 14px; border-radius: 10px; font-size: .92rem; text-align: left;
  }
  .nav-signout:hover { color: var(--danger); }
  html.sidebar-collapsed .nav-brand .nav-label,
  html.sidebar-collapsed .nav-link span:not(.nav-icon),
  html.sidebar-collapsed .nav-signout span:not(.nav-icon) { display: none; }
  html.sidebar-collapsed .bottom-nav { width: 64px; align-items: center; }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 16px; max-width: 640px; }
}

/* ============================================================
   Pulse — team chat surface
   ============================================================ */
.pulse-body {
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  height: 100dvh;
  padding-bottom: 0;
  overflow: hidden;
}

.pulse-topbar {
  background: var(--brand);
  color: #fff;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  height: var(--header-height);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  gap: 16px;
}
.pulse-topbar-left { display: flex; align-items: center; gap: 8px; }
.pulse-topbar-center { display: flex; align-items: center; gap: 10px; justify-self: center; font-weight: 600; }
.pulse-topbar-right { display: flex; align-items: center; gap: 12px; justify-self: end; font-size: .9rem; }
.pulse-back {
  color: #fff; text-decoration: none; font-size: 1.5rem; line-height: 1;
  padding: 4px 8px; border-radius: 6px;
}
.pulse-back:hover { background: rgba(0,0,0,.12); }
.pulse-app-name { font-weight: 800; letter-spacing: -.3px; }
.pulse-conn-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #fde047; box-shadow: 0 0 0 2px rgba(0,0,0,.12);
}
.pulse-conn-dot.connecting { background: #fde047; animation: pulse-blink 1s infinite; }
.pulse-conn-dot.connected  { background: #22c55e; animation: none; }
.pulse-conn-dot.disconnected { background: #ef4444; animation: pulse-blink 1.5s infinite; }
@keyframes pulse-blink { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.pulse-user { opacity: .9; }
.pulse-signout {
  background: rgba(0,0,0,.15); color: #fff; border: none;
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: .85rem;
}
.pulse-signout:hover { background: rgba(0,0,0,.28); }

.pulse-main {
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  background: var(--surface);
}

.pulse-messages {
  overflow-y: auto;
  padding: 16px 16px 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.pulse-empty {
  color: var(--text-muted); font-size: .9rem; text-align: center; padding: 48px 16px;
}

.pulse-msg {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: flex-start;
}
.pulse-avatar {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--brand-light); color: var(--brand-dark);
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.pulse-msg-body { min-width: 0; }
.pulse-msg-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px;
}
.pulse-msg-author { font-weight: 700; color: var(--text); }
.pulse-msg-time   { font-size: .75rem; color: var(--text-muted); }
.pulse-msg-text {
  white-space: pre-wrap; word-wrap: break-word; word-break: break-word;
  color: var(--text); line-height: 1.45;
}

.pulse-composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px;
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  align-items: end;
}
.pulse-composer-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit; color: var(--text); background: #fff;
  resize: none; max-height: 160px; line-height: 1.4;
}
.pulse-composer-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.pulse-send {
  background: var(--brand); color: #fff; border: none;
  padding: 10px 18px; border-radius: 12px; cursor: pointer;
  font-weight: 600; font-size: .95rem;
  transition: background .12s;
}
.pulse-send:hover:not(:disabled) { background: var(--brand-dark); }
.pulse-send:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 640px) {
  .pulse-topbar { grid-template-columns: auto 1fr auto; padding: 0 10px; gap: 8px; }
  .pulse-topbar-center { justify-self: start; font-size: .95rem; }
  .pulse-topbar-right { font-size: .8rem; }
  .pulse-user { display: none; }
  .pulse-messages { padding: 12px; }
}

/* ============================================================
   Pulse — sidebar layout (Phase 2)
   ============================================================ */
.pulse-body-2col {
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-columns: 260px 1fr;
  height: 100dvh;
  padding-bottom: 0;
  overflow: hidden;
}
.pulse-body-2col .pulse-topbar { grid-column: 1 / -1; }

.pulse-sidebar {
  background: #f7f7f7;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 8px 24px;
  display: flex; flex-direction: column;
}
.pulse-sidebar-section { margin-top: 6px; }
.pulse-sidebar-heading {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 700;
  padding: 10px 10px 6px;
}
.pulse-sidebar-add {
  background: none; border: none; cursor: pointer; padding: 2px 8px;
  font-size: 1.1rem; line-height: 1; color: var(--text-muted);
  border-radius: 6px;
}
.pulse-sidebar-add:hover { background: var(--brand-light); color: var(--brand-dark); }
.pulse-channel-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  color: var(--text); font-size: .92rem;
  text-decoration: none; user-select: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pulse-channel-item:hover { background: rgba(0,0,0,.05); }
.pulse-channel-item.active {
  background: var(--brand); color: #fff;
}
.pulse-channel-item .pulse-channel-hash { opacity: .6; }
.pulse-channel-item.active .pulse-channel-hash { opacity: .8; color: #fff; }
.pulse-channel-item .pulse-channel-lock {
  font-size: .8rem; opacity: .7;
}
.pulse-channel-empty {
  color: var(--text-muted); font-size: .85rem;
  padding: 10px 10px; font-style: italic;
}

/* ── Modal ── */
.pulse-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.pulse-modal {
  background: #fff; border-radius: 14px; padding: 22px;
  width: 92%; max-width: 460px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.pulse-modal h2 {
  margin-bottom: 14px; font-size: 1.1rem;
}
.pulse-modal label {
  display: block; font-size: .85rem; color: var(--text-muted);
  margin-bottom: 4px; margin-top: 10px;
}
.pulse-modal input[type="text"],
.pulse-modal textarea {
  width: 100%; padding: 10px 12px; font: inherit;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); resize: vertical;
}
.pulse-modal input:focus, .pulse-modal textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.pulse-modal-check {
  display: flex; gap: 8px; align-items: center; margin-top: 12px;
  font-size: .9rem; color: var(--text);
}
.pulse-modal-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px;
}
.pulse-modal-cancel {
  background: none; border: 1px solid var(--border);
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
  font: inherit; color: var(--text);
}
.pulse-modal-cancel:hover { background: var(--bg); }
.pulse-modal-submit {
  background: var(--brand); color: #fff; border: none;
  padding: 9px 18px; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 600;
}
.pulse-modal-submit:hover:not(:disabled) { background: var(--brand-dark); }
.pulse-modal-submit:disabled { opacity: .5; cursor: not-allowed; }
.pulse-modal-error {
  color: var(--danger); font-size: .85rem; margin-top: 8px;
}

/* ── History loading indicator ── */
.pulse-history-loader {
  text-align: center; color: var(--text-muted);
  font-size: .8rem; padding: 8px 0;
}
.pulse-history-loader.hidden { display: none; }

/* ── Mobile drawer ── */
.pulse-sidebar-toggle {
  display: none;
  background: none; border: none; color: #fff;
  font-size: 1.5rem; padding: 4px 8px; cursor: pointer; line-height: 1;
}
@media (max-width: 720px) {
  .pulse-body-2col { grid-template-columns: 1fr; }
  .pulse-sidebar {
    position: fixed; left: 0; top: var(--header-height); bottom: 0;
    width: 280px; z-index: 60;
    transform: translateX(-100%); transition: transform .18s ease-out;
    box-shadow: 6px 0 20px rgba(0,0,0,.2);
  }
  .pulse-sidebar.open { transform: translateX(0); }
  .pulse-sidebar-toggle { display: inline-block; }
  .pulse-back { display: none; }
}
