/* Maati Living skin (v2): the look on top of app.css.
   Calm, rounded cards on warm cream (day) or Kumaon night blue (dark), editorial serif headings,
   a floating bottom bar on phones, one main action per row with the rest under "⋯".
   Sections: base · loading screen · layout · navigation · components · Today · OTA · connections · motion */

/* ---------- Base ---------- */
body { background: var(--bg); transition: background-color var(--t) var(--ease); }
h1, h2, .page-title, .today-greeting, .modal .panel-title, .sheet .panel-title { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.015em; }
.page-title { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.375rem); }
.panel-title { font-family: var(--font); font-weight: 650; letter-spacing: -0.005em; }
a { text-underline-offset: 3px; }
::selection { background: color-mix(in srgb, var(--primary) 25%, transparent); }

/* ---------- Loading screen ---------- */
.splash {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: var(--sky); overflow: hidden;
  transition: opacity 480ms var(--ease), visibility 0s linear 480ms;
}
.splash-scene { position: absolute; inset: auto 0 0 0; width: 100%; height: 72vh; }
.sc-sky { fill: var(--sky); }
.sc-sun { fill: var(--sun); }
.sc-moon-cut { fill: var(--sky); display: none; }
.sc-stars { fill: #fff; display: none; }
.sc-r1 { fill: var(--ridge-1); }
.sc-r2 { fill: var(--ridge-2); }
.sc-r3 { fill: var(--ridge-3); }
.sc-r4 { fill: var(--ridge-4); }
[data-theme="dark"] .sc-moon-cut, [data-theme="dark"] .sc-stars { display: inline; }
.splash-brand { position: relative; z-index: 1; display: grid; justify-items: center; gap: 2px; margin-bottom: 30vh; color: var(--hero-text); }
.splash-name { font-family: var(--font-display); font-size: clamp(2rem, 1.4rem + 3vw, 3rem); font-weight: 600; letter-spacing: -0.02em; }
.splash-sub { font-size: var(--fs-xs); letter-spacing: 0.32em; text-transform: uppercase; color: var(--hero-muted); }
.splash-bar { margin-top: var(--s4); width: 120px; height: 3px; border-radius: 3px; background: color-mix(in srgb, var(--hero-text) 14%, transparent); overflow: hidden; }
.splash-bar span { display: block; width: 40%; height: 100%; border-radius: inherit; background: var(--hero-text); opacity: 0.7; }
html.app-ready .splash { opacity: 0; visibility: hidden; pointer-events: none; }

@media (prefers-reduced-motion: no-preference) {
  .sc-r1, .sc-r2, .sc-r3, .sc-r4 { transform-box: fill-box; animation: rise 900ms var(--ease-out) both; }
  .sc-r1 { animation-delay: 60ms; }
  .sc-r2 { animation-delay: 160ms; }
  .sc-r3 { animation-delay: 260ms; }
  .sc-r4 { animation-delay: 320ms; }
  .sc-sun-wrap { animation: sunrise 1300ms var(--ease-out) 380ms both; }
  .sc-stars circle { animation: twinkle 2.4s ease-in-out infinite; }
  .sc-stars circle:nth-child(2n) { animation-delay: 0.8s; }
  .sc-stars circle:nth-child(3n) { animation-delay: 1.5s; }
  .splash-brand { animation: fade-up 700ms var(--ease-out) 520ms both; }
  .splash-bar span { animation: bar 1.1s var(--ease) infinite; }
}
@keyframes rise { from { transform: translateY(40%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sunrise { from { transform: translateY(70px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes twinkle { 50% { opacity: 0.25; } }
@keyframes fade-up { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bar { from { transform: translateX(-110%); } to { transform: translateX(260%); } }

/* Sign-in and setup pages share the scenery feel. */
.auth, .fullpage { background: var(--bg); }

/* ---------- Layout ---------- */
.workspace { padding-bottom: calc(var(--bottomnav-h) + 28px + env(safe-area-inset-bottom)); }
.main { padding: var(--s4) var(--s4) var(--s6); }
@media (min-width: 900px) { .main { padding: var(--s6) var(--s6) var(--s7); } }

.topbar {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color var(--t) var(--ease);
}
html.scrolled .topbar { border-bottom-color: var(--border); }
.brand-mark { border-radius: 10px; }
.avatar { background: var(--primary); color: var(--on-primary); }
.avatar-button { padding: 0; border: 0; background: none; cursor: pointer; border-radius: var(--r-pill); }

/* Phones: logo, then search as an icon, Ask, bell and you. The workspace switcher lives in your menu. */
@media (max-width: 599px) {
  .topbar { gap: var(--s2); padding: 0 var(--s3); }
  .topbar-actions > .tenant-select { display: none; }
  .search { flex: 0 0 40px; max-width: 40px; transition: max-width var(--t) var(--ease), flex-basis var(--t) var(--ease); }
  .search-input { padding-right: 0; color: transparent; background: transparent; border-color: transparent; cursor: pointer; }
  .search-input::placeholder { color: transparent; }
  .search:focus-within { flex: 1 1 auto; max-width: none; }
  .search:focus-within .search-input { color: var(--text); background: var(--surface); border-color: var(--border); cursor: text; padding-right: var(--s3); }
  .search:focus-within .search-input::placeholder { color: var(--text-muted); }
  .search:focus-within ~ .topbar-actions { display: none; }
  .topbar-spacer { display: block; flex: 1; }
}
.menu-tenant { padding: var(--s2) var(--s3); display: grid; gap: 6px; }
.menu-tenant .input { min-height: 38px; }
@media (min-width: 600px) { .menu-tenant { display: none; } }

/* ---------- Sidebar (desktop) ---------- */
.sidebar { background: var(--surface); border-right: 1px solid var(--border); }
.nav-link { border-radius: var(--r-pill); min-height: 40px; }
.nav-link[aria-current="page"] { background: var(--primary); color: var(--on-primary); }
.nav-link[aria-current="page"] .icon { color: var(--on-primary); }
.nav-group-label { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; }

/* ---------- Bottom bar (phones): a floating pill ---------- */
.bottom-nav {
  left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
  height: var(--bottomnav-h); padding: 6px; gap: 2px;
  border: 0; border-radius: var(--r-pill); background: var(--ink-pill); box-shadow: var(--shadow-float);
}
.bottom-link {
  border-radius: var(--r-pill); color: color-mix(in srgb, var(--on-ink-pill) 66%, transparent);
  font-size: 10.5px; letter-spacing: 0.01em; transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.bottom-link[aria-current="page"] { background: var(--surface-raised); color: var(--text); }
[data-theme="dark"] .bottom-link[aria-current="page"] { background: var(--primary); color: var(--on-primary); }
.bottom-link:active { transform: scale(0.96); }
.sheet { background: var(--surface); }
.sheet::backdrop, .modal::backdrop { background: rgb(13 24 40 / 0.45); backdrop-filter: blur(2px); }

/* ---------- Components ---------- */
.panel { border: 0; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.panel .panel { box-shadow: none; border: 1px solid var(--border); }
.panel-head { padding: var(--s5) var(--s5) 0; }
.stack { gap: var(--s5); }
.grid-2 { gap: var(--s5); }

.btn {
  min-height: 42px; padding: 0 18px; border-radius: var(--r-pill);
  border-color: var(--border); background: var(--surface-raised);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn:hover { background: var(--surface-sunken); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 28%, transparent); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--surface-raised); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-quiet { background: transparent; border-color: transparent; }
.btn-sm { min-height: 34px; padding: 0 14px; }
.row-actions .btn { min-height: 36px; padding: 0 14px; }
.icon-button { transition: background var(--t-fast) var(--ease); }

.input { min-height: 44px; border-radius: 12px; border-color: var(--border); background: var(--surface-raised); transition: border-color var(--t-fast) var(--ease); }
.input:hover { border-color: var(--border-strong); }
textarea.input { padding-top: 10px; padding-bottom: 10px; }
.chip { border-radius: var(--r-pill); }
.badge { border-radius: var(--r-pill); }
.status { background: var(--surface-raised); }

.notice { border-radius: var(--r-md); }
.empty { border: 1px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-sunken); }
.modal { border: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-overlay); }
.modal-head, .modal-foot { border-color: var(--border); }
@media (max-width: 599px) {
  /* Dialogs become bottom sheets on phones. */
  .modal { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: env(safe-area-inset-bottom); }
}

/* Stats: compact tiles that sit in one row on phones. */
.stats { gap: var(--s2); }
.stat { border: 0; border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-card); padding: var(--s3) var(--s4); }
.stat-value { font-family: var(--font-display); font-weight: 600; }
.stats-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 599px) {
  .stats-4 .stat { padding: var(--s2) var(--s3); }
  .stats-4 .stat-label { font-size: 11px; line-height: 1.25; }
  .stats-4 .stat-value { font-size: var(--fs-lg); }
}

/* Skeleton shimmer follows the theme. */
.skeleton-line { background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--border) 50%, var(--surface-sunken) 100%); background-size: 200% 100%; }

/* Theme switch (account menu) */
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin: var(--s2) var(--s3); border-radius: var(--r-pill); background: var(--surface-sunken); }
.theme-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.theme-switch button[aria-pressed="true"] { background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-card); }
.menu { border: 0; border-radius: var(--r-lg); background: var(--surface-raised); box-shadow: var(--shadow-overlay); min-width: 260px; }
.menu-item { border-radius: var(--r-sm); }

/* "⋯" overflow menu: rows keep one main action, the rest fold in here. */
.overflow { position: relative; display: inline-block; }
.overflow > summary { list-style: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface-raised); color: var(--text-muted); cursor: pointer; }
.overflow > summary::-webkit-details-marker { display: none; }
.overflow > summary:hover { color: var(--text); border-color: var(--border-strong); }
.overflow[open] > summary { color: var(--text); background: var(--surface-sunken); }
.overflow-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 210px; max-width: 78vw;
  display: grid; gap: 2px; padding: 6px; border-radius: var(--r-md); background: var(--surface-raised); box-shadow: var(--shadow-overlay);
}
.overflow-menu .btn, .overflow-menu .link-button {
  justify-content: flex-start; width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); box-shadow: none; font-weight: 550; text-decoration: none;
}
.overflow-menu .btn:hover, .overflow-menu .link-button:hover { background: var(--surface-sunken); text-decoration: none; }
.overflow-menu .btn-danger { color: var(--danger); }
.overflow-up .overflow-menu { top: auto; bottom: calc(100% + 6px); }
.overflow-left .overflow-menu { right: auto; left: 0; }

