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

:root {
  --charcoal:     #1C1C1E;
  --charcoal-2:   #2A2A2D;
  --charcoal-3:   #3A3A3D;
  --steel:        #2C5F8A;
  --steel-light:  #3A7AB5;
  --steel-dim:    #1E4263;
  --amber:        #F5A623;
  --amber-dim:    #C4831A;
  --white:        #FFFFFF;
  --gray-50:      #F9F9F9;
  --gray-100:     #F0F0F0;
  --gray-200:     #E0E0E0;
  --gray-400:     #9E9E9E;
  --gray-600:     #5E5E5E;
  --green:        #27AE60;
  --red:          #E53935;
  --orange:       #FB8C00;
  --sidebar-w:    240px;
  --radius:       8px;
  --shadow:       0 2px 12px rgba(0,0,0,0.10);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.18);
}

/* height:auto lets the document end where content ends — height:100% on html/body was leaving a tall empty band below short pages */
html {
  min-height: 100%;
  height: auto;
  background: var(--gray-50);
  color: var(--charcoal);
}
body {
  min-height: 100%;
  height: auto;
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--gray-50);
  color: var(--charcoal);
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: inherit; outline: none; }
a { color: inherit; text-decoration: none; }

/* ─── Layout ────────────────────────────────────────────────── */
/* No min-height here — combined with html/body height:auto, avoids a full-viewport “ghost” area under short views */
#app { display: flex; align-items: flex-start; width: 100%; }

.auth-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: var(--charcoal);
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 40px, rgba(255,255,255,0.02) 40px, rgba(255,255,255,0.02) 80px
  );
}

.sidebar {
  width: var(--sidebar-w); min-height: 100vh; background: var(--charcoal);
  display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
}

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--charcoal-3);
}
.sidebar-logo h1 { font-size: 22px; font-weight: 800; color: var(--amber); letter-spacing: -0.5px; }
.sidebar-logo .tagline { font-size: 11px; color: var(--gray-400); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.8px; }

.sidebar-company {
  padding: 16px 20px; border-bottom: 1px solid var(--charcoal-3);
}
.sidebar-company .company-name { font-size: 13px; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-company .invite-code {
  font-size: 11px; color: var(--gray-400); margin-top: 4px;
  cursor: pointer; display: flex; align-items: center; gap: 4px;
}
.sidebar-company .invite-code:hover { color: var(--amber); }

.sidebar-alerts {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--charcoal-3);
  cursor: pointer;
  color: var(--gray-400);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.sidebar-alerts:hover { background: var(--charcoal-2); color: var(--white); }
.sidebar-alerts:focus { outline: none; box-shadow: inset 0 0 0 2px var(--steel); }
.sidebar-alerts.has-alerts { color: var(--amber); }
.sidebar-alerts-icon { font-size: 16px; line-height: 1; }
.sidebar-alerts-label { flex: 1; }
.sidebar-alerts-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--red);
  color: var(--white);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.schedule-alert-list { display: flex; flex-direction: column; gap: 8px; max-height: min(60vh, 420px); overflow-y: auto; }
.schedule-alert-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.schedule-alert-row:hover { border-color: var(--steel-light); box-shadow: var(--shadow); }
.schedule-alert-row-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.schedule-alert-row-meta { font-size: 12px; margin-bottom: 8px; }
.schedule-alert-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.schedule-alert-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  background: #FDEDEC;
  color: #922B21;
}

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  font-size: 14px; font-weight: 500; color: var(--gray-400);
  cursor: pointer; transition: background 0.15s, color 0.15s; border-radius: 0;
}
.nav-item:hover { background: var(--charcoal-2); color: var(--white); }
.nav-item.active { background: var(--steel-dim); color: var(--white); border-left: 3px solid var(--amber); padding-left: 17px; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.nav-section-label {
  padding: 16px 20px 6px; font-size: 10px; color: var(--charcoal-3);
  text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
}

.sidebar-project-name {
  padding: 12px 20px; background: var(--charcoal-2);
  border-top: 1px solid var(--charcoal-3); border-bottom: 1px solid var(--charcoal-3);
}
.sidebar-project-name .label { font-size: 10px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.8px; }
.sidebar-project-name .name { font-size: 13px; font-weight: 600; color: var(--white); margin-top: 2px; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--charcoal-3); display: flex; flex-direction: column; gap: 8px; }
.sidebar-footer-link {
  width: 100%; background: transparent; border: none; color: var(--steel-light);
  padding: 6px 0; font-size: 12px; font-weight: 600; text-align: left; cursor: pointer;
}
.sidebar-footer-link:hover { color: var(--amber); text-decoration: underline; }
.btn-logout { width: 100%; background: transparent; border: 1px solid var(--charcoal-3); color: var(--gray-400); padding: 8px 12px; border-radius: var(--radius); font-size: 13px; transition: all 0.15s; }
.btn-logout:hover { border-color: var(--red); color: var(--red); }

