@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --bg-dark: #e8eef6;
  --bg-light: #f6f9fc;
  --bg-surface: #ffffff;
  --card: #ffffff;
  --card-hover: #f6f9ff;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent-primary: #1d4ed8;
  --accent-primary-hover: #1e40af;
  --accent-secondary: #0f172a;
  --accent-tertiary: #0ea5e9;
  --success-bg: #e9f8ef;
  --success-text: #0f6d38;
  --error-bg: #fdecec;
  --error-text: #c62929;
  --border: #d8e1ea;
  --border-light: #cbd5e1;
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 14px 34px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 26px 64px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Avenir Next", "Segoe UI", "Helvetica Neue", "Arial", sans-serif;
  color: var(--text-primary);
  background:
    radial-gradient(circle at 15% 15%, rgba(14, 165, 233, 0.08), transparent 34%),
    radial-gradient(circle at 85% 0%, rgba(29, 78, 216, 0.12), transparent 38%),
    linear-gradient(180deg, var(--bg-light) 0%, var(--bg-dark) 100%);
  font-weight: 400;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  position: relative;
}

.page::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(29, 78, 216, 0.1) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.page::after {
  content: "";
  position: absolute;
  bottom: -30%;
  left: -5%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.1) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.card {
  width: min(1280px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 1;
  backdrop-filter: blur(2px);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

.auth-card {
  width: min(520px, 100%);
}

.auth-shell {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, 0.85fr);
  gap: 28px;
  align-items: stretch;
}

.auth-shell-compact {
  width: min(560px, 100%);
  grid-template-columns: 1fr;
  gap: 0;
}

.auth-brand-panel,
.auth-form-panel {
  border-radius: 16px;
}

.auth-brand-panel {
  padding: 10px 10px 10px 2px;
}

.auth-form-panel {
  padding: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 248, 255, 0.98) 100%);
  border: 1px solid #d9e4f2;
  box-shadow: var(--shadow-sm);
}

.auth-form-panel-full {
  padding: 34px;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
}

.auth-form-panel-full::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-tertiary));
}

.eyebrow {
  margin: 0 0 10px 0;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #2563eb;
}

.auth-panel-title {
  margin: 0 0 8px 0;
  font-size: 1.7rem;
  line-height: 1.15;
  letter-spacing: -0.04em;
  color: var(--text-primary);
}

.auth-subtitle {
  margin-bottom: 22px;
}

.auth-shell-compact .auth-subtitle {
  max-width: 420px;
}

.auth-feature-list {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.auth-feature-item {
  display: grid;
  gap: 4px;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(191, 206, 226, 0.8);
  box-shadow: var(--shadow-sm);
}

.auth-feature-item strong {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.auth-feature-item span {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.card-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}

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

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 22px;
  padding: 26px 28px;
  margin-bottom: 22px;
  border-radius: 18px;
  background: linear-gradient(135deg, #f8fbff 0%, #eef5ff 100%);
  border: 1px solid #d7e4f5;
  box-shadow: var(--shadow-sm);
}

.dashboard-subtitle {
  max-width: 760px;
  margin-bottom: 0;
}

.dashboard-hero-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hero-stat {
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #d9e3f1;
}

.hero-stat-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.hero-stat-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.dashboard-summary-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.summary-band-item {
  padding: 14px 16px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.summary-band-label {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.summary-band-value {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
}

.session-user {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
}

.logout-button {
  width: auto;
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.75rem;
  letter-spacing: 0.4px;
  box-shadow: none;
}

h1 {
  margin: 0 0 8px 0;
  font-size: clamp(1.9rem, 2.4vw, 2.5rem);
  font-weight: 750;
  letter-spacing: -0.6px;
  color: var(--accent-secondary);
}

.subtitle {
  margin: 0 0 24px 0;
  font-size: 0.97rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.token-form {
  display: grid;
  gap: 16px;
}

.token-scope-groups {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  max-height: 340px;
  overflow: auto;
}

.token-scope-section {
  border: 1px solid #e2e8f5;
  border-radius: 10px;
  background: #fbfdff;
  margin-bottom: 8px;
  overflow: hidden;
}

.token-scope-section:last-child {
  margin-bottom: 0;
}

.token-scope-section-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  user-select: none;
}

.token-scope-section-summary::-webkit-details-marker {
  display: none;
}

.token-scope-section-title {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #1e3a8a;
}

.token-scope-section-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: #eef4ff;
  border: 1px solid #d5e2ff;
  border-radius: 999px;
  padding: 2px 8px;
}

.token-scope-section-body {
  display: grid;
  gap: 6px;
  padding: 0 8px 8px;
}

.token-scope-section-body {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.token-scope-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.token-scope-item:hover {
  background: #f7faff;
}

.token-scope-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.token-scope-item span {
  font-size: 0.87rem;
  color: var(--text-primary);
  line-height: 1.3;
}

@media (max-width: 980px) {
  .token-scope-section-body {
    grid-template-columns: 1fr;
  }
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.2px;
  color: var(--text-secondary);
}

input,
select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 13px 16px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text-primary);
  transition: all 0.3s ease;
  font-family: inherit;
}

input::placeholder,
select::placeholder {
  color: var(--text-muted);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--card-hover);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

button {
  width: 100%;
  border-radius: 10px;
  border: none;
  padding: 13px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-primary-hover) 100%);
  color: #fff;
  text-transform: none;
  letter-spacing: 0.2px;
  margin-top: 8px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 8px 20px rgba(29, 78, 216, 0.24);
  position: relative;
  overflow: hidden;
}

