/* ============================================================
   Rebho - Buildware Suite Design System
   Flat, professional, minimal. Inspired by Linear/Vercel/Notion.
   ============================================================ */

/* ---- CSS Custom Properties (Light) ---- */
:root {
  --r-brand: #1A3A2A;
  --r-brand-light: rgba(26,58,42,.08);
  --r-bg: #F7F6F2;
  --r-surface: #FFFFFF;
  --r-nested: #F1EFE8;
  --r-border: rgba(0,0,0,0.10);
  --r-border-hover: rgba(0,0,0,0.18);
  --r-text: #1A1A18;
  --r-text-secondary: #555550;
  --r-text-muted: #6B6A64;
  --r-radius: 12px;
  --r-radius-sm: 9px;
  --r-sidebar-width: 220px;
  --r-navbar-height: 48px;

  /* Status */
  --r-success: #27B371;
  --r-success-bg: #DCFAED;
  --r-success-text: #0A5C3A;
  --r-warn: #E09B2A;
  --r-warn-bg: #FAEEDA;
  --r-warn-text: #633806;
  --r-error: #E24B4A;
  --r-error-bg: #FCEBEB;
  --r-error-text: #A32D2D;
  --r-neutral-bg: #F1EFE8;
  --r-neutral-text: #444441;

  /* Active accent */
  --r-accent: #22C55E;
  --r-accent-border: rgba(34,197,94,0.35);
  --r-accent-bg: rgba(34,197,94,0.06);
  --r-launcher-bg: rgba(255,255,255,0.96);
  --r-launcher-border: rgba(15,23,42,0.08);
  --r-launcher-hover: rgba(15,23,42,0.05);
  --r-launcher-shadow: 0 18px 44px rgba(15,23,42,0.14);

  /* Spacing */
  --r-section-pad: 28px 32px;
  --r-section-gap: 16px;
  --r-nested-pad: 16px 20px;
}

/* ---- Dark Mode ---- */
[data-theme="dark"] {
    --r-bg: #0F1115;
    --r-surface: #161A1D;
    --r-nested: #1E2226;
    --r-border: #2A2F36;
    --r-border-hover: #3A4048;
    --r-text: #F3F4F6;
    --r-text-secondary: #B0B8C4;
    --r-text-muted: #8B95A3;
    --r-brand: #22C55E;
    --r-brand-light: rgba(34,197,94,.08);
    --r-accent: #22C55E;
    --r-accent-border: rgba(34,197,94,.35);
    --r-accent-bg: rgba(34,197,94,.06);
    --r-launcher-bg: rgba(17,24,39,0.96);
    --r-launcher-border: #1e293b;
    --r-launcher-hover: rgba(255,255,255,0.06);
    --r-launcher-shadow: 0 18px 44px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.04);
    --r-success-bg: rgba(34,197,94,.12);
    --r-success-text: #6EE7A0;
    --r-warn-bg: rgba(234,179,8,.12);
    --r-warn-text: #FCD34D;
    --r-error: #EF4444;
    --r-error-bg: rgba(239,68,68,.12);
    --r-error-text: #FCA5A5;
    --r-neutral-bg: #1E2226;
    --r-neutral-text: #9CA3AF;
}

/* Dark mode: sidebar darker than surface */
[data-theme="dark"] .rebho-sidebar {
  background-color: #0D0F12;
}

/* ---- Global ---- */

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

html,
body {
  width: 100%;
  max-width: 100%;
}

body {
  background-color: var(--r-bg);
  font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
  color: var(--r-text);
  -webkit-font-smoothing: antialiased;
  margin: 0;
  line-height: 1.6;
}

a { text-decoration: none; color: var(--r-brand); }

/* Override Bootstrap card */
.card {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius);
  box-shadow: none;
}

/* Override Bootstrap form-control */
.form-control {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: 8px;
  color: var(--r-text);
  font-size: 14px;
  padding: 0.5rem 0.75rem;
}
.form-control:focus {
  border-color: var(--r-brand);
  box-shadow: 0 0 0 2px rgba(34,197,94,.10);
  background: var(--r-surface);
  color: var(--r-text);
}

.form-control::placeholder {
  color: var(--r-text-muted);
}

