/* ============================================================
   Maji - Oma Designlab Design System
   Color palette: #1a1a18 / #ffffff / #f7f7f5
   ============================================================ */

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

:root {
  --black:   #1a1a18;
  --white:   #ffffff;
  --bg:      #f7f7f5;
  --gray-1:  #f0f0ee;
  --gray-2:  #e0e0dd;
  --gray-3:  #b0b0ac;
  --gray-4:  #6b6b68;
  --accent:  #1a1a18;
  --green:   #2d7d46;
  --green-l: #e8f5ed;
  --red:     #c0392b;
  --red-l:   #fdecea;
  --orange:  #d4680a;
  --orange-l:#fff3e0;
  --blue:    #1a5fa8;
  --blue-l:  #e8f0fb;
  --sidebar-w: 196px;
  --font: -apple-system, 'Helvetica Neue', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.18s ease;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--black);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- LAYOUT ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--black);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}
.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.3;
}
.sidebar-brand small {
  display: block;
  font-size: 0.72rem;
  opacity: 0.55;
  margin-top: 2px;
  letter-spacing: 0.02em;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  min-height: 44px;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: var(--white); }
.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: var(--white);
  border-left-color: var(--white);
}
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 16px 20px;
  font-size: 0.72rem;
  opacity: 0.4;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}
.page { display: none; }
.page.active { display: block; }
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 32px 0;
  flex-wrap: wrap;
}
.page-header h2 { font-size: 1.5rem; font-weight: 700; }
.page-header .page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.page-body { padding: 20px 32px 40px; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font);
  min-height: 44px;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--black); color: var(--white); border-color: var(--black); }
.btn-primary:hover { background: #333; border-color: #333; }
.btn-secondary { background: var(--white); color: var(--black); border-color: var(--gray-2); }
.btn-secondary:hover { border-color: var(--gray-3); background: var(--gray-1); }
.btn-danger { background: var(--red); color: var(--white); border-color: var(--red); }
.btn-danger:hover { background: #a93226; }
.btn-ghost { background: transparent; color: var(--black); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-1); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; min-height: 32px; }
.btn-icon { padding: 8px; min-width: 44px; justify-content: center; }
.btn-green { background: var(--green); color: var(--white); border-color: var(--green); }
.btn-green:hover { background: #236138; }

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-2);
  overflow: hidden;
}
.card-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-header h3 { font-size: 0.95rem; font-weight: 700; }
.card-body { padding: 20px; }

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--gray-2);
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: 0.78rem; color: var(--gray-4); margin-bottom: 6px; font-weight: 500; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-card .stat-sub { font-size: 0.78rem; color: var(--gray-4); margin-top: 4px; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  background: var(--gray-1);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--gray-4);
  white-space: nowrap;
  border-bottom: 1px solid var(--gray-2);
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-1);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfbf9; }
.table-actions { display: flex; gap: 6px; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-4);
}
input[type="text"], input[type="number"], input[type="email"],
input[type="tel"], input[type="date"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-2);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--black);
  background: var(--white);
  transition: border-color var(--transition);
  min-height: 40px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--black);
}
textarea { min-height: 80px; resize: vertical; }
.form-hint { font-size: 0.75rem; color: var(--gray-3); margin-top: 4px; }

