:root {
  --bg-main: #f4f6fa;
  --card-bg: #ffffff;
  --border-soft: #e8ecf4;

  /* PrinceBot Brand tokens */
  --pb-dark:    #111827;
  --pb-darker:  #0f172a;
  --pb-blue:    #3b82f6;
  --pb-blue-dk: #2563eb;
  --pb-teal:    #2dd4bf;
  --pb-border:  #dbe7ff;
  --pb-shadow:  rgba(37, 99, 235, 0.12);

  /* Dark theme palette */
  --dk-bg:        #0d1117;
  --dk-surface:   #161b22;
  --dk-surface2:  #1c2333;
  --dk-border:    #30363d;
  --dk-border-b:  rgba(59, 130, 246, 0.25);
  --dk-text:      #e6edf3;
  --dk-text-2:    #8b949e;
  --dk-text-3:    #6e7681;
  --dk-blue:      #58a6ff;
  --dk-blue-dk:   #388bfd;
  --dk-shadow:    rgba(0, 0, 0, 0.4);
}

/* ============================================================
   PrinceBot Brand – Auth pages (Token Access / Token Request)
   ============================================================ */

.pb-auth-bg {
  background: #f4f6fa;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1e2430;
}

/* ---- Header ---- */
.pb-auth-header {
  background: var(--pb-dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 20;
}

.pb-auth-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
}

.pb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #f9fafb;
}

.pb-brand:hover { opacity: 0.85; }

.pb-brand-logo {
  height: 28px;
  border-radius: 6px;
}

.pb-brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.pb-header-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: #f9fafb;
  letter-spacing: 0.02em;
  padding: 0;
  background: none;
  border: none;
}

/* ---- Main area ---- */
.pb-auth-main {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 48px 16px 64px;
  min-height: calc(100vh - 54px);
}

/* ---- Card ---- */
.pb-auth-card {
  width: 100%;
  max-width: 460px;
  background: #ffffff;
  border: 1px solid #e8ecf4;
  border-radius: 16px;
  padding: 28px 28px 24px;
  box-shadow: 0 8px 32px rgba(12, 38, 79, 0.08);
}

/* ---- Card top (icon + title) ---- */
.pb-auth-card-top {
  text-align: center;
  margin-bottom: 24px;
}

.pb-auth-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  color: var(--pb-blue-dk);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.pb-auth-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 6px;
}

.pb-auth-desc {
  font-size: 0.9rem;
  color: #6b7280;
  margin: 0;
  line-height: 1.5;
}

/* ---- Alert ---- */
.pb-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.4;
  margin-bottom: 16px;
}

.pb-alert svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.pb-alert-danger {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #be123c;
}

.pb-alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

/* ---- Form ---- */
.pb-auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.pb-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pb-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pb-label-optional {
  font-size: 0.75rem;
  font-weight: 400;
  color: #9ca3af;
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 4px;
}

.pb-input {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #111827;
  background: #ffffff;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  font-family: inherit;
}

.pb-input::placeholder {
  color: #9ca3af;
}

.pb-input:focus {
  border-color: var(--pb-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.pb-field-hint {
  font-size: 0.8rem;
  color: #9ca3af;
  line-height: 1.3;
}

/* ---- Buttons ---- */
.pb-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  background: var(--pb-blue-dk);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s, box-shadow 0.18s;
  font-family: inherit;
}

.pb-btn-primary:hover,
.pb-btn-primary:focus-visible {
  background: var(--pb-blue);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
  color: #ffffff;
  text-decoration: none;
}

.pb-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pb-btn-outline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--pb-blue-dk);
  background: transparent;
  color: var(--pb-blue-dk);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s, color 0.18s;
  font-family: inherit;
}

.pb-btn-outline:hover,
.pb-btn-outline:focus-visible {
  background: #eff6ff;
  color: var(--pb-blue);
  text-decoration: none;
}

.pb-btn-outline:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---- Divider ---- */
.pb-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #9ca3af;
  font-size: 0.82rem;
  margin: 20px 0;
}

.pb-divider::before,
.pb-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

/* ---- Misc ---- */
.pb-link-row {
  text-align: center;
  margin: 4px 0 0;
}

.pb-link {
  color: var(--pb-blue-dk);
  font-size: 0.85rem;
  text-decoration: none;
}

.pb-link:hover {
  text-decoration: underline;
  color: var(--pb-blue);
}

.pb-auth-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
}

.pb-auth-footer p {
  font-size: 0.8rem;
  color: #9ca3af;
  margin: 0 0 4px;
  line-height: 1.4;
}

.pb-auth-footer p:last-child { margin-bottom: 0; }