button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  transition: left 0.5s ease;
}

button:hover::before {
  left: 100%;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(29, 78, 216, 0.34);
}

button:active {
  transform: translateY(0);
}

.secondary-action {
  margin-top: 16px;
  display: block;
  width: 100%;
  text-align: center;
  border-radius: 10px;
  border: 2px solid var(--border-light);
  background: transparent;
  color: var(--accent-primary);
  font-weight: 600;
  padding: 12px 20px;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0.2px;
  font-size: 0.82rem;
  transition: all 0.3s ease;
  cursor: pointer;
}

.secondary-action:hover {
  background: #eef4ff;
  border-color: var(--accent-primary);
  color: var(--accent-primary-hover);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.inline-permission-editor {
  min-width: min(1240px, 94vw);
}

.inline-permission-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  white-space: nowrap;
  background: #1d4ed8;
  color: #fff;
  border: 1px solid #1e40af;
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.15;
}

.inline-permission-trigger:hover {
  background: #1e40af;
  color: #fff;
  border-color: #1e3a8a;
  box-shadow: none;
}

.inline-permission-editor summary {
  list-style: none;
}

.inline-permission-editor summary::-webkit-details-marker {
  display: none;
}

.inline-permission-editor[open] summary {
  margin-bottom: 12px;
}

.message {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.9rem;
  border-left: 4px solid;
  animation: slideDown 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.success {
  background: var(--success-bg);
  color: var(--success-text);
  border-left-color: var(--success-text);
}

.error {
  background: var(--error-bg);
  color: var(--error-text);
  border-left-color: var(--error-text);
}

.token-box {
  margin-top: 24px;
  border: 1px solid #bcd0f0;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.08) 0%, rgba(14, 165, 233, 0.04) 100%);
  padding: 18px;
  animation: slideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.token-box h2 {
  margin: 0 0 12px 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-primary);
  font-weight: 700;
}

.token-box code {
  display: block;
  word-break: break-all;
  font-size: 0.85rem;
  color: #1e3a8a;
  background: #f8fbff;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: "Monaco", "Menlo", "Courier New", monospace;
  font-weight: 500;
  line-height: 1.5;
}

.order-form {
  margin-top: 18px;
}

.orders-table-wrap {
  margin-top: 24px;
  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-surface);
  animation: slideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.orders-table-wrap h2 {
  margin: 0;
  padding: 16px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.12) 0%, rgba(14, 165, 233, 0.05) 100%);
  border-bottom: 2px solid var(--border);
  color: var(--accent-primary);
}

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

.orders-table th,
.orders-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.orders-table th {
  background: var(--card);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  color: #1e3a8a;
}