.form-select {
  background-color: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: 8px;
  color: var(--r-text);
  font-size: 14px;
}

.form-select:focus {
  border-color: var(--r-brand);
  box-shadow: 0 0 0 2px rgba(34,197,94,.10);
  background-color: var(--r-surface);
  color: var(--r-text);
}

.form-select option {
  background: var(--r-surface);
  color: var(--r-text);
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--r-text-secondary);
  margin-bottom: 0.35rem;
}

/* Override Bootstrap badge */
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
}

/* Override Bootstrap dropdown */
.dropdown-menu {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-sm);
  box-shadow: none;
  font-size: 14px;
  max-width: min(280px, calc(100vw - 24px));
}
.dropdown-item { color: var(--r-text); padding: 0.5rem 1rem; }
.dropdown-item:hover { background: var(--r-nested); color: var(--r-text); }
.dropdown-divider { border-color: var(--r-border); }

/* ---- App modal ---- */

.app-modal .modal-content {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: 18px;
  color: var(--r-text);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.18);
}

[data-theme="dark"] .app-modal .modal-content {
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.app-modal .modal-header,
.app-modal .modal-footer {
  border-color: var(--r-border);
}

.app-modal .modal-header {
  padding: 1rem 1.25rem 0.9rem;
  align-items: flex-start;
}

.app-modal .modal-body {
  padding: 0.25rem 1.25rem 1rem;
}

.app-modal .modal-footer {
  padding: 1rem 1.25rem 1.25rem;
  gap: 0.5rem;
}

.app-modal .modal-footer .btn {
  min-width: 120px;
}

.app-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.app-modal .modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--r-text);
  margin: 0;
}

.app-modal-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
  background: var(--r-brand-light);
  color: var(--r-brand);
}

.app-modal[data-variant="danger"] .app-modal-icon {
  background: var(--r-error-bg);
  color: var(--r-error-text);
}

.app-modal[data-variant="success"] .app-modal-icon {
  background: var(--r-success-bg);
  color: var(--r-success-text);
}

.app-modal-message {
  margin: 0;
  color: var(--r-text-secondary);
  white-space: pre-line;
  line-height: 1.65;
}

.app-modal .btn-close {
  opacity: 0.7;
}

.app-modal .btn-close:hover {
  opacity: 1;
}

[data-theme="dark"] .app-modal .btn-close {
  filter: invert(1) grayscale(1);
}

/* Override Bootstrap list-group */
.list-group-item {
  background: var(--r-surface);
  border-color: var(--r-border);
  color: var(--r-text);
}

/* Override Bootstrap form-check / switch */
.form-check {
  color: var(--r-text);
}

.form-check-label {
  color: var(--r-text);
}

.form-check-label strong {
  color: var(--r-text);
  font-weight: 600;
}

.form-check-input:checked {
  background-color: var(--r-brand);
  border-color: var(--r-brand);
}

/* Override Bootstrap alert */
.alert-danger {
  background: var(--r-error-bg);
  color: var(--r-error-text);
  border: 1px solid var(--r-error);
  border-radius: 8px;
  font-size: 13px;
}
.alert-success {
  background: var(--r-success-bg);
  color: var(--r-success-text);
  border: 1px solid var(--r-success);
  border-radius: 8px;
  font-size: 13px;
}

/* Override Bootstrap text helpers for dark mode */
.text-muted { color: var(--r-text-muted) !important; }
.text-dark { color: var(--r-text) !important; }
.text-body,
.text-body-emphasis,
.text-reset {
  color: var(--r-text) !important;
}
.text-secondary,
.text-body-secondary {
  color: var(--r-text-secondary) !important;
}
.text-success { color: var(--r-success-text) !important; }
.text-danger { color: var(--r-error-text) !important; }

.btn-link {
  color: var(--r-brand);
}

.btn-link:hover,
.btn-link:focus {
  color: var(--r-text);
}

.btn-link.text-muted,
.btn-link.text-muted:hover,
.btn-link.text-muted:focus {
  color: var(--r-text-secondary) !important;
}

.bg-success-subtle { background-color: var(--r-success-bg) !important; }
.bg-danger-subtle { background-color: var(--r-error-bg) !important; }
.bg-warning { background-color: var(--r-warn-bg) !important; color: var(--r-warn-text) !important; }

