/* ============================================================
   BUILD HUB — Main Stylesheet
   White theme, black text, clean construction management PWA
   ============================================================ */

/* --- Custom Properties (Light) --- */
:root {
  --bg: #ffffff;
  --bg-surface: #f5f5f5;
  --bg-elevated: #ffffff;
  --text: #111111;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --accent: #000000;
  --accent-hover: #333333;

  /* Status colours */
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --stuck: #ef4444;
  --incomplete: #9ca3af;
  --in-progress: #eab308;
  --complete: #22c55e;
  --delivery-requested: #93c5fd;
  --delivery-confirmed: #1e40af;
  --subbie-requested: #c4b5fd;
  --subbie-confirmed: #6d28d9;

  /* Sizing */
  --nav-height: 56px;
  --header-height: 52px;
  --sidebar-width: 240px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);

  /* Safe areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --bg-surface: #161616;
    --bg-elevated: #1c1c1c;
    --text: #f0f0f0;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --border: #2a2a2a;
    --border-light: #1e1e1e;
    --accent: #ffffff;
    --accent-hover: #cccccc;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}

/* --- Theme override via data-theme attribute --- */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-surface: #f5f5f5;
  --bg-elevated: #ffffff;
  --text: #111111;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --accent: #000000;
  --accent-hover: #333333;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-surface: #161616;
  --bg-elevated: #1c1c1c;
  --text: #f0f0f0;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --border: #2a2a2a;
  --border-light: #1e1e1e;
  --accent: #ffffff;
  --accent-hover: #cccccc;
}

/* --- Reset / Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Hide scrollbar on mobile but keep scrollable */
@media (max-width: 768px) {
  body::-webkit-scrollbar,
  .scrollable::-webkit-scrollbar {
    display: none;
  }
  body,
  .scrollable {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: 16px; /* Prevent iOS zoom */
  color: var(--text);
  background: var(--bg);
}

img {
  max-width: 100%;
  display: block;
}

/* --- Typography --- */
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.0625rem; font-weight: 600; }
h4 { font-size: 0.9375rem; font-weight: 600; }

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }

/* --- Layout Shell --- */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-content {
  flex: 1;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
  overflow-y: auto;
}

/* Desktop: side nav layout */
@media (min-width: 769px) {
  .app-shell {
    flex-direction: row;
  }
  .app-content {
    margin-left: var(--sidebar-width);
    padding-bottom: 0;
    width: calc(100% - var(--sidebar-width));
  }
}

/* --- Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  padding-top: var(--safe-top);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.app-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header__title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-header__subtitle {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: -2px;
}

.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.btn-back:hover {
  background: var(--bg-surface);
}

.btn-back svg {
  width: 20px;
  height: 20px;
}

/* --- Online/Offline Indicator --- */
.online-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  transition: background 0.3s;
}

.online-indicator.offline {
  background: var(--danger);
}

/* --- Notification Bell --- */
.notification-bell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.notification-bell:hover {
  background: var(--bg-surface);
}

.notification-bell svg {
  width: 22px;
  height: 22px;
}

.notification-badge {
  position: absolute;
  top: 6px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #ffffff;
  font-size: 0.625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.notification-badge:empty,
.notification-badge.hidden {
  display: none;
}

/* --- Bottom Navigation (Mobile) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

@media (min-width: 769px) {
  .bottom-nav {
    display: none;
  }
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  min-width: 44px;
  min-height: 44px;
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.bottom-nav__item svg {
  width: 22px;
  height: 22px;
  transition: color 0.15s;
}

.bottom-nav__item.active {
  color: var(--accent);
}

.bottom-nav__item:active {
  opacity: 0.7;
}

/* --- Side Navigation (Desktop) --- */
.side-nav {
  display: none;
}

@media (min-width: 769px) {
  .side-nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg);
    border-right: 1px solid var(--border);
    z-index: 200;
    overflow-y: auto;
  }
}

.side-nav__brand {
  display: flex;
  flex-direction: column;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.side-nav__brand-name {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.side-nav__brand-sub {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 1px;
}

.side-nav__section {
  padding: 16px 12px 8px;
}

.side-nav__section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 8px 8px;
}

.side-nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  min-height: 44px;
}

.side-nav__item:hover {
  background: var(--bg-surface);
  color: var(--text);
}

.side-nav__item.active {
  background: var(--bg-surface);
  color: var(--accent);
  font-weight: 600;
}

.side-nav__item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.side-nav__spacer {
  flex: 1;
}

.side-nav__footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

/* --- Login Page --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.login-brand {
  text-align: center;
  margin-bottom: 36px;
}

.login-brand__name {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-brand__sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--bg);
  transition: border-color 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-error {
  display: none;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.8125rem;
}

@media (prefers-color-scheme: dark) {
  .form-error {
    background: #1c0a0a;
    border-color: #4a1515;
  }
}

.form-error.visible {
  display: block;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  min-height: 44px;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-ghost {
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-surface);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.8125rem;
  min-height: 36px;
}

/* --- PIN Entry --- */
.pin-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  background: var(--bg);
}

.pin-card {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.pin-greeting {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.pin-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.pin-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 36px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: all 0.15s;
}

.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

.pin-dot.error {
  border-color: var(--danger);
  background: var(--danger);
  animation: pin-shake 0.4s;
}

@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 260px;
  margin: 0 auto 24px;
}

.pin-key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 50%;
  font-size: 1.375rem;
  font-weight: 500;
  background: var(--bg-surface);
  transition: all 0.1s;
  min-width: 44px;
  min-height: 44px;
  -webkit-user-select: none;
  user-select: none;
}

.pin-key:active {
  background: var(--border);
  transform: scale(0.95);
}

.pin-key--empty {
  background: transparent;
  pointer-events: none;
}

.pin-key--backspace {
  background: transparent;
}

.pin-key--backspace svg {
  width: 24px;
  height: 24px;
}

.pin-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.pin-link:hover {
  color: var(--text);
}

/* --- Project Selector --- */
.selector-page {
  padding-top: var(--safe-top);
}

.selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.selector-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.9375rem;
  background: var(--bg-surface);
  transition: border-color 0.15s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.selector-section {
  padding: 16px 16px 8px;
}

.selector-section__title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* --- Project Card --- */
.project-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all 0.15s;
  cursor: pointer;
  min-height: 44px;
}

.project-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.project-card:active {
  transform: scale(0.99);
}

.project-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.project-card__icon svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.project-card__info {
  flex: 1;
  min-width: 0;
}

.project-card__address {
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.project-card__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.project-card--pinned {
  border-color: var(--border);
  background: var(--bg-surface);
}

/* Team chat card */
.team-chat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}

.team-chat-card:active {
  transform: scale(0.99);
  opacity: 0.9;
}

.team-chat-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.team-chat-card__icon svg {
  width: 20px;
  height: 20px;
}

.team-chat-card__title {
  font-weight: 600;
  font-size: 0.9375rem;
}

/* --- Pin / Star --- */
.btn-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  color: var(--text-muted);
  transition: color 0.15s;
}

.btn-pin.pinned {
  color: var(--warning);
}

.btn-pin svg {
  width: 18px;
  height: 18px;
}