.orders-table tbody tr {
  transition: all 0.3s ease;
}

.orders-table tbody tr:hover {
  background: #f8fbff;
  border-left: 3px solid #93c5fd;
  padding-left: 0;
}

.orders-table tbody tr:last-child td {
  border-bottom: none;
}

.orders-table td {
  color: var(--text-primary);
}

.orders-table tbody tr:hover td {
  color: #0f172a;
}

@media (max-width: 680px) {
  .card {
    padding: 24px 16px;
    width: calc(100% - 32px);
  }

  .auth-shell,
  .dashboard-hero,
  .dashboard-summary-band {
    grid-template-columns: 1fr;
  }

  .card-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
  }

  h1 {
    font-size: 1.5rem;
  }

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

  .orders-table {
    min-width: 620px;
  }

  .sync-stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-link-grid,
  .dashboard-link-grid.compact-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    padding: 20px;
  }

  .auth-form-panel {
    padding: 22px 18px;
  }
}

/* ── Admin Panel ── */
.admin-page {
  align-items: flex-start;
  padding-top: 16px;
}

.admin-card {
  width: min(1600px, calc(100vw - 36px));
  min-height: calc(100vh - 40px);
}

.admin-card:hover {
  transform: none;
}

.section-heading {
  margin: 32px 0 8px;
  font-size: 1.12rem;
  font-weight: 700;
  color: #1e293b;
}

.operations-layout {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 14px;
}

.operations-nav {
  position: sticky;
  top: 16px;
  border: 1px solid #d5e2f3;
  border-radius: 16px;
  padding: 14px;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 248, 255, 0.98) 100%);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 8px;
}

.operations-nav-title {
  margin: 2px 4px 8px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #2563eb;
  font-weight: 800;
}

.operations-nav-link {
  width: 100%;
  margin: 0;
  border: 1px solid #d8e3f4;
  border-radius: 10px;
  background: #fff;
  box-shadow: none;
  color: #1f2a44;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
}

.operations-nav-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.12);
  border-color: #b8cbeb;
}

.operations-nav-link.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
}

.operations-main {
  display: grid;
  gap: 14px;
}

.admin-table-wrap {
  border: 1px solid #d8e2ef;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #fbfdff 0%, #f8fbff 100%);
  margin-bottom: 10px;
  overflow-x: auto;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  background: #fff;
}

