:root{
  --ux-shell-max: 1720px;
  --ux-gap: 18px;
  --ux-radius-xl: 28px;
  --ux-radius-lg: 22px;
  --ux-radius-md: 16px;
  --ux-line: #e2eaf6;
  --ux-line-strong: #d4def0;
  --ux-panel: rgba(255,255,255,.96);
  --ux-soft: #f7faff;
  --ux-soft-2: #f1f6ff;
  --ux-text: #1b2740;
  --ux-muted: #64748b;
  --ux-primary: #3f63ff;
  --ux-primary-2: #13b0eb;
  --ux-shadow: 0 18px 54px rgba(17, 30, 62, .09);
  --ux-shadow-soft: 0 10px 28px rgba(17, 30, 62, .06);
}

html,body{overflow-x:hidden}
body{color:var(--ux-text)}
.shell{
  width:min(calc(100vw - 20px), var(--ux-shell-max));
  margin:0 auto;
  gap:var(--ux-gap);
  padding:var(--ux-gap);
  grid-template-columns:280px minmax(0,1fr) 72px;
}

.sidebar,
.topbar,
.card,
.table-shell,
.drawer,
.modal-card,
.toolbar-card,
.hero-kpi,
.kpi-card,
.metric-card,
.drawer-stat,
.analytics-focus-card,
.kanban-column,
.entity-record-details,
.builder-entity-card,
.chat-compose-card,
.modern-messages,
.chat-thread,
.workday-pill,
.api-center-page pre,
.api-center-page code{
  border-color:var(--ux-line)!important;
}

