:root {
  /* SAPO brand palette – docs/2017_SAPO_logo_CMYK Spec.pdf */
  --sapo-red: #ed1c2e;
  --sapo-red-dark: #c81625;
  --sapo-red-light: #fde8ea;
  --sapo-blue: #006bb6;
  --sapo-blue-dark: #005a99;
  --sapo-blue-light: #e6f2fa;
  --lime: var(--sapo-red);
  --lime-dark: var(--sapo-red-dark);
  --lime-light: var(--sapo-red-light);
  --teal: var(--sapo-blue);
  --navy: #003d6b;
  --navy-light: #005a99;
  --purple: #004d80;
  --cyan: #3399cc;
  --white: #ffffff;
  --grey-50: #f8f9fb;
  --grey-100: #f0f2f5;
  --grey-200: #e4e7ec;
  --grey-400: #98a2b3;
  --grey-600: #475467;
  --grey-800: #1d2939;
  --orange: #f79009;
  --red: var(--sapo-red);
  --green: #12b76a;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 64px;
  --header-h: 64px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--grey-800);
  background: var(--grey-50);
  line-height: 1.5;
  min-height: 100vh;
}

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

img { max-width: 100%; height: auto; }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: linear-gradient(135deg, #001a33 0%, #003d6b 45%, #005a99 100%);
}

.login-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.login-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 60%, rgba(0, 107, 182, 0.2) 0%, transparent 50%),
    radial-gradient(circle at 70% 30%, rgba(237, 28, 46, 0.12) 0%, transparent 50%);
  pointer-events: none;
}

.login-hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 107, 182, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 107, 182, 0.08) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.login-hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 480px;
}

.login-hero h1 {
  color: var(--white);
  font-size: 1.75rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  line-height: 1.3;
}

.login-hero p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
}

.login-hero .brand-logo-lg {
  max-width: 280px;
}

.login-shield {
  width: 80px;
  height: 80px;
  margin: 2rem auto 0;
  background: linear-gradient(135deg, rgba(0, 107, 182, 0.25), rgba(237, 28, 46, 0.2));
  border: 2px solid rgba(0, 107, 182, 0.45);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 0 30px rgba(0, 107, 182, 0.25);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  background: var(--white);
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.login-card .subtitle {
  color: var(--grey-400);
  margin-bottom: 2rem;
}

.partner-logos {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--grey-200);
}

.partner-logos img { height: 48px; width: auto; max-width: 100%; }

.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--grey-600);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--sapo-blue);
  box-shadow: 0 0 0 3px rgba(0, 107, 182, 0.15);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475467' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--sapo-red);
  color: var(--white);
}

.btn-primary:hover { background: var(--sapo-red-dark); }

.btn-secondary {
  background: var(--white);
  color: var(--grey-800);
  border: 1px solid var(--grey-200);
}

.btn-secondary:hover { background: var(--grey-50); }

.btn-teal {
  background: linear-gradient(135deg, var(--sapo-blue), var(--sapo-blue-dark));
  color: var(--white);
}

.btn-teal:hover { opacity: 0.9; }

.btn-block { width: 100%; }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

.demo-users {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--grey-50);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

.demo-users h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--grey-400);
  margin-bottom: 0.5rem;
}

.demo-user-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.25rem;
  background: none;
  border: none;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--grey-600);
}

.demo-user-btn:hover { background: var(--sapo-red-light); color: var(--sapo-red); }

.demo-user-btn strong { color: var(--sapo-blue); }

/* ── App Layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--grey-200);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo img { width: 100%; height: 100%; object-fit: contain; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.sidebar-link {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--grey-400);
  font-size: 1.25rem;
  transition: all 0.2s;
  position: relative;
}

.sidebar-link:hover { background: var(--grey-100); color: var(--grey-600); }

.sidebar-link.active {
  background: var(--sapo-red-light);
  color: var(--sapo-red);
}

.sidebar-link[title]::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 8px);
  background: var(--navy);
  color: var(--white);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 200;
}

.sidebar-link:hover[title]::after { opacity: 1; }

.sidebar-link .nav-label { display: none; }

.btn-mobile-primary { display: none; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--grey-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-left .brand-logo-sm { height: 32px; }

.header-greeting {
  font-size: 1rem;
  font-weight: 500;
}

.header-greeting span { color: var(--grey-400); font-weight: 400; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.role-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: var(--sapo-blue-light);
  color: var(--sapo-blue);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sapo-red);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.page-body {
  flex: 1;
  padding: 1.5rem;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--grey-200);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.tab {
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--grey-400);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font);
  transition: all 0.2s;
}

.tab:hover { color: var(--grey-600); }

.tab.active {
  color: var(--sapo-blue);
  border-bottom-color: var(--sapo-red);
}

.tab .tab-icon { font-size: 1rem; }

/* ── Status Pills ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--white);
  border: 1px solid var(--grey-200);
  transition: all 0.2s;
}

.status-pill:hover { border-color: var(--grey-400); }

.status-pill.active {
  background: #fef9ec;
  border-color: var(--orange);
}

.status-count {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--white);
}

.status-count.grey { background: var(--grey-400); }
.status-count.green { background: var(--sapo-blue); }
.status-count.orange { background: var(--orange); }
.status-count.red { background: var(--red); }

/* ── Cards ── */
.card {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--grey-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body { padding: 1.25rem; }

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--grey-400);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--grey-200);
  background: var(--grey-50);
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--grey-100);
  font-size: 0.9rem;
}

