:root {
  color-scheme: light;
  --color-bg: #f3f6f8;
  --color-surface: #ffffff;
  --color-surface-soft: #f8fafb;
  --color-ink: #172332;
  --color-muted: #607080;
  --color-border: #d9e1e7;
  --color-border-strong: #bdc9d2;
  --color-brand: #123b5d;
  --color-brand-strong: #0a2c47;
  --color-brand-soft: #e9f2f8;
  --color-success: #176b48;
  --color-success-soft: #e7f6ee;
  --color-info: #17619a;
  --color-info-soft: #e7f2fa;
  --color-warning: #815300;
  --color-warning-soft: #fff4d6;
  --color-danger: #a12b32;
  --color-danger-strong: #7c1f25;
  --color-danger-soft: #fdebed;
  --color-neutral: #566472;
  --color-neutral-soft: #edf1f4;
  --shadow-sm: 0 1px 2px rgb(15 35 52 / 8%), 0 4px 14px rgb(15 35 52 / 5%);
  --shadow-md: 0 14px 36px rgb(15 35 52 / 13%);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --sidebar-width: 276px;
  --content-width: 1420px;
  --focus-ring: 0 0 0 3px rgb(35 120 177 / 28%);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--color-bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--color-ink);
  background: var(--color-bg);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.menu-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--color-info);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button,
input,
select,
textarea {
  margin: 0;
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

img,
svg {
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
strong {
  overflow-wrap: anywhere;
}

h1 {
  margin-bottom: 0.45rem;
  font-size: clamp(1.65rem, 1.2rem + 1.25vw, 2.35rem);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

h2 {
  margin-bottom: 0.4rem;
  font-size: clamp(1.05rem, 0.98rem + 0.35vw, 1.35rem);
  line-height: 1.25;
}

p:last-child {
  margin-bottom: 0;
}

:focus-visible {
  outline: 3px solid transparent;
  box-shadow: var(--focus-ring);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Estrutura principal */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: var(--sidebar-width);
  height: 100vh;
  padding: 1.4rem 1.2rem;
  overflow-y: auto;
  color: #fff;
  background: linear-gradient(
    180deg,
    var(--color-brand-strong) 0%,
    #123b5d 62%,
    #174968 100%
  );
  border-right: 1px solid rgb(255 255 255 / 10%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 52px;
  color: #fff;
  text-decoration: none;
}

.brand > span:last-child,
.sidebar-user > span:last-child {
  display: grid;
  min-width: 0;
}

.brand strong,
.sidebar-user strong {
  line-height: 1.25;
}

.brand small,
.sidebar-user small {
  margin-top: 0.18rem;
  color: rgb(255 255 255 / 72%);
  font-size: 0.77rem;
}

.brand-mark {
  display: inline-grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #2a83b9, #17618e);
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 14px;
  box-shadow: 0 8px 22px rgb(0 0 0 / 16%);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.sidebar nav {
  display: grid;
  gap: 0.52rem;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 52px;
  padding: 0.48rem 0.7rem;
  overflow: hidden;
  color: rgb(255 255 255 / 82%);
  background: rgb(255 255 255 / 2.5%);
  border: 1px solid rgb(255 255 255 / 9%);
  border-radius: 13px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 3%);
  font-size: 0.94rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.nav-link:hover {
  transform: translateX(2px);
  color: #fff;
  background: rgb(255 255 255 / 9%);
  border-color: rgb(255 255 255 / 17%);
}

.nav-link.active {
  color: #fff;
  background: linear-gradient(100deg, #215f87 0%, #285f80 100%);
  border-color: rgb(127 211 255 / 30%);
  box-shadow:
    0 8px 20px rgb(2 19 31 / 17%),
    inset 0 1px 0 rgb(255 255 255 / 10%);
}

.nav-link.active::before {
  position: absolute;
  inset: 8px auto 8px 0;
  width: 3px;
  content: "";
  background: #7fd3ff;
  border-radius: 0 999px 999px 0;
  box-shadow: 0 0 12px rgb(127 211 255 / 55%);
}

.nav-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  color: rgb(218 238 250 / 88%);
  background: rgb(255 255 255 / 6%);
  border: 1px solid rgb(255 255 255 / 9%);
  border-radius: 10px;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
  color: #fff;
  background: rgb(127 211 255 / 14%);
  border-color: rgb(127 211 255 / 24%);
}

.nav-label {
  min-width: 0;
  line-height: 1.2;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.95rem 0.2rem 0;
  margin-top: auto;
  border-top: 1px solid rgb(255 255 255 / 14%);
}

.avatar {
  display: inline-grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--color-brand-strong);
  background: #dff2fc;
  border-radius: 999px;
  font-weight: 800;
  text-transform: uppercase;
}

.main-column {
  min-width: 0;
}

.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  color: var(--color-brand);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 11px;
  font-size: 1.35rem;
  line-height: 1;
}

.page-content {
  width: min(100%, var(--content-width));
  padding: clamp(1rem, 2.8vw, 2.5rem);
  margin: 0 auto;
}

/* Cabeçalhos, cartões e painéis */
.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}

.page-heading > div {
  max-width: 850px;
}

.page-heading p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--color-muted);
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--color-info);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.095em;
  text-transform: uppercase;
}

