/* ============================================================
   MarketingOS — Shell + shared components
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

/* The hidden attribute always wins — even over display rules like .field's flex */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
::placeholder { color: var(--ink-faint); }

:focus-visible {
  outline: 2px solid var(--sage-deep);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ---------- Shell layout ---------- */
.shell { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(178deg, var(--gunmetal) 0%, var(--gunmetal-2) 100%);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  padding: 26px 14px 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.logo {
  font-family: var(--font-logo);
  font-size: 34px;
  line-height: 1.1;
  color: var(--cream);
  text-decoration: none;
  padding: 2px 12px 14px;
  letter-spacing: .5px;
}

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9.5px 12px;
  border-radius: var(--r-sm);
  color: rgba(248, 246, 239, .78);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .1px;
  transition: background .18s ease, color .18s ease;
}

.nav-link svg {
  width: 19px; height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.nav-link:hover { background: rgba(248, 246, 239, .07); color: var(--cream); }

.nav-link.active {
  background: var(--sage);
  color: var(--gunmetal);
  font-weight: 600;
}

.sidebar-quote {
  margin: auto 10px 0;
  padding-top: 26px;
}

.sidebar-quote blockquote {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 15.5px;
  line-height: 1.5;
  color: rgba(248, 246, 239, .82);
}

.sidebar-quote blockquote::before {
  content: '\201C';
  display: block;
  font-size: 34px;
  line-height: .6;
  color: var(--rose);
  margin-bottom: 8px;
  font-style: normal;
}

.sidebar-quote figcaption {
  margin-top: 10px;
  font-family: var(--font-logo);
  font-size: 22px;
  color: var(--rose);
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--cream) 82%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line-soft);
}

.menu-btn {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: 0;
  padding: 8px;
}
.menu-btn span { width: 20px; height: 2px; background: var(--ink); border-radius: 2px; }

.topbar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 430px;
  background: var(--cream-card);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 8px 16px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.topbar-search:focus-within {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px var(--sage-mist);
}
.topbar-search svg {
  width: 16px; height: 16px;
  fill: none; stroke: var(--ink-faint); stroke-width: 1.6; stroke-linecap: round;
  flex-shrink: 0;
}
.topbar-search input {
  border: 0; outline: 0; background: none; width: 100%;
  font-size: 13.5px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.icon-btn {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--cream-card);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: border-color .18s ease;
}
.icon-btn:hover { border-color: var(--sage); }
.icon-btn svg {
  width: 18px; height: 18px;
  fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn.has-dot::after {
  content: '';
  position: absolute;
  top: 9px; right: 10px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--rose);
  border: 1.5px solid var(--cream);
}

.user-chip {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 3px;
  border-radius: var(--r-pill);
}
.user-chip .chev { width: 14px; height: 14px; fill: none; stroke: var(--ink-soft); stroke-width: 1.6; }

/* ---------- Avatars ---------- */
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--gunmetal);
  background: var(--sage-light);
  flex-shrink: 0;
  user-select: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }
