:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #d92828;
  --primary-dark: #aa1f1f;
  --blue: #2563eb;
  --green: #18864b;
  --amber: #b7791f;
  --danger: #c52b2f;
  --shadow: 0 18px 45px rgba(22, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 440px);
  min-height: 100vh;
}

.brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
  background: #16233a;
  color: white;
}

.brand-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.22);
  color: white;
  font-size: 32px;
  font-weight: 900;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  font-size: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-panel .eyebrow {
  margin-top: 32px;
  color: #aebbd0;
}

.brand-panel h1 {
  margin: 0;
  font-size: 72px;
  line-height: 1;
}

.brand-copy {
  max-width: 620px;
  color: #d4dbea;
  font-size: 20px;
  line-height: 1.6;
}

.login-card {
  align-self: center;
  margin: 32px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 0 0 24px;
  font-size: 28px;
}

label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

.label-help {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  max-width: 100%;
}

.info-dot {
  position: relative;
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid #bdd4ff;
  border-radius: 50%;
  background: #f3f7ff;
  color: #24449a;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  cursor: help;
  user-select: none;
}

.info-dot:focus {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  outline-offset: 2px;
}

.info-dot::after {
  position: absolute;
  top: 24px;
  left: -10px;
  z-index: 20;
  display: none;
  width: min(320px, calc(100vw - 48px));
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px 12px;
  background: #101828;
  color: #f8fafc;
  box-shadow: 0 14px 30px rgba(22, 32, 51, 0.22);
  content: attr(data-tooltip);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.55;
  text-transform: none;
  white-space: normal;
}

.info-dot:hover::after,
.info-dot:focus::after {
  display: block;
}

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

.checkbox-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: #344054;
  font-weight: 700;
}

.checkbox-control input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

input,
select {
  min-height: 42px;
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(37, 99, 235, 0.16);
}

.login-card label + label {
  margin-top: 16px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.login-card button,
.primary-button {
  width: 100%;
  margin-top: 24px;
  background: var(--primary);
  color: white;
}

.login-card button:hover,
.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  margin-top: auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.compact-button,
.danger-button {
  min-height: 34px;
  border: 1px solid var(--line);
  padding: 6px 10px;
  background: #fff;
  color: var(--text);
}

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

.form-error {
  min-height: 20px;
  color: var(--danger);
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--line);
  padding: 20px;
  background: #fff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  color: var(--muted);
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: #344054;
  text-align: left;
}

.nav-item.active {
  border-color: #f1b7b7;
  background: #fff1f1;
  color: var(--primary-dark);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar,
.control-strip,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
}

.topbar h2 {
  margin: 0;
  font-size: 24px;
}

.status-pill,
.method-badge,
.result-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eef3ff;
  color: #24449a;
  font-size: 13px;
  font-weight: 800;
}

.control-strip {
  display: grid;
  grid-template-columns: 1fr 1.4fr 2fr;
  gap: 16px;
  margin-top: 16px;
  padding: 16px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(360px, 1.08fr);
  gap: 16px;
  margin-top: 16px;
}

.profiles-view {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 0.9fr);
  gap: 16px;
  margin-top: 16px;
}

.access-view {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 0.9fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.access-roles-panel {
  grid-column: 1;
}

.permission-fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.permission-fieldset legend {
  padding: 0 6px;
  color: #344054;
  font-size: 14px;
  font-weight: 800;
}

.permission-groups {
  display: grid;
  gap: 12px;
}

.permission-group {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  text-transform: capitalize;
}

.permission-group:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.check-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfe;
  font-weight: 700;
}

.check-option input {
  width: 17px;
  min-height: 17px;
  margin-top: 2px;
  accent-color: var(--primary);
}

.check-option span,
.check-option strong,
.check-option small {
  display: block;
}

.check-option small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.4;
}

.check-option.compact {
  align-items: center;
  padding: 7px 9px;
  text-transform: none;
}

.qr-test-view {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
  margin-top: 16px;
}

.receipt-view {
  display: grid;
  grid-template-columns: minmax(380px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

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

.panel h3 {
  margin: 0;
  font-size: 18px;
}

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

.fields.two-col {
  grid-template-columns: 1fr 1fr;
}

.span-two {
  grid-column: 1 / -1;
}

.field-row {
  display: grid;
  gap: 7px;
}

.input-with-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.field-action {
  min-height: 42px;
  border: 1px solid #f1b7b7;
  padding: 0 12px;
  background: #fff1f1;
  color: var(--primary-dark);
  white-space: nowrap;
}

.field-row .hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.notice {
  margin-bottom: 16px;
  border: 1px solid #bdd4ff;
  border-radius: 6px;
  padding: 12px;
  background: #f3f7ff;
  color: #24449a;
  font-size: 14px;
  line-height: 1.5;
}

.result-status.idle {
  background: #eef2f7;
  color: #475467;
}

.result-status.success {
  background: #e9f8f0;
  color: var(--green);
}

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

.friendly-result {
  display: grid;
  gap: 12px;
  min-height: 220px;
}

.friendly-result p {
  margin: 0;
  color: var(--muted);
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.summary-card strong {
  display: block;
  margin-bottom: 6px;
  color: #344054;
}

.summary-card span {
  word-break: break-word;
}

.qr-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.qr-card strong {
  color: #344054;
}

.qr-card img {
  width: min(260px, 100%);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.qr-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.receipt-form textarea {
  min-height: 120px;
}

.receipt-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 10px;
  margin-top: 16px;
}

.receipt-actions .primary-button {
  margin-top: 0;
}

.receipt-preview-panel {
  overflow: hidden;
}

.receipt-preview-wrap {
  overflow: auto;
  max-height: 72vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #eef2f7;
}

.receipt-preview-wrap canvas {
  display: block;
  max-width: 100%;
  height: auto !important;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(22, 32, 51, 0.16);
}

.raw-result {
  margin-top: 16px;
}

.raw-result summary {
  cursor: pointer;
  color: #344054;
  font-weight: 800;
}

.profiles-list {
  display: grid;
  gap: 12px;
}

.profile-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.profile-card strong,
.profile-card span {
  display: block;
}

.profile-card span,
.empty-state p {
  color: var(--muted);
  font-size: 13px;
}

.profile-card dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.profile-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.profile-card dd {
  margin: 3px 0 0;
  word-break: break-word;
  font-size: 13px;
}

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

.profile-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
}

.profile-message.success {
  color: var(--green);
}

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

pre {
  overflow: auto;
  max-height: 420px;
  border-radius: 8px;
  padding: 14px;
  background: #101828;
  color: #e4e7ec;
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .login-view,
  .app-view,
  .content-grid,
  .control-strip,
  .profiles-view,
  .access-view,
  .qr-test-view,
  .receipt-view,
  .fields.two-col,
  .input-with-action,
  .receipt-actions {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-panel {
    min-height: 360px;
    padding: 32px;
  }

  .brand-panel h1 {
    font-size: 54px;
  }
}