/* --- Unread Badge --- */
.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--bg);
  font-size: 0.6875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.unread-badge:empty,
.unread-badge.hidden {
  display: none;
}

/* --- Status Badge --- */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-badge--live {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
}

.status-badge--pre-start {
  background: rgba(234, 179, 8, 0.12);
  color: var(--warning);
}

.status-badge--complete {
  background: rgba(34, 197, 94, 0.12);
  color: var(--complete);
}

.status-badge--on-hold {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.status-badge--defects {
  background: rgba(239, 68, 68, 0.12);
  color: var(--stuck);
}

.status-badge--incomplete {
  background: rgba(156, 163, 175, 0.12);
  color: var(--incomplete);
}

.status-badge--in-progress {
  background: rgba(234, 179, 8, 0.12);
  color: var(--in-progress);
}

.status-badge--delivery-requested {
  background: rgba(147, 197, 253, 0.15);
  color: var(--delivery-requested);
}

.status-badge--delivery-confirmed {
  background: rgba(30, 64, 175, 0.12);
  color: var(--delivery-confirmed);
}

.status-badge--subbie-requested {
  background: rgba(196, 181, 253, 0.15);
  color: var(--subbie-requested);
}

.status-badge--subbie-confirmed {
  background: rgba(109, 40, 217, 0.12);
  color: var(--subbie-confirmed);
}

/* --- Project Hub (Tab Container) --- */
.hub-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.hub-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.hub-header__title {
  flex: 1;
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

@media (min-width: 769px) {
  .hub-content {
    padding-bottom: 0;
  }
}

.hub-tab {
  display: none;
  min-height: 100%;
}

.hub-tab.active {
  display: block;
}

/* Desktop top tabs */
@media (min-width: 769px) {
  .hub-tabs-desktop {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }

  .hub-tabs-desktop__item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    min-height: 44px;
  }

  .hub-tabs-desktop__item:hover {
    color: var(--text);
  }

  .hub-tabs-desktop__item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
  }

  .hub-tabs-desktop__item svg {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 768px) {
  .hub-tabs-desktop {
    display: none;
  }
}

/* --- Hub Mobile Bottom Nav --- */
.hub-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

@media (min-width: 769px) {
  .hub-bottom-nav {
    display: none;
  }
}

.hub-bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  min-width: 44px;
  min-height: 44px;
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.15s;
  -webkit-user-select: none;
  user-select: none;
  border: none;
  background: none;
  cursor: pointer;
}

.hub-bottom-nav__item svg {
  width: 22px;
  height: 22px;
  transition: color 0.15s;
}

.hub-bottom-nav__item.active {
  color: var(--accent);
}

.hub-bottom-nav__item:active {
  opacity: 0.7;
}

/* --- More Panel --- */
.more-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.more-panel-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.more-panel {
  position: fixed;
  z-index: 300;
  background: var(--bg);
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.more-panel.open {
  opacity: 1;
  pointer-events: auto;
}

/* Desktop: dropdown */
@media (min-width: 769px) {
  .more-panel {
    width: 260px;
    max-height: 70vh;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-8px);
  }

  .more-panel.open {
    transform: translateY(0);
  }

  .more-panel-overlay {
    display: none;
  }

  .more-panel__handle {
    display: none;
  }
}

/* Mobile: bottom sheet */
@media (max-width: 768px) {
  .more-panel {
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 8px);
  }

  .more-panel.open {
    transform: translateY(0);
  }
}

.more-panel__handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 8px auto 0;
}

.more-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
  border-bottom: 1px solid var(--border);
}

.more-panel__title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

.more-panel__close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
}

.more-panel__close:hover {
  background: var(--bg-surface);
  color: var(--text);
}

.more-panel__close svg {
  width: 18px;
  height: 18px;
}

.more-panel__items {
  padding: 8px;
}

.more-panel__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  text-align: left;
}

.more-panel__item:hover {
  background: var(--bg-surface);
  color: var(--text);
}

.more-panel__item.active {
  color: var(--accent);
  background: var(--bg-surface);
}

.more-panel__item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.more-panel__divider {
  height: 1px;
  background: var(--border);
  margin: 4px 16px;
}

.more-panel__accordion-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  text-align: left;
}

.more-panel__accordion-toggle:hover {
  background: var(--bg-surface);
  color: var(--text);
}

.more-panel__accordion-toggle svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.more-panel__chevron {
  margin-left: auto;
  width: 16px !important;
  height: 16px !important;
  transition: transform 0.2s ease;
}

.more-panel__accordion-toggle.expanded .more-panel__chevron {
  transform: rotate(180deg);
}

.more-panel__accordion {
  display: none;
  padding-left: 16px;
}

.more-panel__accordion.open {
  display: block;
}

/* More button highlight when a hidden tab is active */
.hub-more-btn.active {
  color: var(--accent);
}

@media (min-width: 769px) {
  .hub-more-btn.active {
    border-bottom-color: var(--accent);
    font-weight: 600;
  }
}

/* --- Snapshot Tab --- */
.snapshot {
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 80px);
}

.snapshot__overview {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  margin-bottom: 20px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
}

.snapshot__ring-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.snapshot__ring-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

.snapshot__ring-sub {
  font-size: 0.6875rem;
  color: var(--text-secondary);
}

.snapshot__progress {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.snapshot__progress-ring {
  transform: rotate(-90deg);
}

.snapshot__progress-bg {
  stroke: var(--border);
  fill: none;
  stroke-width: 6;
}

.snapshot__progress-fill {
  fill: none;
  stroke-width: 6;
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.snapshot__progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.8125rem;
  font-weight: 700;
}

.snapshot__overview-info {
  flex: 1;
}

.snapshot__overview-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.snapshot__overview-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.snapshot__section {
  margin-bottom: 24px;
}

.snapshot__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.snapshot__section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.snapshot__section-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Task Card --- */
.task-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}

.task-card:hover {
  border-color: var(--border);
}

.task-card:active {
  transform: scale(0.99);
}

.task-card__category {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  flex-shrink: 0;
  margin-top: 2px;
}

.task-card__category svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.task-card__body {
  flex: 1;
  min-width: 0;
}

.task-card__title {
  font-size: 0.875rem;
  font-weight: 500;
}

.task-card__assignee {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.task-card__right {
  flex-shrink: 0;
}

.task-card__details {
  display: none;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border-light);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.task-card.expanded .task-card__details {
  display: block;
}

/* --- Delivery / Subbie Card --- */
.delivery-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  min-height: 44px;
}

.delivery-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.delivery-card__icon svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.delivery-card__body {
  flex: 1;
  min-width: 0;
}

.delivery-card__title {
  font-size: 0.875rem;
  font-weight: 500;
}

.delivery-card__meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* --- Snapshot: Status Button (circle tap target) --- */
.task-card__status-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  margin-top: 1px;
  transition: background 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.task-card__status-btn:active {
  transform: scale(0.85);
}

.task-card__status-btn svg {
  width: 22px;
  height: 22px;
}

.task-card__status-btn--incomplete {
  color: var(--incomplete);
}

.task-card__status-btn--incomplete:hover {
  background: rgba(156, 163, 175, 0.1);
}

.task-card__status-btn--in_progress {
  color: var(--in-progress);
}