.muted,
.optional {
  color: var(--color-muted);
}

.optional {
  font-size: 0.82em;
  font-weight: 500;
}

.panel,
.summary-card,
.equipment-card,
.history-card,
.user-card,
.shift-card,
.filter-panel,
.toolbar,
.inventory-filter-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.panel,
.summary-card,
.history-card,
.user-card,
.shift-card {
  padding: clamp(1rem, 2vw, 1.45rem);
}

.panel + .panel,
.shift-card + .panel {
  margin-top: 1rem;
}

details > summary {
  cursor: pointer;
  color: var(--color-brand);
  font-weight: 750;
}

details > summary::marker {
  color: var(--color-info);
}

details[open] > summary {
  margin-bottom: 1rem;
}

.admin-grid,
.two-column,
.security-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.summary-card {
  position: relative;
  align-self: start;
  overflow: hidden;
}

.summary-card::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  content: "";
  background: var(--color-info);
}

.summary-card h2 {
  margin-top: 0.85rem;
}

/* Botões e formulários */
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.68rem 1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button.primary {
  color: #fff;
  background: var(--color-brand);
  border-color: var(--color-brand);
  box-shadow: 0 6px 14px rgb(18 59 93 / 14%);
}

.button.primary:hover:not(:disabled) {
  background: var(--color-brand-strong);
  border-color: var(--color-brand-strong);
}

.button.secondary {
  color: var(--color-brand);
  background: var(--color-brand-soft);
  border-color: #bed6e5;
}

.button.secondary:hover:not(:disabled) {
  background: #dcecf6;
}

.button.ghost {
  color: var(--color-brand);
  background: transparent;
  border-color: var(--color-border-strong);
}

.sidebar .button.ghost {
  color: #fff;
  border-color: rgb(255 255 255 / 28%);
}

.sidebar .button.ghost:hover:not(:disabled) {
  background: rgb(255 255 255 / 9%);
}

.button.danger {
  color: #fff;
  background: var(--color-danger);
  border-color: var(--color-danger);
}

.button.danger:hover:not(:disabled) {
  background: var(--color-danger-strong);
  border-color: var(--color-danger-strong);
}

.button.small {
  min-height: 38px;
  padding: 0.5rem 0.72rem;
  font-size: 0.85rem;
}

.button.large {
  min-height: 54px;
  padding: 0.85rem 1.2rem;
  font-size: 1.03rem;
}

.button.wide {
  width: 100%;
}

form[aria-busy="true"] .button[type="submit"] {
  cursor: wait;
}

form[aria-busy="true"] .button[type="submit"]::before {
  width: 15px;
  height: 15px;
  content: "";
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 700ms linear infinite;
}