@media (max-width: 480px) {
  .pb-auth-card {
    padding: 20px 16px 18px;
    border-radius: 14px;
  }
  .pb-auth-main {
    padding: 24px 12px 40px;
  }
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #1e2430;
}

.auth-bg {
  background: linear-gradient(160deg, #f5f7fb 0%, #ecf2ff 100%);
  min-height: 100vh;
}

.dashboard-bg {
  background: var(--bg-main);
  min-height: 100vh;
}

.dashboard-builder-bg {
  background: #eceff4;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(12, 38, 79, 0.07);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #8a95ab;
  font-size: 0.9rem;
  margin: 1rem 0;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #dce3f1;
}

.status-banner {
  background: #ffffff;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.metric-card {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px;
  height: 100%;
}

.metric-title {
  font-size: 0.9rem;
  color: #66738d;
}

.metric-value {
  font-size: 1.45rem;
  font-weight: 700;
  margin-top: 6px;
}

.control-card {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 16px;
}

.error-card {
  width: 100%;
  max-width: 460px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: #fff;
  padding: 28px;
}

.error-code {
  font-size: 2rem;
  font-weight: 700;
}

.token-raw {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.95rem;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 10px 94px 10px 12px;
  word-break: break-all;
}

.token-raw-wrap {
  position: relative;
}

.token-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.8);
  border: 0;
  box-shadow: none;
}

.token-copy-btn:hover,
.token-copy-btn:focus {
  color: #ffffff;
  background: rgba(30, 41, 59, 0.95);
  border: 0;
  box-shadow: none;
}

.table-admin-tokens {
  min-width: 1120px;
}

.table-admin-tokens .token-cell {
  display: inline-block;
  max-width: 320px;
  white-space: normal;
  word-break: break-all;
  line-height: 1.2;
}

.pin-edit-group {
  max-width: 300px;
}

.builder-layout {
  display: grid;
  grid-template-columns: 272px 1fr;
  gap: 14px;
  align-items: start;
}

.widget-sidebar {
  background: #dde1e7;
  border: 1px solid #d1d6df;
  border-radius: 10px;
  padding: 14px;
  position: sticky;
  top: 80px;
}

.widget-card {
  background: #ffffff;
  border: 1px solid #d7dde8;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.widget-group-title {
  font-size: 0.86rem;
  text-transform: uppercase;
  color: #687189;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.widget-item {
  background: #ffffff;
  border: 1px solid #d7dde8;
  border-radius: 8px;
  padding: 10px;
  cursor: grab;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.widget-item:active {
  cursor: grabbing;
}

.widget-item.widget-item-disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.widget-item-title {
  font-size: 1.05rem;
  color: #4f566a;
}

.widget-item-number {
  margin-top: 6px;
  font-size: 2.05rem;
  line-height: 1;
  color: #505666;
}

.widget-switch-preview {
  margin-top: 8px;
  width: 58px;
  height: 32px;
  background: #7b7e83;
  border-radius: 999px;
  position: relative;
}

.widget-switch-knob {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  top: 3px;
  left: 3px;
}

.widget-slider-preview {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.widget-slider-track {
  display: inline-block;
  width: 130px;
  height: 4px;
  background: #d6dbe5;
  border-radius: 999px;
}

.widget-slider-thumb {
  position: absolute;
  margin-left: 15px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #26c181;
}

.widget-slider-value {
  font-size: 2rem;
  color: #555d6f;
  margin-left: 2px;
}

.widget-online-bar {
  margin-top: 8px;
  height: 6px;
  border-radius: 999px;
  background: #d8dde6;
  overflow: hidden;
}

.widget-online-bar span {
  display: block;
  width: 65%;
  height: 100%;
  background: #74c843;
}

.widget-card-title {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5f6980;
  margin-bottom: 6px;
}

.widget-card-value {
  font-weight: 700;
  color: #202738;
}

.pin-preview-list {
  display: grid;
  gap: 6px;
}

.pin-preview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px dashed #d6dce8;
  padding-bottom: 4px;
}

.pin-preview-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.canvas-area {
  background: #f7f8fb;
  border: 1px solid #d9deea;
  border-radius: 10px;
  padding: 12px;
}

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

.dashboard-name-input {
  field-sizing: content;
  min-width: 10ch;
  max-width: min(100%, 50ch);
  flex: 0 0 auto;
  font-weight: 600;
  color: #31394d;
}

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

.meta-box {
  background: #ffffff;
  border: 1px solid #dde2ec;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.meta-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6f788d;
}

.meta-value {
  font-size: 0.9rem;
  color: #2b3141;
  margin-top: 2px;
}

.token-full-value {
  margin-top: 6px;
  font-size: 0.78rem;
  font-family: monospace;
  color: #1a9468;
  word-break: break-all;
  background: #eaf6f1;
  border-radius: 4px;
  padding: 4px 6px;
}

.token-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #d2d8e6;
  border-radius: 4px;
  background: #f4f6fa;
  color: #5f6980;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.token-toggle-btn:hover {
  background: #e8ecf4;
  color: #2b3141;
}