/* ---- Loading screen ---- */

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--r-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .3s;
}
#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}
.loading-content { text-align: center; }
.loading-brand {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--r-text);
  letter-spacing: -0.3px;
}
#loading-screen .spinner-border {
  color: var(--r-brand) !important;
  width: 1.5rem;
  height: 1.5rem;
  border-width: 2px;
}

/* ---- Login screen ---- */

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--r-bg);
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: var(--r-radius);
  border: 1px solid var(--r-border);
  box-shadow: none;
}
.login-card .card-body { padding: 2.25rem; }

.login-brand {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--r-brand);
  letter-spacing: -0.3px;
}

#login-error {
  display: none;
  margin-top: 0.75rem;
}

/* ---- Btn primary ---- */

.btn-rebho {
  background-color: var(--r-brand);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  transition: opacity .15s;
}
.btn-rebho:hover,
.btn-rebho:focus {
  background-color: #16A34A;
  color: #fff;
}

.btn-outline-secondary {
  border: 1px solid var(--r-border);
  color: var(--r-text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  background: transparent;
}
.btn-outline-secondary:hover {
  border-color: var(--r-border-hover);
  background: var(--r-nested);
  color: var(--r-text);
}

.btn-outline-danger {
  border: 1px solid rgba(231,76,60,0.6);
  color: var(--r-error-text);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  background: transparent;
}
.btn-outline-danger:hover {
  background: var(--r-error-bg);
  color: var(--r-error-text);
  border-color: var(--r-error);
}

/* Button icons */
.btn i,
.btn .bi {
  font-size: 16px;
  vertical-align: -2px;
}
.btn > i + span,
.btn > .bi + span,
.btn > span + i,
.btn > span + .bi {
  margin-left: 6px;
}

/* ---- Platform wrapper ---- */

#platform { display: none; }

#platform,
.rebho-main,
.page-section,
.tab-content,
.card,
.card-body {
  min-width: 0;
  max-width: 100%;
}

/* ---- Navbar / Topbar ---- */

.rebho-navbar {
  height: var(--r-navbar-height);
  background-color: var(--r-surface);
  border-bottom: 1px solid var(--r-border);
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  gap: 0.75rem;
}

.rebho-navbar > * {
  min-width: 0;
}

.navbar-brand-group {
  min-width: 0;
  flex: 1 1 auto;
}

.navbar-actions {
  min-width: 0;
  flex: 0 1 auto;
}

.rebho-navbar .navbar-brand {
  font-weight: 600;
  font-size: 14px;
  color: var(--r-brand);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}
.rebho-navbar .navbar-brand::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--r-brand);
  flex-shrink: 0;
}

.user-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--r-text);
  font-size: 13px;
  min-width: 0;
  max-width: min(42vw, 240px);
}

.user-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--r-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
}

/* ---- Theme toggle ---- */

.theme-toggle {
  background: none;
  border: 1px solid var(--r-border);
  border-radius: 8px;
  color: var(--r-text-secondary);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  font-size: 16px;
  padding: 0;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--r-nested);
  color: var(--r-text);
  border-color: var(--r-border-hover);
}

/* ---- App launcher ---- */

.app-launcher-toggle {
  background: none;
  border: 1px solid var(--r-border);
  border-radius: 8px;
  color: var(--r-text-secondary);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  font-size: 16px;
  padding: 0;
  flex-shrink: 0;
}
.app-launcher-toggle:hover,
.app-launcher-toggle:focus-visible,
.app-launcher-toggle[aria-expanded="true"] {
  background: var(--r-nested);
  color: var(--r-text);
  border-color: var(--r-border-hover);
  outline: none;
}

