:root {
  --gold: #9d7e52;
  --off-white: #ebe7de;
  --fendi: #cbc2b7;
  --gray: #999999;
  --charcoal: #15130f;
  --ink: #211d17;
  --paper: #f4f0e8;
  --surface: #fffaf1;
  --surface-deep: #e8dfd2;
  --line: rgba(33, 29, 23, 0.12);
  --line-dark: rgba(235, 231, 222, 0.16);
  --shadow: 0 28px 70px rgba(60, 47, 31, 0.16);
  --motion: 520ms cubic-bezier(0.32, 0.72, 0, 1);
  font-family: "Averta", "Satoshi", "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(33, 29, 23, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(33, 29, 23, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 70%);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.75'/%3E%3C/svg%3E");
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

.app-shell {
  width: min(100%, 1760px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  min-height: 100dvh;
  max-width: 100%;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 24px 20px;
  background:
    linear-gradient(180deg, rgba(157, 126, 82, 0.14), transparent 34%),
    var(--charcoal);
  color: var(--off-white);
  display: flex;
  flex-direction: column;
  gap: 26px;
  border-right: 1px solid var(--line-dark);
  min-width: 0;
}

.brand-lockup {
  color: inherit;
  text-decoration: none;
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 14px;
}

.brand-emblem {
  width: 74px;
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  color: var(--gold);
  border: 1px solid rgba(235, 231, 222, 0.32);
  background:
    radial-gradient(circle at 50% 18%, rgba(235, 231, 222, 0.13), transparent 56%),
    rgba(235, 231, 222, 0.03);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.brand-emblem img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.brand-m,
.brand-p,
.brand-stamp span {
  font-family: "IvyPresto Display", "Didot", Georgia, serif;
  line-height: 0.8;
}

.brand-m { font-size: 38px; transform: translateX(-5px); }
.brand-p { position: absolute; font-size: 44px; transform: translate(11px, 12px); font-style: italic; }
.brand-word { display: block; font-size: 21px; font-weight: 500; }
.brand-subtitle { display: block; margin-top: 5px; color: rgba(235, 231, 222, 0.58); font-size: 12px; letter-spacing: 0.04em; }

.eyebrow {
  margin: 0 0 9px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 10px;
  font-weight: 800;
}

h1, h2, h3, h4, p { margin-top: 0; }

.nav-list { display: grid; gap: 7px; }

.nav-item {
  min-height: 48px;
  border: 1px solid transparent;
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  color: rgba(235, 231, 222, 0.70);
  background: transparent;
  text-align: left;
  transition: transform var(--motion), color var(--motion), background var(--motion), border-color var(--motion);
  min-width: 0;
}

.nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover,
.nav-item.active {
  color: var(--off-white);
  background: rgba(235, 231, 222, 0.08);
  border-color: rgba(157, 126, 82, 0.42);
}

.nav-item svg,
.topbar svg,
.section-heading svg,
.primary-action svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.7;
}

.sidebar-note {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line-dark);
  background: rgba(235, 231, 222, 0.06);
}

.sidebar-note p {
  margin: 5px 0 0;
  color: rgba(235, 231, 222, 0.58);
  font-size: 12px;
  line-height: 1.45;
}

.sidebar-note {
  margin-top: auto;
  grid-template-columns: 11px 1fr;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.9s infinite;
}

.main-panel {
  min-width: 0;
  max-width: 100%;
  padding: 26px clamp(18px, 2vw, 34px) 34px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, auto);
  gap: 22px;
  align-items: end;
  margin-bottom: 22px;
  min-width: 0;
}

