.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-page {
  max-width: 480px;
  width: 100%;
  text-align: center;
  background: #efece5;
  border-radius: 26px;
  box-shadow: 0 18px 40px rgba(18, 50, 122, 0.12);
  padding: 32px 28px;
}

.login-header {
  justify-content: center;
  text-align: center;
  margin-bottom: 12px;
  width: 100%;
  align-items: center;
}

.login-header > div {
  width: 100%;
  text-align: center;
}

.login-subtitle {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.login-title {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-strong);
}

.login-card {
  background: transparent;
  border: none;
  padding: 0;
}

.login-page .field label {
  text-align: center;
}

.login-page .field input {
  text-align: center;
}

.login-actions .btn {
  width: 100%;
}

.login-actions {
  justify-content: center;
}

.login-footer {
  text-align: center;
}

.otp-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fdfbf6;
}

.otp-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-strong);
}

.otp-subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.otp-hint {
  margin: 10px 0 0;
}

.otp-qr {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.otp-qr img {
  width: 180px;
  height: 180px;
}

.otp-manual {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  margin: 0 0 12px;
}

/* ── Organization Selector (Login Page) ── */
.org-selector {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.org-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: 14px;
  border: 2px solid rgba(18, 50, 122, 0.15);
  background: #fff;
  cursor: pointer;
  transition: all 0.25s ease;
  flex: 1;
  justify-content: center;
}

.org-radio:hover {
  border-color: var(--accent);
  background: rgba(31, 74, 168, 0.04);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(31, 74, 168, 0.1);
}

.org-radio-active {
  border-color: var(--accent);
  background: rgba(31, 74, 168, 0.08);
  box-shadow: 0 4px 16px rgba(31, 74, 168, 0.15);
}

.org-radio input[type="radio"] {
  display: none;
}

.org-radio-mark {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(18, 50, 122, 0.25);
  position: relative;
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.org-radio-active .org-radio-mark {
  border-color: var(--accent);
}

.org-radio-active .org-radio-mark::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: radio-pop 0.2s ease;
}

@keyframes radio-pop {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.org-radio-label {
  font-weight: 700;
  font-size: 16px;
  color: var(--accent-strong);
  letter-spacing: 0.04em;
}

/* ── Organization Display (Sidebar) ── */
.org-display {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: center;
}

.org-display-label {
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.6);
}

.org-display-value {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ── OTP Login Info Badge ── */
.org-login-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.org-login-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
}

.otp-mobile-display {
  font-weight: 600;
  color: var(--accent-strong);
  font-size: 14px;
}

/* ── OTP Setup Instructions ── */
.otp-instructions {
  background: rgba(31, 74, 168, 0.05);
  border: 1px dashed rgba(31, 74, 168, 0.2);
  border-radius: 12px;
  padding: 12px 18px;
  margin: 12px 0 16px;
  text-align: left;
}

.otp-steps-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}

.otp-steps-list li {
  margin-bottom: 4px;
}

.otp-steps-list li:last-child {
  margin-bottom: 0;
}

/* ── Manual Key Box ── */
.otp-manual-box {
  background: rgba(31, 74, 168, 0.06);
  border: 1px solid rgba(31, 74, 168, 0.12);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  text-align: center;
}

.otp-manual-label {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
}

.otp-manual-box .otp-manual {
  margin: 0;
  font-family: var(--mono-font);
  font-size: 11px;
  color: var(--accent-strong);
  user-select: all;
}

/* ── Loading Spinner ── */
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(31, 74, 168, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 16px auto;
}

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

.app-frame {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  padding: 24px;
}

.sidebar {
  background: linear-gradient(160deg, #12327a 0%, #1f4aa8 45%, #2c63cc 100%);
  color: #fff;
  border-radius: 24px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.15);
  font-weight: 800;
  font-size: 18px;
}

.brand-title {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.side-nav {
  display: grid;
  gap: 10px;
}

.side-link {
  padding: 12px 14px;
  border-radius: 14px;
  display: grid;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.2s, transform 0.2s;
  text-decoration: none;
}

.side-link:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.side-link-active {
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.side-label {
  font-weight: 700;
  color: #fff;
}

.side-caption {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.side-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.side-meta {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.6);
}

.side-user {
  margin: 2px 0 0;
  font-size: 16px;
  color: #fff;
  font-weight: 600;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.topbar-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-strong);
}

.topbar-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.content {
  display: grid;
  gap: 18px;
}

.page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px;
  animation: fade-up 0.45s ease;
}

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