.admin-table thead tr {
  background: linear-gradient(180deg, #f4f8ff 0%, #edf4ff 100%);
  border-bottom: 2px solid #d8e2ef;
}

.admin-table th {
  padding: 16px 14px;
  text-align: left;
  font-size: 0.70rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #1e40af;
  white-space: nowrap;
  background: linear-gradient(180deg, #f4f8ff 0%, #edf4ff 100%);
}

.admin-table td {
  padding: 14px 14px;
  border-bottom: 1px solid #e6edf7;
  color: var(--text-primary);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.admin-table tbody tr:hover td {
  background: rgba(37, 99, 235, 0.06);
}

.admin-table-tokens tbody tr {
  transition: background-color 0.15s ease;
}

.admin-table-tokens tbody tr:last-child td {
  border-bottom: 1px solid var(--border);
}

.greenmoney-card {
  width: min(1700px, calc(100vw - 36px));
}

.greenmoney-config-form {
  display: grid;
  gap: 12px;
}

.greenmoney-config-section {
  margin-bottom: 10px;
}

.greenmoney-section-title {
  margin: 4px 0 10px;
  font-size: 1rem;
  color: #1e293b;
}

.admin-config-input {
  width: 100%;
  min-width: 260px;
}

.config-actions-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.config-action-button {
  width: auto;
  margin: 0;
  min-width: 72px;
  padding: 7px 11px;
  font-size: 0.74rem;
  box-shadow: none;
}

.icon-only-button {
  min-width: 40px;
  padding: 7px 8px;
}

.icon-eye {
  display: inline-flex;
  width: 16px;
  height: 16px;
}

.icon-eye svg {
  width: 100%;
  height: 100%;
}

.config-action-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.config-inline-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #d7e4f5;
  border-radius: 10px;
  background: #f4f8ff;
  color: #1e3a8a;
  font-size: 0.82rem;
}

.dashboard-summary-card {
  width: min(1240px, calc(100vw - 36px));
}

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

.summary-metric-card {
  border: 1px solid #d1dce6;
  border-radius: 14px;
  background: #ffffff;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.summary-metric-title {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.summary-metric-value {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
}

.summary-metric-detail {
  margin: 0;
  color: #475569;
  font-size: 0.85rem;
}

.dashboard-link-panel {
  margin-top: 28px;
  border: 1px solid #d9e4f2;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f8ff 100%);
  padding: 18px;
}

.dashboard-link-header h2 {
  margin: 0;
  font-size: 1.15rem;
  color: #10253f;
}

.dashboard-link-header .subtitle {
  margin-top: 6px;
  margin-bottom: 0;
}

.dashboard-link-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-link-grid.compact-grid {
  grid-template-columns: minmax(260px, 380px);
}

.dashboard-link-card {
  display: block;
  text-decoration: none;
  border: 1px solid #cfdef2;
  border-radius: 14px;
  background: #ffffff;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.dashboard-link-card:hover {
  transform: translateY(-1px);
  border-color: #9bb9e3;
  box-shadow: 0 10px 24px rgba(29, 78, 216, 0.12);
}

.dashboard-link-tag {
  display: inline-block;
  font-size: 0.69rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #1d4ed8;
  background: #eaf2ff;
  border: 1px solid #cadeff;
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 8px;
  font-weight: 700;
}

.dashboard-link-card h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
  color: #0f172a;
}

.dashboard-link-card p {
  margin: 0;
  color: #475569;
  font-size: 0.84rem;
  line-height: 1.45;
}

.col-id {
  color: var(--text-muted);
  font-size: 0.8rem;
  width: 40px;
}

.col-token code {
  font-size: 0.75rem;
  font-family: "Monaco", "Menlo", "Courier New", monospace;
  color: #1e3a8a;
  background: #eef4fb;
  padding: 3px 7px;
  border-radius: 6px;
  word-break: break-all;
}

.col-date {
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.deleted-at {
  color: var(--error-text);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: rgba(29, 78, 216, 0.12);
  color: #1e3a8a;
  border: 1px solid rgba(29, 78, 216, 0.25);
}

.badge-muted {
  background: rgba(138, 146, 160, 0.12);
  color: var(--text-muted);
  border-color: var(--border);
}

.delete-btn {
  width: auto;
  margin: 0;
  padding: 6px 14px;
  font-size: 0.75rem;
  border-radius: 8px;
  background: linear-gradient(135deg, #ff4444, #cc0000);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255, 68, 68, 0.3);
  letter-spacing: 0.3px;
}

.delete-btn:hover {
  box-shadow: 0 4px 14px rgba(255, 68, 68, 0.5);
  transform: translateY(-1px);
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 16px 0;
  margin: 0;
}

.expired {
  color: var(--error-text) !important;
  font-weight: 600;
}

.sync-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.audit-filter-form {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

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

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

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

.audit-filter-grid label {
  display: grid;
  gap: 6px;
  font-size: 0.84rem;
  color: #334155;
  font-weight: 600;
}

.audit-filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.audit-log-details {
  min-width: 220px;
}

.audit-log-details summary {
  cursor: pointer;
  color: #1e3a8a;
  font-weight: 700;
}

.audit-log-detail-group {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.audit-log-detail-group p {
  margin: 0;
}

.audit-log-json {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #d7e4f5;
  background: #f8fbff;
  color: #0f172a;
  font-size: 0.75rem;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 980px) {
  .audit-filter-grid {
    grid-template-columns: 1fr;
  }
}

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

.sync-stat-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-surface);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.sync-stat-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sync-stat-value {
  display: block;
  color: var(--text-primary);
  font-size: 1.02rem;
  font-weight: 700;
}

.sync-action-form {
  margin: 0;
}

.sync-run-button {
  width: auto;
  margin: 0;
  padding: 12px 18px;
}



.report-section {
  border: 1px solid #d6e3f4;
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.99) 0%, rgba(246, 250, 255, 0.99) 100%);
  margin: 12px 0;
  overflow: hidden;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.08);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.report-section:hover {
  transform: translateY(-2px);
  border-color: #c4d8f2;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
}

.report-section summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  font-weight: 700;
  color: #0f1f3a;
  cursor: pointer;
  background: linear-gradient(130deg, rgba(37, 99, 235, 0.10) 0%, rgba(14, 165, 233, 0.09) 100%);
  border-bottom: 1px solid transparent;
  position: relative;
  padding-right: 42px;
}

.report-section summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: #1d4ed8;
  font-weight: 700;
}

