/* ============================================================
   Meridian CRM — app.css
   Application shell: topbar, tabs, launcher, notifications,
   utility bar, view container scaffolding.
   ============================================================ */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-3) 0 var(--sp-3);
  position: sticky; top: 0; z-index: 1200;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 2px; border-radius: var(--r-md); color: var(--text); font-weight: 700; font-size: var(--fs-14); letter-spacing: -0.01em; }
.brand:hover { background: var(--hover-layer); text-decoration: none; }
.brand .brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-md); background: var(--brand); color: #fff; }
.topbar-divider { width: 1px; height: 24px; background: var(--border); margin: 0 3px; flex-shrink: 0; }
.topbar-search { width: min(430px, 40vw); position: relative; }
.topbar-search .input { height: 34px; border-radius: var(--r-pill); padding-left: 34px; background: var(--surface-sunken); }
.topbar-search .searchbox-icon { left: 11px; }
.topbar-search .input:focus { background: var(--surface); }
.topbar-search .ta-kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; opacity: 0.7; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 3px; }
.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-md);
  color: var(--text-soft);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--hover-layer); color: var(--text); }
.icon-btn.active { background: var(--brand-soft); color: var(--brand-strong); }
html[data-theme="dark"] .icon-btn.active { color: var(--brand); }
.icon-btn .dot-badge {
  position: absolute; top: 4px; right: 4px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: var(--r-pill); background: var(--danger); color: #fff;
  font-size: var(--fs-10); font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--surface);
}
.quick-create-btn { height: 34px; border-radius: var(--r-pill); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 3px 10px 3px 4px; border-radius: var(--r-pill); transition: background var(--t-fast); }
.user-chip:hover { background: var(--hover-layer); }
.user-chip .uc-name { font-size: var(--fs-12); font-weight: 600; line-height: 1.15; text-align: left; }
.user-chip .uc-role { font-size: var(--fs-10); color: var(--text-muted); line-height: 1.15; }

/* ---------- Tab bar ---------- */
.tabbar {
  height: var(--tabbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: stretch;
  padding: 0 var(--sp-4);
  position: sticky; top: var(--topbar-h); z-index: 1100;
  overflow-x: auto; scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tabbar .app-name { display: flex; align-items: center; gap: 8px; font-size: var(--fs-12); font-weight: 650; color: var(--text-muted); padding-right: var(--sp-4); margin-right: var(--sp-2); border-right: 1px solid var(--border); white-space: nowrap; }
.navtab {
  position: relative; display: inline-flex; align-items: center;
  padding: 0 var(--sp-3); margin-right: 2px;
  font-size: var(--fs-13); font-weight: 550; color: var(--text-muted);
  white-space: nowrap; border-radius: var(--r-md) var(--r-md) 0 0;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.navtab:hover { color: var(--text); background: var(--hover-layer); }
.navtab::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2.5px; border-radius: 2px 2px 0 0; background: transparent; transition: background var(--t-med) var(--ease); }
.navtab[aria-current="page"] { color: var(--brand); }
.navtab[aria-current="page"]::after { background: var(--brand); }
.tabbar-overflow-btn { display: none; }

/* ---------- View container ---------- */
.view-root { flex: 1; min-height: 0; outline: none; }
.view-page { padding: var(--sp-5) var(--sp-6) 90px; max-width: 1560px; margin: 0 auto; }
.view-page.full-bleed { max-width: none; padding: 0 0 90px; }
.page-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.page-title { font-size: var(--fs-24); font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; }
.page-sub { font-size: var(--fs-13); color: var(--text-muted); margin-top: 3px; }
.page-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-13); color: var(--text-muted); flex-wrap: wrap; }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs .crumb-sep { color: var(--text-faint); display: inline-flex; }