.topbar h1 {
  max-width: 850px;
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 58px);
  line-height: 0.96;
  font-weight: 520;
  letter-spacing: 0;
  text-wrap: balance;
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.search-box {
  width: min(430px, 100%);
  min-height: 50px;
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 11px;
  padding: 0 15px;
  border: 1px solid rgba(33, 29, 23, 0.16);
  background: rgba(255, 250, 241, 0.84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.search-box input {
  border: 0;
  outline: 0;
  background: transparent;
  min-width: 0;
  color: var(--ink);
}

.primary-action {
  min-height: 50px;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px 0 20px;
  color: var(--off-white);
  background: var(--charcoal);
  transition: transform var(--motion), background var(--motion);
  white-space: nowrap;
}

.primary-action svg {
  width: 29px;
  height: 29px;
  padding: 7px;
  background: rgba(235, 231, 222, 0.10);
}

.primary-action:hover { background: #2a251f; transform: translateY(-1px); }
.nav-item:active, .primary-action:active, .icon-button:active { transform: translateY(1px) scale(0.99); }

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 252px;
  gap: 16px;
  margin-bottom: 16px;
}

.today-board {
  min-height: 218px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: clamp(20px, 2vw, 28px);
  overflow: hidden;
  background: rgba(255, 250, 241, 0.9);
  border: 1px solid rgba(33, 29, 23, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.today-board h2 {
  max-width: 660px;
  margin-bottom: 18px;
  font-size: clamp(32px, 4.8vw, 56px);
  line-height: 0.98;
  font-weight: 560;
  letter-spacing: 0;
  text-wrap: balance;
}

.today-board p:not(.eyebrow) {
  max-width: 62ch;
  color: rgba(33, 29, 23, 0.66);
  line-height: 1.68;
  font-size: 16px;
}

.today-actions {
  display: grid;
  gap: 16px;
  min-width: 190px;
}

.secondary-action {
  min-height: 46px;
  border: 1px solid rgba(33, 29, 23, 0.16);
  background: rgba(235, 231, 222, 0.42);
  color: var(--ink);
  padding: 0 16px;
  transition: transform var(--motion), background var(--motion);
}

.secondary-action:hover { background: rgba(203, 194, 183, 0.55); transform: translateY(-1px); }

.metric-strip {
  display: grid;
  gap: 10px;
}

.metric-strip article,
.panel {
  border: 1px solid rgba(33, 29, 23, 0.13);
  background: rgba(255, 250, 241, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.metric-strip article {
  min-height: 94px;
  padding: 18px;
  display: grid;
  align-content: end;
}

.metric-strip span,
.detail-grid span,
.timeline-time,
.client-meta,
.follow-list span {
  color: rgba(33, 29, 23, 0.50);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-strip strong {
  margin-top: 7px;
  font-size: 31px;
  line-height: 1;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}

.metric-strip small { margin-top: 7px; color: var(--gold); }

.operations-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.08fr) minmax(300px, 0.78fr);
  gap: 16px;
  align-items: start;
}

.clients-panel { grid-column: 1 / 2; }
.follow-panel { grid-column: 2 / 3; }

.panel {
  padding: clamp(18px, 2vw, 24px);
}

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

.section-heading h3 {
  margin: 0;
  font-size: clamp(21px, 2vw, 27px);
  line-height: 1.05;
  font-weight: 570;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(235, 231, 222, 0.44);
  transition: transform var(--motion), background var(--motion);
}

.icon-button:hover { background: rgba(203, 194, 183, 0.56); transform: translateY(-1px); }

.segmented-control {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line);
  background: rgba(235, 231, 222, 0.24);
}

.segmented-control button {
  border: 0;
  min-height: 38px;
  padding: 0 12px;
  color: rgba(33, 29, 23, 0.62);
  background: transparent;
}

.segmented-control button.active {
  color: var(--off-white);
  background: var(--charcoal);
}

.timeline,
.client-list,
.follow-list {
  display: grid;
  gap: 10px;
}

.timeline-item,
.client-row,
.follow-row {
  display: grid;
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(33, 29, 23, 0.09);
  background: rgba(255, 250, 241, 0.72);
  transition: transform var(--motion), border-color var(--motion), background var(--motion);
}

.timeline-item { grid-template-columns: 70px 1fr auto; padding: 13px; }
.client-row { grid-template-columns: 58px minmax(0, 1fr) auto; padding: 12px; text-align: left; width: 100%; }
.follow-row { grid-template-columns: 1fr auto; padding: 14px; }

.timeline-item:hover,
.client-row:hover,
.follow-row:hover {
  transform: translateY(-2px);
  border-color: rgba(157, 126, 82, 0.34);
  background: var(--surface);
}

.client-avatar {
  width: 58px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(157, 126, 82, 0.25);
  background: rgba(157, 126, 82, 0.12);
  color: var(--gold);
  font-weight: 800;
}

.client-row h4,
.timeline-item h4,
.follow-row h4 {
  margin: 0 0 5px;
  font-size: 16px;
}

.client-row p,
.timeline-item p,
.profile-card p,
.follow-row p {
  margin: 0;
  color: rgba(33, 29, 23, 0.62);
  line-height: 1.45;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(157, 126, 82, 0.24);
  color: #674f2f;
  background: rgba(157, 126, 82, 0.10);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.status-pill.confirmed { color: #534025; background: rgba(157, 126, 82, 0.18); }
.status-pill.alert { color: #7b4b32; background: rgba(157, 126, 82, 0.08); }

.profile-card {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 16px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.profile-initials {
  width: 118px;
  aspect-ratio: 0.9;
  display: grid;
  place-items: center;
  border: 1px solid rgba(157, 126, 82, 0.34);
  background: rgba(157, 126, 82, 0.12);
  color: var(--gold);
  font-size: 34px;
  font-weight: 800;
}

.profile-card .status-pill { margin-bottom: 10px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.detail-grid div {
  min-height: 82px;
  padding: 13px;
  background: rgba(235, 231, 222, 0.44);
}

.detail-grid strong {
  display: block;
  margin-top: 9px;
  font-weight: 620;
}

.crm-dialog {
  position: relative;
  width: min(820px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

.crm-dialog::backdrop { background: rgba(21, 19, 15, 0.58); backdrop-filter: blur(5px); }

.dialog-card,
.drawer-panel {
  position: relative;
  padding: 28px;
  background: var(--surface);
  border: 1px solid rgba(235, 231, 222, 0.70);
  box-shadow: var(--shadow);
}

.dialog-close {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(235, 231, 222, 0.70);
}

.dialog-summary {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.dialog-summary .profile-initials {
  width: 112px;
  aspect-ratio: 1;
}

.dialog-card h3,
.drawer-panel h3 {
  margin: 0 0 12px;
  font-size: 34px;
  line-height: 1;
}

.dialog-note {
  margin: 18px 0 0;
  color: rgba(33, 29, 23, 0.68);
  line-height: 1.6;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  justify-items: end;
  background: rgba(21, 19, 15, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion);
}

.drawer.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  width: min(460px, 100vw);
  min-height: 100dvh;
  transform: translateX(28px);
  transition: transform var(--motion);
}

.drawer.open .drawer-panel { transform: translateX(0); }

.appointment-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.appointment-form label {
  display: grid;
  gap: 7px;
  color: rgba(33, 29, 23, 0.72);
  font-size: 13px;
  font-weight: 700;
}

.appointment-form input,
.appointment-form select,
.appointment-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.92);
  padding: 12px;
  outline: 0;
}

.appointment-form textarea { min-height: 112px; resize: vertical; }

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

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(157, 126, 82, 0.35); }
  50% { transform: scale(1.12); box-shadow: 0 0 0 7px rgba(157, 126, 82, 0); }
}

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: minmax(230px, 1fr) minmax(0, 2fr);
    align-items: center;
  }
  .nav-list { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .sidebar-note { display: none; }
  .topbar,
  .overview-grid,
  .operations-grid { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .clients-panel,
  .follow-panel { grid-column: auto; }
}

@media (max-width: 820px) {
  .main-panel { padding: 16px; }
  .sidebar { grid-template-columns: 1fr; }
  .brand-lockup { grid-template-columns: 58px 1fr; }
  .brand-emblem { width: 58px; }
  .brand-m { font-size: 30px; }
  .brand-p { font-size: 35px; }
  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
  .nav-item { min-width: 0; }
  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }
  .search-box { width: 100%; }
  .today-board { grid-template-columns: 1fr; min-height: auto; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .timeline-item,
  .client-row,
  .follow-row { grid-template-columns: 1fr; }
  .profile-card,
  .dialog-summary { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .section-heading { display: grid; }
  .segmented-control { width: 100%; grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 520px) {
  .app-shell,
  .sidebar,
  .main-panel {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .topbar,
  .overview-grid,
  .today-board,
  .operations-grid,
  .panel,
  .metric-strip {
    max-width: 100%;
    min-width: 0;
  }
  .nav-list { grid-template-columns: 1fr; }
  .topbar h1 {
    max-width: calc(100vw - 48px);
    font-size: 24px;
    line-height: 1.08;
  }
  .today-board { padding: 22px; }
  .today-board h2 { font-size: 32px; line-height: 0.98; }
  .today-board p:not(.eyebrow) {
    max-width: 280px;
    font-size: 14px;
  }
  .metric-strip { grid-template-columns: 1fr; }
}