.task-card__status-btn--in_progress:hover {
  background: rgba(234, 179, 8, 0.1);
}

.task-card__status-btn--complete {
  color: var(--complete);
}

.task-card__status-btn--complete:hover {
  background: rgba(34, 197, 94, 0.1);
}

.task-card__status-btn--stuck {
  color: var(--stuck);
}

.task-card__status-btn--stuck:hover {
  background: rgba(239, 68, 68, 0.1);
}

.task-card__status-btn--delivery_requested {
  color: var(--delivery-requested);
}

.task-card__status-btn--delivery_confirmed {
  color: var(--delivery-confirmed);
}

.task-card__status-btn--subbie_requested {
  color: var(--subbie-requested);
}

.task-card__status-btn--subbie_confirmed {
  color: var(--subbie-confirmed);
}

/* --- Snapshot: Task title done state --- */
.task-card__title--done {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* --- Snapshot: Task meta row --- */
.task-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.task-card__supplier {
  color: var(--text-muted);
}

.task-card__supplier::before {
  content: '\00b7\00a0';
}

/* --- Task category tinting --- */
.task-card--subbie,
.plan-task--cat-subbie {
  background: rgba(109, 40, 217, 0.08);
  border-left: 3px solid var(--subbie-requested);
}
.task-card--delivery,
.plan-task--cat-delivery {
  background: rgba(30, 64, 175, 0.08);
  border-left: 3px solid var(--delivery-requested);
}

/* --- Day view: prominent category backgrounds for easy visual ID --- */
.day-view__tasks .plan-task--cat-subbie {
  background: rgba(147, 51, 234, 0.15);
  border-left: 4px solid var(--subbie-confirmed);
}
.day-view__tasks .plan-task--cat-delivery {
  background: rgba(59, 130, 246, 0.15);
  border-left: 4px solid var(--delivery-confirmed);
}

/* Calendar task pills (month view) */
.cal-cell__tasks {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  overflow: hidden;
  width: 100%;
}
.cal-task-pill {
  font-size: 0.6875rem;
  line-height: 1.3;
  padding: 3px 5px;
  border-radius: 3px;
  min-height: 24px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: grab;
}
.cal-task-pill[draggable="true"]:active {
  cursor: grabbing;
}
.cal-task-pill--dragging {
  opacity: 0.4;
}
.cal-task-pill--delivery {
  background: rgba(30, 64, 175, 0.12);
  color: var(--delivery-confirmed);
}
.cal-task-pill--subbie {
  background: rgba(109, 40, 217, 0.12);
  color: var(--subbie-confirmed);
}
.cal-task-pill--done {
  text-decoration: line-through;
  opacity: 0.6;
}
.cal-task-pill--more {
  color: var(--text-muted);
  font-style: italic;
}

/* --- Snapshot side-by-side days --- */
.snapshot__days-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 600px) {
  .snapshot__days-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Client contact card --- */
.snapshot__client-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.snapshot__client-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.snapshot__client-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}
.snapshot__client-detail {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 2px 0;
}
.snapshot__client-detail:hover {
  color: var(--accent);
}

/* --- Toggle Switch --- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--success);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* --- Profile avatar edit --- */
.profile-avatar-wrap {
  position: relative;
}
.profile-avatar-edit {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: 2px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.form-input--sm {
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* --- Snapshot: Empty state --- */
.snapshot__empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.snapshot__empty svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.5;
}

/* --- Snapshot: Floating Action Button --- */
.snapshot__fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.snapshot__fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.snapshot__fab:active {
  transform: scale(0.95);
}

.snapshot__fab svg {
  width: 24px;
  height: 24px;
}

@media (min-width: 769px) {
  .snapshot__fab {
    bottom: 24px;
    right: 24px;
  }
}

/* --- Snapshot: Add Task Form --- */
.snapshot__add-form .form-group {
  margin-bottom: 14px;
}

.snapshot__add-form label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.snapshot__add-form input[type="text"],
.snapshot__add-form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}

.snapshot__add-form input[type="text"]:focus,
.snapshot__add-form select:focus {
  outline: none;
  border-color: var(--accent);
}

.snapshot__add-form .form-row {
  display: flex;
  gap: 12px;
}

.snapshot__add-form .form-group--half {
  flex: 1;
}

/* --- Button styles --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  min-height: 44px;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-block {
  width: 100%;
}

/* --- Plan Tab (Calendar/Plan — Week/Day/Task layout) --- */
.plan-tab {
  position: relative;
  padding-bottom: 80px;
}

.plan-weeks {
  /* no extra padding — weeks stack edge-to-edge */
}

/* Empty state */
.plan-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.875rem;
}

/* Week section */
.plan-week {
  border-bottom: 1px solid var(--border);
}

/* Week header (collapsible button) */
.plan-week__header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: none;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
  min-height: 44px;
  -webkit-user-select: none;
  user-select: none;
}

.plan-week__header:active {
  background: var(--border-light);
}

.plan-week__header--current {
  background: var(--accent);
  color: var(--bg);
  border-bottom-color: var(--accent);
}

.plan-week__header--current:active {
  opacity: 0.9;
}

.plan-week__chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.plan-week__chevron--open {
  transform: rotate(180deg);
}

.plan-week__label {
  flex: 1;
}

.plan-week__progress {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.7;
  letter-spacing: 0;
  text-transform: none;
}

.plan-week__done-tag {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--complete);
  color: #fff;
  letter-spacing: 0.04em;
}

/* Week body (collapsible) */
.plan-week__body {
  display: none;
}

.plan-week__body--open {
  display: block;
}

/* Day section */
.plan-day {
  border-bottom: 1px solid var(--border-light);
}

.plan-day:last-child {
  border-bottom: none;
}

.plan-day__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg);
}

.plan-day__name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  min-width: 32px;
}

.plan-day__date-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex: 1;
}

.plan-day__add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}

.plan-day__add-btn:hover {
  color: var(--text);
}

.plan-day__add-btn:active {
  background: var(--bg-surface);
}

.plan-day__tasks {
  padding: 0 8px 8px;
}

.plan-day__empty {
  padding: 6px 16px 2px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Task card within plan */
.plan-task {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 3px 0;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.1s;
  min-height: 40px;
}

.plan-task:active {
  background: var(--bg-surface);
}

/* Status left border colours */
.plan-task--incomplete { border-left-color: var(--incomplete); }
.plan-task--in_progress { border-left-color: var(--in-progress); }
.plan-task--complete { border-left-color: var(--complete); opacity: 0.65; }
.plan-task--stuck { border-left-color: var(--stuck); }
.plan-task--delivery_requested { border-left-color: var(--delivery-requested); }
.plan-task--delivery_confirmed { border-left-color: var(--delivery-confirmed); }
.plan-task--subbie_requested { border-left-color: var(--subbie-requested); }
.plan-task--subbie_confirmed { border-left-color: var(--subbie-confirmed); }

/* Status button (tappable circle) */
.plan-task__status-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

/* Status dots */
.plan-status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid;
}

.plan-status-dot--incomplete {
  border-color: var(--incomplete);
  background: transparent;
}

.plan-status-dot--in_progress {
  border-color: var(--in-progress);
  background: var(--in-progress);
}