.data-table tr:hover td { background: var(--grey-50); }

.data-table .empty-row td {
  text-align: center;
  padding: 3rem;
  color: var(--grey-400);
}

/* ── Dashboard Grid ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: var(--shadow-lg); }

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy);
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--grey-400);
  margin-top: 0.25rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.feature-card {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.feature-card:hover {
  border-color: var(--sapo-red);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.feature-card.lime { border-left: 4px solid var(--sapo-red); }
.feature-card.teal { border-left: 4px solid var(--sapo-blue); }
.feature-card.navy { border-left: 4px solid var(--navy); }
.feature-card.orange { border-left: 4px solid var(--orange); }
.feature-card.purple { border-left: 4px solid var(--sapo-blue-dark); }
.feature-card.cyan { border-left: 4px solid var(--cyan); }

.feature-card h4 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.feature-card p {
  font-size: 0.85rem;
  color: var(--grey-400);
}

.feature-card .feature-icon {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

/* ── Verification Wizard ── */
.wizard {
  max-width: 720px;
  margin: 0 auto;
}

.wizard-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2rem;
  position: relative;
}

.wizard-steps::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--grey-200);
  z-index: 0;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
  flex: 1;
}

.wizard-step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--grey-200);
  color: var(--grey-400);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.3s;
}

.wizard-step.active .wizard-step-num {
  background: var(--sapo-red);
  color: var(--white);
}

.wizard-step.done .wizard-step-num {
  background: var(--green);
  color: var(--white);
}

.wizard-step-label {
  font-size: 0.75rem;
  color: var(--grey-400);
  text-align: center;
  max-width: 100px;
}

.wizard-step.active .wizard-step-label { color: var(--navy); font-weight: 600; }

.wizard-panel { display: none; }
.wizard-panel.active { display: block; }

.api-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: var(--grey-100);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--grey-600);
  margin-bottom: 1rem;
}

.api-badge.connected {
  background: #ecfdf3;
  color: var(--green);
}

.verify-result {
  background: var(--grey-50);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.verify-result.success {
  border-color: var(--green);
  background: #ecfdf3;
}

.verify-result h4 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.verify-field {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--grey-200);
  font-size: 0.9rem;
}

.verify-field:last-child { border-bottom: none; }

.verify-field .label { color: var(--grey-400); }

/* ── Document Editor ── */
.editor-layout {
  display: grid;
  grid-template-columns: 80px 1fr 280px;
  gap: 1rem;
  min-height: calc(100vh - var(--header-h) - 3rem);
}

.editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.editor-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--grey-400);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.editor-step:hover { background: var(--grey-100); }

.editor-step.active {
  background: var(--sapo-red-light);
  color: var(--sapo-red);
}

.editor-step.done { color: var(--green); }

.editor-canvas {
  background: var(--sapo-blue-light);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.document-preview {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  min-height: 500px;
  padding: 2rem;
}

.document-preview h3 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--grey-200);
}

.editor-tools {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.editor-tools h4 {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  color: var(--grey-400);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.75rem;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s;
}

.tool-btn:hover {
  border-color: var(--sapo-red);
  background: var(--sapo-red-light);
}

.tool-btn .tool-icon { font-size: 1.25rem; }

.signature-box {
  border: 2px dashed var(--grey-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--grey-400);
  margin-top: 1.5rem;
  min-height: 80px;
  cursor: pointer;
  transition: all 0.2s;
}

.signature-box:hover { border-color: var(--sapo-red); }

.signature-box.signed {
  border-style: solid;
  border-color: var(--green);
  color: var(--green);
  font-family: 'Brush Script MT', cursive;
  font-size: 1.5rem;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

.modal.modal-lg { max-width: 640px; }
.modal.modal-xl { max-width: 780px; }

.upload-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.upload-dropzone {
  border: 2px dashed var(--grey-200);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--grey-50);
}

.upload-dropzone:hover,
.upload-dropzone.has-file {
  border-color: var(--sapo-red);
  background: var(--sapo-red-light);
}

.upload-dropzone .upload-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }

.upload-dropzone .file-name {
  font-weight: 600;
  color: var(--navy);
  margin-top: 0.5rem;
}

.flow-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border: 2px solid var(--grey-200);
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition: all 0.2s;
}

.flow-option:hover { border-color: var(--grey-400); }

.flow-option.selected {
  border-color: var(--sapo-red);
  background: var(--sapo-red-light);
}

.flow-option input { margin-top: 0.2rem; accent-color: var(--sapo-red); }

.recipient-list { display: flex; flex-direction: column; gap: 0.75rem; }

.recipient-row {
  display: grid;
  grid-template-columns: 28px 1fr 1.4fr 120px 36px;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--grey-50);
  border-radius: var(--radius);
  border: 1px solid var(--grey-200);
}

.recipient-row .order-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sapo-red);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.recipient-row .btn-remove {
  width: 36px;
  height: 36px;
  border: 1px solid var(--grey-200);
  background: var(--white);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--red);
  font-size: 1.1rem;
}

.recipient-row .btn-remove:hover { background: #fef3f2; }

.recipient-row.has-sa-id {
  grid-template-columns: 28px 1fr 1.2fr 100px 1fr 36px;
}

.recipient-row .sa-id-input {
  font-family: ui-monospace, monospace;
  letter-spacing: 0.03em;
}

.registered-id-section {
  margin-top: 0.5rem;
}

.registered-id-row {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--grey-50);
  border-radius: var(--radius);
  border: 1px solid var(--grey-200);
}

.registered-id-label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
}

.registered-id-row .form-control {
  font-family: ui-monospace, monospace;
  letter-spacing: 0.03em;
}

.modal-wizard-steps {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--grey-200);
}

.modal-wizard-step {
  flex: 1;
  text-align: center;
  padding: 0.6rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--grey-400);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.modal-wizard-step.active {
  color: var(--sapo-blue);
  border-bottom-color: var(--sapo-red);
  font-weight: 600;
}

.modal-wizard-step.done { color: var(--green); }

.flow-preview {
  background: var(--grey-50);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.flow-preview .recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: 20px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  margin: 0.25rem 0.25rem 0 0;
}

@media (max-width: 600px) {
  .recipient-row,
  .recipient-row.has-sa-id {
    grid-template-columns: 1fr;
  }
  .recipient-row .order-num { display: none; }
  .registered-id-row { grid-template-columns: 1fr; }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid var(--grey-200);
}

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--grey-400);
  padding: 0.25rem;
}

.modal-body { padding: 1.25rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--grey-200);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  background: var(--navy);
  color: var(--white);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--sapo-blue); color: var(--white); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── API Portal ── */