.report-section[open] summary {
  border-bottom-color: var(--border);
}

.report-section[open] summary::after {
  content: "-";
}

.report-section summary::-webkit-details-marker {
  display: none;
}

.report-meta {
  font-size: 0.78rem;
  font-weight: 700;
  color: #1d4ed8;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(30, 64, 175, 0.25);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.report-content {
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 251, 255, 0.96) 100%);
}

.sync-toolbar {
  border: 1px solid #d5e1f0;
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98) 0%, rgba(242, 247, 255, 0.98) 100%);
  padding: 14px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.sync-stat-card {
  border: 1px solid #dce6f4;
  border-radius: 12px;
  background: #fff;
}

.sync-run-button {
  border-radius: 12px;
  padding: 12px 20px;
}

textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  font-size: 0.92rem;
  background: #fff;
  color: var(--text-primary);
  transition: all 0.3s ease;
  resize: vertical;
  min-height: 84px;
  font-family: inherit;
}

textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--card-hover);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

@media (max-width: 1160px) {
  .operations-layout {
    grid-template-columns: 1fr;
  }

  .operations-nav {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .operations-nav-title {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .operations-nav {
    grid-template-columns: 1fr;
  }
}

.inline-action-link {
  width: auto;
  margin: 0;
  padding: 10px 14px;
  display: inline-block;
}

.small-action-link {
  padding: 4px 9px;
  font-size: 0.72rem;
}

/* Inventory module polish */
.inventory-shell .inventory-card {
  position: relative;
  overflow: hidden;
}

.inventory-shell .inventory-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, #0f766e 0%, #0891b2 38%, #1d4ed8 100%);
}

.inventory-shell .card-topbar {
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px dashed #cdd9ea;
}

.inventory-shell .dashboard-hero {
  background:
    radial-gradient(circle at 82% 16%, rgba(8, 145, 178, 0.17), transparent 45%),
    linear-gradient(125deg, #f8fcff 0%, #eef8ff 52%, #f3f9f8 100%);
  border: 1px solid #cfe3ee;
}

.inventory-shell .hero-stat {
  background: linear-gradient(165deg, #ffffff 0%, #f7fcff 100%);
  border-color: #d2e5f1;
}

.inventory-sync-form {
  max-width: 340px;
  margin-bottom: 18px;
}

.inventory-sync-button {
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: linear-gradient(135deg, #0f766e 0%, #0ea5e9 100%);
  box-shadow: 0 10px 24px rgba(8, 145, 178, 0.3);
}

.inventory-sync-button:hover {
  box-shadow: 0 14px 30px rgba(8, 145, 178, 0.34);
}

.sku-link {
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  color: #0f4a7c;
  text-decoration: none;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(15, 74, 124, 0.25);
}

.sku-link:hover {
  color: #0e7490;
  border-bottom-color: #0e7490;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-ready {
  color: #14532d;
  background: #e8f9ee;
  border-color: #b8ebc8;
}

.status-quarantine,
.status-pending {
  color: #7c2d12;
  background: #fff1df;
  border-color: #ffd6a7;
}

.status-failed {
  color: #991b1b;
  background: #fee9e9;
  border-color: #fecaca;
}

.status-review {
  color: #1d4ed8;
  background: #eaf1ff;
  border-color: #c5d9ff;
}

.lot-count-pill {
  display: inline-flex;
  min-width: 28px;
  justify-content: center;
  border-radius: 999px;
  background: #edf6ff;
  border: 1px solid #c9ddf5;
  color: #13426e;
  font-weight: 700;
  padding: 3px 8px;
  font-size: 0.75rem;
}

.inventory-product-card .report-content {
  padding: 16px;
}

.lot-form-grid {
  max-width: 920px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.lot-form-actions {
  grid-column: 1 / -1;
}

.lot-inline-form {
  display: contents;
}

.admin-table .lot-inline-form input,
.admin-table .lot-inline-form select {
  min-width: 120px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
}

.lot-row-save {
  width: auto;
  margin: 0;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 0.76rem;
  font-weight: 700;
  box-shadow: none;
}

.lot-row-delete {
  margin: 0;
}

.lot-row-save:hover {
  transform: translateY(-1px);
}

.inventory-shell .admin-table tbody tr {
  animation: inventoryFadeIn 0.35s ease both;
}

.inventory-shell .admin-table tbody tr:nth-child(2) { animation-delay: 0.03s; }
.inventory-shell .admin-table tbody tr:nth-child(3) { animation-delay: 0.05s; }
.inventory-shell .admin-table tbody tr:nth-child(4) { animation-delay: 0.07s; }
.inventory-shell .admin-table tbody tr:nth-child(5) { animation-delay: 0.09s; }

@keyframes inventoryFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 720px) {
  .inventory-shell .dashboard-hero-stats {
    grid-template-columns: 1fr;
  }

  .inventory-shell .report-section summary {
    padding-right: 32px;
  }

  .inventory-sync-form {
    max-width: 100%;
  }

  .lot-form-grid {
    grid-template-columns: 1fr;
  }
}

.token-user-email strong {
  display: block;
  font-size: 0.94rem;
}

.token-row-main {
  position: relative;
}

.token-permission-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.token-edit-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-top: 0;
  min-width: 0;
  cursor: pointer;
}

.token-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.token-delete-form {
  margin: 0;
}

.token-delete-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid #dc2626;
  background: #fff1f2;
  color: #b91c1c;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.token-delete-trigger:hover {
  background: #dc2626;
  border-color: #b91c1c;
  color: #fff;
}

.token-permission-row {
  display: none;
}

.token-row-main:has(.token-permission-toggle:checked) + .token-permission-row {
  display: table-row;
}

.token-permission-row td {
  padding: 0 0 14px;
  background: #f8fbff;
  border-top: 0;
}

.token-permission-panel {
  margin-top: 0;
  display: grid;
  gap: 14px;
  width: 100%;
  padding-top: 14px;
}

.token-permission-panel-subtitle {
  margin-bottom: 0;
}

.token-summary-list {
  display: grid;
  gap: 8px;
}

.token-summary-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fbff;
}

.token-summary-item strong {
  font-size: 0.76rem;
  color: #1e3a8a;
}

.token-summary-item span {
  color: var(--text-secondary);
  line-height: 1.45;
}

.token-summary-item-token code {
  font-size: 0.74rem;
  font-family: "Monaco", "Menlo", "Courier New", monospace;
  color: #1e3a8a;
  background: #eef4fb;
  padding: 3px 7px;
  border-radius: 6px;
  word-break: break-all;
}

.permission-token-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fbfdff;
  padding: 18px;
  display: grid;
  gap: 16px;
}

