@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700;900&display=swap');

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

:root {
  --charcoal:  #1A1A1A;
  --olive:     #4D5246;
  --olive-lt:  #5E6357;
  --sand:      #C7BBAA;
  --beige:     #EDE7DF;
  --beige-lt:  #F5F2EE;
  --porcelain: #F5F5F3;
  --white:     #FFFFFF;
  --muted:     rgba(26,26,26,0.4);
  --border:    rgba(26,26,26,0.1);
  --red:       #C0392B;
  --green:     #2D6A4F;
  --sidebar-w: 260px;
  --font: 'Lato', sans-serif;
}

html, body { height: 100%; }
body { font-family: var(--font); background: var(--porcelain); color: var(--charcoal); line-height: 1.5; font-size: 14px; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { display: block; max-width: 100%; }
input, select, textarea, button { font-family: var(--font); }

/* ── AUTH ──────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  background: var(--charcoal);
}

.auth-brand {
  flex: 1;
  background: var(--olive);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 60px;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  border: 60px solid rgba(255,255,255,0.05);
  border-radius: 50%;
}

.auth-brand h2 {
  font-size: clamp(28px,4vw,48px);
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--white);
  line-height: 1.05;
  position: relative;
}

.auth-brand p {
  font-size: 16px;
  font-weight: 300;
  color: rgba(255,255,255,0.6);
  margin-top: 16px;
  max-width: 360px;
  position: relative;
}

.auth-form-wrap {
  width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  background: var(--white);
  flex-shrink: 0;
}

.auth-form { width: 100%; }

.auth-logo { height: 32px; width: auto; margin-bottom: 40px; }

.auth-form h1 { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; margin-bottom: 6px; }
.auth-form > p { font-size: 14px; font-weight: 300; color: var(--muted); margin-bottom: 36px; }

.auth-error {
  background: #fdf0ef;
  border-left: 3px solid var(--red);
  color: var(--red);
  font-size: 13px;
  padding: 12px 16px;
  margin-bottom: 24px;
  display: none;
}
.auth-error.show { display: block; }

.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.form-group label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-group input, .form-group textarea, .form-group select {
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--porcelain);
  font-size: 14px;
  font-weight: 300;
  color: var(--charcoal);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--olive);
  background: var(--white);
}

.form-group textarea { resize: vertical; min-height: 100px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: var(--font);
}

.btn-primary { background: var(--charcoal); color: var(--white); }
.btn-primary:hover { background: var(--olive); }
.btn-sm { padding: 7px 16px; font-size: 11px; }
.btn-ghost { background: transparent; color: var(--muted); padding: 8px 12px; }
.btn-ghost:hover { color: var(--charcoal); background: var(--beige); }

/* ── LAYOUT ─────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--charcoal);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo { padding: 28px 24px 24px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-logo img { height: 28px; width: auto; filter: brightness(0) invert(1); }

.sidebar-client-info {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sci-name { font-size: 14px; font-weight: 700; color: var(--white); }
.sci-company { font-size: 12px; font-weight: 300; color: rgba(255,255,255,0.4); margin-top: 2px; }

.sidebar-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 20px 24px 10px;
}

.sidebar-nav { flex: 1; padding-bottom: 16px; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  font-size: 13px;
  font-weight: 400;
  color: rgba(255,255,255,0.55);
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.04); }
.sidebar-nav a.active { color: var(--white); background: rgba(255,255,255,0.06); border-left-color: var(--sand); font-weight: 700; }
.sidebar-nav .nav-icon { width: 16px; text-align: center; flex-shrink: 0; opacity: 0.7; }
.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-footer { padding: 20px 24px; border-top: 1px solid rgba(255,255,255,0.06); }
.sidebar-footer a { display: flex; align-items: center; gap: 10px; font-size: 12px; color: rgba(255,255,255,0.3); transition: color 0.15s; }
.sidebar-footer a:hover { color: rgba(255,255,255,0.7); }

/* ── MAIN ───────────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 40px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 18px; font-weight: 900; letter-spacing: -0.02em; }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-right a { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); transition: color 0.15s; }
.topbar-right a:hover { color: var(--charcoal); }

.content { padding: 40px; flex: 1; }

/* ── CARDS ──────────────────────────────────────────────────── */
.card { background: var(--white); border: 1px solid var(--border); margin-bottom: 24px; }
.card-header { padding: 20px 28px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-header h2 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.card-body { padding: 28px; }

/* ── PROGRESS ────────────────────────────────────────────────── */
.project-hero {
  background: var(--olive);
  padding: 32px 36px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.project-hero::before {
  content: '';
  position: absolute;
  right: -60px; top: -60px;
  width: 240px; height: 240px;
  border: 40px solid rgba(255,255,255,0.06);
  border-radius: 50%;
}

.ph-label { font-size: 10px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(255,255,255,0.5); margin-bottom: 8px; }
.ph-name { font-size: 28px; font-weight: 900; letter-spacing: -0.02em; color: var(--white); }
.ph-type { font-size: 13px; font-weight: 300; color: rgba(255,255,255,0.55); margin-top: 6px; }

.progress-bar-wrap {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--sand);
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.16,1,0.3,1);
}

.progress-pct { font-size: 20px; font-weight: 900; color: var(--white); letter-spacing: -0.02em; flex-shrink: 0; }

/* Milestones */
.milestones { display: flex; flex-direction: column; gap: 0; }

.milestone {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.milestone:last-child { border-bottom: none; }

.ms-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.ms-dot.done { background: var(--olive); color: var(--white); }
.ms-dot.active { background: var(--sand); color: var(--charcoal); }
.ms-dot.pending { background: var(--beige); color: var(--muted); border: 1.5px solid var(--border); }

.ms-label { font-size: 14px; font-weight: 700; }
.ms-sub { font-size: 12px; font-weight: 300; color: var(--muted); margin-top: 2px; }

.ms-status {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 10px;
  flex-shrink: 0;
}

.ms-status.done { background: rgba(45,106,79,0.12); color: var(--green); }
.ms-status.active { background: rgba(199,187,170,0.3); color: var(--olive); }
.ms-status.pending { color: var(--muted); background: var(--beige); }

/* ── MESSAGES ────────────────────────────────────────────────── */
.messages-wrap {
  display: flex;
  flex-direction: column;
  height: 480px;
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-bubble {
  max-width: 70%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-bubble.me { align-self: flex-end; align-items: flex-end; }
.message-bubble.them { align-self: flex-start; }

.bubble-sender {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.bubble-text {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 300;
  line-height: 1.55;
}

.message-bubble.me .bubble-text {
  background: var(--charcoal);
  color: var(--white);
}

.message-bubble.them .bubble-text {
  background: var(--beige);
  color: var(--charcoal);
}

.bubble-time { font-size: 10px; color: var(--muted); }

.message-input-row {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
  padding: 16px 24px;
}

.message-input-row input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  background: var(--porcelain);
  font-size: 14px;
  font-weight: 300;
  color: var(--charcoal);
  outline: none;
  transition: border-color 0.15s;
}

.message-input-row input:focus { border-color: var(--olive); background: var(--white); }

.message-input-row button {
  padding: 12px 24px;
  background: var(--charcoal);
  color: var(--white);
  border: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.message-input-row button:hover { background: var(--olive); }

/* ── FILES ──────────────────────────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: 1px; background: var(--border); }

.file-item {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--white);
  transition: background 0.15s;
}

.file-item:hover { background: var(--beige-lt, #F5F2EE); }

.file-icon {
  width: 40px;
  height: 40px;
  background: var(--beige);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.file-name { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.file-meta { font-size: 12px; font-weight: 300; color: var(--muted); margin-top: 2px; }

.file-by {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
}

/* Upload drop zone */
.file-drop {
  border: 2px dashed var(--border);
  padding: 36px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  margin-bottom: 24px;
}

.file-drop:hover, .file-drop.dragover { border-color: var(--olive); background: var(--beige-lt, #F5F2EE); }
.file-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-drop-icon { font-size: 32px; opacity: 0.25; margin-bottom: 12px; }
.file-drop p { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.file-drop span { font-size: 12px; font-weight: 300; color: var(--muted); }

/* ── STATS ROW ───────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }

.stat-card { background: var(--white); border: 1px solid var(--border); padding: 24px 24px 20px; }
.stat-card-label { font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.stat-card-value { font-size: 32px; font-weight: 900; letter-spacing: -0.03em; line-height: 1; color: var(--charcoal); }

/* ── TOAST ──────────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 32px; right: 32px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--charcoal); color: var(--white); padding: 14px 20px; font-size: 13px; display: flex; align-items: center; gap: 12px; min-width: 260px; animation: toastIn 0.3s ease both; }
.toast.success::before { content: '✓'; font-weight: 700; color: #5cb85c; }
.toast.error::before { content: '✕'; font-weight: 700; color: #e74c3c; }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ── SIDEBAR OVERLAY (mobile) ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

.mobile-sidebar-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px 8px 0;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}
.mobile-sidebar-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--charcoal);
  border-radius: 1px;
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Auth */
  .auth-brand { display: none; }
  .auth-form-wrap { width: 100%; padding: 40px 24px; }

  /* Sidebar drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; }

  /* Main */
  .main { margin-left: 0 !important; }
  .mobile-sidebar-btn { display: flex; }

  /* Topbar */
  .topbar { padding: 0 16px; gap: 8px; }
  .topbar-title { font-size: 15px; }
  .topbar-right { gap: 8px; }
  .topbar-right a { font-size: 11px; }

  /* Content */
  .content { padding: 16px; }

  /* Cards */
  .card { margin-bottom: 16px; }
  .card-header { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .card-header h2 { font-size: 14px; }
  .card-body { padding: 16px; }

  /* Stats */
  .stats-row { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Project hero */
  .project-hero { padding: 24px 20px; }
  .ph-name { font-size: 22px; }

  /* Milestones */
  .milestone { grid-template-columns: 28px 1fr; gap: 12px; }
  .ms-status { display: none; }

  /* Messages */
  .messages-wrap { height: auto; min-height: 400px; }
  .messages-list { padding: 16px; }
  .message-bubble { max-width: 85%; }
  .message-input-row { padding: 12px 16px; }

  /* Files */
  .file-list { gap: 0; }
  .file-item { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .file-by { display: none; }

  /* Drop zone */
  .file-drop { padding: 24px 16px; }

  /* Tabs */
  #projectTabs { overflow-x: auto; }
  #projectTabs button { white-space: nowrap; flex-shrink: 0; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .topbar-right a:not(:last-child) { display: none; }
}