.api-portal {
  background: linear-gradient(135deg, #003d6b, #005a99);
  border-radius: var(--radius-lg);
  padding: 2rem;
  color: var(--white);
  margin-bottom: 2rem;
}

.api-portal h2 { margin-bottom: 0.5rem; }

.api-portal p { color: rgba(255,255,255,0.7); margin-bottom: 1.5rem; }

.api-endpoints {
  display: grid;
  gap: 0.75rem;
}

.api-endpoint {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.api-method {
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: monospace;
}

.api-method.get { background: #ecfdf3; color: var(--green); }
.api-method.post { background: #eff8ff; color: #2e90fa; }

.api-path {
  font-family: monospace;
  font-size: 0.85rem;
  flex: 1;
}

/* ── Wallet ── */
.wallet-balance {
  background: linear-gradient(135deg, var(--navy), var(--sapo-blue));
  border-radius: var(--radius-lg);
  padding: 2rem;
  color: var(--white);
  margin-bottom: 1.5rem;
}

.wallet-balance .balance-label {
  font-size: 0.85rem;
  opacity: 0.7;
}

.wallet-balance .balance-amount {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0.5rem 0;
}

/* ── Toggle ── */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--grey-200);
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider { background: var(--sapo-red); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Alert ── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert-info {
  background: var(--sapo-blue-light);
  border: 1px solid #99cce8;
  color: var(--sapo-blue-dark);
}

.alert-warning {
  background: #fffaeb;
  border: 1px solid #fedf89;
  color: #b54708;
}

/* ── Page Title ── */
.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: var(--grey-400);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ── Layout utilities ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header .page-title { margin-bottom: 0; }
.page-header .page-subtitle { margin-bottom: 0; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-grid-2 .form-group { margin: 0; }

.flow-indent { margin-left: 2rem; }
.flow-indent-top { margin-left: 2rem; margin-top: 1rem; }

.status-bar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.action-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.workflow-diagram {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 1rem;
}

.workflow-step {
  text-align: center;
  padding: 1rem;
  border-radius: 8px;
  min-width: 120px;
}

.sidebar-toggle {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--grey-800);
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--grey-50); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
}

.sidebar-backdrop.open { display: block; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .editor-layout {
    grid-template-columns: 72px 1fr;
    grid-template-rows: auto auto;
  }

  .editor-tools {
    grid-column: 1 / -1;
  }

  .api-endpoint {
    flex-wrap: wrap;
  }

  .api-path { min-width: 0; word-break: break-all; }
}

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-panel { padding: 2rem 1.5rem; }

  .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .sidebar {
    transform: translateX(-100%);
    width: 240px;
    align-items: stretch;
    padding: 1rem 0.75rem;
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-nav {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-link {
    width: 100%;
    height: auto;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    font-size: 1rem;
  }

  .sidebar-link[title]::after { display: none; }

  .sidebar-link .nav-label {
    display: inline;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
  }

  .main-content { margin-left: 0; }

  .app-header {
    padding: 0 1rem;
    gap: 0.5rem;
  }

  .header-left {
    flex: 1;
    min-width: 0;
    gap: 0.65rem;
  }

  .header-greeting {
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-greeting strong { font-weight: 600; }

  .role-badge { display: none; }

  .header-actions .btn-text-long { display: none; }
  .header-actions .btn-mobile-primary { display: inline-flex; }

  .editor-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .editor-sidebar {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  .editor-step {
    flex-direction: row;
    min-width: 100px;
    flex-shrink: 0;
  }

  .editor-canvas { padding: 1rem; }

  .document-preview {
    padding: 1.25rem;
    min-height: 360px;
  }

  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .card-header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .modal.modal-xl,
  .modal.modal-lg { max-width: calc(100vw - 2rem); }

  .wizard-step-label { font-size: 0.65rem; max-width: 72px; }

  .wallet-balance .balance-amount { font-size: 2rem; }
}

@media (max-width: 600px) {
  html { font-size: 13px; }

  .page-body { padding: 1rem; }

  .login-panel { padding: 1.5rem 1rem; }
  .login-card h2 { font-size: 1.25rem; }
  .partner-logos { gap: 1rem; }
  .partner-logos img { height: 40px; }

  .app-header { height: auto; min-height: var(--header-h); padding: 0.65rem 1rem; }

  .header-left .brand-logo-sm { height: 28px; }

  .header-actions { gap: 0.5rem; }
  .header-actions .btn { display: none; }
  .header-actions .btn-mobile-primary { display: inline-flex; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }

  .stat-card .stat-value { font-size: 1.5rem; }

  .status-bar { gap: 0.4rem; }
  .status-pill { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

  .status-bar-actions {
    width: 100%;
    margin-left: 0;
    margin-top: 0.25rem;
  }

  .form-grid-2 { grid-template-columns: 1fr; }
  .flow-indent,
  .flow-indent-top { margin-left: 0; }

  .data-table { min-width: 520px; }
  .data-table th,
  .data-table td { padding: 0.65rem 0.75rem; font-size: 0.85rem; }

  .tabs { margin-bottom: 1rem; }

  .tab { padding: 0.65rem 0.85rem; font-size: 0.85rem; }

  .modal-overlay { padding: 1rem; align-items: flex-end; }

  .modal {
    max-width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .modal-header,
  .modal-body,
  .modal-footer { padding: 1rem; }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-footer .btn { width: 100%; }

  .modal-wizard-step { font-size: 0.7rem; padding: 0.5rem 0.25rem; }

  .wizard-steps::before { left: 5%; right: 5%; }

  .wizard-step-num { width: 32px; height: 32px; font-size: 0.8rem; }

  .verify-field {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .verify-field span:last-child {
    word-break: break-word;
    text-align: left;
  }

  .api-portal { padding: 1.25rem; }

  .api-endpoint {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .wallet-balance { padding: 1.25rem; }

  .wallet-balance .wallet-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .wallet-balance .wallet-actions .btn { width: 100%; }

  .upload-toolbar { justify-content: stretch; }
  .upload-toolbar .btn { width: 100%; }

  .toast-container {
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 1rem;
  }

  .toast { max-width: none; }

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

  .page-header .btn { width: 100%; }

  .action-row {
    flex-direction: column;
  }

  .action-row .btn { width: 100%; }

  .card-header .form-control,
  .card-header .form-select { width: 100%; }

  .tool-grid { grid-template-columns: repeat(3, 1fr); }

  .workflow-diagram {
    flex-direction: column;
    align-items: stretch;
  }

  .workflow-diagram .workflow-arrow { transform: rotate(90deg); align-self: center; }

  .workflow-step { min-width: 0; width: 100%; }
}

@media (max-width: 380px) {
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
  .status-pill .status-count { display: none; }
}
