:root {
  --acessos-item-col: minmax(140px, 2fr);
  --acessos-senha-col: minmax(110px, 1fr);
  --acessos-acoes-col: minmax(170px, 1.2fr);
  --acessos-border: #dbe2ea;
  --acessos-border-strong: #cbd5e1;
  --acessos-surface: #ffffff;
  --acessos-surface-soft: #f8fbff;
  --acessos-surface-head: #f7faff;
  --acessos-title: #1e3a8a;
  --acessos-text-soft: #64748b;
  --acessos-shadow: 0 10px 24px rgba(36, 56, 129, 0.08);
}

.menu-btn span {
  background: #ffffff;
}

.page-acessos {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 100%;
  box-sizing: border-box;
}

.acessos-card {
  padding: 0;
}

.acessos-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.acessos-toolbar__copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.acessos-toolbar h1 {
  margin: 0;
  color: var(--azul);
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.acessos-toolbar p {
  margin: 0;
  color: var(--acessos-text-soft);
  font-size: 14px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.acessos-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.acessos-group {
  border: 1px solid rgba(148, 163, 184, .26);
  border-radius: 12px;
  background: var(--acessos-surface);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}

.acessos-group__title {
  margin: 0;
  padding: 12px 10px;
  background: linear-gradient(180deg, #fbfdff 0%, #f1f6ff 100%);
  color: var(--acessos-title);
  font-size: 15px;
  font-weight: 800;
  border-bottom: 1px solid rgba(226, 232, 240, .7);
}

.acessos-table-wrapper {
  overflow-x: auto;
}

.acessos-table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.acessos-table col.col-item {
  width: 28%;
}

.acessos-table col.col-senha {
  width: 14%;
}

.acessos-table col.col-checklist {
  width: 22%;
}

.acessos-table col.col-acoes {
  width: 44%;
}

.acessos-table thead th {
  background: var(--acessos-surface-head);
  color: #0f172a;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 11px 10px;
  border-bottom: 1px solid var(--acessos-border);
  text-align: left;
}

.acessos-table td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(226, 232, 240, .65);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

.acessos-table tbody tr:last-child td {
  border-bottom: none;
}

.acessos-table tbody tr:not(.row-editing):hover {
  background: #fbfdff;
}

.row-editing {
  background: var(--acessos-surface-soft);
}

.edit-panel-cell { padding: 14px !important; }
.edit-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, 1.2fr) minmax(180px, 1.4fr) auto; align-items: center; gap: 10px; }
.edit-panel > .item-edit-cell { min-width: 0; }
.edit-panel > .row-actions { width: auto; }
.acesso-edit-panel-wrap { border: 1px solid var(--acessos-border-strong); border-radius: 8px; background: var(--acessos-surface-soft); padding: 14px; margin-bottom: 14px; }
.acesso-edit-panel-title { margin: 0 0 12px; color: var(--acessos-title); font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }

.item-label {
  color: #0f172a;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.senha-mask {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 2px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: #0f172a;
}

.senha-invalida {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
  width: 100%;
}

.row-actions button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.inline-input {
  width: 100%;
  min-height: 42px;
  height: 42px;
  border: 1px solid var(--acessos-border-strong);
  border-radius: 12px;
  padding: 0 12px;
  font-size: 14px;
  background: #ffffff;
  color: #0f172a;
  box-sizing: border-box;
}

.inline-input:focus {
  border-color: var(--azul-claro);
  box-shadow: 0 0 0 3px rgba(61, 80, 195, 0.14);
  outline: none;
}

.item-edit-cell {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-edit-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.input-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--acessos-text-soft);
}

.status-line {
  margin-bottom: 10px;
  font-size: 13px;
  color: #1f2937;
}

.status-line.error {
  color: #b91c1c;
}

.status-line[data-visible="0"] {
  display: none;
}

.muted {
  color: var(--acessos-text-soft);
}