.token-toggle-btn.is-revealed {
  background: #eaf6f1;
  border-color: #26c181;
  color: #1a9468;
}

.canvas-grid {
  position: relative;
  border: 1px dashed #cfd6e4;
  border-radius: 8px;
  padding: 14px;
  min-height: 620px;
  background-image:
    linear-gradient(to right, rgba(187, 196, 214, 0.25) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(187, 196, 214, 0.25) 1px, transparent 1px);
  background-size: 52px 52px;
}

.canvas-grid-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #47506a;
  pointer-events: none;
}

.widget-canvas-dropzone {
  position: relative;
  z-index: 1;
  min-height: 580px;
}

.canvas-widget {
  position: absolute;
  width: 240px;
  background: #ffffff;
  border: 1px solid #d7dde8;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}

.canvas-widget-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.canvas-widget:hover .canvas-widget-actions,
.canvas-widget:focus-within .canvas-widget-actions {
  opacity: 1;
  pointer-events: auto;
}

.dashboard-builder-bg:not(.dashboard-editing) .canvas-widget-actions {
  opacity: 0 !important;
  pointer-events: none !important;
}

.canvas-action-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #d2d8e6;
  border-radius: 4px;
  background: #ffffff;
  color: #4b5468;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  line-height: 1;
}

.canvas-action-btn svg {
  display: block;
}

.canvas-action-edit {
  font-weight: 700;
}

.canvas-action-delete {
  border-color: #ff3b30;
  background: #ff2015;
  color: #ffffff;
}

.canvas-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 0;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.dashboard-builder-bg:not(.dashboard-editing) .canvas-widget-header {
  cursor: default;
}

.canvas-widget-title {
  font-size: 1.05rem;
  font-weight: 400;
  color: #4f566a;
}

.canvas-widget-body {
  padding: 8px 10px 10px;
}

.canvas-switch-control {
  position: relative;
  margin-top: 2px;
  width: 58px;
  height: 32px;
  background: #7b7e83;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.canvas-switch-control.is-on {
  background: #26c181;
}

.canvas-switch-knob {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  top: 3px;
  left: 3px;
  transition: left 0.14s ease;
}

.canvas-switch-control.is-on .canvas-switch-knob {
  left: 29px;
}

.canvas-slider-row {
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.canvas-slider-input {
  -webkit-appearance: none;
  appearance: none;
  width: 130px;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

.canvas-slider-input:focus {
  outline: none;
}

.canvas-slider-input::-webkit-slider-runnable-track {
  height: 4px;
  background: #d6dbe5;
  border-radius: 999px;
}

.canvas-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #26c181;
  margin-top: -7px;
}

.canvas-slider-input::-moz-range-track {
  height: 4px;
  background: #d6dbe5;
  border-radius: 999px;
}

.canvas-slider-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #26c181;
}

.canvas-slider-input::-moz-range-progress {
  height: 4px;
  background: #d6dbe5;
  border-radius: 999px;
}

.slider-widget-value {
  font-size: 2rem;
  font-weight: 400;
  color: #555d6f;
  margin-top: 0;
  line-height: 1;
}

.tile-widget-value {
  font-size: 2.8rem;
  font-weight: 400;
  color: #505666;
  line-height: 1.1;
  margin-top: 6px;
  user-select: none;
  -webkit-user-select: none;
  caret-color: transparent;
}

.slider-widget-value,
.canvas-widget-title,
#connectionState,
#lastUpdated {
  user-select: none;
  -webkit-user-select: none;
  caret-color: transparent;
}

/* Prevent text caret from appearing on display-only dashboard elements. */
.dashboard-builder-bg .canvas-area :not(input):not(textarea):not([contenteditable='true']) {
  caret-color: transparent;
}

.online-widget-bar {
  margin-top: 8px;
  height: 7px;
  border-radius: 999px;
  background: #dde3ee;
  overflow: hidden;
}

.online-widget-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  transition: width 0.2s ease;
  background: #48b652;
}

.grid-widget-pins {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.98);
}

.sf-settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(16, 24, 40, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.sf-settings-dialog {
  width: min(420px, 100%);
  background: #ffffff;
  border: 1px solid #d7ddea;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  padding: 14px;
}

.sf-settings-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #24324a;
}