.permission-token-card-compact {
  gap: 14px;
  width: 100%;
  max-width: none;
  max-height: 76vh;
  overflow: auto;
}

.permission-token-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.permission-token-card__top-compact {
  align-items: center;
}

.permission-token-card__top h4 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--text-primary);
}

.permission-token-card__top p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.permission-token-card__meta {
  display: grid;
  gap: 8px;
}

.permission-token-card__meta-compact {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr);
  gap: 16px;
}

.admin-permission-meta {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.permission-token-card__meta code {
  font-size: 0.75rem;
  font-family: "Monaco", "Menlo", "Courier New", monospace;
  color: #1e3a8a;
  background: #eef4fb;
  padding: 8px 10px;
  border-radius: 8px;
  word-break: break-all;
}

.permission-token-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.permission-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.permission-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(29, 78, 216, 0.1);
  border: 1px solid rgba(29, 78, 216, 0.18);
  color: #1e3a8a;
  font-size: 0.76rem;
  font-weight: 700;
}

.permission-ordered-list {
  margin: 6px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  color: var(--text-secondary);
}

.permission-ordered-list li {
  line-height: 1.35;
  font-size: 0.8rem;
}

.permission-ordered-list-compact {
  margin: 0;
  gap: 4px;
  padding-left: 18px;
}

