:root {
  --bg: #060603;
  --surface: #0F0F0A;
  --surface-raised: #16160F;
  --accent: #BDE427;
  --accent-dim: #8FAD22;
  --text: #F2F2E8;
  --text-dim: #9C9C8E;
  --line: #232319;
  --danger: #E0605A;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  margin: 0;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar-firm { display: flex; align-items: center; gap: 14px; }
.topbar-firm .mark {
  font-family: 'Source Serif 4', serif;
  font-size: 28px;
  color: var(--accent);
  line-height: 1;
}
.topbar-firm .logo-img { height: 34px; width: auto; display: block; }
.topbar-firm .logo-sub { font-size: 13px; color: var(--text-dim); margin: 0; padding-left: 14px; border-left: 1px solid var(--line); }
.topbar-firm h1 { font-size: 19px; color: var(--text); }
.topbar-firm p { margin: 2px 0 0; font-size: 13px; color: var(--text-dim); }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); }
.nav-link { color: var(--text-dim); text-decoration: none; font-size: 13.5px; padding-right: 4px; }
.nav-link:hover { color: var(--accent); }
.user-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.signout { color: var(--text-dim); text-decoration: none; border-left: 1px solid var(--line); padding-left: 10px; margin-left: 2px; }
.signout:hover { color: var(--accent); }

/* ---- Main / controls ---- */
main { max-width: 980px; margin: 0 auto; padding: 24px 20px 60px; }

.cal-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}
.cal-nav { display: flex; align-items: center; gap: 14px; }
.cal-nav h2 { font-size: 22px; min-width: 190px; color: var(--text); }
.nav-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 18px;
  background: var(--surface);
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }

.cal-actions { display: flex; align-items: center; gap: 12px; }
.today-link { font-size: 13px; color: var(--text-dim); text-decoration: none; border-bottom: 1px solid var(--line); }
.today-link:hover { color: var(--accent); border-color: var(--accent); }

.primary-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn:hover { background: var(--accent-dim); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-dim);
}
.ghost-btn:hover { border-color: var(--text-dim); color: var(--text); }

.danger-btn {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.danger-btn:hover { background: var(--danger); color: #060603; }

/* ---- Grid ---- */
.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  font-size: 12px;
  color: var(--text-dim);
  padding: 0 2px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-cell {
  min-height: 96px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: border-color .12s ease;
}
.day-cell:hover { border-color: var(--accent-dim); }
.day-cell.empty { background: transparent; border: none; cursor: default; }
.day-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.day-num { font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.day-cell.today .day-num { color: var(--accent); font-weight: 700; }

.day-events { display: flex; flex-direction: column; gap: 4px; }
.event-chip {
  font-size: 11.5px;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--surface-raised);
  border-left: 3px solid var(--accent);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-chip {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 4px;
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-chip.done { text-decoration: line-through; opacity: .55; }

/* ---- Modal ---- */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .65);
  align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 26px;
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
}
.modal h3 { font-size: 19px; margin-bottom: 16px; color: var(--text); }
.modal label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.modal .optional { color: #6B6B5E; font-weight: 400; }
.modal input, .modal textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
.modal input:focus, .modal textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.modal select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
.modal select:focus { outline: none; border-color: var(--accent); }
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }

/* ---- Action items (per-event tasks) ---- */
.task-section {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 14px;
  margin-bottom: 14px;
}
.task-section-label { font-size: 13px; color: var(--text-dim); margin: 0 0 8px; }
.task-hint { font-size: 12.5px; color: #6B6B5E; margin: 0 0 4px; }
.task-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.task-empty { font-size: 12.5px; color: #6B6B5E; margin: 4px 0; }
.task-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}
.task-row.done .task-desc { text-decoration: line-through; color: var(--text-dim); }
.task-row input[type="checkbox"] { accent-color: var(--accent); }
.task-desc { flex: 1; font-size: 13px; color: var(--text); }
.task-meta { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.task-delete {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 12px; padding: 2px 4px;
}
.task-delete:hover { color: var(--danger); }
.task-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.task-add-row input[type="text"] {
  flex: 1 1 100%;
  width: 100%;
  margin: 0; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); color: var(--text); font-size: 13.5px;
}
.task-add-row select, .task-add-row input[type="date"] {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0; padding: 8px 9px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); color: var(--text); font-size: 13px;
}
.task-add-row button { flex: 0 0 auto; padding: 8px 14px; font-size: 13px; }

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.modal-actions-right { display: flex; gap: 10px; margin-left: auto; }

/* ---- Login page ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.login-card .eyebrow-mark::before {
  content: '§';
  font-family: 'Source Serif 4', serif;
  font-size: 30px;
  color: var(--accent);
}
.login-card .logo-img { height: 46px; width: auto; margin-bottom: 4px; }
.login-card h1 { font-size: 20px; margin-top: 10px; color: var(--text); }
.login-sub { color: var(--text-dim); font-size: 13px; margin: 4px 0 22px; }
.login-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { background: var(--accent-dim); }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 14px; }

/* ---- Mobile ---- */
@media (max-width: 640px) {
  .weekday-row span { font-size: 10px; }
  .day-cell { min-height: 72px; padding: 6px; }
  .day-num { font-size: 12px; }
  .event-chip { font-size: 10px; }
  .cal-nav h2 { font-size: 18px; min-width: 0; }
  .topbar { padding: 14px 16px; }
  main { padding: 18px 12px 50px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions-right { width: 100%; justify-content: flex-end; }
}

/* ---- Tasks page ---- */
.task-filters { display: flex; gap: 10px; margin-bottom: 18px; }
.task-filters select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
}
.tasks-table-wrap { display: flex; flex-direction: column; gap: 8px; }
.task-list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}
.task-list-row input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; }
.task-list-row.done { opacity: .55; }
.task-list-row.done .task-list-desc { text-decoration: line-through; }
.task-list-main { flex: 1; min-width: 0; }
.task-list-desc { font-size: 14.5px; color: var(--text); }
.task-list-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.task-list-assignee {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-dim);
  min-width: 130px; flex-shrink: 0;
}
.task-list-due { font-size: 13px; color: var(--text-dim); min-width: 90px; flex-shrink: 0; text-align: right; }

@media (max-width: 640px) {
  .task-list-row { flex-wrap: wrap; }
  .task-list-assignee, .task-list-due { min-width: 0; }
}