.app-launcher-menu {
  display: none;
  position: fixed !important;
  top: calc(var(--r-navbar-height) + 8px) !important;
  right: 12px !important;
  bottom: auto !important;
  left: auto !important;
  transform: none !important;
  grid-template-columns: repeat(3, 82px) !important;
  gap: 8px;
  width: auto !important;
  max-width: calc(100vw - 16px);
  max-height: min(70vh, 440px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  background: var(--r-launcher-bg);
  border: 1px solid var(--r-launcher-border);
  border-radius: 16px;
  box-shadow: var(--r-launcher-shadow);
  backdrop-filter: blur(16px);
  z-index: 1055;
}

.app-launcher-menu.show {
  display: grid !important;
}

.app-launcher-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 82px;
  min-height: 92px;
  border: 0;
  border-radius: 12px;
  text-decoration: none;
  transition: background .12s, transform .12s;
  padding: 8px 6px 10px;
}
.app-launcher-item i {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  background: var(--app-launcher-accent, #1e293b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: filter .12s, transform .12s;
}
.app-launcher-item:hover {
  background: var(--r-launcher-hover);
  transform: translateY(-1px);
}
.app-launcher-item:hover i {
  filter: brightness(1.06) saturate(1.04);
}
.app-launcher-item:focus-visible {
  outline: 2px solid var(--r-accent);
  outline-offset: 2px;
  border-radius: 12px;
}

.app-launcher-item span {
  display: -webkit-box;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-align: center;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 600;
  color: var(--r-text-secondary);
  max-width: 100%;
  text-wrap: balance;
}

.app-launcher-item:hover span {
  color: var(--r-text);
}

/* Icon swap: sun visible in dark, moon visible in light */
.theme-toggle .bi-moon-fill { display: inline; }
.theme-toggle .bi-sun-fill { display: none; }
[data-theme="dark"] .theme-toggle .bi-moon-fill { display: none; }
[data-theme="dark"] .theme-toggle .bi-sun-fill { display: inline; }

/* ---- Sidebar ---- */

.rebho-sidebar {
  width: var(--r-sidebar-width);
  min-width: var(--r-sidebar-width);
  height: calc(100vh - var(--r-navbar-height));
  background-color: var(--r-surface);
  border-right: 1px solid var(--r-border);
  padding: 0.75rem 0;
  position: sticky;
  top: var(--r-navbar-height);
  overflow-y: auto;
  flex-shrink: 0;
}

.rebho-sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--r-text-secondary);
  font-size: 15px;
  font-weight: 400;
  transition: background 0.12s, color 0.12s;
  border-radius: 0;
}

.rebho-sidebar .nav-link:hover {
  background-color: var(--r-nested);
  color: var(--r-text);
}

.rebho-sidebar .nav-link.active {
  background-color: var(--r-nested);
  color: var(--r-brand);
  font-weight: 600;
  border-left: 3px solid var(--r-brand);
  padding-left: 17px;
}

.rebho-sidebar .nav-link i {
  width: 20px;
  text-align: center;
  font-size: 16px;
  color: var(--r-text-secondary);
}
.rebho-sidebar .nav-link.active i {
  color: var(--r-brand);
}

/* ---- Main content ---- */

.rebho-main {
  flex: 1;
  padding: var(--r-section-pad);
  min-height: calc(100vh - var(--r-navbar-height));
  display: flex;
  flex-direction: column;
  gap: var(--r-section-gap);
}

.rebho-main h4 {
  font-size: 20px;
  font-weight: 600;
  color: var(--r-text);
  letter-spacing: -0.3px;
}
.rebho-main h5 {
  font-size: 17px;
  font-weight: 600;
  color: var(--r-text);
}
.rebho-main h6 {
  font-size: 15px;
  font-weight: 600;
  color: var(--r-text-secondary);
}
.rebho-main p,
.rebho-main .text-muted {
  line-height: 1.6;
}

/* ---- Pages ---- */

.page-section { display: none; }
.page-section.active { display: block; }

/* ---- Hero card (dashboard) ---- */

.hero-card {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  padding: var(--r-section-pad);
}

.hero-card .card-body h5 {
  font-size: 20px;
  font-weight: 600;
  color: var(--r-text);
}
.hero-card .card-body p {
  font-size: 15px;
  color: var(--r-text-secondary);
  line-height: 1.6;
}

.hero-graphic {
  width: 180px;
  flex-shrink: 0;
}
/* Hero SVG icons: ensure visible strokes */
.hero-graphic svg path,
.hero-graphic svg rect,
.hero-graphic svg circle {
  stroke: var(--r-text-secondary);
}

/* ---- News carousel ---- */

#newsCarousel {
  border-radius: 0 0 var(--r-radius) var(--r-radius);
  overflow: hidden;
}

.news-slide-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