.plan-status-dot--complete {
  border-color: var(--complete);
  background: var(--complete);
}

.plan-status-dot--stuck {
  border-color: var(--stuck);
  background: var(--stuck);
}

.plan-status-dot--delivery_requested {
  border-color: var(--delivery-requested);
  background: var(--delivery-requested);
}

.plan-status-dot--delivery_confirmed {
  border-color: var(--delivery-confirmed);
  background: var(--delivery-confirmed);
}

.plan-status-dot--subbie_requested {
  border-color: var(--subbie-requested);
  background: var(--subbie-requested);
}

.plan-status-dot--subbie_confirmed {
  border-color: var(--subbie-confirmed);
  background: var(--subbie-confirmed);
}

/* Task content */
.plan-task__content {
  flex: 1;
  min-width: 0;
}

.plan-task__title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.plan-task__title--done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.plan-task__assignee {
  font-size: 0.6875rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

/* Category badge */
.plan-task__cat {
  font-size: 0.5625rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  text-transform: uppercase;
}

.plan-task__cat--delivery {
  background: rgba(30, 64, 175, 0.1);
  color: var(--delivery-confirmed);
}

.plan-task__cat--subbie {
  background: rgba(109, 40, 217, 0.1);
  color: var(--subbie-confirmed);
}

.plan-task__cat--equipment {
  background: rgba(234, 179, 8, 0.1);
  color: #92400e;
}

/* Floating action button */
.plan-fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  cursor: pointer;
  transition: transform 0.15s;
}

.plan-fab:active {
  transform: scale(0.92);
}

@media (min-width: 769px) {
  .plan-fab {
    bottom: 24px;
    right: 24px;
  }
}

/* --- Plan View Toggle (Day / Week / Month) --- */
.plan-view-toggle {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.plan-toggle-btn {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 38px;
}

.plan-toggle-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.plan-toggle-btn:not(.active):active {
  background: var(--bg-surface);
}

/* --- Day View --- */
.day-view__tasks {
  padding: 8px 12px 16px;
}

.day-view__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.875rem;
}

.day-view__summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 12px;
}

.day-view__summary-count {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text);
}

.day-view__summary-done {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--complete);
}

/* --- Month View — 4-column grid (Mon-Thu only) --- */

/* Month navigation (shared with day view nav) */
.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.cal-nav__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.cal-nav__btn:active {
  background: var(--bg-surface);
}

.cal-nav__label {
  flex: 1;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.cal-nav__today-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}

.cal-nav__today-btn:active {
  background: var(--bg-surface);
}

/* Grid layout — 4 columns (Mon-Thu) */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.cal-grid--header {
  border-bottom: 1px solid var(--border-light);
}

.cal-hdr {
  padding: 8px 4px;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Day cells */
.cal-cell {
  position: relative;
  min-height: 60px;
  padding: 6px;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.cal-cell--drag-over {
  background: rgba(0, 0, 0, 0.06);
  box-shadow: inset 0 0 0 2px var(--accent);
}
@media (prefers-color-scheme: dark) {
  .cal-cell--drag-over {
    background: rgba(255, 255, 255, 0.08);
  }
}
[data-theme="dark"] .cal-cell--drag-over {
  background: rgba(255, 255, 255, 0.08);
}

.cal-cell:nth-child(4n) {
  border-right: none;
}

.cal-cell:active {
  background: var(--bg-surface);
}

.cal-cell--blank {
  cursor: default;
}

.cal-cell--blank:active {
  background: transparent;
}

/* Today highlight */
.cal-cell--today .cal-cell__num {
  background: var(--accent);
  color: var(--bg);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Selected day */
.cal-cell--selected {
  background: rgba(0, 0, 0, 0.04);
  box-shadow: inset 0 0 0 2px var(--accent);
}

@media (prefers-color-scheme: dark) {
  .cal-cell--selected {
    background: rgba(255, 255, 255, 0.06);
  }
}

/* Day number */
.cal-cell__num {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
  margin-bottom: 2px;
}

/* Task dots row */
.cal-cell__dots {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2px;
  max-width: 100%;
}

.cal-cell__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-cell__more {
  font-size: 0.5rem;
  color: var(--text-muted);
  font-weight: 700;
  line-height: 6px;
}

/* Task count badge */
.cal-cell__count {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Cells with tasks get a subtle indicator */
.cal-cell--has-tasks {
  background: var(--bg-elevated);
}

/* --- Day Detail Panel (slide-up from month view) --- */
.cal-day-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 60vh;
  background: var(--bg-elevated);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  z-index: 100;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

.cal-day-panel--open {
  transform: translateY(0);
}

.cal-day-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.cal-day-panel__title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

.cal-day-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
}

.cal-day-panel__close:active {
  background: var(--bg-surface);
}

.cal-day-panel__body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px 16px;
  flex: 1;
}

.cal-day-panel__empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-style: italic;
}

/* Reuse plan-task styles inside the panel */
.cal-day-panel__body .plan-task {
  margin: 4px 0;
}

/* --- Calendar responsive: compact on mobile, larger on wider screens --- */
@media (max-width: 479px) {
  .cal-cell {
    min-height: 54px;
    padding: 3px;
  }
  .cal-cell__num {
    font-size: 0.6875rem;
  }
  .cal-task-pill {
    font-size: 0.5625rem;
    padding: 1px 3px;
    min-height: 16px;
  }
  .cal-hdr {
    padding: 4px 2px;
    font-size: 0.6rem;
  }
}

@media (min-width: 480px) {
  .cal-cell {
    min-height: 110px;
    padding: 8px;
  }

  .cal-cell__num {
    font-size: 0.875rem;
  }

  .cal-cell__dot {
    width: 7px;
    height: 7px;
  }

  .cal-cell__count {
    font-size: 0.6875rem;
  }
}

@media (min-width: 769px) {
  .cal-cell {
    min-height: 130px;
    padding: 10px;
  }
  .cal-task-pill {
    font-size: 0.75rem;
    padding: 4px 6px;
    min-height: 26px;
  }

  .cal-day-panel {
    max-height: 50vh;
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .cal-day-panel--open {
    transform: translateX(-50%) translateY(0);
  }

  .plan-view-toggle {
    max-width: 360px;
    margin: 0 auto;
    padding: 10px 16px;
  }
}

/* --- Week Kanban View (4-column Mon-Thu) --- */
.week-kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  min-height: calc(100vh - 200px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.week-kanban__col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-light);
  min-width: 0;
}

.week-kanban__col:last-child {
  border-right: none;
}

.week-kanban__col--today {
  background: rgba(0, 0, 0, 0.02);
}

@media (prefers-color-scheme: dark) {
  .week-kanban__col--today {
    background: rgba(255, 255, 255, 0.03);
  }
}

[data-theme="dark"] .week-kanban__col--today {
  background: rgba(255, 255, 255, 0.03);
}

.week-kanban__col-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 5;
}