/* ---------- Today ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); min-height: 250px;
  background: var(--sky); box-shadow: var(--shadow-card); isolation: isolate;
}
.hero-scene { position: absolute; inset: auto 0 0 0; width: 100%; height: 78%; z-index: -1; }
.hero-text { padding: var(--s5) var(--s5) 0; color: var(--hero-text); max-width: 34ch; }
.hero-date { font-size: var(--fs-sm); color: var(--hero-muted); font-weight: 550; }
.hero-greeting { margin-top: 2px; font-family: var(--font-display); font-size: clamp(1.75rem, 1.2rem + 2.6vw, 2.6rem); line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; }
.hero-next {
  position: relative; margin: -36px var(--s4) 0; z-index: 1; display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); border-radius: var(--r-lg); background: var(--surface-raised); box-shadow: var(--shadow-float);
}
.hero-next-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); }
.hero-next-label { font-size: var(--fs-xs); color: var(--accent); font-weight: 650; }
.hero-next-title { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.hero-next > div { min-width: 0; flex: 1; }
.hero-next .btn { flex: none; }
@media (min-width: 900px) { .hero { min-height: 300px; } .hero-text { padding: var(--s6) var(--s6) 0; } .hero-next { max-width: 520px; margin-left: var(--s6); } }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-day {
  display: grid; justify-items: center; gap: 2px; padding: 10px 0; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); text-decoration: none; font-size: var(--fs-xs);
}
.week-day b { font-size: var(--fs-md); color: var(--text); font-family: var(--font-num); font-weight: 600; }
.week-day[aria-current="date"] { background: var(--ink-pill); border-color: var(--ink-pill); color: var(--on-ink-pill); }
.week-day[aria-current="date"] b { color: var(--on-ink-pill); }
[data-theme="dark"] .week-day[aria-current="date"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
[data-theme="dark"] .week-day[aria-current="date"] b { color: var(--on-primary); }

.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
@media (min-width: 900px) { .quick { grid-template-columns: repeat(4, 1fr); } }
.quick-tile {
  display: grid; gap: var(--s2); align-content: space-between; min-height: 112px; padding: var(--s4);
  border-radius: var(--r-lg); text-decoration: none; color: var(--text); background: var(--surface); box-shadow: var(--shadow-card);
  transition: transform var(--t-fast) var(--ease);
}
.quick-tile:active { transform: scale(0.98); }
.quick-tile .icon { width: 22px; height: 22px; color: var(--tile-ink, var(--primary)); }
.quick-tile b { font-size: var(--fs-md); }
.quick-tile small { display: block; margin-top: 2px; color: var(--text-muted); font-size: var(--fs-xs); }
.quick-tile.t1 { background: #e3e8d8; --tile-ink: #3d5233; }
.quick-tile.t2 { background: #f6e3d6; --tile-ink: #b0532a; }
.quick-tile.t3 { background: #f4ead2; --tile-ink: #8a5a00; }
.quick-tile.t4 { background: #e0eaf3; --tile-ink: #2d5f8b; }
[data-theme="dark"] .quick-tile.t1 { background: #18301f; --tile-ink: #9fd3a8; }
[data-theme="dark"] .quick-tile.t2 { background: #36221c; --tile-ink: #f0a184; }
[data-theme="dark"] .quick-tile.t3 { background: #33291c; --tile-ink: #e9a35b; }
[data-theme="dark"] .quick-tile.t4 { background: #142d48; --tile-ink: #8ab8e0; }
.section-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; }

/* ---------- OTA tracker ---------- */
.ota-list { padding: var(--s1) var(--s2); }
.ota-row { padding: var(--s3) var(--s3); border-radius: var(--r-md); border-top: 0; flex-wrap: nowrap; cursor: pointer; transition: background var(--t-fast) var(--ease); }
.ota-row + .ota-row { box-shadow: 0 -1px 0 var(--border); }
.ota-row:hover { background: var(--surface-sunken); }
.ota-row .person-main { flex: 1 1 auto; }
.ota-logo { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--surface-sunken); color: var(--text-muted); font-weight: 700; font-size: var(--fs-sm); }
.ota-row .chev { color: var(--text-muted); }
.ota-sheet { display: grid; gap: var(--s4); min-width: 0; }
.ota-sheet > *, .ota-sheet-actions > * { min-width: 0; }
.modal-body { overflow-x: hidden; }
.ota-sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.ota-sheet-actions .btn { width: 100%; }
.ota-sheet-actions .btn:first-child { grid-column: 1 / -1; }
.ota-link-box { min-width: 0; display: flex; gap: var(--s2); align-items: center; padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--surface-sunken); font-size: var(--fs-xs); color: var(--text-muted); }
.ota-link-box code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ota-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }

/* ---------- Connections ---------- */
.connections { display: grid; gap: var(--s3); }
@media (min-width: 700px) { .connections { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } }
.conn {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-card);
}
.conn-logo { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: #fff; font-weight: 700; font-size: 15px; }
.conn-logo.meta { background: #1877f2; }
.conn-logo.google_ads { background: #188038; }
.conn-logo.google_business { background: #1a73e8; }
.conn-logo.aiosell { background: #e8590c; }
.conn-name { font-weight: 650; }
.conn-state { font-size: var(--fs-xs); color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.conn-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.conn.is-saved .conn-state::before { background: var(--warning); }
.conn.is-live .conn-state::before { background: var(--success); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .view-enter { animation: view-in 360ms var(--ease-out) both; }
  .modal[open] { animation: pop-in 260ms var(--ease-out); }
  .overflow[open] .overflow-menu, .menu:not([hidden]) { animation: pop-in 180ms var(--ease-out); transform-origin: top right; }
  .hero-scene path { transform-box: fill-box; animation: rise 900ms var(--ease-out) both; }
  .hero-scene path:nth-of-type(2) { animation-delay: 80ms; }
  .hero-scene path:nth-of-type(3) { animation-delay: 160ms; }
  .hero-scene path:nth-of-type(4) { animation-delay: 220ms; }
  .hero-scene .sc-sun-wrap { animation: sunrise 1200ms var(--ease-out) 200ms both; }
  .hero-next { animation: fade-up 500ms var(--ease-out) 260ms both; }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 599px) {
  .modal[open] { animation: sheet-up 320ms var(--ease-out); }
}
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.menu-tenant .tenant-select { width: 100%; max-width: none; }