#newsCarousel .carousel-control-prev-icon,
#newsCarousel .carousel-control-next-icon {
  width: 1.1rem;
  height: 1.1rem;
  background-color: rgba(0,0,0,.45);
  border-radius: 50%;
  background-size: 55%;
  padding: 10px;
}

/* ---- App cards ---- */

.app-card {
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius);
  background: var(--r-surface);
  transition: border-color 0.15s, transform 0.15s;
  box-shadow: none;
  padding: var(--r-nested-pad);
}
.app-card:hover {
  border-color: var(--r-border-hover);
  transform: translateY(-1px);
  box-shadow: none;
}
.app-card-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.app-card .fw-semibold,
.app-card .text-dark {
  font-size: 15px;
  font-weight: 600;
  color: var(--r-text);
}
.app-card .small,
.app-card .text-muted {
  font-size: 14px;
  color: var(--r-text-secondary);
}

.app-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
}

/* ---- App drag and drop ---- */

.app-sortable {
  cursor: grab;
  transition: opacity .2s, transform .15s;
}
.app-sortable:active { cursor: grabbing; }
.app-dragging { opacity: 0.4; }
.app-drag-over .app-card {
  border: 1.5px solid var(--r-accent-border);
  transform: translateY(-1px);
}

/* ---- 2FA panel ---- */

.twofa-qr-placeholder {
  width: 140px;
  height: 140px;
  border: 1px dashed var(--r-border);
  border-radius: var(--r-radius);
  background: var(--r-nested);
}

/* ---- Section headings ---- */

.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--r-text-muted);
  margin-bottom: 0.75rem;
}

/* ---- Account info / avatar ---- */

.account-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: var(--r-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.5rem;
  transition: background-color .2s;
}

.avatar-edit-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--r-surface);
  background: var(--r-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0;
  transition: opacity .15s;
}
.avatar-edit-btn:hover { opacity: 0.85; }

.avatar-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
  padding: 0;
}
.avatar-color-swatch:hover { transform: scale(1.1); }
.avatar-color-swatch.avatar-color-active {
  border-color: var(--r-text);
  box-shadow: 0 0 0 2px var(--r-surface), 0 0 0 3.5px var(--r-text);
}

/* ---- Profile rows ---- */