/* ---- MODALS ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s ease;
  margin: auto;
}
.modal-lg { max-width: 900px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-1);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; color: var(--gray-3); padding: 4px 8px;
  border-radius: 4px; transition: all var(--transition);
  min-height: 44px; min-width: 44px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--gray-1); color: var(--black); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--gray-1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-black  { background: var(--black); color: var(--white); }
.badge-gray   { background: var(--gray-1); color: var(--gray-4); border: 1px solid var(--gray-2); }
.badge-green  { background: var(--green-l); color: var(--green); }
.badge-red    { background: var(--red-l); color: var(--red); }
.badge-orange { background: var(--orange-l); color: var(--orange); }
.badge-blue   { background: var(--blue-l); color: var(--blue); }

/* ---- PROGRESS TRACK ---- */
.stage-track {
  display: flex;
  align-items: center;
  overflow-x: auto;
  padding: 8px 0 12px;
  gap: 0;
  scrollbar-width: none;
}
.stage-track::-webkit-scrollbar { display: none; }
.stage-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  min-width: 80px;
}
.stage-step::before {
  content: '';
  position: absolute;
  top: 13px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: var(--gray-2);
  z-index: 0;
}
.stage-step:last-child::before { display: none; }
.stage-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--gray-2);
  background: var(--white);
  z-index: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  transition: all var(--transition);
}
.stage-step.done .stage-dot    { background: var(--black); border-color: var(--black); color: var(--white); }
.stage-step.active .stage-dot  { background: var(--white); border-color: var(--black); box-shadow: 0 0 0 3px rgba(26,26,24,0.15); color: var(--black); }
.stage-step.done::before        { background: var(--black); }
.stage-label {
  margin-top: 6px;
  font-size: 0.68rem;
  color: var(--gray-4);
  text-align: center;
  white-space: nowrap;
  font-weight: 500;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-step.active .stage-label { color: var(--black); font-weight: 700; }
.stage-step.done .stage-label   { color: var(--black); }

/* ---- PROGRESS BAR ---- */
.progress-bar-wrap { background: var(--gray-1); border-radius: 99px; overflow: hidden; height: 6px; }
.progress-bar-fill { height: 100%; background: var(--black); border-radius: 99px; transition: width 0.4s ease; }

/* ---- PHOTO GRID ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.photo-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4/3;
  cursor: pointer;
  background: var(--gray-1);
}
.photo-card img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition);
}
.photo-card:hover img { transform: scale(1.04); }
.photo-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  align-items: flex-end;
  padding: 10px;
}
.photo-card:hover .photo-card-overlay { opacity: 1; }
.photo-caption { color: var(--white); font-size: 0.75rem; font-weight: 500; }
.photo-delete-btn {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
  min-height: auto;
}
.photo-card:hover .photo-delete-btn { opacity: 1; }

/* ---- LIGHTBOX ---- */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.lightbox-overlay.open { display: flex; }
.lightbox-img { max-width: 90vw; max-height: 80vh; border-radius: var(--radius); }
.lightbox-caption { color: rgba(255,255,255,0.8); margin-top: 12px; font-size: 0.9rem; }
.lightbox-close {
  position: absolute;
  top: 20px; right: 24px;
  color: white; background: none; border: none;
  font-size: 2rem; cursor: pointer;
  min-height: 44px; min-width: 44px;
  display: flex; align-items: center; justify-content: center;
}

/* ---- TIMELINE ---- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 16px;
  padding-bottom: 20px;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 26px;
  bottom: 0;
  width: 2px;
  background: var(--gray-2);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
  border: 2.5px solid var(--gray-2);
  background: var(--white);
  z-index: 1;
}
.timeline-item.type-stage .timeline-dot    { border-color: var(--green); background: var(--green); }
.timeline-item.type-issue .timeline-dot    { border-color: var(--red); background: var(--red); }
.timeline-item.type-vendor .timeline-dot   { border-color: var(--orange); background: var(--orange); }
.timeline-item.type-general .timeline-dot  { border-color: var(--black); background: var(--black); }
.timeline-content { flex: 1; }
.timeline-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 2px; }
.timeline-body { font-size: 0.83rem; color: var(--gray-4); line-height: 1.5; }
.timeline-meta { font-size: 0.75rem; color: var(--gray-3); margin-top: 4px; }

/* ---- PROJECT CARD ---- */
.project-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-2);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.project-card:hover { box-shadow: var(--shadow-md); border-color: var(--gray-3); }
.project-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; gap: 12px; }
.project-card-title { font-size: 1rem; font-weight: 700; }
.project-card-meta { font-size: 0.8rem; color: var(--gray-4); margin-top: 2px; }
.project-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---- COST ITEM CARD ---- */
.cost-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-2);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.cost-card-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.cost-card-title { font-weight: 700; font-size: 0.95rem; }
.cost-card-meta { font-size: 0.8rem; color: var(--gray-4); }
.cost-card-price { font-size: 1.4rem; font-weight: 800; }
.cost-card-footer { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---- TABS ---- */
.tab-bar { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-2); margin-bottom: 20px; overflow-x: auto; }
.tab-btn {
  padding: 8px 18px;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-4);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  min-height: 44px;
  transition: all var(--transition);
}
.tab-btn.active { color: var(--black); border-bottom-color: var(--black); }
.tab-btn:hover:not(.active) { color: var(--black); background: var(--gray-1); border-radius: var(--radius) var(--radius) 0 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- SEARCH + FILTER BAR ---- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}
.filter-bar input, .filter-bar select { flex: 1; min-width: 180px; max-width: 260px; }

/* ---- QUOTE EDITOR ---- */
.quote-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--gray-1);
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 0.92rem;
}
.quote-items-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.quote-items-table th {
  background: var(--gray-1);
  padding: 8px 10px;
  font-weight: 600;
  color: var(--gray-4);
  font-size: 0.78rem;
  text-align: left;
  white-space: nowrap;
}
.quote-items-table td { padding: 6px 6px; vertical-align: middle; border-bottom: 1px solid var(--gray-1); }
.quote-items-table input, .quote-items-table select {
  padding: 5px 8px;
  min-height: 36px;
  font-size: 0.83rem;
}
.quote-total-box {
  background: var(--gray-1);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 24px;
  justify-content: end;
}
.quote-total-row { display: contents; }
.quote-total-label { font-size: 0.88rem; color: var(--gray-4); text-align: right; }
.quote-total-value { font-size: 0.88rem; font-weight: 600; text-align: right; }
.quote-grand-label { font-size: 1.05rem; font-weight: 800; text-align: right; }
.quote-grand-value { font-size: 1.3rem; font-weight: 800; text-align: right; color: var(--black); }

