:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #f3f6f9;
  --border: #d8dee6;
  --border-strong: #0a65a8;
  --text: #25303b;
  --muted: #626c78;
  --accent: #005da3;
  --accent-hover: #004982;
  --accent-soft: #eaf4fb;
  --brand-orange: #f4770b;
  --brand-orange-soft: #fff3e8;
  --brand-gray: #5d6671;
  --danger: #b42318;
  --success: #067647;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  display: flex;
  height: 64px;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  align-items: center;
  display: flex;
  font-weight: 700;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  display: block;
  height: 42px;
  object-fit: contain;
  width: auto;
}

.brand-logo.horizontal {
  height: 36px;
  max-width: 260px;
}

.login-card .brand-logo {
  height: 120px;
}

.user-actions {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 12px;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
}

.sidebar-logo {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: center;
  margin: 0 0 14px;
  padding: 2px 8px 16px;
}

.sidebar-logo img {
  display: block;
  height: auto;
  max-height: 104px;
  max-width: 150px;
  object-fit: contain;
}

.side-link {
  align-items: center;
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  margin-bottom: 4px;
  padding: 9px 10px;
}

.side-link.active,
.side-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon {
  color: currentColor;
  flex: 0 0 auto;
  height: 18px;
  width: 18px;
}

.content {
  min-width: 0;
}

.page {
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px;
}

.page-header {
  align-items: flex-end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-title {
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--muted);
  margin: 0;
}

.grid-main {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(320px, 420px) 1fr;
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.section-title {
  font-size: 15px;
  margin: 0 0 14px;
}

.form-grid {
  display: grid;
  gap: 13px;
}

.field {
  display: grid;
  gap: 6px;
}

.label {
  color: #3d4654;
  font-size: 13px;
  font-weight: 600;
}

.input,
.select,
.textarea {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

.textarea {
  min-height: 86px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

.code-input {
  font-size: 24px;
  font-weight: 750;
  text-align: center;
}

.login-step {
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.sent-to {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  overflow-wrap: anywhere;
  padding: 10px 12px;
}

.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

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

.options-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.option-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: left;
}

.option-card.selected {
  background: var(--accent-soft);
  border-color: var(--border-strong);
}

.option-card h3 {
  font-size: 15px;
  margin: 0 0 10px;
}

.value {
  font-size: 28px;
  font-weight: 750;
  line-height: 1;
  margin: 0 0 8px;
}

.summary {
  display: grid;
  gap: 14px;
}

.summary-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.summary-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
}

.summary-item strong {
  display: block;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.pix-area {
  display: grid;
  gap: 14px;
  grid-template-columns: 280px 1fr;
}

.qr-box {
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  justify-content: center;
  min-height: 280px;
}

.qr-box img {
  height: 240px;
  width: 240px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
}

.btn:hover {
  background: var(--surface-muted);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.ghost {
  background: transparent;
}

.status {
  border-radius: 6px;
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.status.show {
  display: block;
}

.status.error {
  background: #fff1f0;
  color: var(--danger);
}

.status.success {
  background: #ecfdf3;
  color: var(--success);
}

.login-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 380px;
  padding: 24px;
  width: 100%;
}

.login-card .brand {
  justify-content: center;
  margin-bottom: 20px;
}

.table-tools {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.table {
  border-collapse: collapse;
  width: 100%;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table tbody tr {
  cursor: pointer;
}

.table tbody tr:hover {
  background: var(--surface-muted);
}

.role-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
}

.role-pill.admin {
  background: var(--brand-orange-soft);
  border-color: #ffd0a3;
  color: #b85300;
}

.drawer {
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(16, 24, 40, 0.08);
  bottom: 0;
  max-width: 560px;
  overflow: auto;
  padding: 18px;
  position: fixed;
  right: -620px;
  top: 0;
  transition: right 0.2s ease;
  width: min(100%, 560px);
  z-index: 30;
}

.drawer.open {
  right: 0;
}

.modal {
  display: none;
  inset: 0;
  position: fixed;
  z-index: 60;
}

.modal.open {
  display: block;
}

.modal-backdrop {
  background: rgba(16, 24, 40, 0.36);
  inset: 0;
  position: absolute;
}

.modal-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.16);
  left: 50%;
  max-height: calc(100vh - 48px);
  max-width: 760px;
  overflow: auto;
  padding: 18px;
  position: absolute;
  top: 24px;
  transform: translateX(-50%);
  width: calc(100% - 32px);
}

.modal-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.drawer-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

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

.mobile-menu {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    bottom: 0;
    left: -240px;
    position: fixed;
    top: 0;
    transition: left 0.2s ease;
    width: 220px;
    z-index: 40;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-backdrop.open {
    background: rgba(16, 24, 40, 0.24);
    bottom: 0;
    display: block;
    left: 0;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 35;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .topbar {
    padding: 0 14px;
  }

  .brand-logo.horizontal {
    height: 30px;
    max-width: 170px;
  }

  .page {
    padding: 16px;
  }

  .page-header,
  .table-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-main,
  .options-grid,
  .pix-area,
  .summary-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .table {
    min-width: 760px;
  }

  .table-wrap {
    overflow-x: auto;
  }
}

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

  .topbar,
  .sidebar,
  .page-header,
  .actions,
  .panel:not(.print-keep),
  .drawer-header,
  .sidebar-backdrop {
    display: none !important;
  }

  .app-shell,
  .grid-main,
  .pix-area,
  .summary-grid {
    display: block;
  }

  .page {
    max-width: none;
    padding: 0;
  }

  .summary-box,
  .panel {
    border: 0;
    box-shadow: none;
  }
}