@media (max-width: 768px) {
  .acessos-card {
    padding: 0;
  }

  .acessos-toolbar {
    align-items: flex-start;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions button {
    flex: 1 1 auto;
    min-height: 42px;
  }

  .acessos-table col.col-item {
    width: 34%;
  }

  .acessos-table col.col-senha {
    width: 14%;
  }

  .acessos-table col.col-checklist {
    width: 25%;
  }

  .acessos-table col.col-acoes {
    width: 27%;
  }

  .acessos-table thead th,
  .acessos-table td {
    padding: 11px 10px;
  }

  .acessos-table td:last-child {
    padding-right: 8px;
  }
}

@media (max-width: 640px) {
  body { overflow-x: hidden; }
  .page-acessos { overflow-x: hidden; }
  .acesso-edit-panel-wrap { padding: 12px; margin-bottom: 12px; }
  .acessos-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .acessos-table {
    min-width: 0;
    max-width: 100%;
  }

  .acessos-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .acessos-table .row-editing td {
    vertical-align: top;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .acessos-table .row-editing .inline-input,
  .acessos-table .row-editing select {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  .acessos-table .row-editing .row-actions {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .acessos-table .row-editing td:nth-child(3) label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    font-size: 10px;
    line-height: 1.15;
  }

  .acessos-table .row-editing td:nth-child(3) label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    flex: 0 0 auto;
  }

  .acessos-table .row-editing td:nth-child(3) select {
    font-size: 10px;
    min-height: 32px;
    padding: 0 3px;
  }

  .acessos-table tr.row-editing {
    display: grid !important;
    grid-template-columns: 25% 18% 31% 26%;
    align-items: center;
    width: 100%;
  }

  .acessos-table tr.row-editing > td {
    display: block !important;
    width: auto !important;
    min-width: 0;
    box-sizing: border-box;
  }

  .acessos-table tr.row-editing > td:first-child {
    overflow: hidden;
  }

  .acessos-table tr.row-editing > td.edit-panel-cell {
    display: block !important;
    padding: 12px !important;
  }

  .edit-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
  }

  .edit-panel > strong,
  .edit-panel > .item-edit-cell,
  .edit-panel > .inline-input,
  .edit-panel > label,
  .edit-panel > .row-actions {
    width: 100%;
    box-sizing: border-box;
  }

  .edit-panel > .inline-input {
    min-height: 38px;
  }

  .edit-panel > label {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 5px;
    align-items: center;
    font-size: 11px;
  }

  .edit-panel > label input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    margin: 0;
  }

  .edit-panel > label select {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 36px;
    margin-top: 3px;
  }

  .acessos-table tr.row-editing .row-actions button {
    flex: 1 1 auto;
    min-width: 0;
    padding-inline: 3px;
    font-size: 10px;
  }

  .acessos-table tr.row-editing {
    display: block !important;
    width: 100%;
    padding: 8px 0;
  }

  .acessos-table tr.row-editing > td {
    display: block !important;
    width: 100% !important;
    padding: 7px 10px;
    box-sizing: border-box;
  }

  .acessos-table tr.row-editing > td:first-child {
    font-weight: 700;
  }

  .acessos-table tr.row-editing > td:nth-child(3) label {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
    column-gap: 6px;
    width: 100%;
    font-size: 11px;
  }

  .acessos-table tr.row-editing > td:nth-child(3) label input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    appearance: auto;
  }

  .acessos-table tr.row-editing > td:nth-child(3) select {
    grid-column: 1 / -1;
    margin-top: 5px;
    width: 100%;
    min-height: 36px;
  }

  .acessos-table tr.row-editing .row-actions {
    justify-content: flex-start;
  }

  .acessos-table {
    width: 100%;
    table-layout: fixed;
  }

  .acessos-table col.col-item {
    width: 32%;
  }

  .acessos-table col.col-senha {
    width: 13%;
  }

  .acessos-table col.col-checklist {
    width: 27%;
  }

  .acessos-table col.col-acoes {
    width: 28%;
  }

  .acessos-table thead th,
  .acessos-table td {
    padding: 9px 6px;
    font-size: 12px;
  }

  .acessos-table thead th {
    font-size: 10px;
  }

  .acessos-table td {
    align-items: center;
    min-width: 0;
  }

  .row-actions {
    gap: 4px;
  }

  .row-actions button {
    min-height: 34px;
    padding: 0 6px;
    font-size: 11px;
    border-radius: 10px;
  }

  .item-label {
    font-size: 13px;
    line-height: 1.2;
  }

  .senha-mask {
    min-height: 34px;
    font-size: 12px;
    letter-spacing: 0.06em;
  }

  .senha-invalida {
    min-height: 30px;
    padding: 0 8px;
    font-size: 11px;
  }
}

/* Edição simples: formulário independente da tabela. */
.acesso-edit-panel-wrap {
  box-sizing: border-box;
  width: 100%;
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid var(--acessos-border);
  border-radius: 10px;
  background: var(--acessos-surface-soft);
}
.acesso-edit-panel-title { margin: 0 0 12px; font-size: 16px; color: var(--acessos-title); }
.acesso-edit-panel { display: grid; gap: 11px; }
.acesso-edit-field { display: grid; gap: 5px; min-width: 0; }
.acesso-edit-label { font-size: 11px; font-weight: 700; color: var(--acessos-title); }
.acesso-edit-select, .acesso-edit-input {
  box-sizing: border-box; width: 100%; min-height: 38px; padding: 8px 10px;
  border: 1px solid var(--acessos-border-strong); border-radius: 8px; background: #fff;
}
.acesso-edit-readonly { font-size: 13px; font-weight: 700; color: var(--acessos-title); }
.acesso-edit-panel .row-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }
@media (max-width: 640px) {
  .acesso-edit-panel-wrap { padding: 12px; }
  .acesso-edit-panel .row-actions { justify-content: stretch; }
  .acesso-edit-panel .row-actions button { flex: 1; min-height: 36px; }
}