.sidebar{
  padding:22px 18px 18px;
  border-radius:30px;
  box-shadow:0 20px 60px rgba(7, 16, 39, .26);
  background:linear-gradient(180deg,#0f172a 0%,#132340 52%,#162742 100%);
}
.sidebar .brand{padding-bottom:18px;margin-bottom:10px}
.sidebar .nav{gap:4px}
.sidebar .nav-link{
  min-height:46px;
  padding:11px 14px;
  border-radius:14px;
  font-size:14px;
}
.sidebar .nav-link.is-active{
  background:linear-gradient(135deg,rgba(78,102,255,.48),rgba(20,176,235,.24));
}
.company-user-card{
  margin-top:14px;
  padding:14px;
  border-radius:20px;
  display:flex;
  gap:12px;
  align-items:center;
}
.sidebar-footer{display:grid;gap:10px;margin-top:14px}
.sidebar-footer .ghost-btn{min-height:44px;border-radius:14px}

.main-area{gap:var(--ux-gap)}
.topbar{
  min-height:86px;
  padding:16px 18px;
  border-radius:28px;
  box-shadow:var(--ux-shadow);
}
.topbar-left h1{font-size:28px}
.search-shell{height:50px;border-radius:16px;background:var(--ux-soft)}
.topbar-actions{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap}
.workday-pill{min-height:64px;border-radius:18px}
.workday-actions{display:flex;gap:8px;flex-wrap:wrap}
.workday-actions .ghost-btn{min-height:40px}
.content{
  max-width:none;
  padding:2px 2px 30px;
}
.page-block{gap:18px}
.card,
.drawer-section,
.drawer-section-inline,
.drawer-card,
.entity-record-details,
.builder-entity-card{box-shadow:var(--ux-shadow-soft)}
.card,
.drawer-card{padding:20px}
.card-title{margin-bottom:14px}
.card-title h3{font-size:20px}

.hero-kpi,
.kpi-grid,
.stats-grid,
.analytics-summary-grid,
.analytics-secondary-grid{
  gap:14px;
}
.hero-kpi > div,
.kpi-card,
.metric-card,
.drawer-stat{
  min-height:112px;
  display:grid;
  align-content:start;
  gap:8px;
}
.kpi-value,
.metric-card strong,
.drawer-stat-value,
.hero-kpi strong{font-size:30px}
.metric-meta,
.muted,
.mini,
.small-label{color:var(--ux-muted)}

.table-shell{padding:8px 10px;border-radius:24px;overflow:auto}
.table-head,.table-row{min-width:980px}
.table-head{border-radius:16px;background:var(--ux-soft)}
.table-row{padding:14px 14px}
.list-item,.notice-row,.task-row{padding:12px 2px}

.input,.textarea,select.input,select,textarea,input[type="text"],input[type="email"],input[type="password"],input[type="number"],input[type="date"],input[type="datetime-local"]{
  min-height:48px;
  border-radius:14px;
}
.textarea{min-height:120px}
.primary-btn,.ghost-btn{min-height:44px;border-radius:14px}
.ghost-btn{border:1px solid var(--ux-line-strong);background:#fff}
.ghost-btn:hover{background:var(--ux-soft)}

.right-rail{gap:12px}
.rail-btn{width:64px;min-height:92px;border-radius:22px;box-shadow:var(--ux-shadow-soft)}

.drawer{
  width:min(1040px, calc(100vw - 32px));
  border-radius:30px;
}
.drawer-header{
  position:sticky;
  top:0;
  z-index:8;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  min-height:76px;
  padding:16px 18px;
  box-shadow:0 6px 18px rgba(15, 23, 42, .04);
}
.drawer-body{padding:18px;gap:16px}
.drawer-card{padding:0}
.drawer-card.accent-drawer,
.profile-drawer-card,
.project-view-card{padding:20px;border-radius:24px;background:linear-gradient(180deg,#fbfdff 0%,#f4f7fd 100%)}
.drawer-tabs-nav{padding:8px;background:rgba(255,255,255,.86);backdrop-filter:blur(12px)}
.drawer-tab{min-height:42px;padding:9px 16px}
.drawer-tab-panel{display:grid;gap:16px}
.drawer-tab-panel[hidden]{display:none!important}
.drawer-grid{gap:14px}
.drawer-grid .drawer-stat{padding:14px 16px}
.drawer-headline{gap:18px}
.drawer-view-title{font-size:34px}
.drawer-subtitle{font-size:14px;line-height:1.5}

.task-view-grid .drawer-stat,
.profile-summary-grid .drawer-stat{min-height:92px}
.task-focus-strip,
.project-focus-strip{
  padding:16px;
  border-radius:22px;
  background:linear-gradient(180deg,#fff,#f6f9ff);
}
.task-focus-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.task-focus-actions .primary-btn{min-width:160px}
.task-focus-analytics{gap:12px}
.task-view-overview-grid{
  display:grid;
  grid-template-columns:minmax(0,1.15fr) minmax(320px,.85fr);
  gap:16px;
}
.task-team-card .member-chip-row{margin-top:8px}
.task-team-card .member-chip{background:#fff}
.task-next-step{padding:14px 16px;border-radius:18px;background:var(--ux-soft);border:1px solid var(--ux-line)}
.task-next-step strong{display:block;margin-bottom:6px}
.task-edit-panel{border-radius:20px;background:#fff;border:1px solid var(--ux-line)}

.profile-drawer-card .drawer-headline{align-items:flex-start}
.profile-drawer-card .drawer-input-title{min-height:54px}
.profile-summary-grid{margin-top:16px}
.profile-summary-grid .drawer-stat{min-height:86px}
.profile-hero-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:10px}
.profile-drawer-tabs .drawer-tab-panel{padding-top:2px}
.profile-notification-section .notification-pref-row{padding:14px 0}
.profile-api-section .list-item{padding:12px 0}
.password-inline{display:flex;gap:10px;flex-wrap:wrap;align-items:center}

.drawer-chat-layout{display:grid;grid-template-columns:320px minmax(0,1fr);min-height:72vh;gap:16px}
.chat-side,
.chat-main{border-radius:24px}
.chat-side{padding:18px;background:linear-gradient(180deg,#fbfdff 0%,#f5f8ff 100%)}
.chat-main{padding:18px;background:transparent}
.chat-thread-group{display:grid;gap:10px}
.chat-side-title{font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--ux-muted);font-weight:700}
.chat-thread{padding:14px;border-radius:18px}
.chat-thread:hover{border-color:#cad8fb;background:#fbfdff}
.chat-thread.active{border-color:#9db5ff;box-shadow:0 14px 26px rgba(64,97,255,.12)}
.tg-thread-avatar{width:46px;height:46px;border-radius:14px}
.chat-thread-hero{padding:4px 0 16px;margin-bottom:16px}
.chat-thread-hero-meta strong{font-size:28px}
.chat-thread-hero-meta .tg-thread-title-link,
.chat-thread-hero-meta strong > a,
.chat-thread-hero-meta strong a{color:inherit;text-decoration:none}
.chat-members-summary-row{margin:0 0 14px}
.chat-members-summary{
  width:100%;
  display:grid;
  grid-template-columns:110px minmax(0,1fr) auto;
  align-items:center;
  gap:14px;
  padding:12px 14px;
  border-radius:18px;
  background:#fff;
  border:1px solid var(--ux-line);
}
.chat-members-summary-avatars{width:110px;flex:0 0 110px}
.chat-members-summary-meta strong{font-size:15px;color:var(--ux-text)}
.chat-members-summary-action{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:40px;
  padding:0 14px;
  border-radius:12px;
  border:1px solid var(--ux-line-strong);
  background:var(--ux-soft);
  color:#2a4885;
  font-weight:700;
  white-space:nowrap;
}
.chat-members-modal-card{border-radius:26px}
.chat-members-modal-top{grid-template-columns:minmax(0,1fr) 280px}
.chat-member-grid{gap:12px}
.chat-member-card{padding:12px 14px;border-radius:18px;background:#fff}
.chat-member-avatar,.chat-member-avatar.avatar{width:42px;height:42px}
.chat-member-meta{gap:6px}
.chat-member-name-row{gap:8px}
.modern-messages{padding:18px 18px 10px}
.message{max-width:min(76%, 620px);border-radius:18px;padding:12px 14px}
.message-line{margin-bottom:12px}
.chat-compose-card{margin-top:14px;padding:14px;border-radius:22px}
.chat-compose-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:10px;align-items:end}
.chat-compose-input{min-height:96px}
.attach-thumb-img{width:68px;height:68px;border-radius:14px}

.analytics-page-pro .hero-kpi{margin-bottom:2px}
.analytics-focus-card{padding:18px 20px;border-radius:24px}
.analytics-top-grid,.analytics-bottom-grid{gap:16px}
.analytics-trend-chart{min-height:260px}
.analytics-trend-bars{height:200px}
.analytics-status-right{min-width:170px}

.access-center-page .access-tabs,
.segmented-tabs{gap:8px}
.access-hub-grid{grid-template-columns:minmax(320px,.95fr) minmax(0,1.05fr)}
.access-role-summary-row{padding:14px 0;border-bottom:1px solid #edf2fa}
.access-role-summary-row:last-child{border-bottom:none}
.role-matrix-shell .table-head,.role-matrix-shell .table-row{min-width:760px}

.entity-page-pro .toolbar-inline,
.entity-page-pro .entity-toolbar,
.analytics-toolbar,
.filters-grid,
.toolbar-line{
  grid-template-columns:minmax(240px,1.2fr) repeat(2,minmax(180px,.8fr)) auto;
}
.entity-page-pro .table-head,
.entity-page-pro .table-row{min-width:860px}
.entity-record-details{padding:14px 16px;border-radius:20px}
.entity-record-summary{display:grid;gap:6px}
.kanban-grid,.entity-kanban-grid{grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:16px}
.kanban-column,.entity-kanban-card,.kanban-card{border-radius:20px}
.kanban-column-head,.kanban-head{padding:14px 14px 12px}
.kanban-list,.entity-kanban-list{padding:14px;min-height:220px}
.kanban-card,.entity-kanban-card{padding:14px 14px 12px;box-shadow:var(--ux-shadow-soft)}
.kanban-card:hover,.entity-kanban-card:hover{transform:translateY(-1px)}

.context-chip,
.chip,
.badge{border-radius:999px}
.context-chip{display:inline-flex;align-items:center;padding:4px 10px;background:#edf2ff;border:1px solid #d6e2ff;color:#3d58bf;font-size:12px;font-weight:700}

@media (max-width: 1520px){
  .shell{grid-template-columns:264px minmax(0,1fr) 68px}
}
@media (max-width: 1280px){
  .topbar{grid-template-columns:1fr;align-items:start}
  .topbar-center,.topbar-actions{width:100%}
  .topbar-actions{justify-content:flex-start}
  .drawer-chat-layout{grid-template-columns:280px minmax(0,1fr)}
}
@media (max-width: 1120px){
  .shell{width:min(calc(100vw - 12px), var(--ux-shell-max));grid-template-columns:1fr;padding:12px;gap:12px}
  .sidebar,.right-rail{display:none}
  .mobile-nav-trigger{display:inline-flex}
  .topbar{position:static;min-height:auto}
  .drawer{width:calc(100vw - 24px);height:calc(100vh - 24px);top:12px;right:12px}
}
@media (max-width: 960px){
  .task-view-overview-grid,
  .access-hub-grid,
  .analytics-top-grid,
  .analytics-bottom-grid,
  .drawer-chat-layout,
  .drawer-grid,
  .task-focus-analytics,
  .hero-kpi,
  .kpi-grid,
  .stats-grid,
  .analytics-summary-grid,
  .analytics-secondary-grid,
  .kanban-grid,
  .entity-kanban-grid{grid-template-columns:1fr}
  .chat-members-summary{grid-template-columns:1fr;align-items:start}
  .chat-members-summary-avatars{width:96px}
  .chat-compose-row{grid-template-columns:1fr}
  .message{max-width:100%}
}
@media (max-width: 820px){
  .drawer-body{padding:14px}
  .drawer-card.accent-drawer,
  .profile-drawer-card,
  .project-view-card{padding:16px}
  .drawer-view-title{font-size:28px}
  .chat-thread-hero-meta strong{font-size:24px}
  .table-head,.table-row,
  .entity-page-pro .table-head,
  .entity-page-pro .table-row,
  .role-matrix-shell .table-head,
  .role-matrix-shell .table-row{min-width:0;grid-template-columns:1fr!important}
  .toolbar-inline,.analytics-toolbar,.entity-toolbar,.filters-grid,.toolbar-line{grid-template-columns:1fr}
  .workday-actions{width:100%}
  .workday-actions .ghost-btn{flex:1}
}


/* v22 contrast + layout stabilization */
body{
  background:linear-gradient(180deg,#eef4ff 0%, #f6f9ff 42%, #edf3ff 100%) !important;
  color:var(--ux-text) !important;
}
.shell{
  width:min(calc(100vw - 12px), 1820px) !important;
  padding:12px !important;
  gap:12px !important;
}
.main-area{min-width:0}
.content,.page-block,.section-head,.toolbar-card,.list-stack,.card{width:100%;max-width:none !important}
.section-head h2,.section-head h3,.topbar-left h1,.card-title h3,strong{color:#1a2742}
.section-head p,.muted,.mini,.small-label{color:#5f718f !important}
.sidebar{
  background:linear-gradient(180deg,#111a2d 0%, #15253f 58%, #173152 100%) !important;
  border:1px solid rgba(255,255,255,.08) !important;
  color:#eef4ff !important;
}
.sidebar .brand strong,
.sidebar .brand p,
.sidebar .nav-section-label,
.sidebar .nav-link,
.sidebar .company-user-card strong,
.sidebar .company-user-card p,
.sidebar .company-user-card .muted{color:#eef4ff !important}
.sidebar .brand p,.sidebar .nav-section-label,.sidebar .company-user-card p,.sidebar .company-user-card .muted{opacity:.84}
.sidebar .nav-link{background:transparent !important;border:1px solid transparent !important}
.sidebar .nav-link:hover{background:rgba(255,255,255,.10) !important;color:#fff !important}
.sidebar .nav-link.is-active{background:linear-gradient(135deg,rgba(69,104,255,.55),rgba(26,185,201,.38)) !important;color:#fff !important;box-shadow:0 12px 28px rgba(19,31,57,.35)}
.company-user-card{background:rgba(255,255,255,.10) !important;border:1px solid rgba(255,255,255,.10) !important}
.topbar,.card,.table-shell,.drawer,.toolbar-card,.drawer-card,.workday-pill,.rail-btn,.modal-card,.chat-side,.tg-chat-main,.modern-messages,.chat-compose-card{
  background:#ffffff !important;
  border-color:#d9e4f4 !important;
  box-shadow:0 10px 28px rgba(18,35,71,.08) !important;
}
.drawer{background:#fdfefe !important}
.topbar{grid-template-columns:minmax(0,1fr) minmax(340px,560px) auto !important}
.search-shell{background:#f8fbff !important;border:1px solid #dce8f7 !important}
.input,.textarea,select,.search-input,input[type="text"],input[type="email"],input[type="number"],input[type="date"],input[type="datetime-local"]{
  background:#fff !important;
  color:#1a2742 !important;
  border-color:#d6e2f2 !important;
}
.input::placeholder,.textarea::placeholder{color:#8da0bb !important}
.filters-grid,.toolbar-inline,.analytics-toolbar,.entity-toolbar,.toolbar-line{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr)) !important;
  gap:12px !important;
  align-items:end;
}
.filters-grid > .primary-btn,
.toolbar-inline > .primary-btn,
.analytics-toolbar > .primary-btn,
.entity-toolbar > .primary-btn,
.toolbar-line > .primary-btn{min-width:160px}
.list-stack{gap:14px !important}
.report-card,.comment-card{padding:18px !important;background:#fff !important;border:1px solid #dfe8f5 !important}
.right-rail .rail-btn{background:#fff !important;color:#243757 !important}
.drawer-chat-layout{grid-template-columns:340px minmax(0,1fr) !important;gap:16px !important;min-height:76vh !important}
.chat-side{padding:18px !important;background:linear-gradient(180deg,#fbfdff 0%,#f4f8ff 100%) !important}
.tg-chat-main,.chat-main{padding:18px !important;background:#fff !important}
.chat-thread,.chat-thread.active,.chat-thread.unread{
  background:#fff !important;
  border:1px solid #dce7f6 !important;
  color:#1a2742 !important;
}
.chat-thread:hover{background:#f8fbff !important;border-color:#bfd0ec !important}
.chat-thread.active{background:#eef5ff !important;border-color:#9db6ea !important;box-shadow:0 10px 24px rgba(41,78,161,.12) !important}
.chat-side-title,.chat-thread-meta,.chat-thread small,.chat-thread .muted{color:#607391 !important}
.chat-thread-hero{background:#fff !important;border-bottom:1px solid #e5edf8 !important}
.chat-thread-hero-meta strong,.chat-thread-hero-meta span,.tg-thread-title-link{color:#1a2742 !important}
.chat-members-summary{
  background:#f8fbff !important;
  border:1px solid #dbe6f6 !important;
}
.chat-members-summary-action{background:#fff !important;color:#24457f !important}
.modern-messages{
  background:linear-gradient(180deg,#fbfdff 0%, #f7faff 100%) !important;
  border:1px solid #e4edf8 !important;
  padding:18px !important;
}
.message,.tg-message{
  background:#fff !important;
  color:#18263f !important;
  border:1px solid #dce6f4 !important;
  box-shadow:0 8px 22px rgba(18,35,71,.06) !important;
}
.message.mine,.tg-message.mine{
  background:linear-gradient(135deg,#edf4ff 0%, #e9fbff 100%) !important;
  border-color:#c7dbff !important;
}
.message-author,.chat-body-text,.message-time,.attach,.attach span{color:#1b2740 !important}
.message-time{opacity:.72}
.attach-thumb{background:#fff !important;border:1px solid #dce6f4 !important}
.chat-compose-card{padding:14px !important;background:#fff !important;border-top:none !important}
.chat-compose-row{
  display:grid !important;
  grid-template-columns:auto minmax(0,1fr) auto !important;
  gap:12px !important;
  align-items:end !important;
  padding:12px !important;
  background:#f8fbff !important;
  border:1px solid #dce6f4 !important;
  border-radius:20px !important;
}
.chat-compose-input{
  min-height:84px !important;
  background:#fff !important;
  border:1px solid #dce6f4 !important;
  border-radius:16px !important;
  color:#1a2742 !important;
}
#chat-send.primary-btn{min-width:140px}
.attach-thumb-img{width:92px !important;height:92px !important;object-fit:cover !important}
.message .attach-thumb,.tg-message .attach-thumb{display:inline-grid;grid-template-columns:92px minmax(0,1fr);gap:10px;align-items:center;padding:8px 10px;border-radius:16px}
.message .attach-thumb span,.tg-message .attach-thumb span{word-break:break-word}
@media (max-width: 1100px){
  .topbar{grid-template-columns:1fr !important}
  .drawer-chat-layout{grid-template-columns:1fr !important}
}
