/* Persi Chat — unified responsive layout architecture.
   This file owns viewport scrolling, permanent navigation, Oficina list, inbox,
   and calendar stacking. Only visual layout; no API or backend behavior. */
html,body{height:100%;overflow:hidden}
body{margin:0}
.app-root{
 height:100dvh;min-height:0;display:flex;flex-direction:column;overflow:hidden;
}
.global-header{
 flex:0 0 var(--top);min-height:0;width:100%;max-width:1500px;
 margin-inline:auto;
}
.app-layout{
 flex:1 1 auto;min-height:0;min-width:0;width:100%;max-width:1500px;
 margin-inline:auto;display:flex;gap:20px;padding:6px 20px 16px;
 overflow:hidden;
}
.desktop-sidebar{
 flex:0 0 224px;width:224px;height:100%;min-height:0;
 display:flex;flex-direction:column;overflow-y:auto;overflow-x:hidden;
 overscroll-behavior:contain;scrollbar-width:thin;
}
.desktop-sidebar .sidebar-spacer{flex:1;min-height:12px}
#main-content{
 flex:1 1 auto;width:100%;height:100%;min-width:0;min-height:0;
 overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;
 padding-right:5px;scrollbar-width:thin;
}
/* Calendar: one source of truth for month -> selected-date appointments. */
.calendar-parity-grid{display:flex;flex-direction:column;gap:15px;min-width:0}
.calendar-parity-grid>.calendar-month-panel,
.calendar-parity-grid>.calendar-selected-day{
 order:initial;width:100%;min-width:0;max-width:100%;
}
.calendar-month-panel .calendar-grid{grid-template-columns:repeat(7,minmax(0,1fr));gap:7px}
.calendar-month-panel .calendar-parity-day{
 display:flex;align-items:center;justify-content:center;flex-direction:column;
 min-width:0;min-height:64px;max-width:100%;overflow:hidden;
}
.calendar-month-panel .calendar-parity-day .calendar-date{font-size:14px}
.calendar-month-panel .calendar-parity-day .calendar-count{
 flex-shrink:0;line-height:1;white-space:nowrap;
}
.calendar-selected-day .calendar-day-appointments{display:grid;grid-template-columns:1fr;gap:11px}
.calendar-selected-day .calendar-event-row{max-width:100%;min-width:0}
.calendar-agenda-content strong,.calendar-agenda-person{overflow-wrap:anywhere}
/* Oficina: responsive record collection instead of a squeezed nine-column table. */
.office-records{
 display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,430px),1fr));
 align-items:stretch;gap:13px;margin-top:18px;
}
.office-record{
 border:1px solid var(--border);border-radius:19px;background:var(--white);
 box-shadow:0 3px 13px #00000008;min-width:0;display:flex;flex-direction:column;
 padding:18px;gap:15px;overflow:hidden;cursor:pointer;
}
.office-record:hover{border-color:#93bda8;box-shadow:0 6px 20px #134f2f12}
.office-record:focus-visible{outline:3px solid var(--yellow);outline-offset:2px}
.office-record-head{display:flex;align-items:center;gap:12px;min-width:0}
.office-record-select{
 flex:0 0 31px;min-height:36px;display:grid;place-items:center;
 border-radius:10px;background:var(--surface);border:1px solid var(--border);cursor:pointer;
}
.office-record-select input{accent-color:var(--green);width:17px;height:17px}
.office-record-id{min-width:0;flex:1;display:flex;flex-direction:column;gap:4px}
.office-record-id strong{font-size:18px;line-height:1.1;letter-spacing:.01em;color:var(--ink)}
.office-record-id small{font-size:11px;color:var(--muted)}
.office-record-head .chip{font-size:10px;flex-shrink:0;white-space:nowrap}
.office-record-info{
 margin:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;
}
.office-record-info>div{min-width:0;margin:0}
.office-record-info dt{
 color:var(--muted);font-size:10px;font-weight:900;letter-spacing:.07em;
 text-transform:uppercase;margin:0 0 5px;
}
.office-record-info dd{margin:0;font-size:12px;color:var(--ink);font-weight:750;
 line-height:1.45;overflow-wrap:anywhere}
.office-record-info .field{min-height:39px;font-size:12px;padding:7px 10px}
.office-record-stage{grid-column:1/-1}
.office-record-stage dd{max-width:100%}
.office-record-actions{
 display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;
 border-top:1px solid var(--border);padding-top:13px;margin-top:auto;
}
.office-record-actions .btn{
 width:100%;min-width:0;max-width:100%;min-height:41px;
 display:flex;gap:6px;white-space:normal;text-align:center;
 padding:8px 7px;font-size:11px;line-height:1.25;justify-content:center;
}
.office-record-actions .btn svg{width:15px;height:15px;flex:0 0 15px}
.office-record-actions [data-action="car-whatsapp"]{
 background:#11745a;border-color:#11745a;color:#fff;
}
.office-record-actions [data-action="edit-car"]{
 border-color:#9bbfac;color:#17644c;
}
.restore-office-head{align-items:center}
.restore-office-head .page-actions{
 display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
 min-width:0;gap:8px;max-width:min(100%,410px);
}
.restore-office-head .page-actions .btn{
 min-width:0;width:100%;white-space:normal;line-height:1.3;text-align:center;
 padding:10px 9px;font-size:11px;
}
/* Group filters by task. Preserve names and behavior. */
#main-content:has(.restore-office-tabs) .view-toolbar{
 display:grid;grid-template-columns:minmax(0,2fr) minmax(170px,1.25fr)
 minmax(145px,.95fr) auto auto;gap:10px;align-items:end;
}
#main-content:has(.restore-office-tabs) .view-toolbar>*{min-width:0}
#main-content:has(.restore-office-tabs) .view-toolbar label{width:100%;min-width:0!important}
#main-content:has(.restore-office-tabs) .view-toolbar .pill-tabs{
 justify-content:center;min-width:0;white-space:nowrap;
}
#main-content:has(.restore-office-tabs) .restore-kpi-grid{
 display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;
}
#main-content:has(.restore-office-tabs) .restore-bulk-bar{
 display:flex;align-items:center;flex-wrap:wrap;gap:10px;
}
#main-content:has(.restore-office-tabs) .restore-bulk-bar>*{min-width:0}
#main-content:has(.restore-office-tabs) .restore-bulk-bar .field{
 max-width:220px;
}
/* Inbox occupies the central workspace; only contact list and messages scroll. */
#main-content:has(.inbox-frame){overflow:hidden;padding-bottom:0}
.inbox-frame,.inbox-frame.no-thread{
 height:100%;max-height:100%;min-height:0;min-width:0;
 display:grid;grid-template-columns:minmax(280px,36%) minmax(0,1fr);
 grid-template-rows:minmax(0,1fr);overflow:hidden;
}
.inbox-left,.inbox-thread{min-width:0;min-height:0;height:100%;overflow:hidden}
.inbox-list{min-height:0;overflow-y:auto}
.inbox-top{flex:0 0 auto}
.inbox-thread{display:flex;flex-direction:column}
.thread-head{min-width:0;flex:0 0 auto;padding:13px 15px;gap:10px}
.thread-head>div:not(.thread-toolbar){min-width:0;flex:1}
.thread-head b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.thread-head small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
.thread-toolbar{flex:0 0 auto;min-width:0}
.thread-messages{
 flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;
 padding:18px;gap:12px;overscroll-behavior:contain;
}
.thread-messages .message-row{max-width:82%;min-width:0}
.message-bubble{
 max-width:100%;min-width:0;overflow-wrap:anywhere;word-break:normal;
 white-space:pre-wrap;line-height:1.55;
}
.thread-composer{flex:0 0 auto;min-width:0;padding:11px 13px}
.thread-composer .composer-row{min-width:0;align-items:end}
.thread-composer .composer-input{min-width:0;width:100%;font-size:14px}
.thread-composer .quick-replies{max-width:100%;overflow-x:auto;overflow-y:hidden}
.thread-composer .quick-replies button{min-height:31px}
@media(min-width:761px) and (max-width:1250px){
 /* Tablet: narrow but persistent icon rail preserves space for inbox and office. */
 .app-layout{gap:13px;padding:5px 12px 13px}
 .desktop-sidebar{
  flex:0 0 66px;width:66px;align-items:center;padding:8px 0;gap:5px;
 }
 .desktop-sidebar nav{width:100%;align-items:center}
 .desktop-sidebar .sidebar-section{font-size:0;letter-spacing:0;padding:8px 0}
 .desktop-sidebar .side-link{
  font-size:0;justify-content:center;gap:0;width:50px;height:47px;
  padding:10px 6px;border-radius:14px;position:relative;
 }
 .desktop-sidebar .side-link svg{width:23px;height:23px;flex-shrink:0}
 .desktop-sidebar .side-count{position:absolute;right:0;top:0;font-size:10px;min-width:17px;text-align:center;margin:0}
 .desktop-sidebar .workspace-status{
  font-size:0;padding:8px;min-width:0;width:45px;height:42px;
  overflow:hidden;flex:0 0 auto;border-radius:13px;
 }
 .desktop-sidebar .workspace-status small{display:none}
 .desktop-sidebar .workspace-status .status-dot{margin:0}
 .inbox-frame,.inbox-frame.no-thread{
  grid-template-columns:minmax(248px,36%) minmax(0,1fr);
 }
 .inbox-top{padding:14px 12px 10px}
 .inbox-heading h1{font-size:23px}
 #main-content:has(.restore-office-tabs) .view-toolbar{
  grid-template-columns:repeat(2,minmax(0,1fr));align-items:end;
 }
 #main-content:has(.restore-office-tabs) .view-toolbar>label:first-child{grid-column:1/-1}
 #main-content:has(.restore-office-tabs) .restore-kpi-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
 .restore-office-head .page-actions{max-width:min(100%,355px)}
}
@media(min-width:761px) and (max-width:900px){
 .inbox-frame,.inbox-frame.no-thread{grid-template-columns:minmax(235px,37%) minmax(0,1fr)}
 .inbox-heading h1{font-size:21px}
 .inbox-top{padding:12px 9px 8px}
 .inbox-item{padding:10px 9px;gap:7px}
 .inbox-item .contact-avatar{width:40px;height:40px;flex-basis:40px}
 .contact-title{font-size:12px}
 .thread-head{padding:10px 9px;gap:5px}
 .thread-head .contact-avatar{width:34px!important;height:34px!important;flex-basis:34px!important}
 .thread-head b{font-size:12px}
 .thread-head small{font-size:10px}
 .thread-toolbar .bare-icon{padding:5px}
 .thread-toolbar .bare-icon svg{width:17px}
 .thread-messages{padding:12px}
 .message-row{max-width:88%}
}
@media(max-width:760px){
 :root{--top:78px}
 .app-root{height:100dvh}
 .global-header{flex:0 0 78px}
 .app-layout{
  display:block;flex:1 1 auto;height:auto;min-height:0;
  padding:0 10px 0;overflow:hidden;
 }
 .desktop-sidebar{display:none}
 #main-content{
  height:100%;max-height:100%;min-height:0;min-width:0;
  padding-right:0;padding-bottom:calc(75px + env(safe-area-inset-bottom));
  overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;
 }
 /* Main is the only scrolling region while mobile navbar stays fixed. */
 #main-content:has(.inbox-frame){padding-bottom:calc(75px + env(safe-area-inset-bottom))}
 .inbox-frame,.inbox-frame.no-thread{
  height:100%;max-height:100%;min-height:0;
  display:block;position:relative;overflow:hidden;
 }
 .inbox-left{height:100%;border:0;display:flex;flex-direction:column}
 .inbox-thread{
  position:absolute;inset:0;height:100%;width:100%;
  transform:translateX(104%);transition:transform .2s ease;z-index:3;
 }
 .inbox-frame.thread-open .inbox-thread{transform:translateX(0)}
 .inbox-frame.thread-open .inbox-left{visibility:hidden}
 .back-chat{display:grid}
 .thread-head{min-height:60px;padding:9px 10px}
 .thread-head .contact-avatar{width:36px!important;height:36px!important;flex-basis:36px!important}
 .thread-head b{font-size:14px}
 .thread-head small{font-size:10px}
 .thread-messages{padding:13px 11px}
 .thread-messages .message-row{max-width:90%}
 .message-bubble{font-size:13px;padding:10px 12px}
 .thread-composer{padding:8px 10px 12px}
 .thread-composer .composer-input{font-size:14px;min-height:43px}
 .thread-composer .send-btn{width:43px;height:43px;flex:0 0 43px}
 .inbox-top{padding:14px 11px 8px}
 .inbox-heading h1{font-size:23px}
 .calendar-parity-grid>.calendar-month-panel,
 .calendar-parity-grid>.calendar-selected-day{order:initial}
 .calendar-month-panel .calendar-grid{gap:4px}
 .calendar-month-panel .calendar-parity-day{min-height:47px;padding:4px}
 .calendar-month-panel .calendar-parity-day .calendar-date{font-size:12px}
 .calendar-month-panel .calendar-parity-day .calendar-count{min-width:18px;height:18px;font-size:10px}
 .restore-office-head{gap:13px;align-items:stretch}
 .restore-office-head .page-actions{max-width:none;width:100%;grid-template-columns:repeat(2,minmax(0,1fr))}
 #main-content:has(.restore-office-tabs) .view-toolbar{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
 #main-content:has(.restore-office-tabs) .view-toolbar>label:first-child{grid-column:1/-1}
 #main-content:has(.restore-office-tabs) .view-toolbar .pill-tabs{grid-column:1/-1;justify-self:stretch;display:grid;grid-template-columns:1fr 1fr}
 #main-content:has(.restore-office-tabs) .view-toolbar .pill-tabs button{width:100%;min-height:38px}
 #main-content:has(.restore-office-tabs) .restore-kpi-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
 .office-records{grid-template-columns:minmax(0,1fr);gap:10px}
 .office-record{padding:14px;gap:12px}
 .office-record-id strong{font-size:17px}
 .office-record-head .chip{font-size:9px;padding:5px 6px}
 .office-record-info{gap:10px}
 .office-record-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
 .office-record-actions .btn{min-height:43px;font-size:12px}
 #main-content:has(.restore-office-tabs) .restore-bulk-bar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 #main-content:has(.restore-office-tabs) .restore-bulk-bar b{align-self:center}
 #main-content:has(.restore-office-tabs) .restore-bulk-bar .field{max-width:none;width:100%}
 #main-content:has(.restore-office-tabs) .restore-bulk-bar [data-action="clear-car-selection"]{grid-column:1/-1}
 .restore-page-bar{flex-wrap:wrap;gap:10px}
}
body.dark .office-record{background:#23342d;border-color:#42554a;box-shadow:none}
body.dark .office-record-select{background:#2d4035;border-color:#536d5d}
body.dark .office-record-actions [data-action="edit-car"]{color:#bcf4d0}
body.dark .calendar-month-panel .calendar-parity-day{color:#20362c}
body.dark .inbox-thread,body.dark .thread-head{background:#222f2a}

/* Spacious Oficina records use denser information columns when they expand. */
.office-record{container-type:inline-size;container-name:office-card}
@container office-card (min-width:620px){
 .office-record-info{grid-template-columns:repeat(3,minmax(0,1fr))}
 .office-record-stage{grid-column:auto}
 .office-record-info .field{width:100%}
 .office-record-actions{grid-template-columns:repeat(5,minmax(0,1fr))}
}
@media(max-width:760px){
 /* Comfortable chat reading on phones, with composer retained above bottom bar. */
 .inbox-frame .thread-messages .message-bubble{font-size:14px;line-height:1.55}
 .inbox-frame .thread-head b{font-size:15px}
 .inbox-frame .thread-head small{font-size:11px}
 .inbox-frame .composer-input{font-size:15px}
 .inbox-frame .quick-replies button{font-size:11px;min-height:34px}
 .inbox-frame .inbox-item .contact-title{font-size:15px}
 .inbox-frame .contact-preview-row p{font-size:13px}
}