.notif-pref-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; cursor: pointer; }
.notif-pref-row input { margin-top: 3px; flex-shrink: 0; }
.notif-pref-row-text { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.notif-pref-hint { font-size: 12px; display: block; line-height: 1.35; }

.notif-pref-subgroup {
  margin: 4px 0 8px 0;
  margin-left: 22px;
  padding-left: 16px;
  border-left: 2px solid var(--gray-200);
}
.notif-pref-subgroup .notif-pref-row:last-child { margin-bottom: 0; }
.notif-pref-subgroup-disabled {
  opacity: 0.5;
  pointer-events: none;
}
.notif-pref-subgroup-disabled .notif-pref-row { cursor: not-allowed; }
.notif-pref-subgroup-disabled input:disabled { cursor: not-allowed; }

/* ─── Page Header ───────────────────────────────────────────── */
.page-header {
  padding: 28px 32px 20px; border-bottom: 1px solid var(--gray-200);
  background: var(--white); display: flex; align-items: flex-start; justify-content: space-between;
}
.page-header h2 { font-size: 24px; font-weight: 700; color: var(--charcoal); }
.page-header .subtitle { font-size: 13px; color: var(--gray-400); margin-top: 4px; }
.page-header-actions { display: flex; gap: 10px; align-items: center; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 600; transition: all 0.15s; }
.btn-primary { background: var(--steel); color: var(--white); }
.btn-primary:hover { background: var(--steel-light); }
.btn-secondary { background: var(--gray-100); color: var(--charcoal); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-amber { background: var(--amber); color: var(--charcoal); }
.btn-amber:hover { background: var(--amber-dim); }
.btn-ghost { background: transparent; color: var(--steel); padding: 6px 12px; font-size: 13px; }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-icon { padding: 6px 8px; background: transparent; color: var(--gray-400); border-radius: 4px; }
.btn-icon:hover { background: var(--gray-100); color: var(--charcoal); }

/* ─── Auth Card ─────────────────────────────────────────────── */
.auth-card {
  background: var(--white); border-radius: 16px; padding: 40px;
  width: 420px; box-shadow: var(--shadow-lg);
}
.auth-logo { font-size: 28px; font-weight: 800; color: var(--amber); margin-bottom: 4px; }
.auth-subtitle { font-size: 13px; color: var(--gray-400); margin-bottom: 28px; }
.auth-switch { font-size: 13px; color: var(--gray-400); text-align: center; margin-top: 20px; }
.auth-switch span { color: var(--steel); cursor: pointer; font-weight: 600; }
.auth-switch span:hover { text-decoration: underline; }
.auth-link { color: var(--steel); cursor: pointer; font-weight: 600; }
.auth-link:hover { text-decoration: underline; }

.mode-toggle { display: flex; background: var(--gray-100); border-radius: var(--radius); padding: 3px; margin-bottom: 20px; }
.mode-toggle button { flex: 1; padding: 8px; border-radius: 5px; font-size: 13px; font-weight: 600; background: transparent; color: var(--gray-600); transition: all 0.15s; }
.mode-toggle button.active { background: var(--white); color: var(--charcoal); box-shadow: var(--shadow); }

/* ─── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--charcoal); margin-bottom: 6px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius); font-size: 14px; color: var(--charcoal);
  background: var(--white); transition: border-color 0.15s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--steel); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239E9E9E' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.address-lookup-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.address-lookup-input {
  flex: 1;
  min-width: 0;
}
.project-map {
  height: 240px;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  margin-bottom: 12px;
  background: var(--gray-100);
  z-index: 0;
}
.project-map .leaflet-container {
  font-family: inherit;
  border-radius: var(--radius);
}
.geo-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  max-height: 180px;
  overflow-y: auto;
}
.geo-suggestions.hidden { display: none !important; }
.geo-suggestion-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: var(--white);
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
  color: var(--charcoal);
}
.geo-suggestion-btn:hover {
  border-color: var(--steel-light);
  background: var(--gray-50);
}
.form-hint { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.form-submit { width: 100%; padding: 12px; background: var(--steel); color: var(--white); border-radius: var(--radius); font-size: 15px; font-weight: 700; transition: background 0.15s; }
.form-submit:hover { background: var(--steel-light); }

.checkbox-group { display: flex; align-items: center; gap: 8px; }
.checkbox-group input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--steel); }
.checkbox-group label { font-size: 14px; font-weight: 400; margin-bottom: 0; }

/* ─── Dashboard ─────────────────────────────────────────────── */
.dashboard-body { padding: 28px 32px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; margin-top: 20px; }

.project-card {
  background: var(--white); border-radius: 12px; padding: 22px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
  display: flex; flex-direction: column; min-height: 100%;
}
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--steel); }
.project-card-main { flex: 1; min-width: 0; }
.project-card-footer {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--gray-100);
  flex-shrink: 0;
}
.project-card-remove-dash { color: var(--gray-600) !important; font-weight: 600; }
.project-card-remove-dash:hover { color: var(--steel) !important; }
.project-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.project-card h3 { font-size: 16px; font-weight: 700; color: var(--charcoal); line-height: 1.3; }
.project-card .dates { font-size: 12px; color: var(--gray-400); margin-top: 6px; }
.project-card .companies { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.company-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--gray-100); color: var(--gray-600); }
.company-chip.gc { background: #EBF5FB; color: var(--steel); }

.project-progress { margin-top: 14px; }
.progress-bar-bg { height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width 0.3s; }
.progress-label { font-size: 11px; color: var(--gray-400); margin-top: 4px; }

.new-project-card {
  background: var(--gray-100); border-radius: 12px; padding: 22px;
  border: 2px dashed var(--gray-200); cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 160px; gap: 8px;
}
.new-project-card:hover { border-color: var(--steel); background: #EBF5FB; }
.new-project-card .plus { font-size: 28px; color: var(--gray-400); }
.new-project-card span { font-size: 14px; font-weight: 600; color: var(--gray-400); }
.new-project-card:hover .plus, .new-project-card:hover span { color: var(--steel); }

/* Site history page (#site-history) */
.site-history-page { padding: 0 32px 40px; max-width: 800px; }
.site-history-intro { font-size: 13px; line-height: 1.45; margin-bottom: 18px; max-width: 640px; }
.site-history-search-wrap { max-width: 420px; margin-bottom: 22px; }
.site-history-search-input {
  width: 100%;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.site-history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.site-history-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 14px;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.site-history-address { font-size: 14px; color: var(--charcoal); line-height: 1.4; flex: 1; min-width: 160px; }
.site-history-empty { padding: 20px 14px; text-align: left; font-size: 14px; list-style: none; }

/* ─── Status Badges ─────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.4px; }
.badge-pending { background: var(--gray-100); color: var(--gray-600); }
.badge-in_progress { background: #EBF5FB; color: var(--steel); }
.badge-completed { background: #EAFAF1; color: var(--green); }
.badge-blocked { background: #FEF9E7; color: var(--orange); }
.badge-active { background: #EAFAF1; color: var(--green); }
.badge-paused { background: #FEF9E7; color: var(--orange); }
.badge-gc { background: #EBF5FB; color: var(--steel); }
.badge-subcontractor { background: var(--gray-100); color: var(--gray-600); }
.badge-archived { background: var(--gray-100); color: var(--gray-600); }
.badge-cancelled { background: #FDEDEC; color: #922B21; }

.project-readonly-tag { font-size: 12px; font-weight: 600; color: var(--gray-500); text-transform: lowercase; }

/* ─── Tabs ──────────────────────────────────────────────────── */
.tab-bar {
  display: flex; background: var(--white); border-bottom: 2px solid var(--gray-200); padding: 0 32px;
}
.tab {
  padding: 14px 20px; font-size: 14px; font-weight: 600; color: var(--gray-400);
  cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.15s;
}
.tab:hover { color: var(--charcoal); }
.tab.active { color: var(--steel); border-bottom-color: var(--steel); }

/* ─── Tasks View ─────────────────────────────────────────────── */
/* Explicit height so task split-pane scroll works without relying on a stretched parent */
.tasks-layout {
  display: flex;
  height: calc(100vh - 200px);
  min-height: 280px;
  max-height: calc(100vh - 200px);
  overflow: hidden;
}

.phases-panel {
  width: 220px; background: var(--white); border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
.phases-panel-header { padding: 16px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; }
.phases-panel-header h4 { font-size: 13px; font-weight: 700; color: var(--charcoal); }

.phase-item {
  padding: 12px 16px; border-left: 3px solid transparent;
  font-size: 13px; font-weight: 500; color: var(--gray-600); transition: all 0.15s;
  display: flex; align-items: flex-start; gap: 8px;
}
.phase-item:hover { background: var(--gray-50); color: var(--charcoal); }
.phase-item.active { background: #EBF5FB; color: var(--steel); border-left-color: var(--steel); font-weight: 600; }
.phase-item .phase-task-count { font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.phase-item.active .phase-task-count { color: var(--steel); opacity: 0.7; }
.phase-item-main { flex: 1; min-width: 0; cursor: pointer; }
.phase-order-list { display: flex; flex-direction: column; }
.phase-item-reorder {
  position: relative;
}
.phase-item-reorder.phase-reorder-insert-before::before {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  height: 3px;
  background: var(--steel);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
}
.phase-item-reorder.phase-reorder-insert-after::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 3px;
  background: var(--steel);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
}
.phase-drop-zone.phase-item { cursor: default; }
.phase-drop-zone .phase-item-main { cursor: pointer; }

.drag-handle {
  cursor: grab;
  user-select: none;
  color: var(--gray-400);
  font-size: 14px;
  line-height: 1.2;
  padding: 2px 0;
  flex-shrink: 0;
  letter-spacing: -2px;
}
.drag-handle:active { cursor: grabbing; }

.tasks-panel { flex: 1; overflow-y: auto; padding: 20px 24px; background: var(--gray-50); }
.tasks-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.tasks-panel-header h3 { font-size: 16px; font-weight: 700; }
.tasks-panel-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.task-card {
  background: var(--white); border-radius: 10px; padding: 16px 18px;
  box-shadow: var(--shadow); margin-bottom: 10px; border-left: 4px solid transparent;
  transition: box-shadow 0.15s;
}
.task-card:hover { box-shadow: var(--shadow-lg); }
.task-card.status-completed { border-left-color: var(--green); opacity: 0.75; }
.task-card.status-in_progress { border-left-color: var(--steel); }
.task-card.status-blocked { border-left-color: var(--orange); }
.task-card.status-pending { border-left-color: var(--gray-200); }

.task-card-header { display: flex; align-items: flex-start; gap: 10px; }
.task-card-header--clickable { cursor: pointer; }
.task-card-header--clickable .task-title { text-decoration: none; }
.task-card-header .task-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; color: var(--charcoal); line-height: 1.3; }
.task-card-header .task-card-actions,
.task-card-header .task-card-actions-readonly { margin-left: auto; flex-shrink: 0; }

.task-meta .badge-blocked[title],
.task-card-actions-readonly .badge-blocked[title] { cursor: help; }
.task-card.status-completed .task-title { text-decoration: line-through; color: var(--gray-400); }
.task-card-actions { display: flex; gap: 4px; flex-shrink: 0; align-items: center; }
.task-card-actions-readonly { display: flex; gap: 4px; flex-shrink: 0; align-items: center; }

.task-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.task-meta-item { font-size: 12px; color: var(--gray-400); display: flex; align-items: center; gap: 3px; }
.trade-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: var(--charcoal); color: var(--amber); }

.task-deps { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.dep-chip {
  font-size: 11px; padding: 3px 8px; border-radius: 4px; display: flex; align-items: center; gap: 4px;
}
.dep-chip.completed { background: #EAFAF1; color: var(--green); }
.dep-chip.pending { background: #FEF9E7; color: var(--orange); }

.task-status-select {
  font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 4px;
  border: 1.5px solid var(--gray-200); background: var(--white); cursor: pointer;
  appearance: none; text-align: center;
}

.task-comments { margin-top: 12px; border-top: 1px solid var(--gray-100); padding-top: 10px; }
.comment-item { font-size: 12px; color: var(--gray-600); margin-bottom: 6px; }
.comment-item strong { color: var(--charcoal); }
.comment-form { display: flex; gap: 6px; margin-top: 8px; }
.comment-form input { flex: 1; padding: 6px 10px; border: 1.5px solid var(--gray-200); border-radius: 6px; font-size: 12px; }
.comment-form button { padding: 6px 12px; background: var(--steel); color: var(--white); border-radius: 6px; font-size: 12px; font-weight: 600; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-400); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ─── Weather ───────────────────────────────────────────────── */
.weather-view { padding: 28px 32px; }
.weather-grid { display: flex; gap: 12px; margin-top: 20px; overflow-x: auto; padding-bottom: 8px; }
.weather-card {
  background: var(--white); border-radius: 12px; padding: 18px 16px;
  min-width: 130px; text-align: center; box-shadow: var(--shadow); flex-shrink: 0;
}
.weather-card .day { font-size: 12px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.6px; }
.weather-card .w-icon { font-size: 36px; margin: 10px 0; }
.weather-card .temp-range { font-size: 14px; font-weight: 700; color: var(--charcoal); }
.weather-card .temp-range span { font-weight: 400; color: var(--gray-400); }
.weather-card .precip { font-size: 12px; color: var(--steel); margin-top: 6px; }
.weather-card .wind { font-size: 11px; color: var(--gray-400); margin-top: 3px; }
.weather-card.today { border: 2px solid var(--amber); }

.weather-sensitive-section { margin-top: 28px; }
.weather-sensitive-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.weather-task-row { background: var(--white); border-radius: 8px; padding: 12px 16px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow); }
.weather-task-row .task-info h4 { font-size: 14px; font-weight: 600; }
.weather-task-row .task-info p { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

/* ─── Calendar ──────────────────────────────────────────────── */
.calendar-view { padding: 28px 32px; }
.calendar-nav { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.project-calendar-subscribe {
  margin-top: 24px;
  max-width: 640px;
  padding: 16px 18px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.project-calendar-subscribe h4 { font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.project-calendar-subscribe .schedule-feed-url-row { margin-top: 10px; }
.calendar-nav h3 { font-size: 18px; font-weight: 700; min-width: 200px; text-align: center; }
.calendar-grid { background: var(--white); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.calendar-days-header { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--charcoal); }
.calendar-day-label { padding: 10px; text-align: center; font-size: 12px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; }
.calendar-weeks { }
.calendar-week { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--gray-200); }
.calendar-cell { min-height: 90px; padding: 6px; border-right: 1px solid var(--gray-200); overflow: hidden; }
.calendar-cell:last-child { border-right: none; }
.calendar-cell.other-month { background: var(--gray-50); }
.calendar-cell.today .cell-date { background: var(--amber); color: var(--charcoal); border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.cell-date { font-size: 12px; font-weight: 600; color: var(--charcoal); margin-bottom: 4px; }
.cell-date.other { color: var(--gray-200); }
.calendar-task-pill {
  font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 3px; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  color: var(--white); background: var(--steel);
}
.calendar-task-pill-dnd {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: element;
}
.calendar-task-pill-dnd:active { cursor: grabbing; }
.calendar-cell-dragover { box-shadow: inset 0 0 0 2px var(--steel); background: rgba(44, 95, 138, 0.07); }
.calendar-task-pill-readonly { cursor: default; opacity: 0.92; }
.calendar-task-pill-multi {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  color: var(--white) !important;
  text-shadow: 0 1px 1px rgba(0,0,0,0.25);
}

/* ─── Stripe (subscription page) ─────────────────────────────── */
.subscription-stripe-box {
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  max-width: 640px;
}
.subscription-stripe-title { font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.subscription-stripe-copy { font-size: 12px; line-height: 1.45; margin: 0 0 12px; }
.subscription-stripe-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.subscription-stripe-hint { font-size: 11px; margin: 10px 0 0; line-height: 1.4; }
.billing-pay-mode { font-weight: 600; color: var(--steel); }

/* ─── Dashboard schedule (multi-project) ─────────────────────── */
.schedule-page { padding: 24px 32px 40px; max-width: 1100px; }
.schedule-toolbar { margin-bottom: 18px; max-width: 640px; }
.schedule-filter { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: 8px; }
.schedule-calendar-wrap { margin-bottom: 28px; }
.schedule-subscribe-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
  max-width: 720px;
}
.schedule-subscribe-card h4 { margin: 0 0 8px; font-size: 15px; font-weight: 700; }
.schedule-feed-url-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.schedule-feed-input {
  flex: 1;
  min-width: 200px;
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--gray-50);
}

/* ─── Dependency verification ───────────────────────────────── */
.dep-verify-target { font-size: 14px; margin-bottom: 16px; padding: 12px; background: var(--gray-50); border-radius: 8px; }
.dep-verify-list { display: flex; flex-direction: column; gap: 16px; }
.dep-verify-row { border: 1px solid var(--gray-200); border-radius: 8px; padding: 12px 14px; }
.dep-verify-label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; line-height: 1.4; }
.dep-verify-label input { margin-top: 3px; flex-shrink: 0; }
.dep-verify-note { width: 100%; margin-top: 10px; font-size: 13px; padding: 8px; border: 1px solid var(--gray-200); border-radius: 6px; resize: vertical; min-height: 52px; }

/* ─── Verification report (owner) ─────────────────────────────── */
.verification-view { padding: 28px 32px; }
.verification-table-wrap { overflow-x: auto; background: var(--white); border-radius: 12px; box-shadow: var(--shadow); }
.verification-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.verification-table th, .verification-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
.verification-table th { background: var(--charcoal); color: var(--gray-400); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.verification-table tr:last-child td { border-bottom: none; }
.verification-note { max-width: 220px; color: var(--gray-600); }
.verification-when { white-space: nowrap; color: var(--gray-600); font-size: 12px; }

/* ─── Company plan (subscription page) ───────────────────────── */
.subscription-page { padding: 0 32px 32px; max-width: 1200px; }
.company-team-page .company-roster-wrap {
  overflow-x: auto;
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.company-roster-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.company-roster-table th,
.company-roster-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.company-roster-table th {
  background: var(--charcoal);
  color: var(--gray-400);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.company-roster-table tr:last-child td { border-bottom: none; }
.company-roster-actions { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.company-plan-panel { min-height: 48px; }
.billing-banner { border-radius: 10px; padding: 14px 18px; font-size: 14px; line-height: 1.45; }
.billing-banner-free { background: var(--gray-50); border: 1px solid var(--gray-200); color: var(--gray-600); }
.billing-banner-owner { background: linear-gradient(135deg, rgba(44,95,138,0.08), rgba(39,174,96,0.06)); border: 1px solid var(--gray-200); }
.billing-banner-owner h4 { font-size: 15px; font-weight: 700; margin: 0; color: var(--charcoal); }
.billing-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.billing-row { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: baseline; font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--gray-100); }
.billing-row:last-child { border-bottom: none; }
.billing-row-name { font-weight: 600; min-width: 140px; }
.plan-admin-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--gray-200);
}
.plan-admin-label { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.plan-admin-select { font-size: 13px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--gray-200); }

/* ─── Templates ─────────────────────────────────────────────── */
.templates-page { padding: 0 32px 32px; max-width: 1200px; }
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.templates-empty { grid-column: 1 / -1; }
.template-card {
  background: var(--white);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.template-card-top h3 { font-size: 16px; font-weight: 700; margin: 8px 0 6px; }
.template-card-desc { font-size: 13px; line-height: 1.4; min-height: 2.8em; }
.template-card-actions { margin-top: auto; padding-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.template-card-delete { color: var(--red) !important; }
.templates-editor { padding: 0 32px 40px; max-width: 1100px; }
.template-meta-form { margin-bottom: 24px; max-width: 560px; }
.template-table-wrap { overflow-x: auto; background: var(--white); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 24px; }
.template-task-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.template-task-table th, .template-task-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
.template-task-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500); background: var(--gray-50); }
.template-idx {
  font-weight: 700;
  color: var(--gray-500);
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}
.template-idx-inner {
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
}
/* Table layout can ignore flex gap in some engines; margin is reliable. */
.template-idx-inner .drag-handle.template-row-handle {
  margin-right: 10px;
  flex-shrink: 0;
}
.template-idx-num { line-height: 1; }

/* Template task row DnD — bold black drop line (insert before / after this row).
   Per-cell inset shadow so it works in all browsers (tr::before is unreliable on tables). */
.template-task-table tbody tr.template-row-insert-before > td {
  box-shadow: inset 0 4px 0 0 #000;
}
.template-task-table tbody tr.template-row-insert-after > td {
  box-shadow: inset 0 -4px 0 0 #000;
}
.deps-code { font-size: 11px; background: var(--gray-50); padding: 2px 6px; border-radius: 4px; }
.template-row-actions { white-space: nowrap; }
.template-add-block { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 12px; padding: 18px; max-width: 720px; }
.template-add-block h4 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }

/* Template dependency chart — draw.io-style pan/zoom canvas */
.template-deps-section {
  margin-bottom: 24px;
  max-width: 100%;
}
.template-deps-heading { font-size: 15px; font-weight: 700; margin: 0 0 6px; }
.template-deps-help { font-size: 12px; line-height: 1.45; margin: 0 0 14px; max-width: 720px; }
.template-deps-chart {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
}
.template-deps-canvas-wrap { display: flex; flex-direction: column; min-height: 420px; }
.template-deps-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  flex-shrink: 0;
}
.template-deps-toolbar-hint { margin: 0; font-size: 11px; line-height: 1.4; max-width: 640px; }
.template-deps-toolbar-btns { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.template-deps-viewport {
  position: relative;
  flex: 1;
  min-height: 360px;
  overflow: hidden;
  background: var(--gray-100);
  cursor: default;
  touch-action: none;
}
.template-deps-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.template-deps-plane {
  position: relative;
  background-color: #f0f2f5;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
  background-size: 20px 20px;
}
.template-deps-plane-bg {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  cursor: grab;
}
.template-deps-plane-bg.is-panning { cursor: grabbing; }
.template-deps-svg-edges {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}
.template-deps-nodes-layer {
  position: relative;
  z-index: 2;
  pointer-events: none;
}
.template-deps-svg-hit {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 3;
}
.template-deps-svg-drag-vp {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 4;
}
.template-dep-node {
  position: absolute;
  display: flex;
  align-items: stretch;
  gap: 8px;
  pointer-events: none;
  box-sizing: border-box;
}
.template-dep-node.is-dragging-shape { opacity: 0.92; z-index: 10; }
.template-dep-node-draggable { cursor: grab; }
.template-dep-node-draggable:active { cursor: grabbing; }
.template-dep-port-spacer {
  width: 28px;
  flex-shrink: 0;
  align-self: center;
}
.template-dep-port-in,
.template-dep-port-out {
  position: relative;
  z-index: 6;
  width: 28px;
  min-height: 44px;
  flex-shrink: 0;
  align-self: center;
  border-radius: 8px;
  border: 2px dashed var(--steel);
  background: var(--gray-50);
  padding: 0;
  color: var(--steel);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: grab;
  transition: background 0.15s, border-color 0.15s;
  pointer-events: auto;
}
.template-dep-port-in { border-style: solid; cursor: default; }
.template-dep-port-out:active { cursor: grabbing; }
.template-dep-port-in:hover,
.template-dep-port-out:hover {
  background: rgba(44, 95, 138, 0.12);
  border-color: var(--steel-light);
}
.template-dep-node-inner {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--steel);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  pointer-events: auto;
}
.template-dep-node-idx {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  background: var(--charcoal);
  color: var(--amber);
  border-radius: 8px;
}
.template-dep-node-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.template-dep-node-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.template-dep-node-phase { font-size: 11px; color: var(--gray-600); }
.template-dep-edge-remove {
  pointer-events: all;
}
.template-dep-edge-remove:hover {
  fill: rgba(44, 95, 138, 0.08);
  stroke: var(--steel-light);
}

/* ─── Team View ─────────────────────────────────────────────── */
.team-view { padding: 28px 32px; }
.team-invite-block { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.project-invite-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.project-invite-link-wrap { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--gray-200); }
.project-invite-link-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-600); margin-bottom: 6px; }
.project-invite-link-input {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--white);
  color: var(--charcoal);
}
.team-card-actions { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--gray-100); display: flex; flex-wrap: wrap; gap: 8px; }
.team-card-remove { color: var(--red) !important; }
.team-card-cancel { color: var(--red) !important; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 20px; }
.team-card { background: var(--white); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); }
.team-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.team-card h3 { font-size: 16px; font-weight: 700; }
.team-tasks-list { margin-top: 10px; }
.team-tasks-dropzone {
  margin-top: 8px;
  max-height: 280px;
  overflow-y: auto;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--gray-100);
  padding: 4px 10px;
  background: var(--gray-50);
}
.team-tasks-empty { font-size: 12px; padding: 12px 0; text-align: center; }
.team-task-item {
  font-size: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-700);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}
