/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: #0f172a;
  color: #f8fafc;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

/* === Login === */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: #1e293b;
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-brand { margin-bottom: 32px; }
.login-brand h1 { font-size: 22px; font-weight: 700; color: #f8fafc; margin-top: 12px; }
.login-brand p { font-size: 14px; color: #64748b; }
.login-input {
  width: 100%;
  padding: 14px 16px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #f8fafc;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}
.login-input:focus { border-color: #7f1d1d; }
.login-input::placeholder { color: #475569; }
.login-error { color: #ef4444; font-size: 14px; min-height: 20px; margin-top: 8px; }
.login-btn {
  width: 100%;
  padding: 14px;
  background: #7f1d1d;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.15s;
  min-height: 48px;
}
.login-btn:active { background: #6b1a1a; }
.login-footer { margin-top: 24px; font-size: 12px; color: #475569; }

/* === App Layout === */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 768px;
  margin: 0 auto;
}

/* === Top Bar === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: #f8fafc;
}
.topbar-logout {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-logout:active { background: #334155; }

/* === Main Content === */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 80px;
  -webkit-overflow-scrolling: touch;
}

/* === Bottom Nav === */
.bottom-nav {
  display: flex;
  background: #1e293b;
  border-top: 1px solid #334155;
  flex-shrink: 0;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 768px;
  margin: 0 auto;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0;
  color: #64748b;
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  min-height: 56px;
  justify-content: center;
  transition: color 0.15s;
}
.bottom-nav-item.active { color: #7f1d1d; }
.bottom-nav-item:active { color: #b91c1c; }

/* === Cards === */
.card {
  background: #1e293b;
  border-radius: 12px;
  border: 1px solid #334155;
  overflow: hidden;
  margin-bottom: 12px;
}
.card-header {
  padding: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  cursor: pointer;
  min-height: 48px;
}
.card-body { padding: 0 16px 16px; }

/* === Status Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge-green { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge-green .dot { background: #22c55e; }
.badge-yellow { background: rgba(234, 179, 8, 0.15); color: #facc15; }
.badge-yellow .dot { background: #eab308; }
.badge-red { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-red .dot { background: #ef4444; }
.badge-blue { background: rgba(127, 29, 29, 0.15); color: #b91c1c; }
.badge-blue .dot { background: #7f1d1d; }

/* === Super Tabs === */
.super-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.super-tab {
  padding: 10px 20px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  transition: all 0.15s;
}
.super-tab.active {
  background: #7f1d1d;
  border-color: #7f1d1d;
  color: #fff;
}
.super-tab:active { opacity: 0.8; }

/* === Build Cards === */
.build-card {
  text-decoration: none;
  color: inherit;
  display: block;
}
.build-card-name { font-size: 18px; font-weight: 700; color: #f8fafc; }
.build-card-address { font-size: 14px; color: #94a3b8; margin-top: 2px; }
.build-card-plan { font-size: 13px; color: #64748b; margin-top: 6px; }
.build-card-progress { margin-top: 12px; }
.progress-bar {
  height: 6px;
  background: #334155;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: #7f1d1d;
  border-radius: 3px;
  transition: width 0.3s;
}
.progress-text { font-size: 13px; color: #64748b; display: flex; justify-content: space-between; }
.build-card-actions {
  margin-top: 10px;
  font-size: 13px;
  color: #94a3b8;
}

/* === Build Detail === */
.build-header { margin-bottom: 16px; }
.build-detail-name { font-size: 22px; font-weight: 700; color: #f8fafc; }
.build-detail-address { font-size: 14px; color: #94a3b8; margin-top: 2px; }
.build-detail-meta { font-size: 13px; color: #64748b; margin-top: 6px; }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #64748b;
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 12px;
  padding: 8px 0;
  min-height: 44px;
}
.back-btn:active { color: #7f1d1d; }

/* === Build Tabs === */
.build-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid #334155;
  margin-bottom: 16px;
  margin-left: -16px;
  margin-right: -16px;
  padding: 0 16px;
}
.build-tab {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  min-height: 44px;
  display: flex;
  align-items: center;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color 0.15s;
}
.build-tab.active {
  color: #7f1d1d;
  border-bottom-color: #7f1d1d;
}
.build-tab:active { color: #b91c1c; }

/* === Schedule Phase Accordion === */
.phase-card { margin-bottom: 10px; }
.phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  min-height: 48px;
}
.phase-name { font-size: 15px; font-weight: 600; color: #f8fafc; flex: 1; }
.phase-progress { font-size: 12px; color: #64748b; margin-right: 8px; }
.phase-toggle { color: #64748b; font-size: 12px; transition: transform 0.2s; }
.phase-card.collapsed .phase-toggle { transform: rotate(-90deg); }
.phase-body { padding: 0 16px 12px; }
.phase-card.collapsed .phase-body { display: none; }

/* Steps */
.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #1e293b;
  min-height: 44px;
}
.step-item:last-child { border-bottom: none; }
.step-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid #475569;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}
.step-checkbox:active { border-color: #7f1d1d; }
.step-checkbox.checked {
  background: #22c55e;
  border-color: #22c55e;
}
.step-checkbox.checked::after {
  content: '';
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}
.step-name { font-size: 15px; color: #e2e8f0; flex: 1; }
.step-item.done .step-name { color: #64748b; text-decoration: line-through; }
.step-date { font-size: 12px; color: #475569; }

/* === Action Items === */
.action-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.action-filter {
  padding: 8px 14px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 40px;
}
.action-filter.active { background: #7f1d1d; border-color: #7f1d1d; color: #fff; }
.action-item {
  padding: 14px 16px;
  border-bottom: 1px solid #334155;
}
.action-item:last-child { border-bottom: none; }
.action-text { font-size: 15px; color: #e2e8f0; }
.action-item.completed .action-text { color: #64748b; text-decoration: line-through; }
.action-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
  flex-wrap: wrap;
}
.action-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.priority-high { color: #f87171; }
.priority-medium { color: #facc15; }
.priority-low { color: #4ade80; }

/* === Plans Viewer === */
.plans-empty {
  text-align: center;
  padding: 60px 20px;
  color: #64748b;
}
.plan-image-container {
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  background: #0f172a;
}
.plan-image-container img {
  width: 100%;
  display: block;
}
.plan-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px;
}

/* === Chat === */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
  margin: -16px;
  margin-top: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}
.chat-bubble.user {
  background: #7f1d1d;
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  background: #1e293b;
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
  border: 1px solid #334155;
}
.chat-timestamp {
  font-size: 11px;
  color: #475569;
  margin-bottom: 4px;
  padding: 0 4px;
}
.chat-timestamp.right { text-align: right; }
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #1e293b;
  border-top: 1px solid #334155;
  flex-shrink: 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 20px;
  color: #f8fafc;
  font-size: 16px;
  outline: none;
  min-height: 44px;
}
.chat-input:focus { border-color: #7f1d1d; }
.chat-input::placeholder { color: #475569; }
.chat-send {
  width: 44px;
  height: 44px;
  background: #7f1d1d;
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-send:active { background: #6b1a1a; }
.chat-send:disabled { opacity: 0.5; }

/* === Packages === */
.package-card { margin-bottom: 12px; }
.package-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  min-height: 48px;
}
.package-title { font-size: 15px; font-weight: 600; color: #f8fafc; }
.package-desc { font-size: 13px; color: #64748b; margin-top: 2px; }
.package-item-list { padding: 0 16px 12px; }
.package-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}
.package-item:last-child { border-bottom: none; }
.package-item-desc { color: #cbd5e1; }
.package-item-qty { color: #64748b; font-weight: 600; white-space: nowrap; margin-left: 12px; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: #7f1d1d; color: #fff; }
.btn-primary:active { background: #6b1a1a; }
.btn-secondary { background: #334155; color: #e2e8f0; }
.btn-secondary:active { background: #475569; }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:active { background: #b91c1c; }
.btn-block { width: 100%; }
.btn-outline {
  background: transparent;
  border: 1px solid #334155;
  color: #94a3b8;
}
.btn-outline:active { background: #334155; }

/* === Section Headers === */
.section-title {
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 12px;
}
.section-subtitle {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 16px;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #64748b;
}
.empty-state svg { margin-bottom: 16px; }
.empty-state-title { font-size: 16px; font-weight: 600; color: #94a3b8; margin-bottom: 8px; }

/* === Add Item Form === */
.add-form {
  padding: 16px;
  background: #0f172a;
  border-radius: 8px;
  margin-bottom: 12px;
}
.add-form input, .add-form select {
  width: 100%;
  padding: 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #f8fafc;
  font-size: 15px;
  margin-bottom: 8px;
  min-height: 44px;
  outline: none;
}
.add-form input:focus, .add-form select:focus { border-color: #7f1d1d; }
.add-form input::placeholder { color: #475569; }

/* === Desktop adjustments === */
@media (min-width: 768px) {
  body { background: #0b1120; }
  .app {
    border-left: 1px solid #334155;
    border-right: 1px solid #334155;
  }
  .bottom-nav {
    border-left: 1px solid #334155;
    border-right: 1px solid #334155;
  }
}

/* === Selections === */
.sel-row {
  padding: 10px 0;
  border-bottom: 1px solid #1e293b;
}
.sel-row:last-child { border-bottom: none; }
.sel-item { font-size: 13px; color: #64748b; margin-bottom: 2px; }
.sel-value { font-size: 15px; color: #e2e8f0; }

/* === Calendar === */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}
.cal-month-label {
  font-size: 16px;
  font-weight: 600;
  color: #f8fafc;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: #1e293b;
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 16px;
}
.cal-header {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  padding: 6px 0;
  text-transform: uppercase;
}
.cal-day {
  min-height: 48px;
  padding: 4px;
  border-radius: 6px;
  position: relative;
  background: #0f172a;
}
.cal-day.empty { background: transparent; }
.cal-day.today { outline: 2px solid #7f1d1d; outline-offset: -2px; }
.cal-day-num {
  font-size: 12px;
  color: #94a3b8;
  display: block;
  margin-bottom: 2px;
}
.cal-day.today .cal-day-num { color: #7f1d1d; font-weight: 700; }
.cal-event {
  font-size: 9px;
  padding: 1px 3px;
  border-radius: 3px;
  color: #fff;
  margin-bottom: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-more {
  font-size: 9px;
  color: #64748b;
}

/* === Utilities === */
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