.avatar.lg { width: 46px; height: 46px; font-size: 15px; }
.avatar-jo      { background: var(--sage); }
.avatar-rose    { background: var(--rose-light); color: var(--rose-deep); }
.avatar-sage    { background: var(--sage-light); color: var(--sage-ink); }
.avatar-cream   { background: #EFE9D8; color: #8A7F55; }
.avatar-gun     { background: #DEE1E3; color: var(--gunmetal); }

.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--cream-card); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- View container ---------- */
.view {
  padding: 26px var(--gutter) 48px;
  max-width: 1340px;
  width: 100%;
  margin: 0 auto;
  outline: none;
  animation: view-in .35s ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Page headers ---------- */
.page-head { margin-bottom: 24px; }

.greeting {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(28px, 3.4vw, 40px);
  letter-spacing: -.5px;
  line-height: 1.12;
}
.greeting .accent {
  font-style: italic;
  color: var(--sage-ink);
}
.greeting .spark { color: var(--rose); font-style: normal; }

.page-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(24px, 2.8vw, 32px);
  letter-spacing: -.4px;
}

.page-sub {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 14.5px;
}

.page-head-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- Cards ---------- */
.card {
  background: var(--cream-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .1px;
  margin-bottom: 4px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--sage-ink);
  text-decoration: none;
  white-space: nowrap;
}
.card-link:hover { text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: var(--r-pill);
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .1px;
  text-decoration: none;
  transition: filter .15s ease, background .15s ease;
}
.btn-primary { background: var(--sage); color: var(--gunmetal); }
.btn-primary:hover { filter: brightness(.96); }
.btn-dark { background: var(--gunmetal); color: var(--cream); }
.btn-dark:hover { filter: brightness(1.15); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--sage-deep); background: var(--sage-mist); }
.btn-rose { background: var(--rose); color: #fff; }
.btn-rose:hover { filter: brightness(.95); }
.btn.sm { padding: 6px 13px; font-size: 12.5px; }

/* ---------- Chips, badges, tags ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--r-pill);
  padding: 3.5px 11px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.badge-ai     { background: var(--rose-light); color: var(--rose-deep); }
.badge-sage   { background: var(--sage-light); color: var(--sage-ink); }
.badge-cream  { background: #F1EDDF; color: #8A7F55; }
.badge-gun    { background: #E4E6E7; color: var(--gunmetal); }
.badge-rose   { background: var(--rose); color: #fff; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--r-pill);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--sage-mist);
  color: var(--sage-ink);
}
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tag-rose  { background: var(--rose-light); color: var(--rose-deep); }
.tag-gun   { background: #E7E9EA; color: var(--gunmetal); }
.tag-cream { background: #F1EDDF; color: #8A7F55; }
.tag-warn  { background: #F3E7D3; color: #9A7434; }
.tag-lsage { background: var(--sage-light); color: var(--sage-ink); }
.tag-neutral { background: #E9E9E6; color: var(--ink-soft); }

/* Priority dots */
.prio { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.prio::before { content: ''; width: 8px; height: 8px; border-radius: 50%; }
.prio-high::before   { background: var(--rose); }
.prio-medium::before { background: var(--warn); }
.prio-low::before    { background: var(--sage); }

/* ---------- Progress bars ---------- */
.bar {
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--line-soft);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--sage);
  transition: width .8s cubic-bezier(.2, .7, .3, 1);
}
.bar > i.rose { background: var(--rose); }
.bar > i.warn { background: var(--warn); }
.bar > i.gun  { background: var(--gunmetal); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); letter-spacing: .2px; }
.input, select.input, textarea.input {
  background: var(--cream-card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 13px;
  font-size: 13.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-mist); }
textarea.input { resize: vertical; min-height: 90px; }

.select-pill {
  appearance: none;
  background: var(--cream-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='m1 1 4 4 4-4' stroke='%236B6F66' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 13px center;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 7px 32px 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.select-pill:hover { border-color: var(--sage); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink-faint);
  font-weight: 700;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s ease; }
.tbl tbody tr:hover { background: var(--sage-mist); }

/* ---------- Empty states ---------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
}
.empty .empty-title { font-family: var(--font-display); font-size: 19px; font-weight: 500; color: var(--ink); margin-bottom: 6px; }

/* ---------- Toasts ---------- */
.toast-region {
  position: fixed;
  bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--gunmetal);
  color: var(--cream);
  border-radius: var(--r-sm);
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .3s ease both;
}
.toast.sage-edge { border-left: 3px solid var(--sage); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(53, 57, 60, .4);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 150;
  padding: 20px;
  animation: fade-in .2s ease both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--cream);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px;
  animation: view-in .25s ease both;
}
.modal h3 { font-family: var(--font-display); font-size: 22px; font-weight: 500; margin-bottom: 16px; }
.modal .modal-grid { display: grid; gap: 14px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Botanical accent ---------- */
.botanical {
  position: absolute;
  right: 14px; bottom: 8px;
  width: 74px; height: 74px;
  opacity: .5;
  pointer-events: none;
}
.botanical path { fill: none; stroke: var(--sage-deep); stroke-width: 1.3; stroke-linecap: round; }
.botanical.rose path { stroke: var(--rose); }

/* ---------- Responsive shell ---------- */
@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .28s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: flex; }
  .topbar-search { max-width: none; }
}