.profile-row {
  border-left: none;
  border-right: none;
  border-color: var(--r-border);
  transition: background .1s;
  padding: 0.75rem 1.25rem;
}
.profile-row:hover {
  background: var(--r-nested);
}
.profile-row-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--r-nested);
  color: var(--r-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.profile-edit-btn {
  opacity: 0;
  transition: opacity .15s;
}
.profile-row:hover .profile-edit-btn {
  opacity: 1;
}
@media (max-width: 991.98px) {
  .profile-edit-btn { opacity: 1; }
}
.profile-row-actions { flex-shrink: 0; }

.profile-row > .d-flex,
.profile-value-wrap {
  min-width: 0;
}

/* Profile row text */
.profile-row .fw-medium,
.profile-row .fw-semibold,
.profile-row .text-dark {
  font-size: 15px;
  color: var(--r-text);
}
.profile-row .small,
.profile-row .text-muted {
  font-size: 14px;
  color: var(--r-text-secondary);
  overflow-wrap: anywhere;
}

.profile-row .text-body,
.profile-row [data-display]:not(.text-muted) {
  color: var(--r-text) !important;
  overflow-wrap: anywhere;
}

/* Inline edit sizing */
.profile-inline-input {
  width: auto !important;
  min-width: 60px;
  max-width: 100%;
  font-size: 14px;
}
.profile-inline-input[type="date"] { min-width: 150px; }
.phone-prefix-select {
  width: auto !important;
  min-width: 0 !important;
  max-width: 90px;
  flex: 0 0 auto !important;
  padding: .25rem .4rem .25rem .5rem !important;
  font-size: 13px;
}
.phone-input-group {
  width: auto !important;
  display: inline-flex !important;
  max-width: 100%;
}
.phone-input-group .profile-inline-input {
  min-width: 110px;
  max-width: 160px;
  flex: 0 1 auto !important;
}

/* ---- Activity log ---- */

.activity-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.activity-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.activity-filter-segment {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.25rem;
  background: var(--r-nested);
  border: 1px solid var(--r-border);
  border-radius: 999px;
  white-space: nowrap;
}

.activity-filter-btn {
  border: 0;
  background: transparent;
  color: var(--r-text-secondary);
  border-radius: 999px;
  padding: 0.5rem 0.8rem;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.activity-filter-btn:hover {
  color: var(--r-text);
}

.activity-filter-btn.is-active {
  background: var(--r-surface);
  color: var(--r-text);
  box-shadow: inset 0 0 0 1px var(--r-accent-border);
}

.activity-filter-meta {
  font-size: 13px;
  color: var(--r-text-muted);
  white-space: nowrap;
}

.activity-row {
  border-bottom: 1px solid var(--r-border);
  padding: 0.6rem 0;
}
.activity-row:last-child {
  border-bottom: none;
}
.activity-icon {
  font-size: 1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  color: var(--r-text-secondary);
}
.activity-row .fw-medium,
.activity-row .fw-semibold {
  font-size: 15px;
  color: var(--r-text);
}
.activity-row .small {
  font-size: 14px;
  color: var(--r-text-secondary);
  overflow-wrap: anywhere;
}

@media (max-width: 767.98px) {
  .activity-filter-bar {
    align-items: stretch;
  }

  .activity-filter-segment {
    width: 100%;
    overflow-x: auto;
    padding-inline: 0.35rem;
  }

  .activity-filter-meta {
    width: 100%;
    white-space: normal;
  }
}

/* ---- Security tab ---- */

.session-card {
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-sm);
  transition: border-color .15s;
  background: var(--r-surface);
  box-shadow: none;
  padding: var(--r-nested-pad);
}
.session-card:hover {
  border-color: var(--r-border-hover);
}
.session-card-current {
  border: 1px solid var(--r-border-hover);
  background: var(--r-nested);
}
.session-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-radius-sm);
  background: var(--r-nested);
  color: var(--r-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.session-card-current .session-icon {
  background: var(--r-brand-light);
  color: var(--r-brand);
}
.session-card .fw-semibold,
.session-card .fw-medium,
.session-card .text-dark {
  font-size: 16px;
  color: var(--r-text);
}
.session-card .small {
  font-size: 14px;
  color: var(--r-text-secondary);
  overflow-wrap: anywhere;
}
.session-card .text-muted {
  font-size: 14px;
  color: var(--r-text-secondary) !important;
  overflow-wrap: anywhere;
}

.history-row {
  border-bottom: 1px solid var(--r-border);
  padding: 0.5rem 0;
}
.history-row:last-child {
  border-bottom: none;
}
.history-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--r-nested);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  color: var(--r-text-secondary);
}
.history-row .fw-medium,
.history-row .fw-semibold {
  font-size: 15px;
  color: var(--r-text);
}
.history-row .small {
  font-size: 14px;
  color: var(--r-text-secondary);
  overflow-wrap: anywhere;
}

/* ---- Billing ---- */

.billing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.billing-card {
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius);
}

.billing-card-full {
  grid-column: 1 / -1;
}

.billing-table-wrap {
  max-width: 100%;
}

.billing-history-table th {
  font-size: 13px;
  color: var(--r-text-secondary);
  border-bottom-color: var(--r-border);
}

.billing-history-table td {
  font-size: 14px;
  color: var(--r-text);
  border-bottom-color: var(--r-border);
}

.min-width-0 { min-width: 0; }

/* ---- Cards: consistent sizing ---- */

.card .card-body {
  padding: var(--r-nested-pad);
}
.card .card-body h5 {
  font-size: 17px;
  font-weight: 600;
  color: var(--r-text);
}
.card .card-body h6 {
  font-size: 15px;
  font-weight: 600;
  color: var(--r-text-secondary);
}
.card .card-body .small,
.card .card-body p.small {
  font-size: 14px;
  color: var(--r-text-secondary);
  line-height: 1.6;
}
.card .card-body p {
  line-height: 1.6;
}

/* ---- Nav tabs (account settings) ---- */

