:root {
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --bg: #f3f5f9;
  --card-bg: #ffffff;
  --border: #dde2ea;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Onboarding */
.onboarding-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.onboarding-card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  padding: 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.onboarding-card h1 {
  font-size: 1.6rem;
  color: var(--primary-dark);
  margin-bottom: 4px;
}

.subtitle {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 28px;
}

.onboarding-card form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: -8px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  font-family: inherit;
}

.onboarding-card button[type="submit"] {
  margin-top: 8px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
}

.onboarding-card button[type="submit"]:hover {
  background: var(--primary-dark);
}

.error-text {
  color: var(--danger);
  font-size: 0.9rem;
}

/* Top bar */
.topbar {
  background: var(--primary-dark);
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.95rem;
}

.topbar-user a {
  color: #cbd5e1;
  text-decoration: underline;
  font-size: 0.85rem;
}

.topbar-user a:hover { color: white; }

/* Calendar */
.calendar-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.month-nav h2 {
  margin: 0;
  min-width: 220px;
  text-align: center;
  color: var(--primary-dark);
}

.month-nav button {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.2rem;
  width: 40px;
  height: 40px;
}

.month-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 0;
}

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

.day-cell {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 150px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.day-cell-empty {
  background: transparent;
  border: none;
}

.day-cell-disabled {
  background: #f8f9fb;
  color: #c2c7d0;
}

.day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.day-number {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1;
}

.day-cell-disabled .day-number {
  color: #c2c7d0;
}

.day-count-badge {
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.day-entries {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.entry-chip {
  background: #eef2ff;
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.78rem;
  cursor: pointer;
  flex-shrink: 0;
}

.entry-chip:hover { background: #e0e7ff; }

.entry-chip-owned {
  border-left-color: #059669;
  background: #ecfdf5;
}

.entry-title {
  font-weight: 600;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

.entry-meta {
  color: var(--muted);
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

.add-entry-btn {
  margin-top: 6px;
  flex-shrink: 0;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--primary);
  padding: 4px;
}

.add-entry-btn:hover {
  background: #eef2ff;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: white;
  border-radius: 12px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 {
  margin-top: 0;
  margin-bottom: 2px;
  color: var(--primary-dark);
}

.modal-date {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 18px;
}

.modal-submitter {
  background: #f3f5f9;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: -8px;
  margin-bottom: 18px;
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: white;
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 8px;
}

.btn-danger {
  background: white;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 10px 18px;
  border-radius: 8px;
  margin-right: auto;
}

.btn-danger:hover { background: #fef2f2; }

@media (max-width: 700px) {
  .day-cell { height: 110px; }
  .day-number { font-size: 1.2rem; }
  .form-row { grid-template-columns: 1fr; }
}
