/* EliteMC — experiência mobile dedicada */
@media (max-width:760px) {
  :root { --radius:12px; }
  body { min-width:320px; }

  /* Acesso */
  .login-shell { width:min(100% - 24px,520px); min-height:100dvh; align-content:center; gap:22px; padding:24px 0 34px; }
  .login-hero { min-width:0; }
  .brand-block { margin:0 0 20px; }
  .brand-logo { width:62px; border-radius:11px; }
  .brand-block strong { font-size:20px; }
  .brand-block small { font-size:6px; letter-spacing:2.3px; }
  .hero-kicker { display:flex; margin-bottom:14px; font-size:8px !important; letter-spacing:1.5px; }
  .login-hero>h1 { font-size:clamp(39px,13vw,57px); line-height:.93; letter-spacing:-3.5px; }
  .login-card { padding:25px 20px 21px; border-radius:16px; box-shadow:0 24px 65px #0009,3px 3px #020503; }
  .login-card h2 { padding-right:54px; font-size:25px; }
  .login-card form { gap:15px; margin-top:21px; }
  .login-foot { font-size:8px; }
  input,select,textarea { min-height:47px; padding:13px; font-size:16px; }
  textarea { min-height:100px; }
  .mc-button { min-height:46px; }

  /* Barra e menu */
  .topbar { height:68px; gap:8px; padding:0 max(11px,env(safe-area-inset-left)); }
  .mini-brand { order:1; margin-right:auto; }
  .mini-brand img { width:42px; height:42px; border-radius:9px; }
  .player-menu { order:2; gap:4px; }
  .player-head-frame { width:40px; height:40px; }
  .player-menu img { width:36px; height:36px; }
  .player-menu button { width:31px; height:36px; margin:0; font-size:20px; }
  .nav-toggle { order:3; width:40px; height:40px; padding:0; font-size:19px; }
  .topbar nav { position:fixed; top:76px; right:11px; bottom:auto; left:11px; width:auto; max-height:calc(100dvh - 88px); grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; padding:10px; border-radius:16px; }
  .topbar nav.open { display:grid; }
  .topbar nav a { min-width:0; min-height:56px; margin:0; padding:8px 11px; border:1px solid transparent; border-radius:10px; font-size:10px; white-space:normal; line-height:1.15; }
  .topbar nav a::before { width:24px; flex:0 0 24px; font-size:17px; text-align:center; }
  .topbar nav a:hover,.topbar nav a.active { border-color:#30463a; }

  /* Estrutura de página */
  #content { width:calc(100% - 20px); min-height:72vh; margin:25px auto 70px; }
  .page-head { align-items:flex-start; gap:10px; margin-bottom:20px; padding-left:13px; }
  .page-head h1 { max-width:100%; font-size:clamp(28px,9vw,37px); line-height:1.04; letter-spacing:-1.3px; overflow-wrap:anywhere; }
  .page-head p { font-size:8px; letter-spacing:1.8px; }
  .sync { align-self:flex-start; padding:5px 8px; font-size:7px; }
  .section-title { margin-bottom:13px; }
  .section-title h2 { font-size:20px; }
  .section-title>p { max-width:none; font-size:10px; line-height:1.5; }
  .card { min-width:0; padding:15px; border-radius:12px; box-shadow:0 9px 26px #0003; }
  .card h2,.card h3 { overflow-wrap:anywhere; }
  .grid,.home-grid { gap:12px; }
  .list-row { min-width:0; padding:11px; }
  .list-row>div,.list-row>span { min-width:0; overflow-wrap:anywhere; }
  .empty { padding:29px 14px; }

  /* Home */
  .home-welcome { gap:15px; padding:18px; }
  .home-welcome h2 { font-size:19px; line-height:1.18; }
  .home-welcome .badge { align-self:flex-start; }
  .home-widget { min-height:151px; grid-template-columns:40px minmax(0,1fr); gap:12px; padding:18px; }
  .home-widget-icon { width:39px; height:39px; font-size:17px; }
  .home-widget h2 { margin-bottom:11px; }
  .home-widget strong { font-size:22px; }
  .home-widget-arrow { display:none; }
  .server-signal { right:14px; bottom:14px; transform:scale(.82); transform-origin:right bottom; }

  /* Banco */
  .account-tabs { flex-wrap:nowrap; overflow-x:auto; padding:4px; scrollbar-width:none; scroll-snap-type:x proximity; }
  .account-tabs::-webkit-scrollbar { display:none; }
  .account-tab { min-width:max-content; flex:0 0 auto; scroll-snap-align:start; }
  .bank-stats { grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:9px; }
  .bank-stats .card { min-height:118px; padding:13px; }
  .bank-stats .stat strong { margin:9px 0 5px; font-size:clamp(16px,5vw,21px); overflow-wrap:anywhere; }
  .bank-main,.consolidated,.homebroker,.investments,.receipts { margin-top:12px; }
  .consolidated .section-title>strong { font-size:15px; }
  .consolidated-grid { gap:8px; }
  .consolidated-grid>div { padding:12px; }
  .stock-grid,.investment-grid { gap:9px; }
  .stock-grid article,.investment-grid article { padding:13px; border-radius:9px; }
  .investment-grid dl { grid-template-columns:1fr; }
  .investment-grid dl div { display:flex; justify-content:space-between; padding-top:7px; border-top:1px solid var(--line); }
  .receipt { gap:9px; padding:13px; }

  /* Formulários e folhas inferiores */
  .inline-form { gap:11px; }
  .inline-form label { min-width:0; }
  .command-copy { align-items:flex-start; flex-direction:column; overflow-wrap:anywhere; }
  .actions { gap:7px; }
  .actions .mc-button { flex:1 1 135px; }
  .page-actions,.search-bar { gap:13px; padding:14px; border-radius:11px; }
  .page-actions>.mc-button { width:100%; }
  .search-bar>div { min-height:47px; }
  .modal-backdrop { align-items:end; padding:0; }
  .modal { width:100%; max-width:none; max-height:92dvh; padding:20px 16px max(20px,env(safe-area-inset-bottom)); border-radius:20px 20px 0 0; box-shadow:0 -22px 70px #000c; animation:mobile-sheet-in .22s ease-out; }
  .modal-head { position:sticky; top:-20px; z-index:3; margin:-20px -16px 17px; padding:17px 16px 13px; background:var(--panel); background:color-mix(in srgb,var(--panel) 94%,transparent); border-bottom:1px solid var(--line); backdrop-filter:blur(15px); }
  .modal-head h2 { margin:0; font-size:21px; }
  .modal-head button { width:40px; height:40px; border-radius:9px; background:var(--panel-soft); }
  .invoice-summary { align-items:flex-start; padding:14px; }
  .invoice-summary strong { font-size:21px; }
  .invoice-lines { max-height:none; }
  .stock-order-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .stock-order-summary .stock-order-total { grid-column:1/-1; }
  @keyframes mobile-sheet-in { from { transform:translateY(35px); opacity:.4; } }

  /* Eleições, histórico e gráficos */
  .election-summary { padding:18px; }
  .candidate-list,.live-counting { padding:12px; }
  .election-application { margin:12px 12px 0; }
  .candidate { padding:10px; }
  .counting-progress { padding:13px; }
  .counting-candidate { grid-template-columns:23px 58px minmax(0,1fr); padding:10px; }
  .counting-avatar { width:56px; height:56px; }
  .counting-avatar img { width:44px; height:44px; }
  .counting-percentage { grid-column:3; font-size:15px; }
  .counting-evolution { padding:10px; }
  .counting-evolution svg { min-height:150px; }
  .calendar-card { padding:15px; }
  .history-card-summary { gap:12px; }
  .history-metrics>div { padding:10px; }
  .history-chart-row { overflow:hidden; }
  .history-candidate-result { grid-column:3; align-items:flex-start; }

  /* Pesquisas e conteúdo institucional */
  .research-card details { padding:0; }
  .research-card summary { min-height:49px; padding:12px; line-height:1.4; }
  .research-card summary span { float:none; display:block; margin-top:4px; }
  .research-card .research-chart { margin:8px; padding:11px; }
  .research-bar-row>div:first-child { align-items:flex-start; }
  .budget-grid,.score-ranking { gap:8px; }
  .president-timeline { padding-left:19px; }
  .president-timeline::before { left:5px; }
  .president-entry::before { left:-18px; }
  .newspaper-cover { padding:20px; }
  .newspaper-cover h2 { font-size:25px; }
  .project-special { align-items:flex-start; flex-direction:column; gap:6px; }
  .court-mention-picker { max-height:210px; }
  .newspaper-order-summary strong { font-size:22px; }

  /* Social e perfil */
  .post-composer form>div,.social-post footer { flex-wrap:wrap; gap:7px; }
  .composer-actions { width:100%; }
  .composer-actions .mc-button { flex:1; }
  .gif-results { grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
  .gif-picker { padding-bottom:max(20px,env(safe-area-inset-bottom)); }
  .social-post footer button:last-child { margin-left:0; }
  .social-comment { grid-template-columns:1fr; }
  .social-comments form { align-items:stretch; flex-direction:column; }
  .profile-hero { gap:14px; }
  .profile-stats { overflow-x:auto; grid-template-columns:repeat(5,minmax(90px,1fr)); scrollbar-width:none; }
  .profile-stats>a,.profile-stats>span { padding:12px 8px; }
  .achievement,.player-badge { grid-template-columns:42px minmax(0,1fr); }

  /* Configurações */
  .settings-profile { gap:18px; padding:20px; }
  .settings-profile h2 { font-size:23px; }
  .settings-avatar,.settings-avatar img { width:94px; height:94px; }
  .access-table>div { gap:9px; padding:12px 2px; }
  .server-session-list .list-row { gap:10px; }
  .server-session-list .mc-button { width:100%; }

  /* Elitegram: lista horizontal acima da conversa */
  .elitegram-panel { inset:0; width:100%; height:100dvh; border:0; }
  .elitegram-head { height:62px; padding-top:env(safe-area-inset-top); }
  .elitegram-body { height:calc(100% - 62px); grid-template-columns:1fr; grid-template-rows:118px minmax(0,1fr); }
  .elitegram-body>aside { display:grid; grid-template-columns:105px minmax(0,1fr); overflow:hidden; border-right:0; border-bottom:1px solid var(--line); }
  .elitegram-tools { align-content:center; padding:8px; border-right:1px solid var(--line); }
  #conversation-list { min-width:0; display:flex; overflow-x:auto; overflow-y:hidden; scrollbar-width:thin; }
  .conversation-item { min-width:105px; height:100%; align-content:center; border-right:1px solid #202a23; border-bottom:0; }
  .chat-room>header { min-height:53px; }
  .chat-messages { padding:11px; }
  .chat-message>div { max-width:84%; }
  #message-form { padding:9px max(9px,env(safe-area-inset-right)) max(9px,env(safe-area-inset-bottom)) max(9px,env(safe-area-inset-left)); }
  #message-form input { min-width:0; }
  .selected-gif img { max-height:120px; }

  .site-footer { padding:25px 15px 86px; }
  .toast { right:10px; bottom:max(10px,env(safe-area-inset-bottom)); left:10px; max-width:none; }
}

@media (max-width:390px) {
  .topbar nav { grid-template-columns:1fr 1fr; }
  .topbar nav a { padding:7px 8px; font-size:9px; }
  .player-menu button { width:27px; }
  .bank-stats { grid-template-columns:1fr 1fr !important; }
  .bank-stats .card { padding:11px; }
  .counting-candidate { grid-template-columns:22px 52px minmax(0,1fr); }
  .counting-avatar { width:50px; height:50px; }
  .counting-avatar img { width:39px; height:39px; }
  .stock-order-summary { grid-template-columns:1fr; }
  .stock-order-summary .stock-order-total { grid-column:auto; }
}

@media (hover:none) and (pointer:coarse) {
  .mc-button,.account-tab,.topbar nav a,.conversation-item { touch-action:manipulation; }
  .mc-button:hover,.home-widget:hover { transform:none; }
}

/* Correções de robustez para smartphones — 2026-08-27 */
@media (max-width:760px) {
  html,body,#app,.portal { width:100%; max-width:100%; }
  body { overflow-x:hidden; overscroll-behavior-x:none; }
  img,svg,video,canvas { max-width:100%; }
  table { display:block; width:100%; max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  pre,code,kbd { max-width:100%; overflow-wrap:anywhere; white-space:pre-wrap; }
  #content, #content > *, .grid > *, .home-grid > *, .card, .list-row { min-width:0; max-width:100%; }

  .topbar { padding-left:max(11px,env(safe-area-inset-left)); padding-right:max(11px,env(safe-area-inset-right)); }
  .topbar nav { z-index:60; overflow-y:auto; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; }
  .topbar nav a { overflow:hidden; text-overflow:ellipsis; }

  .page-head { max-width:100%; }
  .page-head > * { min-width:0; max-width:100%; }
  .section-title > *, .page-actions > *, .search-bar > * { min-width:0; max-width:100%; }
  .actions { flex-wrap:wrap; }
  .actions > * { min-width:0; max-width:100%; }

  .social-layout > section,.social-layout > aside { min-width:0; }
  .post-composer textarea { width:100%; resize:vertical; }
  .social-post { overflow:hidden; }
  .social-post header a { min-width:0; }
  .social-post header a > div { min-width:0; }
  .social-post header strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .social-gif,.chat-gif { width:100%; max-width:100%; overflow:hidden; }
  .social-gif img,.chat-gif img { width:auto; max-width:100%; height:auto; }
  .social-post footer { align-items:center; }
  .social-post footer button { min-height:38px; }
  .profile-results { max-height:45dvh; }

  .gif-picker { height:min(88dvh,760px); display:flex; flex-direction:column; overflow:hidden; }
  .gif-search { flex:0 0 auto; grid-template-columns:minmax(0,1fr) auto; }
  .gif-search input { min-width:0; }
  .gif-results { flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; align-content:start; }
  .gif-result { min-height:92px; }
  .gif-attribution { flex:0 0 auto; }
  .gif-error { display:grid; gap:9px; place-items:center; align-content:center; }
  .gif-error strong,.gif-error span { display:block; text-align:center; }

  .elitegram-panel { --elitegram-head-h:62px; inset:0 !important; width:100vw !important; max-width:100vw; height:100dvh !important; max-height:100dvh; border-radius:0; }
  .elitegram-head { height:var(--elitegram-head-h); min-height:var(--elitegram-head-h); padding-left:max(12px,env(safe-area-inset-left)); padding-right:max(12px,env(safe-area-inset-right)); }
  .elitegram-head > div { min-width:0; }
  .elitegram-head > div > div { min-width:0; }
  .elitegram-head strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .elitegram-body { height:calc(100dvh - var(--elitegram-head-h)); min-height:0; }
  .elitegram-body > aside,#chat-view,.chat-room,.chat-messages { min-width:0; min-height:0; }
  .chat-room > header { flex:0 0 auto; min-width:0; padding:8px 10px; }
  .chat-room > header > div:first-child { min-width:0; overflow:hidden; }
  .chat-room > header > div:first-child strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .chat-room > header small { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .chat-actions { flex:0 0 auto; }
  .chat-actions button { width:34px; height:34px; }
  .chat-message { min-width:0; }
  .chat-message > div { min-width:0; max-width:min(86%,520px); }
  #message-form { flex:0 0 auto; min-width:0; }
  .message-controls { min-width:0; align-items:stretch; }
  .message-controls input { min-width:0; }
  .message-controls .mc-button { width:46px; flex:0 0 46px; padding:8px; }
  .gif-chat-button { min-width:50px; flex:0 0 50px; border-radius:8px; }
}

@media (max-width:480px) {
  .gif-results { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .gif-search { grid-template-columns:1fr; }
  .gif-search .mc-button { width:100%; }
  .profile-hero { grid-template-columns:58px minmax(0,1fr); }
  .profile-hero > img { width:58px; height:58px; }
  .profile-stats { grid-template-columns:repeat(5,minmax(82px,1fr)); }
}

@media (max-width:390px) {
  .bank-stats { grid-template-columns:1fr !important; }
  .topbar nav { grid-template-columns:1fr 1fr; }
  .conversation-item { min-width:92px; }
  .elitegram-body { grid-template-rows:104px minmax(0,1fr); }
  .elitegram-body > aside { grid-template-columns:92px minmax(0,1fr); }
}
