/* Nova shell desktop (DEC-301): topbar institucional verde, rail de módulos,
   menu de contexto e conteúdo único em .portal-main. Visível a partir de 768 px. */
.topbar, .sidebar { display: none; }

@media (min-width: 768px) {
  .mobile-header, .bottom-nav { display: none !important; }
  .inicio-mobile { display: none !important; }
  .inicio-desktop { display: block; }

  .topbar {
    display: flex;
    align-items: center;
    gap: 22px;
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 40;
    height: 96px;
    padding: 0 28px;
    background: var(--green-dark, #103f2d);
    color: #fff;
    box-shadow: 0 1px 0 rgb(255 255 255 / 8%);
  }
  .topbar a { color: inherit; }
  .topbar-brand { display: grid; align-content: center; min-width: 250px; color: #fff; text-decoration: none; }
  .topbar-brand__title { font-size: 1.55rem; font-weight: 760; line-height: 1.1; letter-spacing: -.02em; }
  .topbar-brand__campus { margin-top: 4px; color: #d6e9df; font-size: .95rem; }
  .topbar-actions { display: flex; align-items: center; gap: 16px; margin-left: auto; }
  .topbar-icon {
    display: grid; place-items: center; width: 42px; height: 42px; padding: 0;
    border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: default;
  }
  .topbar-icon .icon { width: 25px; height: 25px; }
  .topbar-divider { width: 1px; height: 34px; background: rgb(255 255 255 / 45%); }
  .account-menu { position: relative; }
  .account-menu > .account-link { display: flex; align-items: center; gap: 11px; min-height: 52px; padding: 5px 0; color: #fff; list-style: none; cursor: pointer; }
  .account-menu .avatar { width: 38px; height: 38px; background: #fff; color: var(--green-dark); }
  .account-menu strong { display: block; color: #fff; font-size: .95rem; line-height: 1.2; }
  .account-menu small { display: block; margin-top: 2px; color: #d6e9df; font-size: .78rem; }
  .account-menu .chevron { width: 18px; height: 18px; }
  .account-menu__panel {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 45; min-width: 200px;
    padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
    box-shadow: 0 18px 38px rgb(9 34 24 / 18%);
  }
  .account-menu__panel a, .account-menu__panel .logout-button {
    display: flex; align-items: center; width: 100%; min-height: 40px; padding: 8px 10px;
    border: 0; border-radius: 6px; color: var(--text); background: transparent;
    font: inherit; text-align: left; text-decoration: none; cursor: pointer;
  }
  .account-menu__panel a:hover, .account-menu__panel .logout-button:hover { background: var(--green-soft); color: var(--green-dark); }
  .account-menu__panel .logout-form { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--line); }

  .sidebar {
    display: flex;
    position: fixed;
    top: 96px;
    bottom: 0;
    left: 0;
    z-index: 35;
    width: 356px;
    background: #fff;
    border-right: 1px solid #e3ebe6;
    transition: width .2s ease;
  }
  .module-rail { display: flex; flex-direction: column; width: 128px; flex: none; padding: 14px 9px 12px; border-right: 1px solid #e8eeea; }
  .rail-label { margin: 0 0 8px; color: var(--muted); font-size: .68rem; font-weight: 700; text-align: center; letter-spacing: .08em; text-transform: uppercase; }
  .rail-link {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
    min-height: 94px; margin-bottom: 4px; padding: 10px 4px; border-radius: 9px;
    color: #34463d; font-size: .82rem; line-height: 1.15; text-align: center; text-decoration: none;
  }
  .rail-link .icon { width: 30px; height: 30px; }
  .rail-link:hover { background: #f3f7f4; color: var(--green-dark); }
  .rail-link[aria-current="page"] { background: #e4f1e7; color: var(--green-dark); font-weight: 750; }
  .collapse-sidebar {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
    min-height: 94px; margin: 4px 0 0; padding: 10px 6px;
    border: 1px solid var(--green-dark); border-radius: 9px;
    background: #fff; color: var(--green-dark);
    font-family: inherit; font-size: .82rem; line-height: 1.15; text-align: center;
    cursor: pointer;
  }
  .collapse-sidebar .icon { width: 28px; height: 28px; }
  .collapse-sidebar:hover { background: #e4f1e7; color: var(--green-dark); }
  .collapse-sidebar:focus-visible { outline: 3px solid var(--green-dark); outline-offset: 2px; }

  .context-menu { flex: 1; min-width: 0; padding: 24px 18px 18px; overflow-y: auto; }
  .context-title { margin: 0 12px 14px; color: var(--text); font-size: 1.08rem; font-weight: 750; letter-spacing: -.01em; }
  .context-search { display: flex; align-items: center; gap: 8px; margin: 0 12px 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
  .context-search .icon { width: 17px; height: 17px; color: #4b5f55; flex: none; }
  .context-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: .9rem; outline: none; }
  .context-search:focus-within { border-color: var(--green-dark); box-shadow: 0 0 0 3px rgba(0, 85, 48, .15); }
  .context-group { display: flex; align-items: center; gap: 9px; margin: 24px 12px 8px; color: var(--text); font-size: 1rem; font-weight: 750; }
  .context-group .icon { width: 20px; height: 20px; color: #4b5f55; }
  .context-group--nivel2 { margin: 14px 12px 6px; font-size: .98rem; font-weight: 700; color: #26372f; }
  .context-node__row { display: flex; align-items: center; }
  .context-node__row .context-link { flex: 1; min-width: 0; }
  .context-toggle { color: #4b5f55; cursor: pointer; }
  .context-toggle .icon { flex: none; width: 18px; height: 18px; transition: transform .15s ease; }
  .context-toggle[aria-expanded="false"] .context-toggle__chevron,
  .context-toggle--icon[aria-expanded="false"] .icon { transform: rotate(-90deg); }
  .context-toggle--group {
    width: calc(100% - 24px); min-height: 40px; padding: 6px 0;
    border: 0; background: transparent; font-family: inherit; text-align: left;
  }
  .context-toggle--group .context-toggle__chevron { margin-left: auto; }
  .context-toggle--icon {
    display: grid; place-items: center; flex: none; width: 36px; height: 36px;
    padding: 0; border: 0; border-radius: 6px; background: transparent;
  }
  .context-toggle:hover { color: var(--green-dark); background: #f3f7f4; }
  .context-toggle:focus-visible { outline: 2px solid var(--green-dark); outline-offset: 2px; }
  .context-children[hidden] { display: none; }
  .context-link {
    display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 9px 12px;
    border-radius: 8px; color: #26372f; font-size: .98rem; text-decoration: none;
  }
  .context-link .icon { width: 20px; height: 20px; color: #4b5f55; }
  .context-link[data-nivel="2"] { font-size: .98rem; }
  .context-link[data-nivel="3"] { min-height: 36px; padding: 5px 12px 5px 32px; font-size: .9rem; border-radius: 6px; }
  .context-link[data-nivel="3"] .icon { width: 17px; height: 17px; }
  .context-link[data-nivel="4"] { min-height: 34px; padding: 5px 12px 5px 48px; font-size: .86rem; border-radius: 6px; }
  .context-link[data-nivel="4"] .icon { width: 16px; height: 16px; }
  .context-node[data-nivel="3"] > .context-toggle--group { padding-left: 32px; }
  .context-link:hover { background: #f3f7f4; color: var(--green-dark); }
  .context-link[aria-current="page"] { background: #e4f1e7; color: var(--green-dark); font-weight: 750; }
  .context-link[aria-current="page"] .icon { color: var(--green-dark); }
  .context-help { margin: 20px 12px 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }

  .portal-main {
    margin-left: 356px;
    padding: 122px 34px 38px;
    min-height: 100vh;
    background: #f5f7f5;
    transition: margin-left .2s ease;
  }
  .portal-main--anonimo { margin-left: 0; padding: 0; background: #f3f6f4; }

  .sidebar-collapsed .sidebar { width: 128px; }
  .sidebar-collapsed .context-menu { display: none; }
  .sidebar-collapsed .portal-main { margin-left: 128px; }
  .sidebar-collapsed .topbar-brand { min-width: 0; }
  .sidebar-collapsed .topbar-brand span { display: none; }
  .sidebar-collapsed .rail-label { display: none; }
}

/* Faixa desktop estreita (DEC-332): por padrão o rail fica recolhido de
   768 px a 1279 px para que tabelas e filtros caibam sem rolagem lateral.
   A partir de 1280 px o menu de contexto reaparece; a expansão manual do
   usuário (body.sidebar-expandida) prevalece na faixa estreita. */
@media (min-width: 768px) and (max-width: 1279px) {
  body:not(.sidebar-expandida) .sidebar { width: 128px; }
  body:not(.sidebar-expandida) .context-menu { display: none; }
  body:not(.sidebar-expandida) .portal-main { margin-left: 128px; }
  body:not(.sidebar-expandida) .topbar-brand { min-width: 0; }
  body:not(.sidebar-expandida) .topbar-brand span { display: none; }
  body:not(.sidebar-expandida) .rail-label { display: none; }
}

/* Apresentação expandida (RF-091/092). */
@media (min-width: 1280px) {
  body:not(.sidebar-collapsed) .sidebar { width: 356px; }
  body:not(.sidebar-collapsed) .context-menu { display: block; }
  body:not(.sidebar-collapsed) .portal-main { margin-left: 356px; }
}

/* Conteúdo comum do desktop (protótipos de 19/11/2026). */
@media (min-width: 768px) {
  .breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 0 14px; color: #56675f; font-size: .92rem; }
  .breadcrumb a { color: var(--green-dark); text-decoration: none; }
  .breadcrumb a:hover { text-decoration: underline; text-underline-offset: 3px; }
  .breadcrumb .icon { width: 18px; height: 18px; color: #56675f; }
  .page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
  .page-heading h1 { margin: 0; font-size: clamp(1.8rem, 2.2vw, 2.15rem); line-height: 1.12; letter-spacing: -.035em; }
  .page-heading .muted { max-width: 60ch; margin: 7px 0 0; color: #5c6b63; font-size: .98rem; }
  .page-heading__actions { display: flex; flex-shrink: 0; align-items: center; gap: 10px; padding-top: 4px; }
  .page-heading__actions .button { width: auto; min-height: 46px; margin: 0; padding: 10px 18px; white-space: nowrap; }
  .muted { color: #5c6b63; }
  .filter-panel { margin: 0 0 22px; padding: 18px 20px 16px; border: 1px solid #e0e9e3; border-radius: 10px; background: #eef6f0; }
  .filter-grid { display: grid; grid-template-columns: minmax(220px, 2.1fr) repeat(3, minmax(145px, 1fr)) auto; align-items: end; gap: 14px; }
  .filter-grid .field { display: grid; gap: 6px; min-width: 0; }
  .filter-grid .field label { margin: 0; color: var(--text); font-size: .9rem; font-weight: 750; }
  .filter-grid .control { width: 100%; min-height: 44px; margin: 0; background: #fff; }
  .filter-grid .button { min-height: 44px; padding: 8px 19px; }
  .filter-more { margin: 12px 0 0; border: 0; background: transparent; }
  .filter-more summary { display: inline-flex; align-items: center; gap: 6px; color: var(--green-dark); font-weight: 700; cursor: pointer; list-style: none; }
  .filter-more summary::-webkit-details-marker { display: none; }
  .filter-more[open] summary { margin-bottom: 12px; }
  .filter-more .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 18px 0 10px; }
  .list-toolbar p { margin: 0; color: var(--text); font-size: 1.05rem; font-weight: 750; }
  .list-toolbar .text-button { width: auto; min-height: 36px; margin: 0; padding: 4px 6px; border: 0; background: transparent; color: var(--green-dark); font: inherit; font-weight: 650; cursor: pointer; }
  .table-wrap { overflow-x: auto; border: 1px solid #e0e9e3; border-radius: 9px; background: #fff; }
  .data-table { width: 100%; border-collapse: collapse; font-size: .94rem; }
  .data-table caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table th, .data-table td { padding: 13px 15px; border-bottom: 1px solid #e8eeea; text-align: left; vertical-align: middle; }
  .data-table thead th { background: #edf5ef; color: #26372f; font-size: .86rem; font-weight: 750; white-space: nowrap; }
  .data-table tbody tr:last-child td { border-bottom: 0; }
  .data-table tbody tr:hover { background: #fafcfb; }
  .data-table .code { color: var(--green-dark); font-weight: 700; text-decoration: none; white-space: nowrap; }
  .data-table .code:hover, .data-table .row-action:hover { text-decoration: underline; text-underline-offset: 3px; }
  .data-table .row-action { color: var(--green-dark); font-weight: 650; text-decoration: none; white-space: nowrap; }
  .data-table .row-primary { font-weight: 700; }
  .data-table .row-secondary { display: block; margin-top: 2px; color: #66756d; font-size: .84rem; }
  .data-table .row-date { white-space: nowrap; }
  .badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 5px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
  .badge--green { background: #dff3e4; color: #176c3c; }
  .badge--blue { background: #e0edf8; color: #22577a; }
  .badge--amber { background: #fff1d7; color: #805b12; }
  .badge--red { background: #fde2e1; color: #a22d24; }
  .badge--gray { background: #edf0ee; color: #4d5b53; }
  .table-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-top: 1px solid #e8eeea; color: #5c6b63; font-size: .93rem; }
  .pagination-controls { display: flex; align-items: center; gap: 6px; }
  .pagination-controls .button { width: auto; min-height: 34px; margin: 0; padding: 5px 11px; font-size: .86rem; }
  .pagination-controls .page-current { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 5px; background: var(--green-dark); color: #fff; font-weight: 700; }
  .empty-state { margin: 18px 0 0; padding: 28px; border: 1px dashed #cbd9d0; border-radius: 9px; background: #fff; color: #56675f; text-align: center; }
  .empty-state h2 { margin: 0 0 6px; font-size: 1.12rem; color: var(--text); }
  .empty-state p { margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .context-toggle .icon,,
  .sidebar,
  .portal-main
  .collapse-sidebar .icon {
    transition: none;
  }
}