.page-title {
  font-size: 30px;
}

.page-subtitle {
  font-size: 15px;
  margin: 0;
}

.card {
  background: #fffdf8;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

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

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(14, 33, 45, 0.08);
}

.stat-card-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  display: block;
}

.stat-card-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(14, 33, 45, 0.12);
}

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

.pagination {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.pagination button,
.pagination a {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
  display: inline-block;
}

.pagination button[aria-current='page'],
.pagination a.active-page {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.stat-label {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-value {
  margin: 8px 0;
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-strong);
  font-family: var(--heading-font);
}

.stat-foot {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
}

.section-title {
  margin: 0 0 16px;
  font-size: 18px;
}

.activity-list {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.activity-title {
  margin: 0;
  font-weight: 700;
  color: var(--accent-strong);
}

.activity-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-success {
  background: rgba(27, 107, 79, 0.12);
  color: var(--success);
}

.badge-warn {
  background: rgba(181, 69, 30, 0.12);
  color: var(--warning);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

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

.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(18, 50, 122, 0.2);
  padding: 10px 12px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 74, 168, 0.15);
}

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

.actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 18px;
  flex-wrap: wrap;
}

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 10px 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(31, 74, 168, 0.2);
}

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

.btn-outline {
  background: transparent;
  color: var(--accent-strong);
  border-color: var(--outline);
}

.btn-ghost {
  background: rgba(31, 74, 168, 0.08);
  color: var(--accent-strong);
}

.btn-danger {
  background: rgba(181, 69, 30, 0.12);
  color: var(--warning);
  border-color: rgba(181, 69, 30, 0.3);
}

.hint {
  padding: 10px 14px;
  background: rgba(31, 74, 168, 0.1);
  color: var(--accent-strong);
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}

.warning {
  padding: 10px 14px;
  background: rgba(181, 69, 30, 0.12);
  color: var(--warning);
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}

.search-result {
  margin-top: 20px;
  padding: 18px;
  border-radius: 12px;
  background: rgba(31, 74, 168, 0.08);
  color: var(--accent-strong);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.dictionary {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  display: grid;
  gap: 8px;
}

.dictionary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.dictionary-key {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.dictionary-value {
  font-weight: 700;
  color: var(--accent-strong);
}

.search-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.search-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.search-qty {
  font-family: var(--heading-font);
  font-size: 32px;
  font-weight: 700;
}

.result-meta {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
}

.meta-label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.meta-value {
  margin: 6px 0 0;
  font-weight: 700;
  color: var(--accent-strong);
}

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

.nav-tile {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 16px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
}

.nav-tile::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
}

.nav-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(14, 33, 45, 0.12);
}

.nav-title {
  font-weight: 700;
  color: var(--accent-strong);
}

.table-wrap {
  margin-top: 20px;
  overflow-x: auto;
}

.history-stack {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.history-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

.report-table th {
  background: rgba(31, 74, 168, 0.08);
  color: var(--accent-strong);
}

.report-table tfoot td {
  font-weight: 700;
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.report-actions {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
}

.stagger > * {
  animation: fade-up 0.5s ease forwards;
  opacity: 0;
  animation-delay: var(--delay, 0s);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 720px) {
  .app-frame {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }

  .app-shell {
    padding: 20px 12px 32px;
  }

  .login-page {
    border-radius: 20px;
    padding: 20px;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
    max-height: none;
  }

  .side-footer {
    width: 100%;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

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

  .page {
    padding: 18px;
  }

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

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 1024px) {
  .app-frame {
    gap: 16px;
    padding: 16px;
  }

  .page {
    padding: 22px;
  }

  .card {
    padding: 16px;
  }

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

@media (max-height: 800px) {
  .sidebar {
    max-height: calc(100vh - 32px);
  }

  .activity-list {
    max-height: 280px;
  }
}

/* ── Details page inline-edit inputs ── */
.edit-cell-input {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
  color: var(--text);
  min-width: 60px;
  outline: none;
}

.edit-cell-input:focus {
  box-shadow: 0 0 0 2px rgba(31, 74, 168, 0.3);
}

/* ── Small button variant ── */
.btn-sm {
  padding: 4px 12px !important;
  font-size: 0.78rem !important;
  min-width: auto !important;
}