.team-task-item:last-child { border-bottom: none; }
.team-task-item-title { flex: 1; min-width: 0; font-weight: 500; color: var(--charcoal); }
.team-task-item-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.team-task-item[draggable="true"] { cursor: grab; }
.team-task-item[draggable="true"]:active { cursor: grabbing; }
.team-task-dragging { opacity: 0.45; }
.team-card-drag-over { outline: 2px solid var(--steel); outline-offset: 2px; border-radius: 12px; }
.team-trade-assign { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--gray-100); }
.team-trade-assign-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-600); margin-bottom: 6px; }
.team-trade-assign-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.team-trade-select { flex: 1; min-width: 140px; font-size: 13px; padding: 6px 8px; border: 1px solid var(--gray-200); border-radius: 6px; background: var(--white); color: var(--charcoal); }
.team-trade-assign-hint { font-size: 11px; margin-top: 10px; line-height: 1.4; }
.team-task-trade { font-size: 10px; }

/* ─── Modal ─────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
#modal-overlay.hidden { display: none; }

.modal {
  background: var(--white); border-radius: 16px; padding: 32px;
  width: 540px; max-width: calc(100vw - 40px); max-height: calc(100vh - 80px);
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-wide { width: 680px; }
.modal h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.confirm-modal-body {
  margin: 0 0 8px;
  line-height: 1.45;
  font-size: 14px;
  color: var(--charcoal);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ─── Toast ─────────────────────────────────────────────────── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); color: var(--white); min-width: 240px;
  animation: slideIn 0.2s ease; display: flex; align-items: center; gap: 8px;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-info { background: var(--steel); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
.toast.removing { animation: slideOut 0.2s ease forwards; }

/* ─── Loading ───────────────────────────────────────────────── */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--gray-200); border-top-color: var(--steel); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; align-items: center; justify-content: center; padding: 60px; }