@media (max-width: 520px) {
  .page-acessos {
    gap: 12px;
  }

  .acessos-toolbar h1 {
    font-size: 22px;
  }

  .acessos-toolbar p {
    font-size: 13px;
  }

  .acessos-group__title {
    padding: 10px 8px;
    font-size: 14px;
  }

  .acessos-table col.col-item {
    width: 32%;
  }

  .acessos-table col.col-senha {
    width: 13%;
  }

  .acessos-table col.col-checklist {
    width: 27%;
  }

  .acessos-table col.col-acoes {
    width: 28%;
  }

  .acessos-table thead th,
  .acessos-table td {
    padding: 8px 4px;
    font-size: 11px;
  }

  .acessos-table thead th {
    font-size: 10px;
  }

  .row-actions {
    gap: 3px;
  }

  .row-actions button {
    min-height: 32px;
    padding: 0 4px;
    font-size: 10px;
  }

  .item-label {
    font-size: 12px;
  }

  .senha-mask {
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  .item-edit-meta {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* Mobile visual refresh */
.page-acessos {
  padding-inline: 8px;
}

.acessos-card {
  padding: 14px 12px;
}

.acessos-toolbar {
  margin-bottom: 12px;
}

.acessos-toolbar h1 {
  color: #172b67;
  font-size: 22px;
  letter-spacing: 0;
}

.toolbar-actions button {
  min-height: 44px;
}

.acessos-group {
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(16, 35, 70, 0.07);
}

.acessos-group__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f4f7ff;
}

.acessos-group__title::after {
  content: attr(data-count);
}

.acessos-table tbody tr {
  transition: background 0.15s ease;
}

@media (max-width: 640px) {
  .acessos-card {
    padding: 12px 10px;
  }

  .acessos-toolbar {
    display: grid;
    gap: 12px;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 44px;
    gap: 8px;
  }

  .toolbar-actions .ghost {
    font-size: 0;
    padding: 0;
  }

  .toolbar-actions .ghost::before {
    content: "↻";
    font-size: 20px;
    line-height: 1;
  }

  .acessos-table,
  .acessos-table tbody,
  .acessos-table tr,
  .acessos-table td {
    display: block;
    width: 100%;
  }

  .acessos-table colgroup,
  .acessos-table thead {
    display: none;
  }

  .acessos-table tbody {
    padding: 8px;
  }

  .acessos-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "item senha"
      "actions actions";
    gap: 8px;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid rgba(36, 56, 129, 0.12);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 5px 14px rgba(16, 35, 70, 0.06);
  }

  .acessos-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .acessos-table td {
    padding: 0;
    border: 0;
  }

  .acessos-table td:nth-child(1) {
    grid-area: item;
  }

  .acessos-table td:nth-child(2) {
    grid-area: senha;
    align-self: center;
  }

  .acessos-table td:nth-child(3) {
    grid-area: actions;
  }

  .item-label {
    font-size: 14px;
    font-weight: 800;
  }

  .senha-mask {
    min-height: 30px;
    padding: 0 8px;
    border-radius: 999px;
    background: #edf3ff;
    letter-spacing: 0.08em;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .row-actions button {
    min-height: 38px;
    border-radius: 10px;
    font-size: 12px;
  }
}

/* User preference: compact list instead of mobile cards */
@media (max-width: 640px) {
  .acessos-toolbar {
    gap: 10px;
  }

  .toolbar-actions {
    grid-template-columns: minmax(0, 1fr) 92px;
  }

  .toolbar-actions button {
    min-height: 38px;
    border-radius: 10px;
    font-size: 12px;
    padding-inline: 10px;
  }

  .toolbar-actions .ghost {
    font-size: 12px;
    padding: 0 10px;
  }

  .toolbar-actions .ghost::before {
    content: none;
  }

  .acessos-groups {
    gap: 12px;
  }

  .acessos-group {
    border-radius: 12px;
  }

  .acessos-group__title {
    padding: 9px 10px;
    font-size: 13px;
    border-bottom: 1px solid rgba(36, 56, 129, 0.10);
  }

  .acessos-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .acessos-table {
    display: table !important;
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
  }

  .acessos-table colgroup {
    display: table-column-group !important;
  }

  .acessos-table col.col-item {
    width: 32%;
  }

  .acessos-table col.col-senha {
    width: 13%;
  }

  .acessos-table col.col-checklist {
    width: 27%;
  }

  .acessos-table col.col-acoes {
    width: 28%;
  }

  .acessos-table thead {
    display: table-header-group !important;
  }

  .acessos-table tbody {
    display: table-row-group !important;
    padding: 0;
  }

  .acessos-table tr {
    display: table-row !important;
  }

  .acessos-table th,
  .acessos-table td {
    display: table-cell !important;
    width: auto;
  }

  .acessos-table thead th {
    padding: 7px 5px;
    font-size: 9px;
    letter-spacing: 0.03em;
  }

  .acessos-table td {
    padding: 7px 5px;
    font-size: 11px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.75);
    vertical-align: middle;
  }

  .acessos-table tbody tr {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .acessos-table tbody tr:nth-child(even) {
    background: #f8fbff;
  }

  .item-label {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.22;
  }

  .senha-mask {
    min-height: 24px;
    padding: 0 2px;
    border-radius: 0;
    background: transparent;
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  .row-actions {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
  }

  .row-actions button {
    min-height: 28px;
    padding: 0 5px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
  }
}