.week-kanban__day-name {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.week-kanban__day-date {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.week-kanban__day-date--today {
  background: var(--accent);
  color: var(--bg);
}

.week-kanban__col-count {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.week-kanban__tasks {
  flex: 1;
  padding: 6px 6px 4px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 80px;
  transition: background 0.15s, box-shadow 0.15s;
}

.week-kanban__tasks--drag-over {
  background: rgba(0, 0, 0, 0.04);
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: var(--radius-sm);
}

@media (prefers-color-scheme: dark) {
  .week-kanban__tasks--drag-over {
    background: rgba(255, 255, 255, 0.06);
  }
}

[data-theme="dark"] .week-kanban__tasks--drag-over {
  background: rgba(255, 255, 255, 0.06);
}

.week-kanban__empty {
  padding: 16px 8px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.week-kanban__tasks .plan-task {
  margin: 4px 0;
  cursor: grab;
}

.week-kanban__tasks .plan-task:active {
  cursor: grabbing;
}

.week-kanban__tasks .plan-task--dragging {
  opacity: 0.4;
}

.week-kanban__add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border-top: 1px solid var(--border-light);
  transition: color 0.15s, background 0.15s;
  min-height: 36px;
}

.week-kanban__add-btn:hover {
  color: var(--text);
  background: var(--bg-surface);
}

.week-kanban__add-btn:active {
  background: var(--border-light);
}

/* Mobile: all 4 days visible at once (Mon-Thu) */
@media (max-width: 600px) {
  .week-kanban {
    grid-template-columns: repeat(4, 1fr);
    overflow-x: hidden;
  }
  .week-kanban__col {
    min-width: 0;
  }
  .week-kanban__col-header {
    padding: 6px 2px;
  }
  .week-kanban__day-name {
    font-size: 0.6rem;
  }
  .week-kanban__tasks {
    padding: 2px;
  }
  .week-kanban__tasks .plan-task {
    padding: 4px 3px;
    font-size: 0.65rem;
  }
}

/* Tablet+ : columns fill available space */
@media (min-width: 601px) {
  .week-kanban {
    overflow-x: hidden;
  }
  .week-kanban__tasks {
    padding: 8px;
  }
  .week-kanban__tasks .plan-task {
    margin: 5px 0;
  }
}

/* --- Files Tab --- */
.files-tab {
  padding: 16px;
}

.files-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: nowrap;
}

.files-breadcrumb__item {
  color: var(--text-secondary);
  font-weight: 500;
}

.files-breadcrumb__item:last-child {
  color: var(--text);
  font-weight: 600;
}

.files-breadcrumb__sep {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.folder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
  text-align: center;
}

.folder-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.folder-card:active {
  transform: scale(0.97);
}

.folder-card svg {
  width: 32px;
  height: 32px;
  color: var(--text-secondary);
}

.folder-card__name {
  font-size: 0.8125rem;
  font-weight: 500;
}

.folder-card__count {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.folder-card--history {
  opacity: 0.5;
}

.files-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
}

.files-loading {
  padding: 24px;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
}

.file-item:hover {
  background: var(--bg-surface);
}

.file-item__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.file-item__icon svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.file-item__info {
  flex: 1;
  min-width: 0;
}

.file-item__name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item__meta {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.file-item__badge {
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--bg);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Upload FAB */
.fab-upload {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  transition: transform 0.15s;
}

.fab-upload:active {
  transform: scale(0.92);
}

.fab-upload svg {
  width: 24px;
  height: 24px;
}

@media (min-width: 769px) {
  .fab-upload {
    bottom: 24px;
    right: 24px;
  }
}

/* File preview overlay */
.file-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.file-preview-overlay.visible {
  display: flex;
}

.file-preview-overlay__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.file-preview-overlay__close svg {
  width: 24px;
  height: 24px;
}

.file-preview-overlay img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.file-preview-overlay iframe {
  width: 100%;
  max-width: 800px;
  height: 90vh;
  border: none;
  border-radius: var(--radius-sm);
  background: #ffffff;
}

/* --- Chat Tab --- */
.chat-tab {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height) - var(--nav-height) - var(--safe-bottom));
  height: calc(100dvh - var(--header-height) - var(--nav-height) - var(--safe-bottom));
}

@media (min-width: 769px) {
  .chat-tab {
    height: calc(100vh - var(--header-height) - 48px);
  }
}

/* Pinned message bar */
.chat-pinned {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.chat-pinned__icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-pinned__icon svg {
  width: 14px;
  height: 14px;
}

.chat-pinned__text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

.chat-pinned.hidden {
  display: none;
}

/* Load more messages */
.chat-load-more {
  text-align: center;
  padding: 8px 0 12px;
}

.chat-load-more.hidden {
  display: none;
}

.chat-load-more__btn {
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  cursor: pointer;
  transition: all 0.15s;
}

.chat-load-more__btn:hover {
  color: var(--text);
  border-color: var(--border);
}

/* Message list */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Message bubble */
.message {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: msg-in 0.2s ease-out;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message--own {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message--system {
  align-self: center;
  max-width: 90%;
}

.message__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.message--own .message__avatar {
  display: none;
}

.message__content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message__header {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.message--own .message__header {
  flex-direction: row-reverse;
}

.message__sender {
  font-size: 0.75rem;
  font-weight: 600;
}

.message__time {
  font-size: 0.625rem;
  color: var(--text-muted);
}

.message__bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.45;
  word-wrap: break-word;
}

/* Other's messages */
.message:not(.message--own):not(.message--system):not(.message--ai) .message__bubble {
  background: var(--bg-surface);
  border-top-left-radius: 4px;
}

/* Own messages — light green */
.message--own .message__bubble {
  background: #2d6a4f;
  color: #e8f5e9;
  border-top-right-radius: 4px;
}

/* AI messages */
.message--ai .message__bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}

.message--ai .message__sender {
  color: var(--text-secondary);
  font-style: italic;
}

/* @mention tags */
.mention-tag {
  font-weight: 600;
  color: var(--accent);
}
.mention-tag--ai {
  font-weight: 700;
}
/* Own messages have green background — mentions need contrasting color */
.message--own .mention-tag {
  color: #e8f5e9;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* System messages */
.message--system .message__bubble {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-align: center;
  padding: 6px 12px;
}

/* Reply-to */
.message__reply {
  padding: 6px 10px;
  margin-bottom: 4px;
  border-left: 3px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg-surface);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.message__reply-sender {
  font-weight: 600;
  margin-bottom: 1px;
}

/* Photo message */
.message__photo {
  max-width: 240px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 4px;
  cursor: pointer;
}

.message__photo img {
  width: 100%;
  display: block;
}

/* Read receipts */
.message__receipts {
  display: flex;
  gap: -4px;
  margin-top: 2px;
}

.message--own .message__receipts {
  justify-content: flex-end;
}

.message__receipt-avatar {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1.5px solid var(--bg);
  margin-left: -4px;
  font-size: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-muted);
}

/* Typing indicator */
.chat-typing {
  padding: 4px 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  flex-shrink: 0;
}

.chat-typing.hidden {
  display: none;
}

/* @mention autocomplete */
.mention-popup {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}

.mention-popup.visible {
  display: block;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.1s;
  min-height: 44px;
}

.mention-item:hover,
.mention-item.selected {
  background: var(--bg-surface);
}

.mention-item__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.mention-item__name {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Chat input bar */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  position: relative;
}

@media (min-width: 769px) {
  .chat-input-bar {
    padding-bottom: 10px;
  }
}

.chat-input-bar__attach {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: color 0.15s;
  flex-shrink: 0;
}

.chat-input-bar__attach:hover {
  color: var(--text);
}

.chat-input-bar__attach svg {
  width: 22px;
  height: 22px;
}

.chat-input-bar__field {
  flex: 1;
  min-width: 0;
}

.chat-input-bar__input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.9375rem;
  background: var(--bg-surface);
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color 0.15s;
}

.chat-input-bar__input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-input-bar__input::placeholder {
  color: var(--text-muted);
}

.chat-input-bar__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.chat-input-bar__send:disabled {
  opacity: 0.3;
}

.chat-input-bar__send svg {
  width: 20px;
  height: 20px;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in 0.3s ease-out;
}

.toast--success { background: var(--success); color: #ffffff; }
.toast--warning { background: var(--warning); color: #000000; }
.toast--error { background: var(--danger); color: #ffffff; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast.toast-out {
  animation: toast-out 0.2s ease-in forwards;
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-12px); }
}

/* --- Modal / Popup --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: modal-bg-in 0.2s ease-out;
}

@media (min-width: 769px) {
  .modal-overlay {
    align-items: center;
  }
}

.modal-overlay.visible {
  display: flex;
}

@keyframes modal-bg-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  animation: modal-slide-up 0.3s ease-out;
}

@media (min-width: 769px) {
  .modal {
    border-radius: var(--radius-lg);
    margin: 24px;
  }

  @keyframes modal-slide-up {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
  }
}

@keyframes modal-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  font-size: 1rem;
  font-weight: 600;
}

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.modal__close:hover {
  background: var(--bg-surface);
  color: var(--text);
}

.modal__close svg {
  width: 20px;
  height: 20px;
}

.modal__body {
  padding: 20px;
  overflow-y: auto;
  max-height: 60vh;
}

.modal__footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.modal__footer .btn {
  flex: 1;
}

/* --- Offline Banner --- */
.offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--warning);
  color: #000000;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: center;
}