/* ---- PROFIT SLIDER ---- */
.slider-wrap { display: flex; align-items: center; gap: 12px; }
.slider-wrap input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--gray-2);
  border-radius: 99px;
  border: none;
  padding: 0;
  min-height: unset;
  cursor: pointer;
}
.slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--black);
  cursor: pointer;
}
.slider-value {
  font-weight: 800;
  font-size: 1.1rem;
  min-width: 50px;
  text-align: center;
}

/* ---- CHECKBOX TASK ---- */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-1);
}
.task-item:last-child { border-bottom: none; }
.task-check {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-3);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  margin-top: 2px;
  transition: all var(--transition);
  min-height: auto;
  background: var(--white);
}
.task-check.done { background: var(--black); border-color: var(--black); color: var(--white); }
.task-text { flex: 1; font-size: 0.88rem; line-height: 1.4; }
.task-text.done { text-decoration: line-through; color: var(--gray-3); }
.task-meta { font-size: 0.75rem; color: var(--gray-3); margin-top: 2px; }

/* ---- GRID LAYOUTS ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* ---- VENDOR STATUS ---- */
.vendor-row { background: var(--white); border-radius: var(--radius); border: 1px solid var(--gray-2); margin-bottom: 10px; }
.vendor-row-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.vendor-delay { background: var(--red-l); border-left: 4px solid var(--red); padding: 10px 16px; font-size: 0.82rem; color: var(--red); border-radius: 0 0 var(--radius) var(--radius); }

/* ---- ALERTS ---- */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 0.88rem; margin-bottom: 16px; }
.alert-info    { background: var(--blue-l); color: var(--blue); }
.alert-success { background: var(--green-l); color: var(--green); }
.alert-warning { background: var(--orange-l); color: var(--orange); }
.alert-error   { background: var(--red-l); color: var(--red); }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-3);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 0.88rem; }

/* ---- TOAST ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--black);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease;
  pointer-events: auto;
  max-width: 340px;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- SECTION DIVIDER ---- */
.section-gap { margin-bottom: 28px; }
.section-title { font-size: 0.8rem; font-weight: 700; color: var(--gray-4); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px; }

/* ---- BACK BUTTON ---- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--gray-4);
  padding: 8px 0;
  min-height: 44px;
  transition: color var(--transition);
}
.back-btn:hover { color: var(--black); }

/* ---- LOADING ---- */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2.5px solid var(--gray-2);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   PORTAL - MOBILE STYLES
   ============================================================ */
.portal-body {
  background: var(--bg);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

.portal-header {
  position: sticky;
  top: 0;
  background: var(--black);
  color: var(--white);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}
.portal-brand { font-size: 0.9rem; font-weight: 700; line-height: 1.25; }
.portal-brand small { display: block; font-size: 0.68rem; opacity: 0.55; margin-top: 1px; }
.portal-lastupdate { font-size: 0.72rem; opacity: 0.6; text-align: right; }

.portal-container { padding: 16px; max-width: 600px; margin: 0 auto; }

.portal-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-2);
  margin-bottom: 14px;
  overflow: hidden;
}
.portal-card-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--gray-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  min-height: 50px;
}
.portal-card-title { font-size: 0.92rem; font-weight: 700; }
.portal-card-toggle { font-size: 1rem; color: var(--gray-3); transition: transform var(--transition); }
.portal-card.collapsed .portal-card-toggle { transform: rotate(-90deg); }
.portal-card-body { padding: 16px; }
.portal-card.collapsed .portal-card-body { display: none; }

.portal-project-info table { width: 100%; font-size: 0.85rem; }
.portal-project-info td { padding: 5px 8px; vertical-align: top; }
.portal-project-info td:first-child { color: var(--gray-4); font-weight: 600; width: 90px; }

.portal-progress-wrap { margin: 4px 0 12px; }
.portal-progress-label { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--gray-4); margin-bottom: 4px; }