/* ─── Misc ──────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--gray-200); margin: 20px 0; }
.text-muted { color: var(--gray-400); font-size: 13px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.no-coords-notice { background: #FEF9E7; border: 1px solid var(--amber); border-radius: 8px; padding: 16px; font-size: 14px; color: var(--charcoal); }
.no-coords-notice strong { display: block; margin-bottom: 4px; }

/* Task form — prerequisite search-ahead */
.tf-dep-search-wrap { position: relative; }
.tf-dep-search {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  font-size: 14px; background: var(--white);
}
.tf-dep-results {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px;
  max-height: 220px; overflow-y: auto; background: var(--white); border: 1.5px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.tf-dep-results.hidden { display: none; }
.tf-dep-result {
  display: block; width: 100%; text-align: left; padding: 10px 12px; font-size: 13px;
  border: none; background: transparent; cursor: pointer; color: var(--charcoal);
  border-bottom: 1px solid var(--gray-100);
}
.tf-dep-result:last-child { border-bottom: none; }
.tf-dep-result:hover { background: var(--gray-50); }
.tf-dep-result-empty { padding: 12px; font-size: 13px; color: var(--gray-400); }
.tf-dep-selected { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; min-height: 28px; align-items: center; }
.tf-dep-empty { font-size: 13px; }
.tf-dep-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 10px;
  background: #EBF5FB; color: var(--steel-dim); border-radius: 6px; font-size: 12px; font-weight: 600;
}
.tf-dep-chip-remove {
  border: none; background: transparent; cursor: pointer; font-size: 16px; line-height: 1;
  color: var(--gray-600); padding: 0 2px; border-radius: 4px;
}
.tf-dep-chip-remove:hover { color: var(--red); background: rgba(229, 57, 53, 0.08); }