.sf-settings-label {
  display: block;
  margin: 8px 0 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #43506b;
}

.sf-settings-input {
  font-size: 0.95rem;
}

.sf-settings-error {
  margin-top: 8px;
  font-size: 0.84rem;
  color: #d11f2a;
}

.sf-settings-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

  .widget-sidebar {
    position: static;
  }

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

@media (max-width: 767.98px) {
  .canvas-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-name-input {
    width: 100%;
    max-width: none;
  }

  .canvas-grid {
    min-height: 520px;
  }

  .widget-canvas-dropzone {
    min-height: 480px;
  }
}

/* ============================================================
   PrinceBot Brand – Admin pages
   ============================================================ */

/* Admin page background */
.pb-admin-bg {
  background: var(--bg-main);
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1e2430;
}

/* Admin badge in header */
.pb-header-badge-admin {
  color: #fca5a5 !important;
}

/* Admin icon style */
.pb-auth-icon-admin {
  background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%) !important;
  border-color: #fecdd3 !important;
  color: #be123c !important;
}

/* Admin sign-in button (dark) */
.pb-btn-admin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  background: #111827;
  color: #f9fafb;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s;
  font-family: inherit;
}

.pb-btn-admin:hover,
.pb-btn-admin:focus-visible {
  background: #1f2937;
  color: #ffffff;
}

/* Logout button in header */
.pb-btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s;
}

.pb-btn-logout:hover {
  background: rgba(239, 68, 68, 0.22);
  color: #fecdd3;
}

/* Admin main content area */
.pb-admin-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

/* Admin card (section box) */
.pb-admin-card {
  background: #ffffff;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

/* Section header row */
.pb-admin-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: #374151;
}

.pb-admin-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.pb-token-count {
  margin-left: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #eff6ff;
  color: var(--pb-blue-dk);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 1px 9px;
}

/* Create token form grid */
.pb-admin-form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}

.pb-admin-form-grid .pb-field {
  flex: 1 1 160px;
  min-width: 140px;
}

.pb-admin-form-grid .pb-field-wide {
  flex: 2 1 220px;
}

.pb-admin-form-grid .pb-field-action {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
}

/* Select */
.pb-select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #111827;
  background: #ffffff;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  font-family: inherit;
  appearance: auto;
}

.pb-select:focus {
  border-color: var(--pb-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Status tabs */
.pb-tab-group {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0;
  margin-bottom: 0;
}

.pb-tab {
  padding: 6px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  text-decoration: none;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  transition: color 0.15s, background 0.15s;
  margin-bottom: -1px;
}

.pb-tab:hover {
  color: var(--pb-blue-dk);
  background: #f0f7ff;
}

.pb-tab-active {
  color: var(--pb-blue-dk) !important;
  background: #ffffff;
  border-color: #e5e7eb;
  border-bottom-color: #ffffff;
  font-weight: 600;
}

/* Filter row */
.pb-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 14px 0 0;
  border-top: 1px solid #f1f5f9;
  margin-top: 0;
}

.pb-filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding-top: 20px;
}

/* Smaller button variant */
.pb-btn-sm {
  padding: 7px 14px !important;
  font-size: 0.85rem !important;
  white-space: nowrap;
}

/* Admin table overrides */
.pb-admin-table thead th {
  background: #f8fafc;
  color: #4b5563;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 2px solid #e5e7eb;
}

.pb-admin-table tbody tr:hover {
  background: #f8fbff;
}

.pb-td-id {
  color: #9ca3af;
  font-size: 0.85rem;
}

.pb-td-date {
  font-size: 0.82rem;
  color: #6b7280;
  white-space: nowrap;
}

.pb-td-dash {
  color: #d1d5db;
}

.pb-table-empty {
  text-align: center;
  padding: 32px 0;
  color: #9ca3af;
  font-size: 0.9rem;
}

/* Status badge */
.pb-status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}

.pb-status-active {
  background: #dcfce7;
  color: #166534;
}

.pb-status-revoked {
  background: #f3f4f6;
  color: #6b7280;
}

/* Mode badge */
.pb-mode-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 500;
}

/* Table action buttons */
.pb-tbl-btn {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid;
  background: transparent;
  transition: background 0.15s;
  font-family: inherit;
}

.pb-tbl-btn-blue {
  border-color: var(--pb-blue-dk);
  color: var(--pb-blue-dk);
}

.pb-tbl-btn-blue:hover {
  background: #eff6ff;
}

.pb-tbl-btn-red {
  border-color: #dc2626;
  color: #dc2626;
}

