/* Manage v0.1 — light, sleek, mobile-friendly. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1a1d23;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --danger: #d92d20;
  --warn: #b54708;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}
* { box-sizing: border-box; }
/* The `hidden` attribute must win over component display rules
   (author styles beat the browser default for [hidden], so without this
   the login screen and dialogs would render even while hidden). */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.big { font-size: 1.25rem; font-weight: 600; margin: 0.25rem 0 0.75rem; }
.strike { text-decoration: line-through; color: var(--muted); }

/* top bar */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.logo { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; }
.topbar-spacer { flex: 1; }
.user-chip {
  font-size: 0.9rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* layout */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  width: 280px;
  flex-shrink: 0;
  padding: 1rem;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.side-head { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.project-list { display: flex; flex-direction: column; gap: 0.15rem; }
.group-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0.9rem 0.5rem 0.3rem;
}
.project-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  color: var(--ink);
}
.project-btn:hover { background: #eceef2; }
.project-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ptitle { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdue { font-size: 0.75rem; color: var(--muted); }
.pshared { font-size: 0.7rem; background: var(--accent-soft); color: var(--accent); padding: 0.1rem 0.4rem; border-radius: 999px; }
.side-foot { margin-top: 1.5rem; padding: 0 0.5rem; }
.main { flex: 1; min-width: 0; padding: 1.5rem; max-width: 980px; }

/* buttons, inputs */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn:hover { border-color: #cbd2dc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.danger { color: var(--danger); border-color: #fecdca; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.3rem 0.5rem;
  color: var(--muted);
}
.icon-btn.danger { color: var(--danger); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: var(--card);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; font-weight: 600; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 0.95rem; }
.link.danger { color: var(--danger); }

/* project header + tabs */
.proj-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.proj-head h2 { margin: 0 0 0.4rem; font-size: 1.6rem; letter-spacing: -0.02em; }
.proj-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.badge {
  font-size: 0.75rem;
  background: #f2f4f7;
  border: 1px solid var(--line);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.badge.danger { background: #fef3f2; border-color: #fecdca; color: var(--danger); }
.badge.warn { background: #fffaeb; border-color: #fedea8; color: var(--warn); }
.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
  padding-bottom: 0.25rem;
}
.tab {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
}
.tab.active { background: var(--accent-soft); color: var(--accent); }

/* cards + grids */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.card h3 { margin: 0 0 0.6rem; font-size: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
ul.plain { margin: 0; padding-left: 1.1rem; }
ul.plain li { margin-bottom: 0.3rem; }
.empty { text-align: center; padding: 4rem 1rem; }

/* forms */
.form-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.form-row input, .form-row select { flex: 1 1 140px; width: auto; }
.form-row button { flex-shrink: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.6rem; }
.form-grid button { grid-column: 1 / -1; justify-self: end; }

/* tasks */
.task-row {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}
.task-row:first-of-type { border-top: none; }
.task-row input[type="checkbox"] { width: 20px; height: 20px; margin-top: 0.1rem; accent-color: var(--accent); }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.task-sub { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; font-size: 0.85rem; }

/* files */
.crumbs { margin-bottom: 0.8rem; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; }
.file-card {
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}
.file-card img { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; margin-bottom: 0.4rem; }
.file-icon { font-size: 2rem; margin-bottom: 0.4rem; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }

/* timeline + contacts */
ul.timeline { list-style: none; margin: 0; padding: 0; }
ul.timeline li { padding: 0.6rem 0; border-top: 1px solid var(--line); }
ul.timeline li:first-child { border-top: none; }
.tdate { color: var(--muted); font-size: 0.85rem; margin-right: 0.5rem; }
.contact-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}
.contact-row:first-of-type { border-top: none; }

/* login + dialog + toast */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card h1 { margin: 0 0 0.3rem; font-size: 2rem; letter-spacing: -0.02em; }
#loginButtons { display: flex; flex-direction: column; gap: 0.6rem; margin: 1.5rem 0 0.5rem; }
.dialog {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 40;
}
.dialog-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
}
.dialog-card form { display: flex; flex-direction: column; gap: 0.8rem; }
.dialog-card h2 { margin: 0 0 0.5rem; }
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  z-index: 50;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}
.toast.error { background: var(--danger); }
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.4);
  z-index: 15;
}

/* live updates badge */
.live-badge { font-size: 0.8rem; color: #067647; font-weight: 600; white-space: nowrap; }

/* calendar */
.cal-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.cal-head h2 { margin: 0; }
.cal-month { font-weight: 700; min-width: 10rem; text-align: center; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-weekdays { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.cal-weekdays div { padding: 0.25rem 0.4rem; }
.cal-grid { gap: 4px; margin-bottom: 1rem; }
.cal-cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 88px;
  padding: 0.35rem 0.4rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  color: var(--ink);
}
.cal-cell.dim { opacity: 0.45; }
.cal-cell.selected { outline: 2px solid var(--accent); }
.cal-num { font-size: 0.8rem; font-weight: 700; }
.cal-dot { display: none; }
.cal-ev { font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; padding: 0.05rem 0.3rem; }
.ev-task { background: var(--accent-soft); color: var(--accent); }
.ev-event { background: #ecfdf5; color: #067647; }
.ev-deadline { background: #fffaeb; color: #b54708; }
.cal-more { font-size: 0.72rem; color: var(--muted); }
.cal-detail { display: flex; gap: 0.5rem; align-items: center; padding: 0.4rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.cal-detail:first-of-type { border-top: none; }
#calendarBtn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* mobile */
@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    bottom: 0;
    background: var(--card);
    z-index: 30;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(16, 24, 40, 0.15);
    height: calc(100vh - 56px);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 1rem; }
  .cal-cell { min-height: 64px; }
  .cal-ev, .cal-more { display: none; }
  .cal-dot { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: auto; }
  .proj-head { flex-direction: column; }
  .proj-head h2 { font-size: 1.35rem; }
  .form-row input, .form-row select { flex-basis: 100%; }
  .user-chip { display: none; }
}
@media (min-width: 821px) {
  #menuBtn { display: none; }
}