.portal-stage-scroll { overflow-x: auto; padding: 4px 0 10px; }
.portal-stage-track { display: flex; align-items: flex-start; gap: 0; min-width: max-content; padding: 4px 0; }
.portal-stage-step { display: flex; flex-direction: column; align-items: center; width: 72px; position: relative; }
.portal-stage-step::before {
  content: '';
  position: absolute;
  top: 12px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: var(--gray-2);
}
.portal-stage-step:last-child::before { display: none; }
.portal-stage-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2.5px solid var(--gray-2);
  background: var(--white);
  z-index: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700;
}
.portal-stage-step.done .portal-stage-dot    { background: var(--black); border-color: var(--black); color: var(--white); }
.portal-stage-step.active .portal-stage-dot  { border-color: var(--black); box-shadow: 0 0 0 3px rgba(26,26,24,0.15); }
.portal-stage-step.done::before { background: var(--black); }
.portal-stage-label { font-size: 0.62rem; color: var(--gray-4); text-align: center; margin-top: 5px; line-height: 1.2; max-width: 68px; }
.portal-stage-step.active .portal-stage-label { color: var(--black); font-weight: 700; }
.portal-stage-step.done .portal-stage-label   { color: var(--black); }

.line-banner {
  background: linear-gradient(135deg, #00b300 0%, #00c900 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  cursor: pointer;
}
.line-banner-icon { font-size: 1.8rem; flex-shrink: 0; }
.line-banner-text h4 { font-size: 0.9rem; font-weight: 700; }
.line-banner-text p  { font-size: 0.75rem; opacity: 0.9; }

.portal-photo-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-chip {
  padding: 5px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--gray-2);
  background: var(--white);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  display: flex; align-items: center;
  transition: all var(--transition);
}
.filter-chip.active { background: var(--black); color: var(--white); border-color: var(--black); }

.portal-photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.portal-photo-item {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--gray-1);
  cursor: pointer;
}
.portal-photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.portal-update-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-1);
}
.portal-update-item:last-child { border-bottom: none; }
.portal-update-item.issue { border-left: 3px solid var(--red); padding-left: 12px; margin-left: -16px; padding-left: 12px; }
.portal-update-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; background: var(--gray-3); }
.portal-update-item.type-stage .portal-update-dot  { background: var(--green); }
.portal-update-item.type-issue .portal-update-dot  { background: var(--red); }
.portal-update-item.type-vendor .portal-update-dot { background: var(--orange); }
.portal-update-title { font-weight: 700; font-size: 0.88rem; }
.portal-update-body  { font-size: 0.82rem; color: var(--gray-4); margin-top: 3px; line-height: 1.5; }
.portal-update-meta  { font-size: 0.73rem; color: var(--gray-3); margin-top: 4px; }

.portal-milestone-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-1);
}
.portal-milestone-item:last-child { border-bottom: none; }
.milestone-status-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  background: var(--gray-3);
}
.milestone-status-dot.completed { background: var(--green); }
.milestone-status-dot.in_progress { background: var(--orange); }
.milestone-status-dot.upcoming { background: var(--gray-3); }
.milestone-status-dot.delayed { background: var(--red); }
.portal-milestone-name { font-weight: 600; font-size: 0.88rem; }
.portal-milestone-date { font-size: 0.78rem; color: var(--gray-4); margin-top: 2px; }

/* ---- PORTAL TASK LIST ---- */
.portal-task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--gray-1);
}
.portal-task-item:last-child { border-bottom: none; }
.portal-task-check {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 2px solid var(--gray-3);
  flex-shrink: 0;
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem;
}
.portal-task-check.done { background: var(--black); border-color: var(--black); color: white; }
.portal-task-text { font-size: 0.85rem; line-height: 1.4; }
.portal-task-text.done { text-decoration: line-through; color: var(--gray-3); }

/* ---- PORTAL FOOTER ---- */
.portal-footer {
  text-align: center;
  padding: 24px 20px;
  font-size: 0.78rem;
  color: var(--gray-3);
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    min-height: auto;
    flex-direction: row;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    overflow: hidden;
    z-index: 100;
  }
  .sidebar-brand, .sidebar-footer { display: none; }
  .sidebar-nav {
    display: flex;
    flex-direction: row;
    width: 100%;
    padding: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .nav-item {
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    font-size: 0.62rem;
    min-height: 60px;
    border-left: none;
    border-top: 3px solid transparent;
    flex: 1;
    justify-content: center;
    min-width: 60px;
  }
  .nav-item.active { border-left: none; border-top-color: var(--white); }
  .nav-item .nav-icon { font-size: 1.2rem; }
  .main-content { margin-left: 0; margin-bottom: 60px; }
  .page-header { padding: 16px 16px 0; }
  .page-body { padding: 14px 16px 32px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .toast-container { bottom: 70px; right: 12px; left: 12px; }
  .toast { max-width: none; }
  .modal-overlay { padding: 20px 12px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .page-header h2 { font-size: 1.2rem; }
}

/* ---- UTILITIES ---- */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.text-gray { color: var(--gray-4); }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.pointer { cursor: pointer; }
