:root {
  --cream: #fbf7ef;
  --mist: #ece8ef;
  --lavender: #c9b7dc;
  --lavender-deep: #7f6592;
  --plum: #51394f;
  --charcoal: #242229;
  --gray: #68616d;
  --line: #ded6e4;
  --success: #35765f;
  --warning: #a9673f;
  --danger: #a74455;
  --card: #fffdf8;
  --shadow: 0 18px 48px rgba(47, 38, 53, 0.14);
  --radius: 8px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--cream), #f2eef5 52%, #e8e5e9);
  color: var(--charcoal);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea { font: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 3px solid #6d547f;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 50;
  padding: 0.75rem 1rem;
  background: var(--charcoal);
  color: #fff;
  border-radius: var(--radius);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.is-hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-shell {
  width: min(100%, 980px);
  min-height: min(720px, calc(100vh - 2.5rem));
  display: grid;
  align-items: center;
  background:
    linear-gradient(rgba(36, 34, 41, 0.48), rgba(36, 34, 41, 0.38)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 800'%3E%3Crect fill='%239784a8' width='1200' height='800'/%3E%3Cpath fill='%23f8f1e7' opacity='.6' d='M0 640c180-80 314-63 459-104 223-64 315-237 551-212 93 10 153 46 190 78v398H0z'/%3E%3Cpath fill='%2351394f' opacity='.24' d='M0 0h1200v280c-102 35-207 45-333 12C618 227 520 86 315 103 179 114 78 178 0 249z'/%3E%3Ccircle cx='899' cy='221' r='150' fill='%23d9c9e8' opacity='.55'/%3E%3Ccircle cx='281' cy='526' r='96' fill='%237f6592' opacity='.28'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-panel {
  width: min(100%, 450px);
  margin: 1rem;
  padding: clamp(1.4rem, 4vw, 2.5rem);
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
}

.eyebrow,
.card-label {
  margin: 0 0 0.35rem;
  color: var(--lavender-deep);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p { overflow-wrap: anywhere; }

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 { font-size: clamp(2rem, 8vw, 3.35rem); }
h2 { font-size: clamp(1.4rem, 4vw, 2rem); }
h3 { font-size: 1.08rem; }

.login-copy,
.section-note,
.card p,
.project-notes p,
.details-panel p { color: var(--gray); }

.demo-note {
  padding: 0.85rem 1rem;
  background: #f5eff8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--plum);
  font-weight: 700;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field.full { grid-column: 1 / -1; }

label {
  color: var(--charcoal);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfc6d6;
  border-radius: var(--radius);
  background: #fff;
  color: var(--charcoal);
  padding: 0.78rem 0.85rem;
}

textarea { resize: vertical; }

.error {
  min-height: 1.1rem;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}

.login-actions,
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.primary-button,
.secondary-button,
.ghost-button,
.text-button,
.icon-button,
.resource-card {
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  background: var(--plum);
  color: #fff;
  border-color: var(--plum);
  padding: 0.78rem 1rem;
  font-weight: 800;
}

.secondary-button,
.ghost-button {
  background: #fff;
  color: var(--plum);
  border-color: var(--line);
  padding: 0.78rem 1rem;
  font-weight: 800;
}

.text-button {
  background: transparent;
  color: var(--plum);
  border: 0;
  padding: 0;
  min-height: 0;
  font-weight: 800;
  text-decoration: underline;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.resource-card:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(47, 38, 53, 0.12);
}

.app-view {
  min-height: 100vh;
  padding-bottom: 5.5rem;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: rgba(251, 247, 239, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.app-header h1 { font-size: clamp(1.35rem, 4vw, 2.1rem); }

.portal-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #fffdf8;
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px rgba(47, 38, 53, 0.1);
}

.portal-nav a {
  color: var(--gray);
  padding: 0.8rem 0.25rem;
  text-align: center;
  text-decoration: none;
  font-size: clamp(0.68rem, 2vw, 0.82rem);
  font-weight: 800;
}

.portal-nav a[aria-current="page"] {
  color: var(--plum);
  background: #f3edf7;
}

.dashboard {
  display: grid;
  gap: 1rem;
  width: min(1180px, calc(100% - 2rem));
  margin: 1rem auto;
}

.section,
.project-notes {
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 1.5rem);
  box-shadow: 0 12px 32px rgba(47, 38, 53, 0.08);
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-grid,
.resource-grid,
.saved-list,
.tracker {
  display: grid;
  gap: 1rem;
}

.card,
.details-panel,
.request-item,
.tracker-card,
.message {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

.next-card {
  background: linear-gradient(135deg, #fffdf8, #f1e9f7);
}

.calendar-controls {
  display: grid;
  grid-template-columns: 44px minmax(8rem, 1fr) 44px;
  align-items: center;
  gap: 0.5rem;
}

.calendar-controls p {
  margin: 0;
  text-align: center;
  font-weight: 800;
  color: var(--plum);
}

.icon-button {
  width: 44px;
  height: 44px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--plum);
  font-weight: 900;
}

.calendar-layout {
  display: grid;
  gap: 1rem;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  color: var(--gray);
  font-size: 0.9rem;
  font-weight: 700;
}

.dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.3rem;
  border-radius: 50%;
}

.consultation { background: #7f6592; }
.review { background: #35765f; }
.session { background: #a9673f; }
.followup { background: #596f93; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
}

.weekday {
  color: var(--gray);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.date-button {
  aspect-ratio: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--charcoal);
  font-weight: 800;
}

.date-button.muted {
  color: #9b949f;
  background: #f6f3f0;
}

.date-button.has-appointment {
  color: #fff;
  border-color: transparent;
}

.date-button.is-selected {
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--plum);
}

.portal-form {
  display: grid;
  gap: 0 1rem;
}

.status-message {
  min-height: 1.4rem;
  color: var(--success);
  font-weight: 800;
}

.request-item h3,
.tracker-card h3,
.message p { margin: 0; }

.tracker-card {
  position: relative;
  border-left: 8px solid #cbc3d1;
}

.tracker-card.complete { border-left-color: var(--success); }
.tracker-card.current { border-left-color: var(--warning); background: #fff8f0; }
.tracker-card.upcoming { opacity: 0.72; }

.message-thread {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.message {
  max-width: 760px;
}

.message.client {
  margin-left: auto;
  background: #f2edf6;
}

.message strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--plum);
}

.reply-form {
  display: grid;
  gap: 0.5rem;
}

.resource-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.resource-card {
  min-height: 130px;
  display: grid;
  align-content: space-between;
  text-align: left;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--charcoal);
  font-weight: 900;
}

.resource-card span {
  color: var(--lavender-deep);
  font-size: 0.9rem;
}

.project-notes {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto 1rem;
}

.project-notes h2 {
  font-size: 1.15rem;
}

@media (min-width: 720px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .saved-list { grid-template-columns: repeat(2, 1fr); }
  .portal-form { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 940px) {
  .app-view {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    padding-bottom: 0;
  }

  .app-header {
    grid-column: 1 / -1;
    padding: 1.1rem 1.5rem;
  }

  .portal-nav {
    position: sticky;
    top: 87px;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    height: calc(100vh - 87px);
    padding: 1rem;
    border-top: 0;
    border-right: 1px solid var(--line);
    box-shadow: none;
  }

  .portal-nav a {
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    text-align: left;
    font-size: 0.95rem;
  }

  .dashboard {
    width: min(100% - 2rem, 1180px);
    margin: 1rem;
  }

  .calendar-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .tracker { grid-template-columns: repeat(3, 1fr); }

  .project-notes {
    grid-column: 2;
    width: min(100% - 2rem, 1180px);
    margin: 0 1rem 1rem;
  }
}

@media (max-width: 520px) {
  .section-heading {
    display: grid;
  }

  .calendar-controls {
    width: 100%;
  }

  .calendar-grid {
    gap: 0.25rem;
  }

  .date-button {
    font-size: 0.84rem;
  }
}

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