/* ---------- App launcher ---------- */
.launcher-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 6px; }
.launcher-item {
  display: flex; flex-direction: column; gap: 7px; align-items: flex-start;
  padding: 13px 12px; border-radius: var(--r-lg);
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast), transform var(--t-fast);
  text-align: left;
}
.launcher-item:hover { background: var(--hover-layer); border-color: var(--border); text-decoration: none; transform: translateY(-1px); }
.launcher-item .li-name { font-size: var(--fs-13); font-weight: 620; color: var(--text); }
.launcher-item .li-desc { font-size: var(--fs-11); color: var(--text-muted); line-height: 1.35; }

/* ---------- Notifications panel ---------- */
.notif-panel { width: min(400px, calc(100vw - 24px)); }
.notif-item { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--r-md); cursor: pointer; transition: background var(--t-fast); position: relative; }
.notif-item:hover { background: var(--hover-layer); }
.notif-item .notif-body { font-size: var(--fs-13); line-height: 1.45; color: var(--text); min-width: 0; }
.notif-item .notif-time { font-size: var(--fs-11); color: var(--text-muted); margin-top: 2px; }
.notif-item .notif-unread-dot { position: absolute; left: 3px; top: 16px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.notif-item.unread { background: var(--brand-softer); }
.notif-item.unread:hover { background: var(--brand-soft); }

/* ---------- Utility bar (docked) ---------- */
.utility-bar {
  position: fixed; right: 18px; bottom: 16px; z-index: 1500;
  display: flex; align-items: center; gap: 2px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  padding: 4px 6px;
}
.util-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--r-pill);
  color: var(--text-soft);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.util-btn:hover { background: var(--hover-layer); color: var(--text); }
.util-btn.active { background: var(--brand-soft); color: var(--brand-strong); }
html[data-theme="dark"] .util-btn.active { color: var(--brand); }
.util-panel {
  position: fixed; right: 18px; bottom: 66px; z-index: 1490;
  width: min(360px, calc(100vw - 36px));
  max-height: min(60vh, 520px);
  background: var(--elevated); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: utilIn var(--t-slow) var(--ease);
  overflow: hidden;
}
@keyframes utilIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
.util-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; font-size: var(--fs-13); font-weight: 650; border-bottom: 1px solid var(--border); }
.util-panel-body { overflow-y: auto; padding: 10px 12px 12px; }

/* ---------- Keyboard cheatsheet ---------- */
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; }
.sc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: var(--fs-13); }
.sc-keys { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }

/* ---------- Welcome / onboarding ---------- */
.welcome-hero { display: flex; gap: 14px; align-items: center; margin-bottom: var(--sp-4); }
.welcome-steps { display: flex; flex-direction: column; gap: 10px; }
.welcome-step { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-lg); transition: all var(--t-fast); }
.welcome-step:hover { border-color: var(--brand); background: var(--brand-softer); text-decoration: none; }
.welcome-step .ws-num { width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); display: grid; place-items: center; font-size: var(--fs-12); font-weight: 700; flex-shrink: 0; }
html[data-theme="dark"] .welcome-step .ws-num { color: var(--brand); }

/* ---------- Mobile nav ---------- */
.nav-drawer-btn { display: none; }

@media (max-width: 680px) {
  .quick-create-btn .hide-sm { display: none; }
}

/* ---------- Responsive shell ---------- */
@media (max-width: 1080px) {
  .topbar-search { width: min(340px, 34vw); }
  .user-chip .uc-meta { display: none; }
}
@media (max-width: 900px) {
  .tabbar { display: none; }
  .nav-drawer-btn { display: inline-flex; }
  .topbar { padding: 0 var(--sp-2); gap: 4px; }
  .topbar-search { flex: 1 1 auto; width: auto; }
  .brand .brand-name { display: none; }
  .utility-bar { right: 12px; bottom: 12px; }
  .util-panel { right: 12px; bottom: 62px; }
}
@media (max-width: 620px) {
  .topbar-search .ta-kbd { display: none; }
  .user-chip { padding: 3px; }
  .view-page { padding: var(--sp-4) var(--sp-3) 120px; }
}