/* legacy multi-select (templates etc.) */
.multi-select { border: 1.5px solid var(--gray-200); border-radius: var(--radius); max-height: 140px; overflow-y: auto; }
.multi-select-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: 13px; }
.multi-select-item:hover { background: var(--gray-50); }
.multi-select-item input { width: 14px; height: 14px; accent-color: var(--steel); }

.back-btn { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-400); cursor: pointer; padding: 10px 20px; border-bottom: 1px solid var(--charcoal-3); transition: color 0.15s; }
.back-btn:hover { color: var(--amber); }

/* ─── Mobile & touch ─────────────────────────────────────────── */
.mobile-shell-header,
.mobile-sidebar-backdrop {
  display: none;
}

@media (max-width: 880px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  #app {
    display: block;
    position: relative;
  }

  .mobile-shell-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
    background: var(--charcoal);
    border-bottom: 1px solid var(--charcoal-3);
    position: sticky;
    top: 0;
    z-index: 35;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: -6px;
    padding: 8px 12px;
    border-radius: var(--radius);
    background: var(--charcoal-2);
    color: var(--white);
    font-size: 20px;
    line-height: 1;
    border: 1px solid var(--charcoal-3);
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-menu-btn:active {
    background: var(--charcoal-3);
  }

  .mobile-shell-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--amber);
    letter-spacing: -0.3px;
  }

  .mobile-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 40;
    -webkit-tap-highlight-color: transparent;
  }

  #app.mobile-nav-open .mobile-sidebar-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(300px, calc(100vw - 48px));
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    z-index: 45;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #app.mobile-nav-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-content {
    width: 100%;
    min-width: 0;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 16px max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
  }

  .page-header h2 {
    font-size: 20px;
  }

  .page-header-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .dashboard-body,
  .weather-view,
  .calendar-view,
  .verification-view,
  .team-view {
    padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  }

  .site-history-page,
  .schedule-page,
  .subscription-page,
  .templates-page,
  .templates-editor {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .tab-bar {
    padding: 0 max(12px, env(safe-area-inset-left)) 0 max(12px, env(safe-area-inset-right));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    gap: 0;
    flex-wrap: nowrap;
  }

  .tab {
    flex-shrink: 0;
    padding: 12px 14px;
    white-space: nowrap;
  }

  .project-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .address-lookup-row {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-card {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 28px max(24px, env(safe-area-inset-left)) 32px max(24px, env(safe-area-inset-right));
  }

  .auth-wrapper {
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    min-height: 100dvh;
  }

  .tasks-layout {
    flex-direction: column;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  .phases-panel {
    width: 100%;
    max-height: min(220px, 35vh);
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
  }

  .tasks-panel {
    overflow-y: visible;
    padding: 16px max(14px, env(safe-area-inset-right)) 24px max(14px, env(safe-area-inset-left));
    min-height: 50vh;
  }

  .task-card-header {
    flex-wrap: wrap;
  }

  .task-card-actions,
  .task-card-actions-readonly {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
    margin-top: 6px;
  }

  .calendar-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .calendar-nav h3 {
    min-width: 0;
    order: -1;
  }

  .calendar-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
  }

  .calendar-days-header,
  .calendar-week {
    min-width: 560px;
  }

  .calendar-cell {
    min-height: 72px;
    padding: 4px;
  }

  .cell-date {
    font-size: 11px;
  }

  .calendar-task-pill {
    font-size: 9px;
    padding: 2px 4px;
  }

  .weather-grid {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }

  .weather-task-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .modal {
    width: 100%;
    max-width: min(540px, calc(100vw - 24px));
    max-height: min(90dvh, calc(100vh - 24px));
    padding: 22px max(18px, env(safe-area-inset-right)) 24px max(18px, env(safe-area-inset-left));
    margin: max(12px, env(safe-area-inset-top)) auto max(12px, env(safe-area-inset-bottom));
    border-radius: 14px;
  }

  .modal-wide {
    width: 100%;
    max-width: calc(100vw - 24px);
  }

  .modal-actions {
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .modal-actions .btn {
    flex: 1 1 auto;
    min-width: 120px;
    justify-content: center;
  }

  #toast-container {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
    align-items: stretch;
  }

  .toast {
    min-width: 0;
    width: 100%;
    justify-content: center;
    text-align: center;
    animation: toastSlideInUp 0.2s ease;
  }

  .toast.removing {
    animation: toastSlideOutDown 0.2s ease forwards;
  }

  .nav-item {
    min-height: 44px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .sidebar-alerts {
    min-height: 44px;
  }

  .btn {
    min-height: 40px;
    padding: 10px 16px;
    -webkit-tap-highlight-color: transparent;
  }

  .btn-sm {
    min-height: 36px;
  }

  .template-grid,
  .team-grid {
    grid-template-columns: 1fr;
  }

  .template-deps-canvas-wrap {
    min-height: 280px;
  }

  .template-deps-viewport {
    min-height: 260px;
  }

  .company-roster-table th,
  .company-roster-table td,
  .verification-table th,
  .verification-table td,
  .template-task-table th,
  .template-task-table td {
    padding: 10px 8px;
    font-size: 12px;
  }

  .schedule-feed-url-row,
  .project-invite-row {
    flex-direction: column;
    align-items: stretch;
  }

  .schedule-feed-input,
  .project-invite-link-input {
    min-width: 0;
    width: 100%;
  }

  .comment-form {
    flex-direction: column;
    align-items: stretch;
  }

  .comment-form button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .page-header h2 {
    font-size: 18px;
  }

  .project-card,
  .new-project-card {
    padding: 18px;
  }

  .task-card {
    padding: 14px;
  }

  .billing-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

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

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