.form-stack,
.compact-form {
  display: grid;
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-grid > .button:last-child {
  align-self: end;
}

label {
  display: grid;
  gap: 0.42rem;
  color: #314252;
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.68rem 0.78rem;
  color: var(--color-ink);
  background: #fff;
  border: 1px solid var(--color-border-strong);
  border-radius: 9px;
  font-weight: 500;
  line-height: 1.35;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #7f8c98;
  opacity: 1;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #8fa3b2;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #287db2;
  box-shadow: var(--focus-ring);
}

input:user-invalid,
select:user-invalid,
textarea:user-invalid {
  border-color: var(--color-danger);
}

fieldset {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

legend {
  padding: 0;
  margin-bottom: 0.65rem;
  color: #314252;
  font-size: 0.9rem;
  font-weight: 800;
}

.checkbox-field {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.8rem;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: 9px;
}

.checkbox-field input,
.choice-card input {
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  margin: 0;
  accent-color: var(--color-brand);
}

.choice-card {
  display: flex;
  min-height: 66px;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.9rem;
  margin-bottom: 0.65rem;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: 11px;
  cursor: pointer;
}

.choice-card:has(input:checked) {
  background: var(--color-brand-soft);
  border-color: #70a8cb;
  box-shadow: 0 0 0 2px rgb(35 120 177 / 10%);
}

.choice-card span {
  display: grid;
  gap: 0.15rem;
}

.choice-card small,
.field-hint {
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.is-required > textarea {
  background: #fffdf8;
  border-color: #c79231;
}

.inline-form {
  display: flex;
  align-items: end;
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.inline-form input,
.inline-form select {
  min-width: 150px;
}

.inline-details summary,
.details-form summary {
  width: fit-content;
  min-height: 38px;
  padding: 0.45rem 0;
}

.details-form {
  padding-top: 0.75rem;
  margin-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.action-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.action-panel h2,
.action-panel p {
  margin-bottom: 0.2rem;
}

/* Estados e mensagens */
.status-pill {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  gap: 0.42rem;
  padding: 0.3rem 0.58rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
}

.status-pill::before {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  content: "";
  background: currentColor;
  border-radius: 999px;
}

.status-success {
  color: var(--color-success);
  background: var(--color-success-soft);
  border-color: #bce1cc;
}

.status-info {
  color: var(--color-info);
  background: var(--color-info-soft);
  border-color: #c0dced;
}

.status-warning {
  color: var(--color-warning);
  background: var(--color-warning-soft);
  border-color: #edd494;
}

.status-danger {
  color: var(--color-danger);
  background: var(--color-danger-soft);
  border-color: #efbdc1;
}

.status-neutral {
  color: var(--color-neutral);
  background: var(--color-neutral-soft);
  border-color: #d5dde3;
}

.flash-stack {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.flash {
  padding: 0.15rem 0;
  color: var(--color-info);
  background: transparent;
  border: 0;
  border-radius: 0;
  font-weight: 650;
}

.flash-success {
  color: var(--color-success);
}

.flash-warning {
  color: var(--color-warning);
}

.flash-error {
  color: var(--color-danger);
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  padding: 2rem;
  text-align: center;
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
}

.empty-state.compact {
  min-height: 150px;
  padding: 1.25rem;
}

.empty-state h1,
.empty-state h2 {
  margin-bottom: 0.35rem;
}

.empty-state p {
  max-width: 620px;
  color: var(--color-muted);
}

.empty-icon {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  margin-bottom: 0.7rem;
  color: var(--color-danger);
  background: var(--color-danger-soft);
  border-radius: 999px;
  font-size: 1.55rem;
  font-weight: 900;
}

/* Painel de equipamentos */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.stat-card {
  position: relative;
  display: grid;
  min-height: 112px;
  align-content: space-between;
  padding: 1rem;
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.stat-card::after {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  content: "";
  background: var(--color-neutral);
}

.stat-card span {
  color: var(--color-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.stat-card strong {
  font-size: 2rem;
  line-height: 1;
}

.stat-success::after {
  background: var(--color-success);
}
.stat-info::after {
  background: var(--color-info);
}
.stat-warning::after {
  background: var(--color-warning);
}
.stat-danger::after {
  background: var(--color-danger);
}

.toolbar,
.filter-panel,
.inventory-filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr);
  gap: 0.8rem;
  align-items: end;
  padding: 0.9rem;
  margin-bottom: 1rem;
}

.filter-panel {
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(140px, 1fr)) auto;
}

.inventory-filter-bar {
  grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(150px, 1fr));
}

.filter-result {
  grid-column: 1 / -1;
  margin: -0.15rem 0 0;
  color: var(--color-muted);
  font-size: 0.82rem;
}

.equipment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
}

.equipment-card {
  position: relative;
  display: flex;
  min-height: 250px;
  flex-direction: column;
  padding: 1.05rem;
  overflow: hidden;
}

.equipment-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  content: "";
  background: var(--color-neutral);
}

.equipment-card.status-success-card::before {
  background: var(--color-success);
}
.equipment-card.status-info-card::before {
  background: var(--color-info);
}
.equipment-card.status-warning-card::before {
  background: var(--color-warning);
}
.equipment-card.status-danger-card::before {
  background: var(--color-danger);
}
.equipment-card.status-neutral-card::before {
  background: var(--color-neutral);
}

.equipment-card h2 {
  margin-top: 0.9rem;
}

.equipment-card > p {
  color: var(--color-muted);
}

.equipment-card > .button:last-child {
  margin-top: auto;
}

.card-top,
.history-header,
.user-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-top > strong,
.history-header > strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  text-align: right;
}

.meta-list {
  display: grid;
  gap: 0.55rem;
  margin: 0.9rem 0 1rem;
}

.meta-list.horizontal {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-top: 0.9rem;
  border-top: 1px solid var(--color-border);
}

.meta-list > div {
  min-width: 0;
}

.meta-list dt {
  color: var(--color-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.meta-list dd {
  margin: 0.12rem 0 0;
  font-size: 0.9rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.reason-text {
  padding: 0.65rem 0.75rem;
  background: var(--color-danger-soft);
  border-radius: 8px;
  font-size: 0.86rem;
}

/* Confirmação de retirada/devolução */
.confirmation-screen {
  width: min(100%, 900px);
  padding: clamp(1rem, 2.5vw, 2rem);
  margin: 0 auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.confirmation-header {
  max-width: 720px;
  margin-bottom: 1.2rem;
}

.confirmation-header p:last-child {
  color: var(--color-muted);
}

.confirmation-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.85rem;
  margin-bottom: 1rem;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.confirmation-summary > div {
  display: grid;
  gap: 0.2rem;
  min-height: 88px;
  align-content: center;
  padding: 0.8rem;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 9px;
}

.confirmation-summary span,
.confirmation-summary small {
  color: var(--color-muted);
}

.confirmation-summary span {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.confirmation-form {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 0.65rem;
  background: var(--color-brand-soft);
  border: 1px solid #bed6e5;
  border-radius: 12px;
}

.confirmation-form input[type="password"] {
  min-height: 54px;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
}

/* Histórico */
.history-list,
.user-grid {
  display: grid;
  gap: 1rem;
}

.history-header h2 {
  margin: 0.55rem 0 0;
}

.timeline {
  position: relative;
  display: grid;
  gap: 0.8rem;
  padding: 1rem 0;
}

.timeline-event {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 0.75rem;
}

.timeline-event > span {
  position: relative;
  width: 12px;
  height: 12px;
  margin-top: 0.33rem;
  background: var(--color-neutral);
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 2px var(--color-neutral);
}

.timeline-event.complete > span {
  background: var(--color-success);
  box-shadow: 0 0 0 2px var(--color-success);
}

.timeline-event.pending > span {
  background: var(--color-warning);
  box-shadow: 0 0 0 2px var(--color-warning);
}

.timeline-event:not(:last-child) > span::after {
  position: absolute;
  top: 14px;
  left: 4px;
  width: 2px;
  height: calc(100% + 1.15rem);
  content: "";
  background: var(--color-border-strong);
}

.timeline-event p {
  margin: 0.14rem 0 0;
  color: var(--color-muted);
  font-size: 0.86rem;
}

/* Retificações preservadas */
.rectification-card {
  position: relative;
  padding: 0.9rem 1rem;
  margin-top: 0.85rem;
  overflow: hidden;
  color: #4d3a13;
  background: #fffaf0;
  border: 1px solid #ead49e;
  border-left: 5px solid var(--color-warning);
  border-radius: 10px;
}

.rectification-card > strong {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  color: var(--color-warning);
}

.rectification-card > strong::before {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  content: "";
  background: currentColor;
  border: 2px solid #fffaf0;
  border-radius: 999px;
  box-shadow: 0 0 0 2px currentColor;
}

.rectification-card p {
  margin-bottom: 0.42rem;
  overflow-wrap: anywhere;
}

.rectification-card small {
  display: block;
  padding-top: 0.45rem;
  margin-top: 0.65rem;
  color: #6f603f;
  border-top: 1px solid #eadfbe;
}

/* Auditoria somente leitura */
.audit-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 1rem;
}

.audit-card {
  min-width: 0;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.audit-card .card-top {
  align-items: center;
}

.audit-card .card-top time {
  color: var(--color-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.audit-card h2 {
  margin: 0.85rem 0 0.7rem;
  color: var(--color-brand-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
}

.audit-card > p:not(.audit-details) {
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.audit-details {
  max-width: 100%;
  padding: 0.72rem;
  margin: 0.8rem 0;
  overflow-wrap: anywhere;
  color: #344655;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.audit-card > small {
  display: block;
  color: var(--color-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  overflow-wrap: anywhere;
}

/* Inventário */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.85rem 0.9rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}

th {
  color: #455766;
  background: var(--color-surface-soft);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfcfd;
}

td > small {
  display: block;
  margin-top: 0.18rem;
  color: var(--color-muted);
}

.inventory-empty {
  margin-top: 1rem;
}

/* Usuários e plantão */
.user-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  margin-top: 1rem;
}

.user-card-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

.user-card-header h2,
.user-card-header p {
  margin-bottom: 0;
}

.user-card-header p {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.shift-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  border-left: 5px solid var(--color-neutral);
}

.shift-card.shift-open {
  border-left-color: var(--color-success);
}

.shift-card h2 {
  margin: 0.6rem 0 0.25rem;
  font-size: 1.7rem;
}

.shift-card p {
  color: var(--color-muted);
}

.shift-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 0.7rem;
}

.shift-metrics > div {
  display: grid;
  min-height: 86px;
  align-content: center;
  padding: 0.8rem;
  text-align: center;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.shift-metrics strong {
  font-size: 1.7rem;
  line-height: 1;
}

.shift-metrics span {
  margin-top: 0.25rem;
  color: var(--color-muted);
  font-size: 0.76rem;
}

.check-list {
  display: grid;
  gap: 0.75rem;
  padding-left: 1.2rem;
  margin-bottom: 0;
}

.check-list li::marker {
  color: var(--color-success);
}

/* Segundo fator */
.mfa-enrollment {
  margin-bottom: 1rem;
  background:
    linear-gradient(135deg, rgb(233 242 248 / 82%), rgb(255 255 255 / 96%)),
    var(--color-surface);
  border-left: 5px solid var(--color-info);
}

.mfa-enrollment > ol {
  display: grid;
  gap: 0.45rem;
  padding-left: 1.35rem;
  color: #405261;
}

.mfa-enrollment > ol li::marker {
  color: var(--color-info);
  font-weight: 800;
}

.secret-code {
  display: block;
  width: 100%;
  padding: 0.9rem;
  margin: 1rem 0;
  overflow-wrap: anywhere;
  color: var(--color-brand-strong);
  background: #fff;
  border: 1px dashed #78a8c6;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(0.92rem, 0.82rem + 0.45vw, 1.18rem);
  font-weight: 800;
  letter-spacing: 0.09em;
  line-height: 1.7;
  text-align: center;
  white-space: normal;
  user-select: all;
}

.mfa-enrollment .form-grid {
  align-items: end;
}

.mfa-enrollment .form-grid > .button:last-child {
  grid-column: 1 / -1;
  width: 100%;
}

input[name="mfa_code"] {
  min-height: 54px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.18rem;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: 0.34em;
  text-align: center;
}

.auth-card form + form {
  margin-top: 0.7rem;
}

/* Login */
.auth-layout {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
  overflow: hidden;
  background: #edf3f6;
}

.auth-background {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 14% 16%, rgb(57 145 194 / 18%), transparent 30%),
    radial-gradient(circle at 82% 86%, rgb(32 105 144 / 17%), transparent 34%),
    linear-gradient(135deg, #edf4f7 0%, #f8fafb 50%, #e4eef3 100%);
}

.auth-background::after {
  position: absolute;
  inset: 0;
  content: "";
  background-image:
    linear-gradient(rgb(18 59 93 / 3%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(18 59 93 / 3%) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
}

.auth-content {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
}

.auth-card {
  padding: clamp(1.35rem, 4vw, 2.1rem);
  background: rgb(255 255 255 / 96%);
  border: 1px solid rgb(189 201 210 / 85%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.auth-card > .brand-mark {
  margin-bottom: 1.25rem;
}

.auth-card .muted {
  margin-bottom: 1.4rem;
}

.security-note {
  padding-top: 1rem;
  margin: 1.1rem 0 0;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
  font-size: 0.78rem;
  text-align: center;
}

.auth-layout:has(.login-card) {
  padding: 1.25rem;
  background: #eef2f7;
}

.auth-layout:has(.login-card) .auth-background {
  background: #eef2f7;
}

.auth-layout:has(.login-card) .auth-background::after {
  display: none;
}

.auth-content:has(.login-card) {
  width: min(100%, 424px);
}

.login-card {
  padding: clamp(2rem, 7vw, 2.75rem) clamp(1.5rem, 6vw, 2.4rem) 2.35rem;
  background: #fff;
  border-color: #d5dee9;
  border-radius: 20px;
  box-shadow: 0 12px 32px rgb(24 48 77 / 8%);
}

.login-card h1 {
  margin-bottom: 2.25rem;
  color: #091d3a;
  font-size: clamp(2rem, 1.6rem + 1.5vw, 2.35rem);
  line-height: 1.08;
  text-align: center;
}

.login-form {
  gap: 1rem;
}

.login-field {
  display: grid;
  gap: 0.42rem;
}

.login-field label {
  color: #182b47;
  font-size: 0.88rem;
  font-weight: 750;
}

.login-field input {
  min-height: 48px;
  padding: 0.72rem 0.85rem;
  background: #eaf2ff;
  border-color: #c7d5e8;
  border-radius: 10px;
}

.login-field input:hover {
  border-color: #94add0;
}

.login-field input:focus {
  background: #eaf2ff;
  border-color: #2d6eb4;
  box-shadow: 0 0 0 3px rgb(45 110 180 / 18%);
}

.password-input {
  position: relative;
}

.password-input input {
  padding-right: 5rem;
}

.password-visibility {
  position: absolute;
  top: 50%;
  right: 0.8rem;
  padding: 0.3rem 0.2rem;
  color: #0e315c;
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  transform: translateY(-50%);
}

.password-visibility:hover {
  color: #081e3a;
  text-decoration: underline;
}

.password-visibility:focus-visible {
  outline: 2px solid #2d6eb4;
  outline-offset: 2px;
  box-shadow: none;
}

.login-form .button.primary {
  min-height: 48px;
  margin-top: 0.05rem;
  background: #1d4a82;
  border-color: #1d4a82;
  border-radius: 9px;
  box-shadow: none;
}

.login-form .button.primary:hover:not(:disabled) {
  background: #153b6c;
  border-color: #153b6c;
}

.login-card .security-note {
  padding-top: 0;
  margin-top: 1.1rem;
  color: #65738a;
  border-top: 0;
  font-size: 0.72rem;
  line-height: 1.45;
}

.auth-content:has(.login-card) .flash-stack {
  margin-bottom: 0.75rem;
}

.auth-content:has(.login-card) .flash {
  padding: 0.8rem 0.95rem;
  background: #fff;
  border: 1px solid currentColor;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgb(24 48 77 / 6%);
}

@media (max-width: 440px) {
  .auth-layout:has(.login-card) {
    padding: 0.75rem;
  }

  .login-card {
    padding-inline: 1.25rem;
  }

  .login-card h1 {
    margin-bottom: 1.8rem;
  }
}

.setup-card {
  width: min(100%, 540px);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1080px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-panel .button {
    width: 100%;
  }
}

@media (max-width: 860px) {
  body.menu-open::before {
    position: fixed;
    inset: 0;
    z-index: 35;
    content: "";
    background: rgb(8 25 39 / 56%);
    backdrop-filter: blur(2px);
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(86vw, var(--sidebar-width));
    transform: translateX(-104%);
    box-shadow: var(--shadow-md);
    transition: transform 190ms ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .menu-toggle {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 34;
    display: grid;
    box-shadow: var(--shadow-sm);
  }

  .page-content {
    padding-top: 4.7rem;
    padding-bottom: 2rem;
  }

  .admin-grid,
  .two-column,
  .security-columns {
    grid-template-columns: 1fr;
  }

  .summary-card {
    position: static;
  }
}

@media (max-width: 720px) {
  .page-heading,
  .shift-card,
  .action-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading > .button,
  .action-panel > .button {
    width: 100%;
  }

  .toolbar,
  .filter-panel,
  .inventory-filter-bar,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .confirmation-summary,
  .meta-list.horizontal,
  .shift-metrics {
    grid-template-columns: 1fr;
  }

  .confirmation-screen {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .history-header,
  .card-top {
    flex-wrap: wrap;
  }

  .history-header > strong {
    width: 100%;
    text-align: left;
  }

  .audit-list {
    grid-template-columns: 1fr;
  }

  .audit-card .card-top {
    align-items: flex-start;
  }

  .table-wrap {
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

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

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  tbody {
    display: grid;
    gap: 0.85rem;
  }

  tbody tr {
    padding: 0.55rem 0.85rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }

  tbody tr:hover {
    background: var(--color-surface);
  }

  td {
    display: grid;
    grid-template-columns: minmax(112px, 36%) minmax(0, 1fr);
    gap: 0.7rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--color-border);
    overflow-wrap: anywhere;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--color-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.035em;
    text-transform: uppercase;
  }

  td .status-pill,
  td .inline-details {
    justify-self: start;
  }

  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form input,
  .inline-form select,
  .inline-form .button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .page-content {
    padding: 4.7rem 0.8rem 1.6rem;
  }

  .stats-grid {
    gap: 0.65rem;
  }

  .stat-card {
    min-height: 98px;
    padding: 0.85rem;
  }

  .stat-card strong {
    font-size: 1.65rem;
  }

  .equipment-grid {
    grid-template-columns: 1fr;
  }

  .user-card-header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .user-card-header .status-pill {
    grid-column: 1 / -1;
    margin-top: 0.45rem;
  }

  .secret-code {
    padding-inline: 0.65rem;
    letter-spacing: 0.045em;
  }

  input[name="mfa_code"] {
    letter-spacing: 0.24em;
  }

  td {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  .status-pill,
  .button,
  .equipment-card,
  .panel,
  .audit-card,
  .rectification-card {
    border: 1px solid CanvasText;
  }

  .status-pill::before,
  .equipment-card::before,
  .stat-card::after {
    background: CanvasText;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    display: block;
  }

  .sidebar,
  .button,
  .filter-panel,
  .toolbar,
  .inventory-filter-bar,
  .details-form,
  .inline-details,
  .flash-stack {
    display: none !important;
  }

  .page-content {
    width: 100%;
    padding: 0;
  }

  .history-card,
  .equipment-card,
  .panel,
  .audit-card,
  .rectification-card,
  .table-wrap {
    box-shadow: none;
    break-inside: avoid;
  }

  .mfa-enrollment,
  .secret-code {
    display: none !important;
  }
}