.offline-banner.visible {
  display: flex;
}

.offline-banner svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Profile Tab --- */
.profile-tab {
  padding: 24px 16px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-name {
  font-size: 1.125rem;
  font-weight: 600;
}

.profile-role {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.profile-section {
  margin-bottom: 20px;
}

.profile-section__title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.profile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  min-height: 44px;
}

.profile-item__label {
  font-size: 0.875rem;
  color: var(--text);
}

.profile-item__value {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.profile-item__action {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.profile-item__action svg {
  width: 16px;
  height: 16px;
}

/* --- Utility Classes --- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Transitions --- */
.fade-in {
  animation: fade-in 0.2s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-up {
  animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Print (hide app chrome) --- */
@media print {
  .bottom-nav,
  .side-nav,
  .app-header,
  .chat-input-bar,
  .fab-upload {
    display: none !important;
  }
  .app-content {
    margin-left: 0 !important;
    padding-bottom: 0 !important;
  }
}


/* ============================================================
   COST TRACKER
   ============================================================ */

.costs-page {
  padding: 0 16px 80px;
  max-width: 900px;
  margin: 0 auto;
}

.costs-page .app-header {
  position: static;
  padding: 20px 0 12px;
  border-bottom: none;
}

.costs-page .app-header__title {
  font-size: 1.25rem;
  font-weight: 700;
}

.costs-sync-info {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Summary cards */
.costs-summary {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 0 16px;
  -webkit-overflow-scrolling: touch;
}

.costs-summary__card {
  flex: 0 0 auto;
  min-width: 120px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.costs-summary__card--danger {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.06);
}

.costs-summary__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.costs-summary__value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

/* Job cards */
.costs-jobs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.costs-job-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s;
  border-left: 4px solid var(--success);
}

.costs-job-card--warning {
  border-left-color: var(--warning);
}

.costs-job-card--danger {
  border-left-color: var(--danger);
}

.costs-job-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.costs-job-card__address {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 4px;
}

.costs-job-card__meta {
  display: flex;
  gap: 8px;
  align-items: center;
}

.costs-alert-badge {
  font-size: 0.7rem;
  background: var(--danger);
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.costs-job-card__gp {
  text-align: right;
  flex-shrink: 0;
}

.costs-job-card__gp-value {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
}

.costs-job-card__gp-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.costs-gp--good { color: var(--success); }
.costs-gp--ok { color: var(--warning); }
.costs-gp--bad { color: var(--danger); }
.costs-gp--none { color: var(--text-muted); }

/* Budget bar */
.costs-budget-bar {
  margin-top: 10px;
}

.costs-budget-bar__track {
  width: 100%;
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
}

.costs-budget-bar__fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.costs-budget-bar__fill--good { background: var(--success); }
.costs-budget-bar__fill--warning { background: var(--warning); }
.costs-budget-bar__fill--danger { background: var(--danger); }

.costs-budget-bar__labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Detail expansion */
.costs-job-card__detail {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.costs-job-card__breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.costs-category-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 60px;
  gap: 8px;
  font-size: 0.85rem;
  padding: 4px 0;
  align-items: center;
}

.costs-category-row--header {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 6px;
}

.costs-category-row--total {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  font-weight: 600;
}

.costs-category-row__label {
  font-weight: 500;
}

.costs-pct--good { color: var(--success); font-weight: 600; }
.costs-pct--warning { color: var(--warning); font-weight: 600; }
.costs-pct--danger { color: var(--danger); font-weight: 700; }

.costs-no-estimate {
  padding: 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.costs-no-estimate p {
  margin-bottom: 8px;
}

.costs-job-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.costs-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* Cost tracker tabs */
.costs-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.costs-tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.costs-tab.active {
  background: var(--accent);
  color: var(--bg);
}

.costs-tab:not(.active):active {
  background: var(--bg-surface);
}

/* Project selector tabs */
.selector-tabs {
  display: flex;
  gap: 0;
  margin: 0 16px 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.selector-tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.selector-tab.active {
  background: var(--accent);
  color: var(--bg);
}

.selector-tab:not(.active):active {
  background: var(--bg-surface);
}

/* Drag and drop */
.project-card__drag-handle {
  display: flex;
  align-items: center;
  padding: 0 4px 0 0;
  color: var(--text-muted);
  cursor: grab;
  touch-action: none;
  flex-shrink: 0;
}

.project-card__drag-handle:active {
  cursor: grabbing;
}

.project-draggable {
  transition: opacity 0.15s, transform 0.15s;
}

.project-draggable.dragging {
  opacity: 0.4;
  transform: scale(0.97);
}

.selector-drop-zone {
  transition: background 0.15s, border-color 0.15s;
  border: 2px dashed transparent;
  border-radius: var(--radius-md);
  min-height: 60px;
}

.selector-drop-zone.drop-hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: var(--accent);
}

.selector-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* Date range filter */
.costs-date-filter {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.costs-date-filter__row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.costs-date-filter__field {
  flex: 1;
  margin-bottom: 0;
}

.costs-date-filter__field .form-label {
  font-size: 0.7rem;
  margin-bottom: 4px;
}

.costs-date-filter__field .form-input {
  font-size: 0.8125rem;
  padding: 6px 8px;
}

.costs-date-filter__btn {
  flex-shrink: 0;
  min-height: 34px;
}

/* Completed date badge */
.costs-completed-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Modal (costs) */
.modal-overlay.costs-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.costs-modal.visible {
  display: flex;
}

.modal-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-card__header h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-card__body {
  padding: 16px 20px;
}

.modal-card__footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.form-static {
  font-weight: 600;
  color: var(--text);
  padding: 6px 0;
}


/* ============================================================
   VARIATION TRACKER
   ============================================================ */

/* Page layout */
.var-page {
  padding: 0 16px 80px;
  max-width: 900px;
  margin: 0 auto;
}

.var-page .app-header {
  position: static;
  padding: 20px 0 12px;
  border-bottom: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.var-page .app-header__left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.var-page .app-header__back {
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  align-items: center;
}

.var-page .app-header__title {
  font-size: 1.25rem;
  font-weight: 700;
}

.var-page .app-header__subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Summary cards */
.var-summary {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 0 16px;
  -webkit-overflow-scrolling: touch;
}

.var-summary__card {
  flex: 0 0 auto;
  min-width: 120px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.var-summary__card--success {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.06);
}

.var-summary__card--warning {
  border-color: var(--warning);
  background: rgba(234, 179, 8, 0.06);
}

.var-summary__card--danger {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.06);
}

.var-summary__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.var-summary__value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

/* Project variation summary */
.var-project-summary {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.var-project-summary__row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.var-project-summary__row + .var-project-summary__row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.var-project-summary__item {
  flex: 1;
  min-width: 100px;
}

.var-project-summary__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 2px;
  display: block;
}

.var-project-summary__value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.var-val--positive { color: var(--success); }
.var-val--danger { color: var(--danger); }
.var-val--bold { font-weight: 800; }

.var-pct--good { color: var(--success); }
.var-pct--warning { color: var(--warning); }
.var-pct--danger { color: var(--danger); }

/* Filters */
.var-filters {
  margin-bottom: 16px;
}

.var-filters__row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.var-filters__select {
  flex: 1;
  min-width: 140px;
  font-size: 0.85rem;
}

/* Variation cards */
.var-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.var-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s;
  border-left: 4px solid var(--text-muted);
}

.var-card:hover {
  border-color: var(--accent);
}

.var-card--identified { border-left-color: var(--text-muted); }
.var-card--priced { border-left-color: #60a5fa; }
.var-card--awaiting_approval { border-left-color: var(--warning); }
.var-card--approved { border-left-color: var(--success); }
.var-card--completed { border-left-color: var(--success); }
.var-card--cancelled { border-left-color: var(--danger); opacity: 0.6; }

.var-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.var-card__project {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.var-card__desc {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 6px;
}

.var-card__meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.var-card__amount {
  text-align: right;
  flex-shrink: 0;
}

.var-card__amount-value {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.var-card__amount-value--none {
  color: var(--text-muted);
}

.var-card__amount-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.var-card__footer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.var-card__raised {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Type badges */
.var-type-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.var-type-badge--client_requested { background: #dbeafe; color: #1e40af; }
.var-type-badge--site_error { background: #fee2e2; color: #991b1b; }
.var-type-badge--third_party_design { background: #fef3c7; color: #92400e; }
.var-type-badge--alex_design_unknown { background: #e0e7ff; color: #3730a3; }
.var-type-badge--alex_design_could_have_known { background: #fce7f3; color: #9d174d; }
.var-type-badge--sm_discovered { background: #d1fae5; color: #065f46; }

[data-theme="dark"] .var-type-badge--client_requested { background: rgba(30, 64, 175, 0.3); color: #93c5fd; }
[data-theme="dark"] .var-type-badge--site_error { background: rgba(153, 27, 27, 0.3); color: #fca5a5; }
[data-theme="dark"] .var-type-badge--third_party_design { background: rgba(146, 64, 14, 0.3); color: #fcd34d; }
[data-theme="dark"] .var-type-badge--alex_design_unknown { background: rgba(55, 48, 163, 0.3); color: #a5b4fc; }
[data-theme="dark"] .var-type-badge--alex_design_could_have_known { background: rgba(157, 23, 77, 0.3); color: #f9a8d4; }
[data-theme="dark"] .var-type-badge--sm_discovered { background: rgba(6, 95, 70, 0.3); color: #6ee7b7; }

/* Status badges */
.var-status-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.var-status-badge--identified { background: var(--bg-surface); color: var(--text-secondary); border: 1px solid var(--border); }
.var-status-badge--priced { background: #dbeafe; color: #1d4ed8; }
.var-status-badge--awaiting_approval { background: #fef3c7; color: #d97706; }
.var-status-badge--approved { background: #d1fae5; color: #059669; }
.var-status-badge--completed { background: #d1fae5; color: #065f46; }
.var-status-badge--cancelled { background: #fee2e2; color: #dc2626; }

[data-theme="dark"] .var-status-badge--priced { background: rgba(29, 78, 216, 0.25); color: #93c5fd; }
[data-theme="dark"] .var-status-badge--awaiting_approval { background: rgba(217, 119, 6, 0.25); color: #fcd34d; }
[data-theme="dark"] .var-status-badge--approved { background: rgba(5, 150, 105, 0.25); color: #6ee7b7; }
[data-theme="dark"] .var-status-badge--completed { background: rgba(6, 95, 70, 0.25); color: #6ee7b7; }
[data-theme="dark"] .var-status-badge--cancelled { background: rgba(220, 38, 38, 0.25); color: #fca5a5; }

/* Warning / absorb badges */
.var-warning-badge {
  font-size: 0.65rem;
  background: var(--danger);
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.var-absorb-badge {
  font-size: 0.65rem;
  background: var(--warning);
  color: #000;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* Empty state */
.var-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.var-empty p + p {
  margin-top: 8px;
  font-size: 0.85rem;
}

/* Detail modal */
.var-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.var-detail__row {
  display: flex;
  gap: 12px;
  font-size: 0.9rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
  align-items: flex-start;
}

.var-detail__row:last-child {
  border-bottom: none;
}

.var-detail__label {
  flex: 0 0 140px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Form hint box */
.var-form-hint-box {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

[data-theme="dark"] .var-form-hint-box {
  background: rgba(234, 179, 8, 0.08);
  border-color: rgba(234, 179, 8, 0.2);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Danger button */
.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover {
  opacity: 0.9;
}

/* ============================================================
   PAYMENTS PAGE
   ============================================================ */

.payments-page {
  padding: 0 16px 80px;
  max-width: 900px;
  margin: 0 auto;
}

.payments-page .app-header {
  position: static;
  padding: 20px 0 12px;
  border-bottom: none;
}

.payments-page .app-header__title {
  font-size: 1.25rem;
  font-weight: 700;
}

/* Summary cards */
.payments-summary {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 0 16px;
  -webkit-overflow-scrolling: touch;
}

.payments-summary__card {
  flex: 0 0 auto;
  min-width: 120px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.payments-summary__card--danger {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.06);
}

.payments-summary__card--warning {
  border-color: var(--warning);
  background: rgba(234, 179, 8, 0.06);
}

.payments-summary__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.payments-summary__value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

/* Section headers */
.payments-section {
  margin-bottom: 24px;
}

.payments-section__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 12px;
}

.payments-section__header--overdue {
  border-bottom-color: var(--danger);
}

.payments-section__header--warning {
  border-bottom-color: var(--warning);
}

.payments-section__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.payments-section__count {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

.payments-section__header--overdue .payments-section__count {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

.payments-section__header--warning .payments-section__count {
  background: rgba(234, 179, 8, 0.1);
  border-color: var(--warning);
  color: #92400e;
}

/* Payment cards */
.payments-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.payment-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border-left: 4px solid var(--success);
  transition: border-color 0.15s;
}

.payment-card--overdue {
  border-left-color: var(--danger);
}

.payment-card--due-soon {
  border-left-color: var(--warning);
}

.payment-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.payment-card__project {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 4px;
}

.payment-card__meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.payment-card__code {
  font-size: 0.7rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.payment-type-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.payment-type-badge--deposit_1 {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: #1d4ed8;
}

.payment-type-badge--deposit_2 {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.3);
  color: #6d28d9;
}

.payment-type-badge--stage_claim {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #15803d;
}

/* Dark mode badge overrides */
[data-theme="dark"] .payment-type-badge--deposit_1 {
  background: rgba(59, 130, 246, 0.15);
  color: #93bbfd;
}
[data-theme="dark"] .payment-type-badge--deposit_2 {
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
}
[data-theme="dark"] .payment-type-badge--stage_claim {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.payment-card__amount {
  text-align: right;
  flex-shrink: 0;
}

.payment-card__amount-value {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.payment-card__days-overdue {
  font-size: 0.7rem;
  color: var(--danger);
  font-weight: 700;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.payment-card__days-warning {
  font-size: 0.7rem;
  color: var(--warning);
  font-weight: 600;
  margin-top: 4px;
}

.payment-card__days-ok {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.payment-card__dates {
  display: flex;
  gap: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Follow-up tracker steps */
.payment-card__followups {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.followup-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.followup-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.followup-step--sent {
  color: var(--text);
}

.followup-step__indicator {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.followup-step--sent .followup-step__indicator {
  color: var(--success);
}

.followup-step__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.followup-step__label {
  flex: 1;
}

.followup-step--sent .followup-step__label {
  text-decoration: line-through;
  opacity: 0.7;
}

.followup-step__date {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Action buttons */
.payment-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

/* Small buttons */
.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
  min-height: 36px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-surface);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  opacity: 0.9;
}

/* Empty state */
.payments-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.payments-empty h3 {
  margin-bottom: 8px;
  color: var(--text);
}

/* Modal (payments) */
.modal-overlay.payments-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-overlay.payments-modal.visible {
  display: flex;
}

.payments-modal .modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.payments-modal .modal-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.payments-modal .modal-card__header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.payments-modal .modal-close {
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.payments-modal .modal-close:hover {
  background: var(--bg-surface);
  color: var(--text);
}

.payments-modal .modal-card__body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.payments-modal .modal-card__footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.payments-textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.5;
  font-size: 0.875rem;
  padding: 12px;
}

/* Toast styling */
.toast {
  background: var(--accent);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.3s ease;
}

.toast--fade {
  opacity: 0;
  transition: opacity 0.3s ease;
}

@keyframes toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive — stacked on mobile */
@media (max-width: 480px) {
  .payment-card__header {
    flex-direction: column;
    gap: 8px;
  }
  .payment-card__amount {
    text-align: left;
  }
  .payment-card__dates {
    flex-direction: column;
    gap: 4px;
  }
  .payment-card__actions {
    flex-direction: column;
  }
  .payment-card__actions .btn-sm {
    width: 100%;
  }
}

/* Dark mode adjustments for payments */
@media (prefers-color-scheme: dark) {
  .payments-summary__card--danger {
    background: rgba(239, 68, 68, 0.1);
  }
  .payments-summary__card--warning {
    background: rgba(234, 179, 8, 0.1);
  }
  .payments-section__header--overdue .payments-section__count {
    color: #fca5a5;
  }
  .payments-section__header--warning .payments-section__count {
    color: #fde047;
  }
}

[data-theme="dark"] .payments-summary__card--danger {
  background: rgba(239, 68, 68, 0.1);
}
[data-theme="dark"] .payments-summary__card--warning {
  background: rgba(234, 179, 8, 0.1);
}
[data-theme="dark"] .payments-section__header--overdue .payments-section__count {
  color: #fca5a5;
}
[data-theme="dark"] .payments-section__header--warning .payments-section__count {
  color: #fde047;
}

/* ---------------------------------------------------------------------------
   Inclusions / Master Inclusion List
   --------------------------------------------------------------------------- */

.inclusions-tab {
  padding: 0 16px 16px;
}

.inclusions-setup {
  text-align: center;
  padding: 48px 24px;
}

.inclusions-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.inclusions-header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.inclusions-header__counts {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.inclusions-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--surface);
}

.inclusions-count--confirmed { color: var(--complete); }
.inclusions-count--unconfirmed { color: var(--text-muted); }
.inclusions-count--flagged { color: var(--warning, #f59e0b); }

.inclusions-header__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.inclusions-group {
  margin-bottom: 16px;
}

.inclusions-group__header {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.inclusion-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.1);
  transition: background 0.15s;
}

.inclusion-row:hover {
  background: rgba(128, 128, 128, 0.05);
}

.inclusion-status--flagged {
  background: rgba(245, 158, 11, 0.08);
}

.inclusion-row__status {
  flex-shrink: 0;
  padding-top: 2px;
}

.inclusion-row__content {
  flex: 1;
  min-width: 0;
}

.inclusion-row__item {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.inclusion-row__desc {
  font-size: 0.8rem;
  color: var(--text-secondary, var(--text-muted));
  margin-top: 2px;
}

.inclusion-row__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.inclusion-row__flag {
  font-size: 0.8rem;
  color: var(--warning, #f59e0b);
  margin-top: 4px;
  padding: 4px 8px;
  background: rgba(245, 158, 11, 0.1);
  border-radius: 4px;
}

.inclusion-row__actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Small buttons for inclusion actions */
.btn-xs {
  padding: 3px 8px;
  font-size: 0.7rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
}

.btn-xs:hover {
  background: var(--border);
}

.btn-confirm {
  background: var(--complete);
  color: #fff;
  border-color: var(--complete);
}

.btn-confirm:hover {
  opacity: 0.9;
}

.btn-danger-outline {
  border-color: var(--danger, #ef4444);
  color: var(--danger, #ef4444);
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
}

.btn-sm:hover {
  background: var(--border);
}

.btn-primary {
  padding: 10px 24px;
  font-size: 0.9rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-outline {
  background: transparent;
}

/* AI thinking indicator */
.ai-thinking-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
  margin-right: 4px;
  vertical-align: middle;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

@media (max-width: 600px) {
  .inclusions-header {
    flex-direction: column;
    align-items: stretch;
  }
  .inclusions-header__actions {
    justify-content: flex-end;
  }
  .inclusion-row {
    flex-wrap: wrap;
  }
  .inclusion-row__actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 4px;
  }
}