.pb-tbl-btn-red:hover {
  background: #fff1f2;
}

/* Token banner (new token created) */
.pb-token-banner {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.pb-token-banner-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #166534;
  margin-bottom: 4px;
}

.pb-copy-hint {
  font-size: 0.82rem;
  color: #16a34a;
  margin-top: 6px;
}

/* Pagination */
.pb-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pb-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 500;
  color: #374151;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.pb-page-btn:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--pb-blue-dk);
  text-decoration: none;
}

.pb-page-btn-active {
  background: var(--pb-blue-dk) !important;
  border-color: var(--pb-blue-dk) !important;
  color: #ffffff !important;
}

.pb-page-btn-disabled {
  opacity: 0.4;
  pointer-events: none;
}

@media (max-width: 768px) {
  .pb-admin-main {
    padding: 16px 12px 40px;
  }

  .pb-admin-card {
    padding: 14px 14px;
  }

  .pb-admin-form-grid {
    flex-direction: column;
  }

  .pb-admin-form-grid .pb-field,
  .pb-admin-form-grid .pb-field-wide {
    flex: 1 1 100%;
  }

  .pb-filter-row {
    flex-direction: column;
  }

  .pb-filter-actions {
    width: 100%;
  }
}

/* ============================================================
   Create App Token Card — enhanced layout
   ============================================================ */

.pb-create-card {
  border-top: 3px solid var(--pb-blue-dk);
}

/* Header strip */
.pb-create-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}

.pb-create-header-left {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.pb-create-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  color: var(--pb-blue-dk);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pb-create-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 3px;
}

.pb-create-desc {
  font-size: 0.83rem;
  color: #6b7280;
  margin: 0;
  line-height: 1.4;
}

/* Form layout */
.pb-create-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pb-create-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: start;
}

/* Input with icon prefix */
.pb-input-with-icon {
  position: relative;
}

.pb-input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

.pb-input-icon-pad {
  padding-left: 36px !important;
}

/* Required asterisk */
.pb-label-required {
  color: #ef4444;
  margin-left: 2px;
}

/* Action row */
.pb-create-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid #f1f5f9;
  margin-top: 4px;
}

/* Bigger create button */
.pb-btn-create {
  padding: 10px 22px !important;
  font-size: 0.95rem !important;
  min-width: 160px;
}

@media (max-width: 640px) {
  .pb-create-row {
    grid-template-columns: 1fr;
  }

  .pb-create-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .pb-create-actions .pb-btn-outline,
  .pb-create-actions .pb-btn-primary {
    width: 100%;
    justify-content: center;
  }

  .pb-create-header-left {
    flex-direction: column;
  }
}

/* Compact 2-col row สำหรับ Access Mode + Expires เท่านั้น */
.pb-create-row-compact {
  grid-template-columns: 1fr 1fr;
  max-width: 560px;
}

@media (max-width: 480px) {
  .pb-create-row-compact {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
}

/* Inline single-row form layout */
.pb-create-inline-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.pb-create-inline-row .pb-field { margin: 0; }

.pb-field-name    { flex: 2 1 200px; min-width: 0; }
.pb-field-mode    { flex: 1 1 130px; min-width: 110px; }
.pb-field-expires { flex: 0 1 130px; min-width: 100px; }
.pb-field-action  { flex: 0 0 auto; }

.pb-field-action .pb-btn-primary {
  width: auto;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .pb-create-inline-row {
    flex-wrap: wrap;
  }
  .pb-field-name    { flex: 1 1 100%; }
  .pb-field-mode    { flex: 1 1 140px; }
  .pb-field-expires { flex: 1 1 120px; }
  .pb-field-action  { flex: 1 1 100%; }
  .pb-field-action .pb-btn-primary { width: 100%; justify-content: center; }
  .pb-field-action label { display: none; }
}

/* Issued Tokens table — refined columns */
.pb-td-label {
  font-size: 0.875rem;
  color: #111827;
  font-weight: 500;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-token-prefix {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  background: #f1f5f9;
  color: #334155;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.pb-td-noexpiry {
  color: #16a34a !important;
  font-style: italic;
}

.pb-td-unused {
  color: #9ca3af !important;
  font-style: italic;
}

/* Token Prefix copy cell */
.pb-prefix-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pb-prefix-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}

.pb-prefix-copy-btn:hover {
  background: #eff6ff;
  color: var(--pb-blue-dk);
  border-color: #bfdbfe;
}

.pb-prefix-copy-btn--copied {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #86efac;
}

/* Token prefix variants */
.pb-token-prefix-full {
  cursor: default;
}

.pb-token-prefix-legacy {
  opacity: 0.55;
  font-style: italic;
}