.nav-tabs {
  border-bottom: 1px solid var(--r-border);
}
.nav-tabs .nav-link {
  font-size: 14px;
  font-weight: 400;
  color: var(--r-text-secondary);
  border: none;
  padding: 0.6rem 1rem;
}
.nav-tabs .nav-link:hover {
  color: var(--r-text);
  border-color: transparent;
}
.nav-tabs .nav-link.active {
  font-weight: 600;
  color: var(--r-brand);
  border: none;
  border-bottom: 2px solid var(--r-brand);
  background: transparent;
}

/* ---- Responsive ---- */

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1019;
  background: rgba(0,0,0,.35);
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
  .rebho-sidebar {
    position: fixed;
    top: var(--r-navbar-height);
    left: 0;
    bottom: 0;
    width: 250px;
    min-width: 0;
    flex: none;
    height: auto;
    z-index: 1020;
    transform: translateX(-100%);
    transition: transform .2s ease;
    border-right: 1px solid var(--r-border);
  }
  .rebho-sidebar.open {
    transform: translateX(0);
  }
  .rebho-main {
    margin-left: 0;
    padding: 1rem;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }
  .rebho-navbar { padding: 0 0.75rem; }
  .navbar-actions { gap: 0.5rem !important; }
  .user-dropdown-toggle { max-width: min(38vw, 180px); }

  .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-tabs .nav-link {
    white-space: nowrap;
    font-size: 13px;
    padding: .5rem .75rem;
  }

  .profile-row.list-group-item { padding-left: 1rem; padding-right: .75rem; }
  .profile-row-icon { width: 30px; height: 30px; font-size: .8rem; }
  .profile-row > .d-flex {
    flex-wrap: wrap;
    align-items: flex-start !important;
  }
  .profile-row-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    padding-left: 2.75rem;
  }
  .profile-value-wrap {
    width: 100%;
  }
  .profile-inline-input,
  .profile-inline-input[type="date"],
  .phone-input-group,
  .phone-input-group .profile-inline-input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .phone-input-group {
    display: flex !important;
  }
  .phone-prefix-select {
    flex: 0 0 76px !important;
    max-width: 76px;
  }
  #tab-password .card-body > .d-flex.justify-content-between.align-items-start,
  #tab-security .card-body > .d-flex.justify-content-between.align-items-start {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .hero-graphic { display: none; }

  .session-card { padding: 12px 14px; }
  .session-card .d-flex { gap: .5rem !important; }

  .activity-row {
    flex-wrap: wrap;
    gap: .25rem !important;
    padding-top: .35rem !important;
    padding-bottom: .35rem !important;
  }
  .activity-row .activity-icon { font-size: .9rem; width: 22px; }
  .activity-row .flex-grow-1 .fw-medium { font-size: 13px; }
  .activity-row .flex-grow-1 .small { font-size: 12px; }
  .activity-row .text-end {
    text-align: start !important;
    width: 100%;
    padding-left: 26px;
    font-size: 12px;
  }
  .activity-row .text-end .small { display: inline; }
  .activity-row .text-end .small + .small::before { content: " . "; }

  .card-body.p-4 { padding: 1rem !important; }

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

@media (max-width: 575.98px) {
  .login-card .card-body { padding: 1.5rem; }
  .login-brand { font-size: 1.15rem; }
  .account-avatar { width: 56px; height: 56px; font-size: 1.2rem; }
  .avatar-color-swatch { width: 24px; height: 24px; }
  .rebho-main { padding: .75rem; }
  .rebho-main h4 { font-size: 17px; }
  .user-name { display: none; }
  .user-dropdown-toggle { max-width: none; }

  /* App grid: 2 columns on mobile */
  #dash-grid {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.5rem;
  }
  #dash-grid > * {
    flex: 0 0 50%;
    max-width: 50%;
  }

  .app-launcher-menu {
    right: 8px !important;
    grid-template-columns: repeat(3, 72px) !important;
    gap: 6px;
    padding: 10px;
  }

  .app-launcher-item {
    width: 72px;
    min-height: 84px;
    padding: 7px 4px 8px;
  }

  .app-launcher-item i {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  .app-launcher-item span {
    font-size: 10px;
  }

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

  .app-modal .modal-footer .btn {
    min-width: 0;
  }
}

@media (max-width: 399.98px) {
  .app-launcher-menu {
    grid-template-columns: repeat(2, 72px) !important;
    justify-content: end;
  }
}