.permission-edit-form {
  display: grid;
  gap: 14px;
}

.permission-edit-form-compact {
  padding-top: 4px;
  border-top: 1px solid #e5edf7;
}

.permission-action-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.permission-action-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
}

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

.permission-scope-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.permission-scope-groups {
  max-height: none;
}

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

.permission-version-stack {
  display: grid;
  gap: 16px;
}

.permission-version-toggle {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fbff;
  overflow: hidden;
}

.permission-version-toggle-summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  color: var(--text-primary);
}

.permission-version-toggle-summary::-webkit-details-marker {
  display: none;
}

.permission-version-section {
  padding: 0 16px 16px;
  display: grid;
  gap: 14px;
}

.permission-version-header h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--text-primary);
}

.permission-version-header p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.token-hero-email {
  font-size: 1rem;
  line-height: 1.35;
  word-break: break-word;
}

.permission-scope-item {
  align-items: flex-start;
  min-height: 100%;
  border: 1px solid var(--border);
  background: #fff;
}

.permission-scope-item-active {
  border-color: #b9cdfb;
  background: #f4f8ff;
}

.permission-scope-section-body {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.permission-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@media (max-width: 860px) {
  .inline-permission-editor {
    min-width: 100%;
  }

  .token-permission-panel {
    min-width: 100%;
  }

  .admin-permission-meta {
    grid-template-columns: 1fr;
  }

  .permission-token-card__meta-compact {
    grid-template-columns: 1fr;
  }

  .permission-token-card__top-compact {
    flex-direction: column;
    align-items: stretch;
  }

  .permission-version-grid {
    grid-template-columns: 1fr;
  }

  .permission-scope-section-body {
    grid-template-columns: 1fr;
  }

  .permission-edit-actions {
    flex-direction: column-reverse;
  }
}

.error-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fbff;
  padding: 16px;
}

.error-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  font-family: "Menlo", "Monaco", "Courier New", monospace;
  font-size: 0.84rem;
  line-height: 1.55;
}

/* ── Profile Page ── */
.profile-page {
  align-items: flex-start;
  padding-top: 40px;
}

.profile-card {
  width: min(860px, 100%);
}

.profile-card:hover {
  transform: none;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-primary-hover) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.profile-header-info {
  flex: 1;
  min-width: 0;
}

.profile-header-info h1 {
  margin: 0 0 4px 0;
  font-size: 1.5rem;
}

.profile-header-info p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.profile-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-nav a {
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0.4px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: transparent;
  transition: all 0.2s ease;
}

.profile-nav a:hover,
.profile-nav a.active {
  border-color: var(--accent-primary);
  color: var(--accent-primary-hover);
  background: rgba(29, 78, 216, 0.08);
}

.profile-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
}

.profile-panel:last-child {
  margin-bottom: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
}

.panel-header p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.token-count-badge {
  background: rgba(29, 78, 216, 0.12);
  border: 1px solid rgba(29, 78, 216, 0.25);
  color: #1e3a8a;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.inline-form .form-group {
  display: grid;
  gap: 6px;
}

.inline-form button {
  margin: 0;
  padding: 12px 24px;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .inline-form {
    grid-template-columns: 1fr;
  }

  .permission-scope-grid {
    grid-template-columns: 1fr;
  }

  .permission-edit-actions {
    flex-direction: column;
  }
}

/* ── Account Settings Page ── */
.account-page {
  align-items: flex-start;
  padding-top: 40px;
}

.account-card {
  width: min(980px, 100%);
}

.account-card:hover {
  transform: none;
}

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

.form-grid-3 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: grid;
  gap: 6px;
}

.form-group label {
  margin: 0;
}

.form-group input,
.form-group select {
  margin: 0;
}

@media (max-width: 600px) {
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
}

