:root {
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-soft: #eef1eb;
  --ink: #1c221f;
  --muted: #69736d;
  --line: #dfe4de;
  --green: #176b4d;
  --green-dark: #0f513a;
  --green-soft: #dcefe5;
  --red: #b23b3b;
  --shadow: 0 16px 40px rgba(20, 35, 27, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Manrope", system-ui, sans-serif;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; font-size: 18px; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; padding: 5px; display: grid; place-items: center; background: var(--ink); border-radius: 7px; }
.brand-mark span { width: 13px; height: 13px; border: 3px solid #8ed2af; border-top-color: transparent; border-radius: 50%; transform: rotate(-35deg); }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.timezone { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.timezone svg { width: 16px; }

.button, .icon-button, .send-button, .agent-button {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button { min-height: 40px; padding: 0 15px; gap: 8px; border-radius: 7px; font-size: 13px; font-weight: 700; }
.button svg { width: 17px; height: 17px; }
.button-primary { color: white; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: var(--ink); background: var(--surface-soft); }
.button-danger { color: var(--red); background: #f8e9e7; }

.workspace { padding: 24px 28px 36px; }
.calendar-shell { min-height: calc(100vh - 132px); padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
#calendar { max-width: 1500px; margin: 0 auto; }

.fc { --fc-border-color: var(--line); --fc-today-bg-color: #f1f7f3; --fc-event-bg-color: var(--green); --fc-event-border-color: var(--green); }
.fc .fc-toolbar { margin-bottom: 22px; }
.fc .fc-toolbar-title { font-size: 24px; font-weight: 700; text-transform: capitalize; }
.fc .fc-button-primary { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: none; font-weight: 600; text-transform: capitalize; }
.fc .fc-button-primary:hover, .fc .fc-button-primary:focus { background: var(--surface-soft); border-color: #cbd3cc; color: var(--ink); box-shadow: none; }
.fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--ink); border-color: var(--ink); }
.fc-theme-standard th { padding: 10px 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.fc .fc-daygrid-day-number { padding: 9px; color: var(--ink); font-size: 13px; text-decoration: none; }
.fc .fc-event { padding: 3px 5px; border-radius: 4px; font-size: 12px; }
.fc .fc-daygrid-day-frame { min-height: 92px; }

.agent-button {
  position: fixed;
  z-index: 20;
  right: 26px;
  bottom: 24px;
  width: 54px;
  height: 54px;
  color: white;
  background: var(--ink);
  border-radius: 50%;
  box-shadow: var(--shadow);
}
.agent-button:hover { background: var(--green); }
.agent-button svg { width: 22px; height: 22px; }

.agent-panel {
  position: fixed;
  z-index: 40;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform 180ms ease;
}
.agent-panel.open { transform: translateX(0); }
.agent-header { min-height: 78px; padding: 17px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.agent-title { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.agent-status { width: 8px; height: 8px; background: #34a36f; border-radius: 50%; }
.agent-header p { margin: 4px 0 0 16px; color: var(--muted); font-size: 12px; }
.icon-button { width: 36px; height: 36px; color: var(--muted); background: transparent; border-radius: 6px; }
.icon-button:hover { color: var(--ink); background: var(--surface-soft); }
.icon-button svg { width: 19px; }
.messages { min-height: 0; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.message { width: fit-content; max-width: 86%; padding: 10px 12px; border-radius: 7px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.message.assistant { align-self: flex-start; background: var(--surface-soft); }
.message.user { align-self: flex-end; color: white; background: var(--green); }
.message.loading { color: var(--muted); }
.suggestions { padding: 0 18px 12px; display: flex; flex-wrap: wrap; gap: 7px; }
.suggestions button { padding: 7px 9px; color: var(--green-dark); background: var(--green-soft); border: 0; border-radius: 6px; font-size: 11px; }
.chat-form { margin: 0 18px 18px; padding: 7px 7px 7px 12px; display: grid; grid-template-columns: 1fr 38px; align-items: end; gap: 8px; border: 1px solid var(--line); border-radius: 8px; }
.chat-form:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 77, 0.12); }
.chat-form textarea { max-height: 120px; resize: none; padding: 8px 0; border: 0; outline: 0; background: transparent; font-size: 13px; }
.send-button { width: 38px; height: 38px; color: white; background: var(--green); border-radius: 6px; }
.send-button:disabled { opacity: 0.5; cursor: wait; }
.send-button svg { width: 18px; }

.overlay { position: fixed; z-index: 30; inset: 0; background: rgba(20, 28, 24, 0.26); }
.event-dialog { width: min(560px, calc(100vw - 28px)); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.event-dialog::backdrop { background: rgba(20, 28, 24, 0.34); }
.dialog-header { padding: 20px 22px; display: flex; align-items: start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 3px 0 0; font-size: 20px; }
.eyebrow { margin: 0; color: var(--green); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.form-body { padding: 22px; display: grid; gap: 17px; }
.form-body label { display: grid; gap: 7px; }
.form-body label > span { color: var(--muted); font-size: 12px; font-weight: 600; }
.form-body input, .form-body textarea { width: 100%; padding: 11px 12px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 6px; outline: none; }
.form-body input:focus, .form-body textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 77, 0.1); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-error { min-height: 18px; margin: 0; color: var(--red); font-size: 12px; }
.dialog-actions { padding: 15px 22px; display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--line); }
.action-spacer { flex: 1; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; max-width: calc(100vw - 30px); padding: 10px 14px; color: white; background: var(--ink); border-radius: 6px; font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: 160ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 700px) {
  .topbar { height: 64px; padding: 0 14px; }
  .topbar-actions { gap: 8px; }
  .timezone { display: none; }
  .button { min-height: 38px; padding: 0 11px; }
  .workspace { padding: 10px; }
  .calendar-shell { min-height: calc(100vh - 84px); padding: 10px; }
  .fc .fc-toolbar { align-items: flex-start; gap: 10px; }
  .fc .fc-toolbar-title { font-size: 18px; }
  .fc .fc-daygrid-day-frame { min-height: 68px; }
  .fc .fc-daygrid-day-number { padding: 6px; }
  .fc .fc-event { padding: 2px; font-size: 10px; }
  .agent-button { right: 16px; bottom: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .dialog-actions { flex-wrap: wrap; }
}

@media (max-width: 430px) {
  .topbar .button span { display: none; }
  .fc .fc-toolbar { flex-wrap: wrap; }
  .fc .fc-toolbar-chunk:nth-child(2) { order: -1; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
