/* ==========================================================================
   Intrabase UI – Main Stylesheet
   Version: 1.0.0
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Brand palette */
  --ib-primary:           #3b6fda;
  --ib-primary-dark:      #2a55b8;
  --ib-primary-light:     #e8eefb;
  --ib-secondary:         #6c757d;
  --ib-secondary-dark:    #545b62;
  --ib-secondary-light:   #f0f1f2;
  --ib-danger:            #d93025;
  --ib-danger-dark:       #b0251d;
  --ib-danger-light:      #fdecea;
  --ib-success:           #1a8754;
  --ib-success-dark:      #14663f;
  --ib-success-light:     #d4edda;
  --ib-warning:           #d97706;
  --ib-warning-dark:      #b45309;
  --ib-warning-light:     #fef3c7;
  --ib-info:              #0891b2;
  --ib-info-light:        #e0f7fa;

  /* Neutrals */
  --ib-bg:                #000000;
  --ib-surface:           #2d3d57;
  --ib-border:            #dde1e7;
  --ib-border-focus:      var(--ib-primary);
  --ib-text:              #1a202c;
  --ib-text-muted:        #64748b;
  --ib-text-inverted:     #ffffff;

  /* App Bar */
  --ib-appbar-width:      52px;
  --ib-appbar-bg:         #000000;
  --ib-app-bg:     #151c27;

  /* Sidebar */
  --ib-sidebar-width:     240px;
  --ib-sidebar-bg:        #1f2a3b;
  --ib-sidebar-text:      #cbd5e1;
  --ib-sidebar-hover-bg:  #334155;
  --ib-sidebar-active-bg: var(--ib-primary);
  --ib-sidebar-active-text: #ffffff;

  /* Header */
  --ib-header-height:     50px;
  --ib-header-bg:         #000000;
  --ib-header-border:     var(--ib-border);

  /* Spacing */
  --ib-space-xs:  4px;
  --ib-space-sm:  8px;
  --ib-space-md:  8px;
  --ib-space-lg:  24px;
  --ib-space-xl:  32px;
  --ib-space-2xl: 48px;

  /* Typography */
  --ib-font:       'Inter', system-ui, -apple-system, sans-serif;
  --ib-font-size:  14px;
  --ib-line-h:     1.5;

  /* Radii */
  --ib-radius:      20px;
  --ib-radius-sm:   4px;
  --ib-radius-md:   8px;
  --ib-radius-lg:   12px;
  --ib-radius-xl:   16px;
  --ib-radius-pill: 9999px;

  /* Shadows */
  --ib-shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --ib-shadow-md:  0 4px 12px rgba(0,0,0,.10);
  --ib-shadow-lg:  0 8px 24px rgba(0,0,0,.12);

  /* Transitions */
  --ib-transition: 200ms ease;

  /* Z-index layers */
  --ib-z-sidebar:  100;
  --ib-z-header:   90;
  --ib-z-toast:    200;
  --ib-z-overlay:  150;
}

/* --------------------------------------------------------------------------
   2. Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
input, textarea, select, [contenteditable] {
  user-select: text;
  -webkit-user-select: text;
}

html {
  font-size: var(--ib-font-size);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--ib-font);
  font-size: 1rem;
  line-height: var(--ib-line-h);
  color: var(--ib-text);
  background-color: var(--ib-appbar-bg);
  min-height: 100vh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

a {
  color: var(--ib-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

ul, ol { list-style: none; }

img, svg { display: block; max-width: 100%; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   3. Layout Shell
   -------------------------------------------------------------------------- */
.ib-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.ib-sidebar {
  position: fixed;
  top: var(--ib-header-height); /* below header */
  left: var(--ib-appbar-width); /* next to app bar */
  width: var(--ib-sidebar-width);
  height: calc(100vh - var(--ib-header-height));
  background: var(--ib-sidebar-bg);
  color: var(--ib-sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 1001;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
  border-radius: 20px 0 0 0;
}

.ib-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* padding: var(--ib-space-md) var(--ib-space-md); */
  /* min-height: var(--ib-header-height); */
  padding: 0 15px;
  height: 56px;
  min-height: 56px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.ib-sidebar__logo {
  text-decoration: none;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 10px;
}
.ib-sidebar__logo:hover { text-decoration: none; }
.ib-sidebar__logo-img {
  width: 24px;
  height: 24px;
  filter: brightness(0) invert(1);
}
@media (min-width: 769px) {
  .ib-sidebar__header {
    height: 56px;
    min-height: 56px;
  }
  .ib-sidebar__logo {
    display: none;
  }
  #ib-menu-open {
    padding: 0 15px 0 2px;
  }
}

.ib-sidebar__toggle {
  background: none;
  border: none;
  color: var(--ib-sidebar-text);
  padding: var(--ib-space-xs);
  border-radius: var(--ib-radius-sm);
  display: flex; /* always shown */
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.ib-sidebar__toggle:hover { background: rgba(255,255,255,.1); }

.ib-sidebar__nav {
  padding: var(--ib-space-sm) 0;
  flex: 1;
}

.ib-sidebar__item { display: block; }

.ib-sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
  padding: 10px var(--ib-space-md);
  color: var(--ib-sidebar-text);
  border-radius: 0;
  transition: background var(--ib-transition), color var(--ib-transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .9rem;
}
.ib-sidebar__link:hover {
  background: var(--ib-sidebar-hover-bg);
  color: #ffffff;
  text-decoration: none;
}

.ib-sidebar__item--active .ib-sidebar__link {
  background: var(--ib-sidebar-active-bg);
  color: var(--ib-sidebar-active-text);
  font-weight: 600;
}

.ib-sidebar__icon { width: 18px; text-align: center; flex-shrink: 0; }
.ib-sidebar__label { overflow: hidden; text-overflow: ellipsis; }

/* Main area — offset by app bar + sidebar, and below fixed header */
.ib-layout__main {
  margin-left: calc(var(--ib-appbar-width) + var(--ib-sidebar-width));
  margin-top: var(--ib-header-height);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--ib-header-height));
  min-width: 0;
  transition: margin-left .22s cubic-bezier(.4,0,.2,1);
}

/* Sidebar collapsed state */
body.ib-sidebar-closed .ib-sidebar {
  transform: translateX(-100%);
}
body.ib-sidebar-closed .ib-layout__main {
  margin-left: var(--ib-appbar-width);
  border-radius: 20px 0 0 0;
}

/* Header — fixed full-width top bar, above app bar and sidebar */
.ib-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: var(--ib-space-md);
  height: var(--ib-header-height);
  padding: 0;
  background: var(--ib-header-bg);
  /* box-shadow: var(--ib-shadow-sm); */
}

.ib-header__left,
.ib-header__right {
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
}

.ib-header__left {
  flex-shrink: 0;
  width: var(--ib-appbar-width);
  justify-content: center;
  padding: 0;
}

.ib-header__right {
  margin-left: auto;
  margin-right: 10px;
  flex-shrink: 0;
}

/* Logo in header left column */
.ib-header__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  opacity: .9;
  transition: opacity .15s;
}
.ib-header__logo:hover { opacity: 1; text-decoration: none; }
.ib-header__logo-img {
  width: 25px;
  height: 25px;
  object-fit: contain;
  filter: brightness(0) invert(1); /* white logo on dark header */
}

/* Main header section (hamburger + breadcrumb) */
.ib-header__main {
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
  flex-shrink: 0;
}

#ib-menu-open {
  display: inline-flex;
  margin-left: -4px;
}
#ib-menu-open svg {
  width: 24px;
  height: 24px;
}

.ib-header__user {
  display: flex;
  align-items: center;
  gap: var(--ib-space-xs);
  font-size: .875rem;
  color: var(--ib-text-muted);
  font-weight: 500;
}

/* Flash message area */
.ib-layout__flash {
  padding: 0 var(--ib-space-lg);
}
.ib-layout__flash:empty { display: none; }

/* Content */
.ib-layout__content {
  flex: 1;
  padding: 0;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* Disable text selection on app sidemenus */
.mail-sidebar,
.ib-chat__sidebar {
  -webkit-user-select: none;
  user-select: none;
}

/* Footer */
.ib-layout__footer {
  padding: 5px 10px;
  font-size: .6rem;
  color: var(--ib-text-muted);
  border-top: 1px solid var(--ib-border);
  text-align: right;
}

/* --------------------------------------------------------------------------
   4. Login page
   -------------------------------------------------------------------------- */
.ib-login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #0a0f1a;
}

.ib-login-footer {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: .8rem;
  color: #64748b;
}
.ib-login-footer__info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ib-login-footer a {
  color: #64748b;
  text-decoration: none;
}
.ib-login-footer a:hover {
  color: #94a3b8;
  text-decoration: underline;
}

/* Language switcher */
.ib-login-footer__lang {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ib-login-lang__item {
  color: #64748b;
  text-decoration: none;
  padding: 2px 4px;
  border-radius: var(--ib-radius-sm);
  transition: color var(--ib-transition);
}
.ib-login-lang__item:hover {
  color: #e2e8f0;
  text-decoration: none;
}
.ib-login-lang__item--active {
  color: #e2e8f0;
  font-weight: 600;
}
.ib-login-lang__sep {
  color: #334155;
  user-select: none;
}

.ib-login-box .ib-form__label {
  color: #94a3b8;
}
.ib-login-box .ib-input {
  background: #0f1626;
  border-color: #1e293b;
  color: #e2e8f0;
}
.ib-login-box .ib-input:focus {
  border-color: var(--ib-primary);
  box-shadow: 0 0 0 3px rgba(59,111,218,.18);
}
.ib-login-box .ib-input::placeholder {
  color: #475569;
}
.ib-login-box .ib-input-icon__svg {
  color: #475569;
}
.ib-login-box .ib-btn--primary {
  background: var(--ib-primary);
  color: #fff;
  border-color: var(--ib-primary);
}
.ib-login-box .ib-btn--primary:hover {
  background: var(--ib-primary-dark);
  border-color: var(--ib-primary-dark);
}

.ib-login-box {
  width: 100%;
  max-width: 400px;
  padding: var(--ib-space-xl);
  background: #141c2b;
  border: 1px solid #1e293b;
  border-radius: var(--ib-radius-lg);
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}

.ib-login-box__logo {
  text-align: center;
  margin-bottom: var(--ib-space-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ib-login-box__logo-img {
  max-width: 48px;
  width: 48px;
  height: auto;
  filter: invert(1);
}

.ib-login-box__brand {
  font-size: 1.35rem;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: -.3px;
}

/* Login box entrance animation */
@keyframes ib-login-fadein {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.ib-login-box--animate {
  animation: ib-login-fadein .5s ease-out both;
}

/* Input with icon */
.ib-input-icon {
  position: relative;
  display: flex;
  align-items: center;
}
.ib-input-icon__svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: #999;
  pointer-events: none;
}
.ib-input-icon .ib-input {
  padding-left: 38px;
}

/* --------------------------------------------------------------------------
   5. Breadcrumb
   -------------------------------------------------------------------------- */
.ib-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  list-style: none;
}

.ib-breadcrumb__item {
  display: flex;
  align-items: center;
  font-size: .85rem;
  color: var(--ib-text-muted);
}

.ib-breadcrumb__item + .ib-breadcrumb__item::before {
  content: '/';
  margin: 0 6px;
  color: var(--ib-border);
}

.ib-breadcrumb__link { color: var(--ib-primary); }
.ib-breadcrumb__link:hover { text-decoration: underline; }

.ib-breadcrumb__item--current { color: var(--ib-text); font-weight: 500; }

/* Breadcrumb inside dark header */
.ib-header__main .ib-breadcrumb__item {
  color: rgba(255,255,255,.5);
}
.ib-header__main .ib-breadcrumb__item + .ib-breadcrumb__item::before {
  color: rgba(255,255,255,.25);
}
.ib-header__main .ib-breadcrumb__link {
  color: rgba(255,255,255,.75);
}
.ib-header__main .ib-breadcrumb__link:hover {
  color: #ffffff;
}
.ib-header__main .ib-breadcrumb__item--current {
  color: #ffffff;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   6. Buttons
   -------------------------------------------------------------------------- */
.ib-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--ib-space-xs);
  padding: 10px 14px;
  font-size: .875rem;
  font-weight: 500;
  border-radius: var(--ib-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--ib-transition), border-color var(--ib-transition),
              color var(--ib-transition), box-shadow var(--ib-transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
  user-select: none;
}

.ib-btn:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* Variants */
.ib-btn--primary {
  background: #000;
  color: #fff;
  border-color: #000;
}
.ib-btn i,
.ib-btn svg { color: inherit !important; font-size: .85em !important; line-height: 1; }
.ib-btn--primary:hover {
  background: #222;
  border-color: #222;
}

.ib-btn--secondary {
  background: #fff;
  color: #000;
  border-color: #ccc;
}
.ib-btn--secondary:hover {
  background: #f0f0f0;
  border-color: #999;
}

.ib-btn--danger {
  background: var(--ib-danger);
  color: #fff;
  border-color: var(--ib-danger);
}
.ib-btn--danger:hover {
  background: var(--ib-danger-dark);
  border-color: var(--ib-danger-dark);
}

.ib-btn--ghost {
  background: transparent;
  color: var(--ib-text);
  border-color: var(--ib-border);
}
.ib-btn--ghost:hover { background: var(--ib-secondary-light); }

.ib-btn--outline {
  background: #fff;
  color: #000;
  border-color: #a6a6a6;
}
.ib-btn--outline:hover {
  background: #f0f0f0;
  border-color: #888;
}
.ib-btn--success {
  background: transparent;
  color: #16a34a;
  border-color: #16a34a;
}
.ib-btn--success:hover {
  background: #f0fdf4;
  border-color: #15803d;
}
.mail-detail-actions .ib-btn--outline i,
.mail-detail-actions .ib-btn--outline svg,
.mail-detail-actions .ib-btn--success i,
.mail-detail-actions .ib-btn--success svg {
  font-size: 1em !important;
}

/* Sizes */
.ib-btn--sm {
  padding: 6px 10px;
  font-size: .8rem;
  border-radius: var(--ib-radius-sm);
}

.ib-btn--lg {
  padding: 14px 20px;
  font-size: 1rem;
}

.ib-btn--block {
  width: 100%;
  justify-content: center;
}

.ib-btn--icon {
  padding: 3px 8px;
  border-radius: var(--ib-radius-sm);
  background: transparent;
  border-color: transparent;
  color: var(--ib-text-muted);
}
.ib-btn--icon:hover { background: var(--ib-secondary-light); color: var(--ib-text); }

.ib-btn:disabled,
.ib-btn[aria-disabled="true"] {
  opacity: .55;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   7. Forms
   -------------------------------------------------------------------------- */
.ib-form {
  display: flex;
  flex-direction: column;
  gap: var(--ib-space-md);
}

.ib-form__row {
  display: flex;
  flex-direction: column;
  gap: var(--ib-space-xs);
}

.ib-form__label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--ib-text);
}

.ib-form__control {
  display: flex;
  flex-direction: column;
  gap: var(--ib-space-xs);
}

.ib-form__hint {
  font-size: .8rem;
  color: var(--ib-text-muted);
}

.ib-form__error {
  font-size: .8rem;
  color: var(--ib-danger);
}

/* Fields */
.ib-input,
.ib-select,
.ib-textarea {
  width: 100%;
  padding: 8px 12px;
  font-family: inherit;
  font-size: .9rem;
  color: var(--ib-text);
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-md);
  transition: border-color var(--ib-transition), box-shadow var(--ib-transition);
  line-height: 1.5;
  appearance: none;
  -webkit-appearance: none;
}

.ib-input:focus,
.ib-select:focus,
.ib-textarea:focus {
  outline: none;
  border-color: var(--ib-border-focus);
  box-shadow: 0 0 0 3px rgba(59,111,218,.18);
}

.ib-input::placeholder,
.ib-textarea::placeholder { color: var(--ib-text-muted); }

.ib-input--error,
.ib-select--error,
.ib-textarea--error { border-color: var(--ib-danger); }

.ib-textarea { min-height: 100px; resize: vertical; }

/* Password field with inline eye toggle */
.ib-password__wrap {
  position: relative;
}
.ib-password__wrap .ib-input {
  padding-right: 40px;
}
.ib-password__eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--ib-text-muted);
  font-size: .9rem;
  line-height: 1;
  user-select: none;
}
.ib-password__eye:hover {
  color: var(--ib-text);
}
.ib-password__confirm {
  margin-top: .5rem;
}

/* Picture component with inline name */
.ib-picture__header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.ib-picture__name {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ib-text);
}

.ib-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 34px;
}
@media (pointer: coarse) {
  select,
  select.ib-select,
  select.ib-input,
  select.ib-form-control,
  select.planner-input,
  select.planner-filter-select {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    min-height: 44px !important;
    height: auto !important;
  }
}

/* Inline form row */
.ib-form--inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
}
.ib-form--inline .ib-form__row { flex: 1; min-width: 180px; }

/* --------------------------------------------------------------------------
   8. Browser (DataBrowser)
   -------------------------------------------------------------------------- */
.ib-browser {
  background: var(--ib-surface);
  border-radius: var(--ib-radius-lg);
  box-shadow: var(--ib-shadow-sm);
  overflow: hidden;
}

.ib-browser__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--ib-space-sm);
  padding: var(--ib-space-md) var(--ib-space-md);
  border-bottom: 1px solid var(--ib-border);
  background: var(--ib-bg);
}

.ib-browser__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ib-text);
}

.ib-browser__actions {
  display: flex;
  align-items: center;
  gap: var(--ib-space-xs);
  flex-wrap: wrap;
}

.ib-browser__toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
  margin-left: auto;
}

.ib-browser__search {
  display: flex;
  align-items: center;
  position: relative;
  min-width: 280px;
  max-width: 500px;
  flex-wrap: nowrap;
}

.ib-browser__search-icon {
  position: absolute;
  left: 10px;
  color: var(--ib-text-muted);
  font-size: 13px;
  pointer-events: none;
  z-index: 1;
}

.ib-browser__search .ib-input--search {
  padding-left: 32px;
  padding-right: 28px;
  width: 100%;
}

.ib-browser__search .ib-btn--clear {
  position: absolute;
  right: 4px;
  width: 24px;
  height: 24px;
  padding: 0;
  z-index: 1;
}

/* Table */
.ib-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.ib-table__th,
.ib-table__td {
  text-align: left;
  padding: 10px var(--ib-space-md);
  border-bottom: 1px solid var(--ib-border);
}

.ib-table__th {
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ib-text-muted);
  background: var(--ib-bg);
  white-space: nowrap;
  user-select: none;
}

.ib-table__th--sortable { cursor: pointer; }
.ib-table__th--sortable:hover { color: var(--ib-primary); }
.ib-table__th--asc::after  { content: ' ↑'; }
.ib-table__th--desc::after { content: ' ↓'; }

.ib-table__td { vertical-align: middle; }

/* .ib-table__tr:hover — removed, HTML uses .ib-table__row */

.ib-table__td--actions {
  white-space: nowrap;
  text-align: right;
  width: 1px;
}
.ib-table__td--actions .ib-btn--sm {
  padding: 5px 8px;
  font-size: .8rem;
  line-height: 1;
  vertical-align: middle;
  box-sizing: border-box;
}
.ib-table__td--actions > a + a,
.ib-table__td--actions > a + form,
.ib-table__td--actions > form + a,
.ib-table__td--actions > form + form {
  margin-left: 4px;
}
.ib-table__td--actions .ib-dup-form {
  display: inline;
}

/* Empty state */
.ib-browser__empty {
  padding: var(--ib-space-2xl) var(--ib-space-lg);
  text-align: center;
  color: var(--ib-text-muted);
}

/* --------------------------------------------------------------------------
   9. Pagination
   -------------------------------------------------------------------------- */
.ib-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--ib-space-sm);
  padding: var(--ib-space-sm) var(--ib-space-md);
  border-top: 1px solid var(--ib-border);
}

.ib-pagination__info {
  font-size: .8rem;
  color: var(--ib-text-muted);
}

.ib-pagination__nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ib-pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-size: .8rem;
  font-family: inherit;
  font-weight: 500;
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-sm);
  background: var(--ib-surface);
  color: var(--ib-text);
  cursor: pointer;
  transition: background var(--ib-transition), border-color var(--ib-transition);
  text-decoration: none;
}

.ib-pagination__btn:hover { background: var(--ib-secondary-light); }
.ib-pagination__btn--active {
  background: var(--ib-primary);
  border-color: var(--ib-primary);
  color: var(--ib-text-inverted);
}
.ib-pagination__btn:disabled { opacity: .45; pointer-events: none; }

/* --------------------------------------------------------------------------
   10. Tabs
   -------------------------------------------------------------------------- */
.ib-tabs { display: flex; flex-direction: column; }

.ib-tabs__nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--ib-border);
  overflow-x: auto;
}

.ib-tabs__nav-item {
  display: inline-flex;
  align-items: center;
  gap: var(--ib-space-xs);
  padding: 10px var(--ib-space-md);
  font-size: .875rem;
  font-weight: 500;
  color: var(--ib-text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--ib-transition), border-color var(--ib-transition);
}
.ib-tabs__nav-item:hover { color: var(--ib-text); }
.ib-tabs__nav-item--active {
  color: var(--ib-primary);
  border-bottom-color: var(--ib-primary);
}

.ib-tabs__panel {
  display: none;
  padding: var(--ib-space-lg) var(--ib-space-md);
}
.ib-tabs__panel--active { display: block; }

/* --------------------------------------------------------------------------
   11. Badges
   -------------------------------------------------------------------------- */
.ib-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 9999px;
  white-space: nowrap;
  line-height: 1.4;
}

.ib-badge--primary  { background: var(--ib-primary-light);  color: var(--ib-primary-dark); }
.ib-badge--success  { background: var(--ib-success-light);  color: var(--ib-success-dark); }
.ib-badge--danger   { background: var(--ib-danger-light);   color: var(--ib-danger-dark); }
.ib-badge--warning  { background: var(--ib-warning-light);  color: var(--ib-warning-dark); }
.ib-badge--neutral  { background: var(--ib-secondary-light); color: var(--ib-secondary-dark); }
.ib-badge--info     { background: var(--ib-info-light);     color: var(--ib-info); }

/* Tags input */
.ib-tags-input {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.ib-tags-input__list {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}
.ib-tags-input__tag {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: 2px 8px;
  font-size: .78rem;
  font-weight: 500;
  border-radius: 9999px;
  background: var(--ib-primary-light);
  color: var(--ib-primary-dark);
  line-height: 1.4;
}
.ib-tags-input__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font-size: .85rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  opacity: .6;
  transition: opacity .15s, background .15s;
}
.ib-tags-input__remove:hover {
  opacity: 1;
  background: rgba(0,0,0,.1);
}
.ib-tags-input__field {
  flex: 1;
  min-width: 120px;
}

/* --------------------------------------------------------------------------
   12. Alerts / Toasts
   -------------------------------------------------------------------------- */
.ib-alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ib-space-sm);
  padding: 12px var(--ib-space-md);
  border-radius: var(--ib-radius-md);
  border-left: 4px solid transparent;
  font-size: .9rem;
  margin-bottom: var(--ib-space-sm);
}

.ib-alert--success {
  background: var(--ib-success-light);
  border-color: var(--ib-success);
  color: var(--ib-success-dark);
}
.ib-alert--danger {
  background: var(--ib-danger-light);
  border-color: var(--ib-danger);
  color: var(--ib-danger-dark);
}
.ib-alert--warning {
  background: var(--ib-warning-light);
  border-color: var(--ib-warning);
  color: var(--ib-warning-dark);
}
.ib-alert--info {
  background: var(--ib-info-light);
  border-color: var(--ib-info);
  color: var(--ib-info);
}

.ib-alert__close {
  background: none;
  border: none;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: .7;
  flex-shrink: 0;
  padding: 0 2px;
}
.ib-alert__close:hover { opacity: 1; }

/* Toast variant (fixed position, auto-dismiss) */
.ib-toast {
  position: fixed;
  bottom: var(--ib-space-lg);
  right: var(--ib-space-lg);
  z-index: var(--ib-z-toast);
  min-width: 280px;
  max-width: 420px;
  box-shadow: var(--ib-shadow-lg);
  animation: ib-slide-in .25s ease;
}

@keyframes ib-slide-in {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.ib-toast--dismiss {
  animation: ib-slide-out .25s ease forwards;
}

@keyframes ib-slide-out {
  to { transform: translateX(110%); opacity: 0; }
}

/* --------------------------------------------------------------------------
   13. Dashboard
   -------------------------------------------------------------------------- */
.ib-dashboard {
  max-width: 1100px;
  padding: 0 0 0 20px;
}

.ib-dashboard__header {
  margin-bottom: var(--ib-space-xl);
}

.ib-dashboard__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ib-text);
  margin-bottom: var(--ib-space-xs);
}

.ib-dashboard__subtitle {
  color: var(--ib-text-muted);
}

.ib-dashboard__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--ib-space-md);
}

.ib-dashboard-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ib-space-md);
  padding: var(--ib-space-lg);
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-lg);
  box-shadow: var(--ib-shadow-sm);
  text-align: center;
  color: var(--ib-text);
  transition: transform var(--ib-transition), box-shadow var(--ib-transition),
              border-color var(--ib-transition);
  text-decoration: none;
}

.ib-dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--ib-shadow-md);
  border-color: var(--ib-primary);
  text-decoration: none;
  color: var(--ib-text);
}

.ib-dashboard-card__icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: var(--ib-radius-lg);
  background: var(--ib-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ib-dashboard-card__icon {
  font-size: 1.5rem;
  color: var(--ib-primary);
}

.ib-dashboard-card__name {
  display: block;
  font-weight: 600;
  font-size: .95rem;
}

.ib-dashboard-card__desc {
  font-size: .8rem;
  color: var(--ib-text-muted);
  margin-top: 2px;
}

.ib-dashboard__empty {
  padding: var(--ib-space-2xl);
  text-align: center;
  color: var(--ib-text-muted);
}

.ib-dashboard__empty-icon {
  font-size: 2.5rem;
  margin-bottom: var(--ib-space-md);
  opacity: .4;
}

/* --------------------------------------------------------------------------
   14. Detailer (DataDetailer)
   -------------------------------------------------------------------------- */
.ib-detailer {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-lg);
  box-shadow: var(--ib-shadow-sm);
  overflow: hidden;
}

.ib-detailer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ib-space-md) var(--ib-space-lg);
  border-bottom: 1px solid var(--ib-border);
  background: var(--ib-bg);
  gap: var(--ib-space-sm);
  flex-wrap: wrap;
}

.ib-detailer__title {
  font-size: 1rem;
  font-weight: 600;
}

.ib-detailer__actions {
  display: flex;
  gap: var(--ib-space-xs);
  flex-wrap: wrap;
}

.ib-detailer__body { padding: var(--ib-space-lg); }

.ib-detailer__section {
  margin-bottom: var(--ib-space-xl);
}
.ib-detailer__section:last-child { margin-bottom: 0; }

.ib-detailer__section-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ib-text-muted);
  margin-bottom: var(--ib-space-md);
  padding-bottom: var(--ib-space-xs);
  border-bottom: 1px solid var(--ib-border);
}

.ib-detailer__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--ib-space-md) var(--ib-space-lg);
}

.ib-detailer__field { display: flex; flex-direction: column; gap: 2px; }

.ib-detailer__field-label {
  font-size: .75rem;
  font-weight: 500;
  color: var(--ib-text-muted);
  text-transform: uppercase;
  letter-spacing: .3px;
}

.ib-detailer__field-value {
  font-size: .9rem;
  color: var(--ib-text);
}

/* --------------------------------------------------------------------------
   15. Modal / Overlay
   -------------------------------------------------------------------------- */
.ib-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: var(--ib-z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ib-space-lg);
}

.ib-modal {
  background: var(--ib-surface);
  border-radius: var(--ib-radius-lg);
  box-shadow: var(--ib-shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: ib-fade-in .2s ease;
}

@keyframes ib-fade-in {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}

.ib-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ib-space-md) var(--ib-space-lg);
  border-bottom: 1px solid var(--ib-border);
  font-weight: 600;
}

.ib-modal__body { padding: var(--ib-space-lg); }
.ib-modal__footer {
  padding: var(--ib-space-md) var(--ib-space-lg);
  border-top: 1px solid var(--ib-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--ib-space-sm);
}

/* --------------------------------------------------------------------------
   16. Utility classes
   -------------------------------------------------------------------------- */
.ib-text-muted   { color: var(--ib-text-muted); }
.ib-text-danger  { color: var(--ib-danger); }
.ib-text-success { color: var(--ib-success); }
.ib-text-right   { text-align: right; }
.ib-text-center  { text-align: center; }

.ib-mt-sm  { margin-top: var(--ib-space-sm); }
.ib-mt-md  { margin-top: var(--ib-space-md); }
.ib-mt-lg  { margin-top: var(--ib-space-lg); }
.ib-mb-sm  { margin-bottom: var(--ib-space-sm); }
.ib-mb-md  { margin-bottom: var(--ib-space-md); }
.ib-mb-lg  { margin-bottom: var(--ib-space-lg); }

.ib-d-flex      { display: flex; }
.ib-align-center { align-items: center; }
.ib-gap-sm      { gap: var(--ib-space-sm); }

.ib-w-full      { width: 100%; }
.ib-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}


/* --------------------------------------------------------------------------
   18. Print
   -------------------------------------------------------------------------- */
@media print {
  .ib-appbar,
  .ib-sidebar,
  .ib-header,
  .ib-layout__footer,
  .ib-toast,
  .ib-btn { display: none !important; }
  .ib-layout__main { margin-left: 0 !important; margin-top: 0 !important; }
  .ib-layout__content { padding: 0 !important; }
}

/* --------------------------------------------------------------------------
   19. Advanced filters panel
   -------------------------------------------------------------------------- */
.ib-browser__filters {
  background: var(--ib-surface);
  border-bottom: 1px solid var(--ib-border);
}

.ib-browser__filters-toggle {
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
  padding: var(--ib-space-sm) var(--ib-space-md);
  cursor: pointer;
  font-weight: 500;
  font-size: .875rem;
  color: var(--ib-text-muted);
  list-style: none;
  user-select: none;
}
.ib-browser__filters-toggle::-webkit-details-marker { display: none; }
.ib-browser__filters-toggle:hover { color: var(--ib-primary); }
details.ib-browser__filters[open] .ib-browser__filters-toggle {
  border-bottom: 1px solid var(--ib-border);
  color: var(--ib-primary);
}

.ib-filter__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ib-primary);
  color: #fff;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
}

.ib-filters__form {
  padding: var(--ib-space-md);
}

.ib-filters__fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ib-space-md);
  margin-bottom: var(--ib-space-md);
}

.ib-filter__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
}

.ib-filter__field--active .ib-filter__label {
  color: var(--ib-primary);
  font-weight: 600;
}

.ib-filter__label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--ib-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.ib-filter__range {
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
}

.ib-filter__range-sep {
  color: var(--ib-text-muted);
  font-size: .85rem;
}

.ib-input--date {
  min-width: 130px;
}

/* Filter text inputs — pill style */
.ib-filter__field .ib-input:not([type="date"]) {
  border-radius: var(--ib-radius-pill);
}

.ib-filters__actions {
  display: flex;
  gap: var(--ib-space-sm);
  padding-top: var(--ib-space-sm);
  border-top: 1px solid var(--ib-border);
}

/* Bulk actions bar */
.ib-bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--ib-space-md);
  padding: var(--ib-space-sm) var(--ib-space-md);
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-top: none;
  border-radius: 0 0 var(--ib-radius) var(--ib-radius);
}
.ib-bulk-bar__count {
  font-size: .85rem;
  font-weight: 600;
  color: var(--ib-text);
}
.ib-table__th--check,
.ib-table__td--check {
  width: 36px;
  text-align: center;
  padding: var(--ib-space-xs) var(--ib-space-xs) var(--ib-space-xs) var(--ib-space-sm) !important;
}

/* Custom checkboxes for table selection – theme-aware */
.ib-table__th--check input[type="checkbox"],
.ib-table__td--check input[type="checkbox"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid #94a3b8;
  border-radius: var(--ib-radius-sm, 4px);
  background: var(--ib-surface);
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  transition: background var(--ib-transition), border-color var(--ib-transition);
}
.ib-table__th--check input[type="checkbox"]:hover,
.ib-table__td--check input[type="checkbox"]:hover {
  border-color: var(--ib-primary);
}
.ib-table__th--check input[type="checkbox"]:checked,
.ib-table__td--check input[type="checkbox"]:checked {
  background: var(--ib-primary);
  border-color: var(--ib-primary);
}
.ib-table__th--check input[type="checkbox"]:checked::after,
.ib-table__td--check input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 45%;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
}
.ib-table__th--check input[type="checkbox"]:indeterminate,
.ib-table__td--check input[type="checkbox"]:indeterminate {
  background: var(--ib-primary);
  border-color: var(--ib-primary);
}
.ib-table__th--check input[type="checkbox"]:indeterminate::after,
.ib-table__td--check input[type="checkbox"]:indeterminate::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 2px;
  background: #fff;
  transform: translate(-50%, -50%);
}
.ib-table__th--check input[type="checkbox"]:focus-visible,
.ib-table__td--check input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--ib-primary);
  outline-offset: 2px;
}

/* ==========================================================================
   Sidebar – Two-level navigation (App Groups + Modules)
   ========================================================================== */

/* App group container */
.ib-sidebar__group {
  display: block;
}

/* App group header button */
.ib-sidebar__group-btn {
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
  width: 100%;
  padding: 10px var(--ib-space-md);
  background: none;
  border: none;
  color: var(--ib-sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--ib-transition), color var(--ib-transition);
  line-height: 1.3;
}
.ib-sidebar__group-btn:hover {
  background: var(--ib-sidebar-hover-bg);
  color: #ffffff;
}

/* When group is active (contains the current module) */
.ib-sidebar__group--active > .ib-sidebar__group-btn {
  color: #ffffff;
}

/* Chevron icon – rotates when open */
.ib-sidebar__chevron {
  margin-left: auto;
  font-size: .7rem;
  opacity: .7;
  transition: transform .2s ease;
  flex-shrink: 0;
}
.ib-sidebar__group--open > .ib-sidebar__group-btn .ib-sidebar__chevron {
  transform: rotate(180deg);
}
.ib-sidebar__group--open > .ib-sidebar__group-btn {
  color: #ffffff;
}

/* Sub-navigation (collapsed by default) */
.ib-sidebar__subnav {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height .28s cubic-bezier(0.4,0,0.2,1);
  background: rgba(0, 0, 0, .18);
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.ib-sidebar__group--open > .ib-sidebar__subnav {
  max-height: 3000px; /* large enough for many modules */
}

/* Sub-level link style */
.ib-sidebar__link--sub {
  padding: 8px var(--ib-space-md) 8px calc(var(--ib-space-md) + 24px);
  font-size: .83rem;
  font-weight: 400;
}

/* Sub-level icon – smaller */
.ib-sidebar__icon--sub {
  width: 16px;
  font-size: .8rem;
  opacity: .75;
}
.ib-sidebar__item--active .ib-sidebar__icon--sub {
  opacity: 1;
}

/* Sub-groups within an app subnav (collapsible sections) */
.ib-sidebar__subgroup { display: block; }

/* Collapsible group label — styled as a full-width button */
.ib-sidebar__subgroup-label {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 10px 5px 15px;
  font-size: .69rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: rgba(255,255,255,.42);
  background: none;
  border: none;
  cursor: pointer;
  user-select: none;
  line-height: 1.2;
  text-align: left;
  font-family: inherit;
  transition: color .15s;
}
.ib-sidebar__subgroup-label:hover {
  color: rgba(255,255,255,.68);
}
/* First icon (section icon) */
.ib-sidebar__subgroup-label > i:first-child {
  font-size: .67rem;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}
/* Section name */
.ib-sidebar__subgroup-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Chevron — rotates when collapsed */
.ib-sidebar__subgroup-chevron {
  font-size: .58rem;
  flex-shrink: 0;
  opacity: .55;
  transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .15s;
}
.ib-sidebar__subgroup--collapsed .ib-sidebar__subgroup-chevron {
  transform: rotate(-90deg);
  opacity: .4;
}

.ib-sidebar__subgroup + .ib-sidebar__subgroup .ib-sidebar__subgroup-label {
  padding-top: 8px;
}

/* Animated nav container */
.ib-sidebar__subgroup-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
  max-height: 2000px; /* large enough for any group */
  transition: max-height .25s cubic-bezier(.4,0,.2,1);
}
/* Collapsed: hide items */
.ib-sidebar__subgroup--collapsed .ib-sidebar__subgroup-nav {
  max-height: 0;
}


/* Dashboard card badge (module count) */
.ib-dashboard-card__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: .72rem;
  font-weight: 600;
  background: var(--ib-primary);
  color: #fff;
  border-radius: 10px;
  margin-top: 4px;
}

/* ==========================================================================
   Dashboard Widgets
   ========================================================================== */

.ib-widgets-section {
  padding: var(--ib-space-lg) var(--ib-space-xl);
}

.ib-widgets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--ib-space-lg);
}

.ib-widgets-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ib-text);
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
}

.ib-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--ib-space-lg);
}

/* Individual widget card */
.ib-widget {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ib-widget__header {
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
  padding: var(--ib-space-md) var(--ib-space-lg);
  background: var(--ib-bg);
  border-bottom: 1px solid var(--ib-border);
  font-weight: 600;
  font-size: .85rem;
  color: var(--ib-text-muted);
}

.ib-widget__icon {
  color: var(--ib-primary);
  font-size: .9rem;
}

.ib-widget__title {
  text-transform: uppercase;
  letter-spacing: .03em;
  font-size: .75rem;
}

.ib-widget__body {
  padding: var(--ib-space-md);
  flex: 1;
}

.ib-widget__empty {
  color: var(--ib-text-muted);
  font-size: .875rem;
  text-align: center;
  padding: var(--ib-space-md) 0;
}

/* Stats widget grid */
.ib-widget-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--ib-space-sm);
}

.ib-widget-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--ib-space-sm);
  background: var(--ib-bg);
  border-radius: calc(var(--ib-radius) / 2);
  text-align: center;
}

.ib-widget-stat__icon {
  font-size: 1.1rem;
  color: var(--ib-primary);
  margin-bottom: 4px;
}

.ib-widget-stat__count {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ib-text);
  line-height: 1;
}

.ib-widget-stat__label {
  font-size: .68rem;
  color: var(--ib-text-muted);
  margin-top: 2px;
}

/* List widget */
.ib-widget-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: .85rem;
}

.ib-widget-list__item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--ib-border);
}

.ib-widget-list__item:last-child {
  border-bottom: none;
}

.ib-widget-list__badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ib-widget-list__badge--danger  { background: var(--ib-danger); }
.ib-widget-list__badge--warning { background: var(--ib-warning); }
.ib-widget-list__badge--info    { background: var(--ib-info); }
.ib-widget-list__badge--default { background: var(--ib-border); }

.ib-widget-list__icon {
  color: var(--ib-primary);
  font-size: .8rem;
  flex-shrink: 0;
}

.ib-widget-list__link {
  flex: 1;
  color: var(--ib-text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ib-widget-list__link:hover {
  color: var(--ib-primary);
  text-decoration: underline;
}

.ib-widget-list__tag {
  font-size: .7rem;
  padding: 1px 6px;
  background: var(--ib-bg);
  border: 1px solid var(--ib-border);
  border-radius: 10px;
  color: var(--ib-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.ib-widget-list__meta {
  font-size: .72rem;
  color: var(--ib-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Bookmarks widget */
.ib-widget-bookmarks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ib-widget-bookmark {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--ib-bg);
  border: 1px solid var(--ib-border);
  border-radius: 14px;
  font-size: .8rem;
  color: var(--ib-text);
  text-decoration: none;
  transition: background .15s, border-color .15s;
}

.ib-widget-bookmark:hover {
  background: var(--ib-primary);
  border-color: var(--ib-primary);
  color: #fff;
}

/* (Widgets mobile rules consolidated in section 17) */

/* ==========================================================================
   DARK THEME — [data-theme="dark"]
   Override CSS custom properties for the dark colour scheme.
   All components use var() tokens from :root, so this single block
   is enough to switch the entire UI.
   ========================================================================== */

[data-theme="dark"] {
  --ib-app-bg:            #161e2a;

  /* Brand (keep primary accent; slightly lighter for contrast on dark bg) */
  --ib-primary:           #6b9aef;
  --ib-primary-dark:      #4d7ee0;
  --ib-primary-light:     #1e2d4d;
  --ib-secondary:         #94a3b8;
  --ib-secondary-dark:    #64748b;
  --ib-secondary-light:   #1e293b;
  --ib-danger:            #f87171;
  --ib-danger-dark:       #dc2626;
  --ib-danger-light:      #3b1818;
  --ib-success:           #4ade80;
  --ib-success-dark:      #16a34a;
  --ib-success-light:     #14321f;
  --ib-warning:           #fbbf24;
  --ib-warning-dark:      #d97706;
  --ib-warning-light:     #3b2a0c;
  --ib-info:              #38bdf8;
  --ib-info-light:        #0c2a38;

  /* Neutrals */
  --ib-bg:               #000000;
  --ib-surface:          #1f2a3b;
  --ib-border:           #334155;
  --ib-border-focus:     var(--ib-primary);
  --ib-text:             #e2e8f0;
  --ib-text-muted:       #94a3b8;
  --ib-text-inverted:    #0f172a;

  /* Sidebar (slightly lighter than page bg for differentiation) */
  --ib-sidebar-bg:        #1d2737;
  --ib-sidebar-text:      #94a3b8;
  --ib-sidebar-hover-bg:  #1e293b;
  --ib-sidebar-active-bg: var(--ib-primary);
  --ib-sidebar-active-text: #ffffff;

  /* Header */
  --ib-header-bg:         #000000;
  --ib-header-border:     var(--ib-border);

  /* Shadows (darker base) */
  --ib-shadow-sm:  0 1px 3px rgba(0,0,0,.30), 0 1px 2px rgba(0,0,0,.25);
  --ib-shadow-md:  0 4px 12px rgba(0,0,0,.40);
  --ib-shadow-lg:  0 8px 24px rgba(0,0,0,.50);
}
[data-theme="dark"] .ib-sidebar__app-name {
  color: #fff;
}
[data-theme="dark"] .mail-search-wrap,
[data-theme="dark"] .mail-detail-header {
  background: var(--ib-app-bg);
}

/* ==========================================================================
   LIGHT THEME — [data-theme="light"]
   Explicit overrides for elements that need adjustment in light mode.
   ========================================================================== */

[data-theme="light"] {
  /* Content background — light grey, not the dark appbar colour */
  --ib-bg:               #f4f6f9;
  --ib-surface:          #ffffff;
  --ib-border:           #dde1e7;
  --ib-text:             #1a202c;
  --ib-text-muted:       #64748b;

  /* Sidebar stays dark in light mode */
  --ib-sidebar-bg:        #1e293b;
  --ib-sidebar-text:      #cbd5e1;
  --ib-sidebar-hover-bg:  #334155;

  /* Header stays the same dark as appbar */
  --ib-header-bg:         #000000;
}

/* Main content area — always light in light mode */
[data-theme="light"] .ib-layout__main {
  background: var(--ib-bg);
  color: var(--ib-text);
}

[data-theme="light"] .ib-header {
  background: var(--ib-appbar-bg);
  color: #ffffff;
  border-bottom: none;
}

/* Specific overrides for elements that don't use CSS variables */
[data-theme="dark"] .ib-table th {
  background: #1a2744;
  color: var(--ib-text-muted);
}

[data-theme="dark"] .ib-table tr:hover td,
[data-theme="dark"] .ib-table tr:hover:nth-child(2n) td {
  background: #273550;
}

[data-theme="dark"] .ib-input,
[data-theme="dark"] .ib-select,
[data-theme="dark"] textarea.ib-input {
  background: #0f172a;
  color: var(--ib-text);
  border-color: var(--ib-border);
}

[data-theme="dark"] .ib-input:focus,
[data-theme="dark"] .ib-select:focus {
  border-color: var(--ib-primary);
  box-shadow: 0 0 0 3px rgba(107,154,239,.25);
}

[data-theme="dark"] .ib-card,
[data-theme="dark"] .ib-panel,
[data-theme="dark"] .ib-module-header {
  /* background: var(--ib-surface); */
  /* border-color: var(--ib-border); */
}

[data-theme="dark"] .ib-alert--danger  { background: var(--ib-danger-light);  color: var(--ib-danger);  border-color: var(--ib-danger-dark); }
[data-theme="dark"] .ib-alert--success { background: var(--ib-success-light); color: var(--ib-success); border-color: var(--ib-success-dark); }
[data-theme="dark"] .ib-alert--warning { background: var(--ib-warning-light); color: var(--ib-warning); border-color: var(--ib-warning-dark); }
[data-theme="dark"] .ib-alert--info    { background: var(--ib-info-light);    color: var(--ib-info);    border-color: var(--ib-info); }

[data-theme="dark"] .ib-badge--success  { background: var(--ib-success-light); color: var(--ib-success); }
[data-theme="dark"] .ib-badge--danger   { background: var(--ib-danger-light);  color: var(--ib-danger); }
[data-theme="dark"] .ib-badge--warning  { background: var(--ib-warning-light); color: var(--ib-warning); }
[data-theme="dark"] .ib-badge--info     { background: var(--ib-info-light);    color: var(--ib-info); }
[data-theme="dark"] .ib-badge--primary  { background: var(--ib-primary-light); color: var(--ib-primary); }
[data-theme="dark"] .ib-badge--secondary { background: var(--ib-secondary-light); color: var(--ib-secondary); }

[data-theme="dark"] .ib-form__group-header {
  background: var(--ib-primary-light);
  color: var(--ib-primary);
}

[data-theme="dark"] .ib-detailer__field-label {
  color: var(--ib-text-muted);
}

/* Theme toggle button */
.ib-theme-toggle {
  background: none;
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-sm);
  color: var(--ib-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  transition: background var(--ib-transition), color var(--ib-transition);
  margin-right: var(--ib-space-sm);
}
.ib-theme-toggle:hover {
  background: var(--ib-secondary-light);
  color: var(--ib-text);
}

/* Smooth theme transition */
html {
  transition: background-color 200ms ease, color 200ms ease;
}


/* ==========================================================================
   Search overlay (triggered by icon button in ib-header__right)
   ========================================================================== */

/* Overlay panel — drops below the fixed header */
.ib-search-overlay {
  position: fixed;
  top: var(--ib-header-height);
  left: 0;
  right: 0;
  z-index: 1199;
  background: var(--ib-surface);
  border-bottom: 1px solid var(--ib-border);
  box-shadow: var(--ib-shadow-md);
  padding: var(--ib-space-sm) var(--ib-space-md);
  animation: ibSearchSlideDown .15s ease;
}
.ib-search-overlay[hidden] { display: none; }

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

.ib-search-overlay__inner {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 680px;
  margin: 0 auto;
}

.ib-search-overlay__close {
  flex-shrink: 0;
  margin-left: var(--ib-space-xs);
  color: var(--ib-text-muted);
}

.ib-search-bar__icon {
  position: absolute;
  left: 10px;
  color: var(--ib-text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

.ib-search-bar__input {
  flex: 1;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-pill);
  background: var(--ib-bg);
  color: var(--ib-text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--ib-transition), box-shadow var(--ib-transition);
}
.ib-search-bar__input:focus {
  border-color: var(--ib-primary);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
.ib-search-bar__input::-webkit-search-cancel-button { cursor: pointer; }

.ib-search-bar__results {
  position: absolute;
  top: calc(100% + var(--ib-space-sm));
  left: 0;
  right: 40px; /* clear close button */
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius);
  box-shadow: var(--ib-shadow-md);
  z-index: 9000;
  max-height: 380px;
  overflow-y: auto;
}
.ib-search-bar__results[hidden] { display: none; }

.ib-search-group__title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ib-text-muted);
  border-top: 1px solid var(--ib-border);
}
.ib-search-group__title:first-child {
  border-top: none;
}

.ib-search-result-item {
  display: flex;
  flex-direction: column;
  padding: 7px 14px;
  text-decoration: none;
  color: var(--ib-text);
  transition: background var(--ib-transition);
  cursor: pointer;
}
.ib-search-result-item:hover,
.ib-search-result-item.ib-search-result-item--focused {
  background: var(--ib-secondary-light);
}
.ib-search-result-item__label {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ib-search-result-item__sub {
  font-size: 0.75rem;
  color: var(--ib-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ib-search-no-results {
  padding: 14px;
  font-size: 0.875rem;
  color: var(--ib-text-muted);
  text-align: center;
}

/* ==========================================================================
   Notification Bell
   ========================================================================== */
.ib-notif {
  position: relative;
}

.ib-notif__btn {
  position: relative;
  background: none;
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-sm);
  color: var(--ib-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  transition: background var(--ib-transition), color var(--ib-transition);
}
.ib-notif__btn:hover {
  background: var(--ib-secondary-light);
  color: var(--ib-text);
}
.ib-notif__btn[aria-expanded="true"] {
  background: var(--ib-secondary-light);
  color: var(--ib-primary);
}

.ib-notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ef4444;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  pointer-events: none;
}
.ib-notif-badge--hidden {
  display: none;
}

.ib-notif__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius);
  box-shadow: var(--ib-shadow-md, 0 4px 12px rgba(0,0,0,.12));
  z-index: 9000;
  display: flex;
  flex-direction: column;
}
.ib-notif__panel[hidden] {
  display: none;
}

.ib-notif__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ib-border);
}
.ib-notif__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ib-text);
}
.ib-notif__mark-all {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: var(--ib-primary);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.ib-notif__mark-all:hover {
  color: var(--ib-primary-dark, #1d4ed8);
}

.ib-notif__list {
  flex: 1;
  overflow-y: auto;
  max-height: 320px;
}

.ib-notif-empty {
  padding: 20px 14px;
  font-size: 0.875rem;
  color: var(--ib-text-muted);
  text-align: center;
}

.ib-notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--ib-text);
  border-bottom: 1px solid var(--ib-border);
  transition: background var(--ib-transition);
  position: relative;
}
.ib-notif-item:last-child { border-bottom: none; }
.ib-notif-item:hover { background: var(--ib-secondary-light); }

.ib-notif-item--unread {
  background: rgba(59, 130, 246, 0.04);
}
.ib-notif-item--unread::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--ib-primary);
  border-radius: var(--ib-radius-sm) 0 0 var(--ib-radius-sm);
}

.ib-notif-item__icon {
  margin-top: 2px;
  font-size: 0.875rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.ib-notif-item--info    .ib-notif-item__icon { color: var(--ib-info,    #3b82f6); }
.ib-notif-item--success .ib-notif-item__icon { color: var(--ib-success, #22c55e); }
.ib-notif-item--warning .ib-notif-item__icon { color: var(--ib-warning, #f59e0b); }
.ib-notif-item--danger  .ib-notif-item__icon { color: var(--ib-danger,  #ef4444); }
.ib-notif-item--system  .ib-notif-item__icon { color: var(--ib-text-muted); }

.ib-notif-item__body { flex: 1; min-width: 0; }
.ib-notif-item__title {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ib-notif-item__msg {
  font-size: 0.75rem;
  color: var(--ib-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ib-notif-item__time {
  font-size: 0.7rem;
  color: var(--ib-text-muted);
  margin-top: 2px;
}

.ib-notif__footer {
  padding: 8px 14px;
  border-top: 1px solid var(--ib-border);
  text-align: center;
  font-size: 0.8rem;
}
.ib-notif__footer a {
  color: var(--ib-primary);
  text-decoration: none;
}
.ib-notif__footer a:hover { text-decoration: underline; }

/* (Notif panel mobile consolidated in section 17) */

/* Dark mode adjustments */
[data-theme="dark"] .ib-notif-item--unread {
  background: rgba(59, 130, 246, 0.08);
}

/* ==========================================================================
   DataEditor — ib-editor
   ========================================================================== */

.ib-editor {
  background: var(--ib-surface);
  border: none;
  border-radius: var(--ib-radius-lg);
  box-shadow: none;
  overflow: hidden;
}

.ib-editor__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ib-space-md) var(--ib-space-lg);
  border-bottom: 1px solid var(--ib-border);
  background: var(--ib-bg);
  gap: var(--ib-space-sm);
  flex-wrap: wrap;
}

.ib-editor__title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--ib-space-xs);
}
.ib-editor__subtitle {
  color: var(--ib-text-muted);
  font-weight: 400;
  margin-left: var(--ib-space-sm);
}

/* ==========================================================================
   Form – extended classes
   ========================================================================== */

/* Fields container (inside ib-form) */
.ib-form__fields {
  display: flex;
  flex-direction: column;
  gap: var(--ib-space-md);
  padding: var(--ib-space-lg);
}

/* Actions bar (Save / Cancel / Duplicate) */
.ib-form__actions {
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
  padding: var(--ib-space-md) var(--ib-space-lg);
  border-top: 1px solid var(--ib-border);
  background: var(--ib-bg);
  flex-wrap: wrap;
}

/* Required asterisk */
.ib-form__required {
  color: var(--ib-danger);
  margin-left: 2px;
  font-weight: 600;
}

/* Help / hint text below field (alias for ib-form__hint) */
.ib-form__help {
  font-size: .8rem;
  color: var(--ib-text-muted);
  margin-top: 2px;
}

/* Group header inside tabs */
.ib-form__group-header {
  padding: var(--ib-space-xs) var(--ib-space-md);
  background: var(--ib-primary-light);
  color: var(--ib-primary);
  font-size: .8rem;
  font-weight: 600;
  border-radius: var(--ib-radius-sm);
  margin-bottom: var(--ib-space-sm);
}

/* Back button – visually same as secondary */
.ib-btn--back {
  display: inline-flex;
  align-items: center;
  gap: var(--ib-space-xs);
  padding: 10px var(--ib-space-md);
  font-size: .875rem;
  font-weight: 500;
  border-radius: var(--ib-radius-md);
  background: var(--ib-secondary-light);
  color: var(--ib-text);
  border: 1px solid var(--ib-border);
  cursor: pointer;
  transition: background var(--ib-transition), color var(--ib-transition);
  text-decoration: none;
}
.ib-btn--back:hover {
  background: var(--ib-border);
  color: var(--ib-text);
  text-decoration: none;
}

/* ==========================================================================
   Form Components – Checkbox / Radio / Upload
   ========================================================================== */

/* Checklist and radiolist containers */
.ib-checklist,
.ib-radiolist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Individual checkbox / radio label */
.ib-checkbox,
.ib-radio {
  display: flex;
  align-items: center;
  gap: var(--ib-space-xs);
  cursor: pointer;
  font-size: .9rem;
  user-select: none;
}

.ib-checkbox__label,
.ib-radio__label {
  cursor: pointer;
}

/* File / image upload */
.ib-upload {
  display: flex;
  flex-direction: column;
  gap: var(--ib-space-sm);
}
.ib-upload--picture {}
.ib-upload--file {}

.ib-upload__preview {
  max-width: 200px;
  height: auto;
  border-radius: var(--ib-radius-md);
  border: 1px solid var(--ib-border);
  object-fit: cover;
}

.ib-upload__input {
  font-size: .875rem;
  color: var(--ib-text-muted);
}

.ib-upload__current {
  display: inline-flex;
  align-items: center;
  gap: var(--ib-space-xs);
  font-size: .875rem;
  color: var(--ib-text-muted);
}

.ib-upload__clear {
  font-size: .8rem;
  color: var(--ib-text-muted);
}

/* HTML (WYSIWYG) editor textarea */
.ib-html-editor {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-md);
  font-family: var(--ib-font);
  font-size: .875rem;
  color: var(--ib-text);
  background: var(--ib-surface);
  padding: var(--ib-space-sm) var(--ib-space-md);
  resize: vertical;
  transition: border-color var(--ib-transition), box-shadow var(--ib-transition);
  line-height: 1.5;
}
.ib-html-editor:focus {
  outline: none;
  border-color: var(--ib-border-focus);
  box-shadow: 0 0 0 3px rgba(59,111,218,.18);
}

/* Multi-select overrides */
.ib-select--multi {
  height: auto;
  min-height: 120px;
  background-image: none;
  padding-right: var(--ib-space-md);
}

/* Tabs panels wrapper */
.ib-tabs__panels {
  flex: 1;
}

/* ==========================================================================
   DataDetailer — extended / value classes
   ========================================================================== */

/* Empty / null value */
.ib-detailer__empty {
  color: var(--ib-text-muted);
  font-style: italic;
  font-size: .875rem;
}

/* Rendered HTML block */
.ib-detailer__html {
  font-size: .9rem;
  line-height: 1.6;
}
.ib-detailer__html img { max-width: 100%; }
.ib-detailer__html p  { margin-bottom: .5em; }

/* JSON code block */
.ib-detailer__json {
  font-family: Courier New, monospace;
  font-size: .8rem;
  background: var(--ib-bg);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-sm);
  padding: var(--ib-space-sm) var(--ib-space-md);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  color: var(--ib-text);
}

/* Image in detail view */
.ib-detailer__image {
  max-width: 200px;
  height: auto;
  border-radius: var(--ib-radius-md);
  border: 1px solid var(--ib-border);
  object-fit: cover;
}

/* Dark mode overrides for new classes */
[data-theme="dark"] .ib-editor {
  background: var(--ib-surface);
  border-color: var(--ib-border);
}
[data-theme="dark"] .ib-editor__header,
[data-theme="dark"] .ib-form__actions {
  background: var(--ib-sidebar-bg);
  border-color: var(--ib-border);
}
[data-theme="dark"] .ib-form__group-header {
  background: var(--ib-primary-light);
  color: var(--ib-primary);
}
[data-theme="dark"] .ib-html-editor {
  background: var(--ib-bg);
  color: var(--ib-text);
  border-color: var(--ib-border);
}
[data-theme="dark"] .ib-detailer__json {
  background: var(--ib-bg);
  border-color: var(--ib-border);
  color: var(--ib-text);
}

/* ==========================================================================
   MISSING CLASSES FIX — Added 2026-02-26
   All classes used in DataBrowser/DataEditor PHP but absent from CSS
   ========================================================================== */

/* DataBrowser table wrapper – horizontal scroll on small viewports */
.ib-browser__table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Table row – hover effect (HTML uses .ib-table__row, CSS had .ib-table__tr) */
.ib-table__row:hover .ib-table__td {
  background: var(--ib-primary-light);
}
.ib-table__row--selected .ib-table__td {
  background: var(--ib-primary-light);
}

/* Actions column header */
.ib-table__th--actions {
  text-align: right;
  white-space: nowrap;
  width: 1px;
}

/* Empty state row in table */
.ib-table__empty {
  padding: var(--ib-space-xl) var(--ib-space-md);
  text-align: center;
  color: var(--ib-text-muted);
  font-style: italic;
}

/* Sort link in table header */
.ib-table__sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--ib-transition);
}
.ib-table__sort-link:hover {
  color: var(--ib-primary);
  text-decoration: none;
}

/* Nowrap modifiers for th and td */
.ib-table__th--nowrap,
.ib-table__td--nowrap {
  white-space: nowrap;
}

/* Search input modifier — pill style */
.ib-input--search {
  min-width: 160px;
  max-width: 300px;
  border-radius: var(--ib-radius-pill);
}

/* Edit button – primary-tinted variant */
.ib-btn--edit {
  background: var(--ib-primary-light);
  color: var(--ib-primary);
  border-color: transparent;
}
.ib-btn--edit:hover {
  background: var(--ib-primary);
  color: var(--ib-text-inverted);
  border-color: var(--ib-primary);
}

/* View (detail) button – info-tinted variant */
.ib-btn--view {
  background: var(--ib-info-light);
  color: var(--ib-info);
  border-color: transparent;
}
.ib-btn--view:hover {
  background: var(--ib-info);
  color: var(--ib-text-inverted);
  border-color: var(--ib-info);
}

/* Clear search / reset button */
.ib-btn--clear {
  color: var(--ib-text-muted);
}
.ib-btn--clear:hover {
  color: var(--ib-danger);
  background: var(--ib-danger-light);
}

/* Pagination list (ul) – alias for ib-pagination__nav */
.ib-pagination__list {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
}

/* Pagination ellipsis */
.ib-pagination__ellipsis {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  color: var(--ib-text-muted);
  font-size: .8rem;
  height: 32px;
}

/* HTML cell in table (stripped, truncated) */
.ib-cell--html {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .85rem;
  color: var(--ib-text-muted);
}

/* Inline delete/duplicate forms in table */
.ib-delete-form,
.ib-duplicate-form {
  display: inline;
  margin: 0;
  padding: 0;
}

/* Dark mode overrides for the new classes */
[data-theme="dark"] .ib-table__row--selected .ib-table__td {
  background: var(--ib-primary-light);
  filter: brightness(.85);
}
[data-theme="dark"] .ib-btn--edit {
  background: rgba(59,111,218,.2);
  color: var(--ib-primary);
}
[data-theme="dark"] .ib-btn--edit:hover {
  background: var(--ib-primary);
  color: #fff;
}
[data-theme="dark"] .ib-btn--view {
  background: rgba(8,145,178,.2);
  color: var(--ib-info);
}
[data-theme="dark"] .ib-btn--view:hover {
  background: var(--ib-info);
  color: #fff;
}
[data-theme="dark"] .ib-btn--primary {
  background: #fff;
  color: #000;
  border-color: #fff;
}
[data-theme="dark"] .ib-btn--primary i,
[data-theme="dark"] .ib-btn--primary i::before {
  color: #000;
}
[data-theme="dark"] .ib-btn--primary:hover {
  background: #e0e0e0;
  border-color: #e0e0e0;
}
[data-theme="dark"] .ib-btn--secondary {
  background: #000;
  color: #fff;
  border-color: #333;
}
[data-theme="dark"] .ib-btn--secondary:hover {
  background: #1a1a1a;
  border-color: #555;
}
[data-theme="dark"] .ib-btn--outline {
  background: #000;
  color: #fff;
  border-color: #a6a6a6;
}
[data-theme="dark"] .ib-btn--outline:hover {
  background: #1a1a1a;
  border-color: #888;
}
[data-theme="dark"] .ib-btn--success {
  background: #000;
  color: #4ade80;
  border-color: #4ade80;
}
[data-theme="dark"] .ib-btn--success:hover {
  background: #0a1a0a;
  border-color: #22c55e;
}
[data-theme="dark"] .ib-cell--html {
  color: var(--ib-text-muted);
}

/* ==========================================================================
   MISSING COMPONENTS FIX — Added 2026-02-26 (UI Review pass)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Card component — used in profile page and custom modules
   -------------------------------------------------------------------------- */
.ib-card {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-lg);
  box-shadow: var(--ib-shadow-sm);
  overflow: hidden;
}

.ib-card__header {
  padding: var(--ib-space-md) var(--ib-space-lg);
  border-bottom: 1px solid var(--ib-border);
  background: var(--ib-bg);
}

.ib-card__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ib-text);
  display: flex;
  align-items: center;
  gap: var(--ib-space-xs);
  margin: 0;
}

.ib-card__subtitle {
  font-size: .85rem;
  color: var(--ib-text-muted);
  margin-top: 4px;
}

.ib-card__body {
  padding: var(--ib-space-lg);
}

.ib-card__footer {
  padding: var(--ib-space-sm) var(--ib-space-lg);
  border-top: 1px solid var(--ib-border);
  background: var(--ib-bg);
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Panel component — used in custom modules
   -------------------------------------------------------------------------- */
.ib-panel {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-lg);
  box-shadow: var(--ib-shadow-sm);
  overflow: hidden;
}

.ib-panel__header {
  padding: var(--ib-space-sm) var(--ib-space-lg);
  border-bottom: 1px solid var(--ib-border);
  background: var(--ib-bg);
  display: flex;
  align-items: center;
  gap: var(--ib-space-sm);
}

.ib-panel__title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--ib-text);
  margin: 0;
}

.ib-panel__body {
  padding: var(--ib-space-lg);
}

.ib-panel__body--flush {
  padding: 0;
}

/* --------------------------------------------------------------------------
   Module header — used in custom module renders
   -------------------------------------------------------------------------- */
.ib-module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ib-space-sm);
  padding: var(--ib-space-md) var(--ib-space-lg);
  /* background: var(--ib-surface); */
  /* border: 1px solid var(--ib-border); */
  border-radius: var(--ib-radius-lg);
  box-shadow: var(--ib-shadow-sm);
  margin-bottom: var(--ib-space-md);
  flex-wrap: wrap;
}

.ib-module-header__title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ib-text);
  display: flex;
  align-items: center;
  gap: var(--ib-space-xs);
  margin: 0;
}

.ib-module-header__actions {
  display: flex;
  align-items: center;
  gap: var(--ib-space-xs);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Alert error alias — DataDetailer.php uses ib-alert--error
   -------------------------------------------------------------------------- */
.ib-alert--error {
  background: var(--ib-danger-light);
  color: var(--ib-danger);
  border-color: var(--ib-danger);
}

/* --------------------------------------------------------------------------
   Thumbnail in DataBrowser
   -------------------------------------------------------------------------- */
.ib-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--ib-radius-sm);
  border: 1px solid var(--ib-border);
  display: block;
}

/* --------------------------------------------------------------------------
   Sidebar brand text (next to logo)
   -------------------------------------------------------------------------- */
.ib-sidebar__brand {
  font-size: .875rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
  margin-left: 8px;
}

/* --------------------------------------------------------------------------
   Dark mode overrides for new components
   -------------------------------------------------------------------------- */
[data-theme="dark"] .ib-card {
  background: var(--ib-surface);
  border-color: var(--ib-border);
}
[data-theme="dark"] .ib-card__header {
  background: rgba(0,0,0,.2);
  border-color: var(--ib-border);
}
[data-theme="dark"] .ib-card__footer {
  background: rgba(0,0,0,.2);
  border-color: var(--ib-border);
}
[data-theme="dark"] .ib-panel {
  background: var(--ib-surface);
  border-color: var(--ib-border);
}
[data-theme="dark"] .ib-panel__header {
  background: rgba(0,0,0,.2);
  border-color: var(--ib-border);
}
[data-theme="dark"] .ib-module-header {
  /* background: var(--ib-surface); */
  /* border-color: var(--ib-border); */
}
[data-theme="dark"] .ib-alert--error {
  background: var(--ib-danger-light);
  color: var(--ib-danger);
  border-color: var(--ib-danger-dark);
}

/* ==========================================================================
   MISSING CLASSES — Added 2026-02-26 (Interface Review pass 2)
   ========================================================================== */

/* --------------------------------------------------------------------------
   ib-badge--muted — grey/inactive badge (used in Output.php boolean false)
   -------------------------------------------------------------------------- */
.ib-badge--muted {
  background: var(--ib-border);
  color: var(--ib-text-muted);
}
[data-theme="dark"] .ib-badge--muted {
  background: rgba(255,255,255,.08);
  color: var(--ib-text-muted);
}

/* --------------------------------------------------------------------------
   Login box subtitle (2FA verify page)
   -------------------------------------------------------------------------- */
.ib-login-box__subtitle {
  font-size: .875rem;
  color: var(--ib-text-muted);
  text-align: center;
  margin-bottom: var(--ib-space-md);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   ib-input--code — OTP / verification code input (monospace, large, centered)
   -------------------------------------------------------------------------- */
.ib-input--code {
  font-family: "Courier New", Courier, monospace;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: .4em;
  max-width: 220px;
}

/* --------------------------------------------------------------------------
   Checkbox row inside form
   -------------------------------------------------------------------------- */
.ib-form__row--checkbox {
  flex-direction: row;
  align-items: center;
  gap: var(--ib-space-sm);
}
.ib-form__checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--ib-space-xs);
  font-size: .875rem;
  color: var(--ib-text);
  cursor: pointer;
  user-select: none;
}
.ib-form__checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--ib-primary);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   ib-section — generic content section block
   -------------------------------------------------------------------------- */
.ib-section {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius);
  padding: var(--ib-space-md);
  margin-bottom: var(--ib-space-md);
}
.ib-section__title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--ib-text);
  margin: 0 0 var(--ib-space-sm) 0;
  display: flex;
  align-items: center;
  gap: var(--ib-space-xs);
}
[data-theme="dark"] .ib-section {
  background: var(--ib-surface);
  border-color: var(--ib-border);
}

/* --------------------------------------------------------------------------
   ib-module-title / ib-module-actions — aliases for module-header children
   -------------------------------------------------------------------------- */
.ib-module-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ib-text);
  display: flex;
  align-items: center;
  gap: var(--ib-space-xs);
  margin: 0;
}
.ib-module-actions {
  display: flex;
  align-items: center;
  gap: var(--ib-space-xs);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   ib-filters-bar — horizontal filter bar (flex row, wraps)
   -------------------------------------------------------------------------- */
.ib-filters-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--ib-space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--ib-space-md);
  padding: var(--ib-space-sm) var(--ib-space-md);
  background: var(--ib-surface-alt, var(--ib-surface));
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius);
}
.ib-filters-bar label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--ib-text-muted);
  margin-bottom: 3px;
}
[data-theme="dark"] .ib-filters-bar {
  background: var(--ib-surface);
  border-color: var(--ib-border);
}

/* --------------------------------------------------------------------------
   ib-label — standalone label element
   -------------------------------------------------------------------------- */
.ib-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--ib-text-muted);
  margin-bottom: 3px;
}

/* --------------------------------------------------------------------------
   ib-form-group — wrapper around label + input
   -------------------------------------------------------------------------- */
.ib-form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* --------------------------------------------------------------------------
   ib-empty-state — centered empty state block
   -------------------------------------------------------------------------- */
.ib-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--ib-space-xl) var(--ib-space-lg);
  color: var(--ib-text-muted);
  text-align: center;
  gap: var(--ib-space-sm);
}
.ib-empty-state i {
  font-size: 1rem;
  opacity: 1;
  color: #f2f2f2;
  padding: 5px 5px 5px 0px;
}
.ib-empty-state p {
  margin: 0;
  font-size: .9rem;
}

/* --------------------------------------------------------------------------
   ib-table-wrap — table with horizontal scroll
   -------------------------------------------------------------------------- */
.ib-table-wrap {
  overflow-x: auto;
  border-radius: var(--ib-radius);
  border: 1px solid var(--ib-border);
}

/* --------------------------------------------------------------------------
   ib-detail-table — simple two-column key/value table
   -------------------------------------------------------------------------- */
.ib-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.ib-detail-table th,
.ib-detail-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--ib-border);
  text-align: left;
  vertical-align: top;
}
.ib-detail-table th {
  width: 35%;
  font-weight: 500;
  color: var(--ib-text-muted);
  white-space: nowrap;
}
.ib-detail-table tr:last-child th,
.ib-detail-table tr:last-child td {
  border-bottom: none;
}
[data-theme="dark"] .ib-detail-table th,
[data-theme="dark"] .ib-detail-table td {
  border-color: var(--ib-border);
}

/* --------------------------------------------------------------------------
   ib-browser__meta — meta/info text above the table in browser modules
   -------------------------------------------------------------------------- */
.ib-browser__meta {
  font-size: .8rem;
  color: var(--ib-text-muted);
  margin-bottom: var(--ib-space-xs);
}

/* --------------------------------------------------------------------------
   ib-status — inline status indicator dot (used in SysCron)
   -------------------------------------------------------------------------- */
.ib-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.ib-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
  flex-shrink: 0;
}
.ib-status--active   { background: var(--ib-success-light); color: var(--ib-success-dark); }
.ib-status--inactive { background: var(--ib-danger-light);  color: var(--ib-danger-dark); }
.ib-status--pending  { background: var(--ib-warning-light); color: var(--ib-warning-dark); }

/* --------------------------------------------------------------------------
   ib-thread — message/reply thread container (SysMessages)
   -------------------------------------------------------------------------- */
.ib-thread {
  display: flex;
  flex-direction: column;
  gap: var(--ib-space-sm);
  margin-bottom: var(--ib-space-md);
}
.ib-thread__item {
  background: var(--ib-surface-alt, var(--ib-bg));
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius);
  padding: var(--ib-space-sm) var(--ib-space-md);
}
.ib-thread__meta {
  font-size: .78rem;
  color: var(--ib-text-muted);
  margin-bottom: 4px;
  display: flex;
  gap: var(--ib-space-sm);
}
.ib-thread__body {
  font-size: .875rem;
  color: var(--ib-text);
  line-height: 1.5;
}
[data-theme="dark"] .ib-thread__item {
  background: rgba(255,255,255,.03);
  border-color: var(--ib-border);
}

/* ==========================================================================
   Layout Redesign — App Bar + Sidebar per App + Avatar Dropdown
   Added: 27/02/2026
   ========================================================================== */

/* --------------------------------------------------------------------------
   App Bar  (vertical strip, always visible, left edge)
   -------------------------------------------------------------------------- */
.ib-appbar {
  position: fixed;
  left: 0;
  top: var(--ib-header-height); /* below full-width header */
  bottom: 0;
  width: var(--ib-appbar-width);
  z-index: 1100;
  background: var(--ib-appbar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0 8px;
  overflow: hidden;
}

.ib-appbar__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-bottom: 8px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background .15s;
}
.ib-appbar__logo:hover { background: rgba(255,255,255,.08); }

.ib-appbar__logo-img {
  width: 26px;
  height: 26px;
  filter: brightness(0) invert(1);
}

.ib-appbar__nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  padding: 0 6px;
}
.ib-appbar__nav::-webkit-scrollbar { display: none; }

.ib-appbar__item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  color: #94a3b8;
  text-decoration: none;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  font-size: 1.15rem;
}
.ib-appbar__item:hover {
  background: rgba(255,255,255,.08);
  color: #e2e8f0;
  text-decoration: none;
}
.ib-appbar__item--active {
  background: rgba(255,255,255,.15);
  color: #ffffff;
}
.ib-appbar__item--active:hover {
  background: rgba(255,255,255,.2);
  color: #ffffff;
}

/* Tooltip (shown on hover, appears to the right of the app bar) */
.ib-appbar__tooltip {
  position: absolute;
  left: calc(var(--ib-appbar-width) - 6px);
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: #e2e8f0;
  font-size: .72rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s .05s;
  z-index: 1020;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.06);
}
.ib-appbar__item:hover .ib-appbar__tooltip { opacity: 1; }

/* --------------------------------------------------------------------------
   Sidebar — repositioned next to App Bar
   -------------------------------------------------------------------------- */

/* Override — sidebar starts below full-width header */
.ib-sidebar {
  left: var(--ib-appbar-width) !important;
  top: var(--ib-header-height) !important;
  height: calc(100vh - var(--ib-header-height)) !important;
  z-index: 1001 !important;
}

/* App name label in sidebar header (replaces logo) */
.ib-sidebar__app-name {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.ib-sidebar__app-name--mobile { display: none; }
.ib-sidebar__app-name--desktop { display: inline; }
@media (max-width: 768px) {
  .ib-sidebar__app-name--mobile { display: inline; }
  .ib-sidebar__app-name--desktop { display: none; }
}

/* Always show toggle button (not only on mobile) */
.ib-sidebar__toggle {
  display: flex !important;
  cursor: pointer;
}

/* Sidebar empty state */
.ib-sidebar__empty {
  padding: var(--ib-space-lg) var(--ib-space-md);
  color: rgba(255,255,255,.35);
  font-size: .85rem;
  text-align: center;
  display: block;
}

/* --------------------------------------------------------------------------
   Main area — offset by both App Bar + Sidebar, below fixed header
   -------------------------------------------------------------------------- */
.ib-layout__main {
  margin-left: calc(var(--ib-appbar-width) + var(--ib-sidebar-width)) !important;
  margin-top: var(--ib-header-height) !important;
  transition: margin-left .22s cubic-bezier(.4,0,.2,1);
}

/* When sidebar is open in desktop, no border-radius */
@media (min-width: 769px) {
  body:not(.ib-sidebar-closed) .ib-editor,
  body:not(.ib-sidebar-closed) .ib-browser {
    border-radius: 0;
  }
}

/* When sidebar is collapsed (class on body) */
body.ib-sidebar-closed .ib-sidebar {
  transform: translateX(-100%);
}
body.ib-sidebar-closed .ib-layout__main {
  margin-left: var(--ib-appbar-width) !important;
}

/* --------------------------------------------------------------------------
   Header — hamburger always shown, updated right section
   -------------------------------------------------------------------------- */
#ib-menu-open {
  display: inline-flex !important; /* always show, not just mobile */
}

/* --------------------------------------------------------------------------
   Messages Badge
   -------------------------------------------------------------------------- */
.ib-messages-btn,
.ib-header-app {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  color: var(--ib-text-muted);
  text-decoration: none;
  transition: background .15s, color .15s;
  font-size: 1.15rem;
}
.ib-messages-btn:hover,
.ib-header-app:hover {
  background: var(--ib-bg);
  color: var(--ib-text);
  text-decoration: none;
}

.ib-messages-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  border-radius: 9999px;
  background: var(--ib-danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Avatar Dropdown
   -------------------------------------------------------------------------- */
.ib-avatar {
  position: relative;
}

.ib-avatar__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  margin-top: 4px;
  padding: 0;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: var(--ib-text);
  cursor: pointer;
  transition: background .15s;
  font-size: .83rem;
  font-weight: 500;
  font-family: inherit;
  max-width: 180px;
}
.ib-avatar__btn:hover {
  background: var(--ib-secondary-light);
}

/* Button inside dark header — always light, both themes */
.ib-header__right .ib-avatar__btn:hover,
.ib-header__right .ib-avatar__btn[aria-expanded="true"] {
  background: rgba(255,255,255,.14);
  color: #ffffff;
}
.ib-header__right .ib-avatar__name {
  color: #e2e8f0;
}
.ib-header__right .ib-avatar__chevron {
  color: rgba(255,255,255,.45);
}

.ib-avatar__initial {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: var(--ib-primary);
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.ib-avatar__img {
  width: 35px;
  height: 35px;
  min-width: 35px;
  min-height: 35px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.ib-avatar__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100px;
}

.ib-avatar__chevron {
  font-size: .65rem;
  color: var(--ib-text-muted);
  flex-shrink: 0;
  transition: transform .2s;
}
.ib-avatar__btn[aria-expanded="true"] .ib-avatar__chevron {
  transform: rotate(180deg);
}

.ib-avatar__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-lg);
  box-shadow: var(--ib-shadow-lg);
  z-index: 600;
  overflow: hidden;
}

.ib-avatar__info {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--ib-border);
}
.ib-avatar__info-name {
  font-weight: 600;
  font-size: .875rem;
  color: var(--ib-text);
  line-height: 1.3;
}
.ib-avatar__info-email {
  font-size: .75rem;
  color: var(--ib-text-muted);
  margin-top: 2px;
  word-break: break-all;
}

.ib-avatar__menu {
  list-style: none;
  margin: 0;
  padding: 5px 0;
}
.ib-avatar__menu li { display: block; }

.ib-avatar__menu a,
.ib-avatar__menu button,
.ib-avatar__logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 16px;
  font-size: .84rem;
  color: var(--ib-text);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: background .12s;
  text-align: left;
  font-family: inherit;
  font-weight: 400;
}
.ib-avatar__menu a:hover,
.ib-avatar__menu button:hover,
.ib-avatar__logout:hover {
  background: var(--ib-secondary-light);
  text-decoration: none;
}
.ib-avatar__menu a i,
.ib-avatar__menu button i {
  width: 16px;
  text-align: center;
  color: var(--ib-text-muted);
}

.ib-avatar__sep {
  height: 1px !important;
  background: var(--ib-border) !important;
  margin: 4px 0 !important;
  padding: 0 !important;
}

/* Logout — danger color */
.ib-avatar__logout {
  color: var(--ib-danger);
}
.ib-avatar__logout i {
  color: var(--ib-danger) !important;
}
.ib-avatar__logout:hover {
  background: var(--ib-danger-light);
}

/* (Mobile responsive rules consolidated in section 17 above) */

/* --------------------------------------------------------------------------
   Organization Badge (inline in avatar btn) & Switcher (inside dropdown)
   -------------------------------------------------------------------------- */

/* Pill wrapper around both avatars with entity color */
.ib-avatar__duo {
  display: inline-flex;
  align-items: center;
  border-radius: 50px;
  padding: 3px;
  flex-shrink: 0;
}

/* Round org avatar shown to the right of user avatar inside the button */
.ib-avatar__org {
  width: 35px;
  height: 35px;
  min-width: 35px;
  min-height: 35px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
  margin-left: 3px;
}
.ib-avatar__org--initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ib-primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .02em;
}

/* Org section header inside dropdown */
.ib-avatar__org-section {
  display: block;
}
.ib-avatar__org-header {
  padding: 8px 16px 4px;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ib-text-muted);
}
.ib-avatar__org-list {
  padding: 2px 0 4px;
  max-height: 200px;
  overflow-y: auto;
}

/* Org items inside the avatar dropdown */
.ib-org-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .82rem;
  color: var(--ib-text);
  text-align: left;
  transition: background .12s;
}
.ib-org-item:hover {
  background: var(--ib-secondary-light);
}
.ib-org-item--active {
  background: var(--ib-secondary-light);
}
.ib-org-item__img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.ib-org-item__initial {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ib-primary);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: .02em;
}
.ib-org-item__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.ib-org-item__name {
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ib-org-item__role {
  font-size: .65rem;
  color: var(--ib-text-muted);
  line-height: 1.3;
}
.ib-org-item__check {
  font-size: .7rem;
  color: var(--ib-primary);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Dark mode overrides for new components
   -------------------------------------------------------------------------- */
[data-theme="dark"] .ib-appbar {
  /* background: #000000; */
}

[data-theme="dark"] .ib-avatar__panel {
  background: var(--ib-surface);
  border-color: var(--ib-border);
}

/* Avatar panel and menu in dark theme */
[data-theme="dark"] .ib-avatar__menu a:hover,
[data-theme="dark"] .ib-avatar__menu button:hover {
  background: var(--ib-secondary-light);
}

[data-theme="dark"] .ib-messages-btn:hover,
[data-theme="dark"] .ib-header-app:hover {
  background: var(--ib-secondary-light);
  color: var(--ib-text);
}

/* --------------------------------------------------------------------------
   Header dark background — icon buttons inside ib-header__main and
   ib-header__right always appear light, regardless of page theme.
   -------------------------------------------------------------------------- */
.ib-header__main .ib-btn--icon,
.ib-header__right .ib-btn--icon {
  color: rgba(255,255,255,.65);
  font-size: 1.15rem;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ib-header__main .ib-btn--icon:hover,
.ib-header__right .ib-btn--icon:hover {
  background: rgba(255,255,255,.1);
  color: #ffffff;
}

.ib-header__right .ib-messages-btn,
.ib-header__right .ib-header-app {
  color: rgba(255,255,255,.65);
}
.ib-header__right .ib-messages-btn:hover,
.ib-header__right .ib-header-app:hover {
  background: rgba(255,255,255,.1);
  color: #ffffff;
  text-decoration: none;
}
.ib-header__right .ib-messages-btn.ib-appbar__item--active,
.ib-header__right .ib-header-app.ib-appbar__item--active {
  color: #ffffff;
  height: 30px;
}

.ib-header__right .ib-notif__btn {
  color: rgba(255,255,255,.65);
  border-color: transparent;
  background: none;
}
.ib-header__right .ib-notif__btn:hover {
  background: rgba(255,255,255,.1);
  color: #ffffff;
}
.ib-header__right .ib-notif__btn[aria-expanded="true"] {
  background: rgba(255,255,255,.15);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Print — hide appbar too
   -------------------------------------------------------------------------- */
@media print {
  .ib-appbar { display: none !important; }
  .ib-layout__main { margin-left: 0 !important; margin-top: 0 !important; }
}

/* --------------------------------------------------------------------------
   WYSIWYG / Rich Text Editor (custom, no dependencies)
   Replaces plain textarea for fields with data-editor="html"
   -------------------------------------------------------------------------- */
.ib-html-editor-wrap {
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-md);
  overflow: hidden;
  background: var(--ib-surface);
  transition: border-color var(--ib-transition), box-shadow var(--ib-transition);
}
.ib-html-editor-wrap:focus-within {
  border-color: var(--ib-border-focus);
  box-shadow: 0 0 0 3px rgba(59,111,218,.18);
}

.ib-html-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1px;
  padding: 4px 6px;
  background: var(--ib-secondary-light);
  border-bottom: 1px solid var(--ib-border);
  user-select: none;
}

.ib-html-toolbar__btn {
  width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--ib-radius-sm);
  background: transparent;
  cursor: pointer;
  color: var(--ib-text);
  font-size: .8rem;
  font-family: inherit;
  transition: background var(--ib-transition), border-color var(--ib-transition);
}
.ib-html-toolbar__btn:hover {
  background: var(--ib-surface);
  border-color: var(--ib-border);
}
.ib-html-toolbar__btn.ib-active {
  background: var(--ib-primary-light);
  border-color: var(--ib-primary);
  color: var(--ib-primary);
}

.ib-html-toolbar__sep {
  width: 1px;
  height: 20px;
  background: var(--ib-border);
  margin: 0 4px;
  flex-shrink: 0;
}

.ib-html-toolbar__select {
  padding: 2px 6px;
  font-size: .78rem;
  font-family: inherit;
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-sm);
  background: var(--ib-surface);
  color: var(--ib-text);
  cursor: pointer;
}

.ib-html-editor-content {
  min-height: 200px;
  max-height: 600px;
  padding: 12px 16px;
  background: var(--ib-surface);
  color: var(--ib-text);
  outline: none;
  line-height: 1.6;
  overflow-y: auto;
  font-family: var(--ib-font);
  font-size: .9rem;
}

/* Content element styling */
.ib-html-editor-content b,
.ib-html-editor-content strong { font-weight: 600; }
.ib-html-editor-content i,
.ib-html-editor-content em { font-style: italic; }
.ib-html-editor-content u { text-decoration: underline; }
.ib-html-editor-content s { text-decoration: line-through; }
.ib-html-editor-content ul { list-style: disc; padding-left: 24px; margin: 4px 0; }
.ib-html-editor-content ol { list-style: decimal; padding-left: 24px; margin: 4px 0; }
.ib-html-editor-content li { margin: 2px 0; }
.ib-html-editor-content a { color: var(--ib-primary); text-decoration: underline; }
.ib-html-editor-content p { margin-bottom: 8px; }
.ib-html-editor-content blockquote {
  border-left: 3px solid var(--ib-primary);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--ib-text-muted);
}
.ib-html-editor-content h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.ib-html-editor-content h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.ib-html-editor-content h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.ib-html-editor-content code {
  background: var(--ib-secondary-light);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: .85em;
}

/* Dark theme */
[data-theme="dark"] .ib-html-toolbar {
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.1);
}
[data-theme="dark"] .ib-html-toolbar__btn:hover {
  background: rgba(255,255,255,.1);
}
[data-theme="dark"] .ib-html-toolbar__select {
  background: #1e293b;
  border-color: rgba(255,255,255,.15);
  color: #cbd5e1;
}
[data-theme="dark"] .ib-html-editor-content {
  background: #0f172a;
  color: #e2e8f0;
}

/* HTML source code editor textarea */
.ib-html-source {
  width: 100%;
  min-height: 200px;
  max-height: 600px;
  padding: 12px 16px;
  background: var(--ib-surface);
  color: var(--ib-text);
  border: none;
  outline: none;
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
  font-size: .85rem;
  line-height: 1.5;
  resize: vertical;
  tab-size: 2;
  box-sizing: border-box;
}
[data-theme="dark"] .ib-html-source {
  background: #0f172a;
  color: #e2e8f0;
}

/* --------------------------------------------------------------------------
   Dashboard improvements
   -------------------------------------------------------------------------- */
.ib-dashboard-kpi-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ib-space-md);
  margin-bottom: var(--ib-space-lg);
}
.ib-dashboard-kpi {
  flex: 1;
  min-width: 140px;
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius-lg);
  padding: var(--ib-space-md) var(--ib-space-lg);
  display: flex;
  align-items: center;
  gap: var(--ib-space-md);
  box-shadow: var(--ib-shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--ib-transition), border-color var(--ib-transition);
}
.ib-dashboard-kpi:hover {
  box-shadow: var(--ib-shadow-md);
  border-color: var(--ib-primary);
  text-decoration: none;
}
.ib-dashboard-kpi__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--ib-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.ib-dashboard-kpi__icon--primary { background: var(--ib-primary-light); color: var(--ib-primary); }
.ib-dashboard-kpi__icon--success { background: var(--ib-success-light); color: var(--ib-success); }
.ib-dashboard-kpi__icon--warning { background: var(--ib-warning-light); color: var(--ib-warning); }
.ib-dashboard-kpi__icon--danger  { background: var(--ib-danger-light);  color: var(--ib-danger); }
.ib-dashboard-kpi__icon--info    { background: var(--ib-info-light);    color: var(--ib-info); }

.ib-dashboard-kpi__body { min-width: 0; }
.ib-dashboard-kpi__value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ib-text);
  white-space: nowrap;
}
.ib-dashboard-kpi__label {
  font-size: .78rem;
  color: var(--ib-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================================
   Toggle switch (checkbox/boolean component type)
   ========================================================================= */
.ib-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: .5rem;
  user-select: none;
}
.ib-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.ib-toggle__slider {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  background: var(--ib-secondary-light);
  border-radius: 12px;
  transition: background .2s ease;
  flex-shrink: 0;
  border: 1px solid var(--ib-border);
}
.ib-toggle__slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.ib-toggle input:checked ~ .ib-toggle__slider {
  background: var(--ib-primary);
  border-color: var(--ib-primary);
}
.ib-toggle input:checked ~ .ib-toggle__slider::after {
  transform: translateX(18px);
}
.ib-toggle input:disabled ~ .ib-toggle__slider {
  opacity: .5;
  cursor: not-allowed;
}
.ib-toggle input:focus-visible ~ .ib-toggle__slider {
  outline: 2px solid var(--ib-primary);
  outline-offset: 2px;
}

/* Compact icon-only badge (boolean list view) */
.ib-badge--icon {
  padding: 3px 5px;
  min-width: 22px;
  text-align: center;
}

/* ==========================================================================
   MISSING CLASSES — Added 2026-02-28 (Quality Review pass 3)
   ========================================================================== */

/* --------------------------------------------------------------------------
   ib-browser__count — record count row below table when pages=1
   -------------------------------------------------------------------------- */
.ib-browser__count {
  padding: var(--ib-space-sm) var(--ib-space-md);
  font-size: .8rem;
  color: var(--ib-text-muted);
  text-align: right;
}

/* --------------------------------------------------------------------------
   ib-browser__perpage — per-page selector inline form in toolbar
   -------------------------------------------------------------------------- */
.ib-browser__perpage {
  display: inline-flex;
  align-items: center;
  gap: var(--ib-space-xs);
  flex-shrink: 0;
}

.ib-browser__perpage-label {
  font-size: .8rem;
  color: var(--ib-text-muted);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   ib-select--sm — compact select for inline use (toolbar, per-page, filters)
   -------------------------------------------------------------------------- */
.ib-select--sm {
  padding: 4px 28px 4px 8px;
  font-size: .8rem;
  border-radius: var(--ib-radius-sm);
  height: 30px;
}

/* --------------------------------------------------------------------------
   ib-btn--confirm — no extra styling; JS intercepts submit and shows confirm
   This class is a semantic marker only — inherits from ib-btn parent classes
   -------------------------------------------------------------------------- */
/* .ib-btn--confirm { } */

/* --------------------------------------------------------------------------
   ib-dup-form — hidden duplicate form (inline, similar to ib-delete-form)
   -------------------------------------------------------------------------- */
.ib-dup-form {
  display: inline;
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   ib-dashboard-card__body — wraps card name + badge, centered
   -------------------------------------------------------------------------- */
.ib-dashboard-card__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

/* Dark mode overrides */
[data-theme="dark"] .ib-browser__toolbar {
  background: var(--ib-sidebar-bg);
}
[data-theme="dark"] .ib-browser__count {
  color: var(--ib-text-muted);
}

/* --------------------------------------------------------------------------
   Dashboard layout mode — no sidebar, full width after appbar
   -------------------------------------------------------------------------- */

/* When body has ib-layout--dashboard, sidebar is not rendered.
   Main content only offsets by appbar width, not sidebar. */
body.ib-layout--dashboard .ib-layout__main {
  margin-left: var(--ib-appbar-width);
}

/* Dashboard appbar icon — separator line above apps */
.ib-appbar__item--dashboard {
  height: 51px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  border-radius: 0;
}
.ib-appbar__item--dashboard.ib-appbar__item--active {
  background: rgba(255,255,255,.15);
  color: #fff;
  border-bottom: none;
  padding-bottom: 0;
}

/* ==========================================================================
   Dashboard layout — Fase 146 fixes
   ========================================================================== */

/* Fix: override !important margin from base rule on dashboard */
body.ib-layout--dashboard .ib-layout__main {
  margin-left: var(--ib-appbar-width) !important;
  border-radius: 20px 0 0 0;
}

/* Hide hamburger button on dashboard (no sidebar to toggle) */
body.ib-layout--dashboard #ib-menu-open {
  display: none !important;
}

/* Dashboard main content padding */
body.ib-layout--dashboard .ib-layout__content {
  padding: 20px 0 0 0;
  max-width: 1400px;
  margin-right: auto;
}

/* Dashboard — app cards responsive grid improvements */
.ib-dashboard__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--ib-space-md);
  margin-bottom: var(--ib-space-xl);
}

/* Better spacing for ib-dashboard-kpi-bar on dashboard */
body.ib-layout--dashboard .ib-dashboard-kpi-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ib-space-md);
}

body.ib-layout--dashboard .ib-dashboard-kpi {
  flex: 1 1 180px;
  min-width: 160px;
}

/* ==========================================================================
   No-Sidebar layout (mail, etc.) — full width after appbar
   ========================================================================== */

body.ib-layout--no-sidebar {
  overflow: hidden;
  height: 100vh;
}

body.ib-layout--no-sidebar .ib-layout__main {
  margin-left: var(--ib-appbar-width) !important;
  border-radius: 20px 0 0 0;
  height: calc(100vh - var(--ib-header-height));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.ib-layout--no-sidebar #ib-menu-open {
  display: none !important;
}

body.ib-layout--no-sidebar .ib-layout__content {
  padding: 0;
  max-width: none;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.ib-layout--no-sidebar .ib-layout__footer {
  flex-shrink: 0;
}

/* ==========================================================================
   Dashboard Mode (/dashboard route) — Fase 146
   ========================================================================== */

.ib-dashboard-mode {
  padding: var(--ib-space-xl);
  max-width: 1400px;
}

.ib-dashboard-mode__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--ib-space-xl);
  padding-bottom: var(--ib-space-lg);
  border-bottom: 1px solid var(--ib-border);
}

.ib-dashboard-mode__title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ib-text);
  margin: 0 0 4px;
}

.ib-dashboard-mode__date {
  font-size: 0.85rem;
  color: var(--ib-text-muted);
  margin: 0;
  text-transform: capitalize;
}

/* Activity Widget */
.ib-widget-activity {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ib-widget-activity__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--ib-border);
  font-size: 0.82rem;
  line-height: 1.4;
}

.ib-widget-activity__item:last-child {
  border-bottom: none;
}

.ib-widget-activity__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 0.7rem;
}

.ib-widget-activity__icon--success  { background: rgba(16,185,129,.15); color: #10b981; }
.ib-widget-activity__icon--info     { background: rgba(59,130,246,.15);  color: #3b82f6; }
.ib-widget-activity__icon--danger   { background: rgba(239,68,68,.15);   color: #ef4444; }
.ib-widget-activity__icon--warning  { background: rgba(245,158,11,.15);  color: #f59e0b; }
.ib-widget-activity__icon--primary  { background: rgba(99,102,241,.15);  color: #6366f1; }
.ib-widget-activity__icon--default  { background: rgba(100,116,139,.12); color: var(--ib-text-muted); }

.ib-widget-activity__text {
  flex: 1;
  color: var(--ib-text);
}

.ib-widget-activity__text em {
  font-style: normal;
  color: var(--ib-text-muted);
  font-family: monospace;
  font-size: 0.78rem;
}

.ib-widget-activity__time {
  flex-shrink: 0;
  color: var(--ib-text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* ==========================================================================
   Widget: Announcements
   ========================================================================== */

.ib-widget-announcements {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ib-widget-announcement {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--ib-radius-sm, 6px);
  border-left: 3px solid transparent;
}

.ib-widget-announcement--info    { background: rgba(59,130,246,.08);  border-color: #3b82f6; }
.ib-widget-announcement--warning { background: rgba(245,158,11,.08);  border-color: #f59e0b; }
.ib-widget-announcement--success { background: rgba(16,185,129,.08);  border-color: #10b981; }
.ib-widget-announcement--danger  { background: rgba(239,68,68,.08);   border-color: #ef4444; }

.ib-widget-announcement__icon {
  flex-shrink: 0;
  margin-top: 0.1rem;
  font-size: 0.85rem;
}

.ib-widget-announcement--info    .ib-widget-announcement__icon { color: #3b82f6; }
.ib-widget-announcement--warning .ib-widget-announcement__icon { color: #f59e0b; }
.ib-widget-announcement--success .ib-widget-announcement__icon { color: #10b981; }
.ib-widget-announcement--danger  .ib-widget-announcement__icon { color: #ef4444; }

.ib-widget-announcement__title {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ib-text);
  text-decoration: none;
  line-height: 1.4;
}

.ib-widget-announcement__title:hover {
  text-decoration: underline;
  color: var(--ib-primary);
}

/* ==========================================================================
   Widget: Quick Actions
   ========================================================================== */

.ib-widget--full {
  grid-column: 1 / -1;
}

.ib-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.25rem 0;
}

.ib-quick-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .15s, transform .15s;
  white-space: nowrap;
}

.ib-quick-action:hover {
  opacity: .85;
  transform: translateY(-1px);
  text-decoration: none;
}

.ib-quick-action--primary   { background: var(--ib-primary); color: #fff; }
.ib-quick-action--success   { background: var(--ib-success); color: #fff; }
.ib-quick-action--info      { background: #0dcaf0; color: #000; }
.ib-quick-action--warning   { background: var(--ib-warning, #ffc107); color: #000; }
.ib-quick-action--secondary { background: var(--ib-border); color: var(--ib-text); }

.ib-quick-action__icon {
  font-size: 0.875rem;
}

.ib-quick-action__label {
  line-height: 1.2;
}


/* --------------------------------------------------------------------------
   Table Totals Footer Row
   -------------------------------------------------------------------------- */
.ib-table__foot-row td {
  background: var(--ib-primary-light);
  border-top: 2px solid var(--ib-border);
  font-weight: 600;
}
.ib-table__td--total-label {
  color: var(--ib-text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.ib-table__td--total {
  text-align: right;
  color: var(--ib-text);
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .ib-table__foot-row td {
  background: rgba(59, 111, 218, 0.12);
  border-top-color: rgba(255,255,255,.12);
}

/* --------------------------------------------------------------------------
   Color Swatch, Rating Stars, Pre-text (DataDetailer/DataBrowser)
   -------------------------------------------------------------------------- */
.ib-color-swatch {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-variant-numeric: tabular-nums;
}
.ib-color-swatch__dot {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.15);
  flex-shrink: 0;
}
.ib-rating {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
}
.ib-rating__label {
  font-size: .78rem;
  color: var(--ib-text-muted, #6b7280);
  margin-left: .15rem;
}
.ib-detailer__pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .88rem;
  line-height: 1.55;
  color: var(--ib-text);
}

/* ==========================================================================
   Quality Improvements — Fase 180
   ========================================================================== */

/* Sticky table header — keeps column headers visible while scrolling */
.ib-browser__table-wrap {
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: auto;
}
.ib-browser__table-wrap .ib-table__th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--ib-bg);
  box-shadow: 0 1px 0 var(--ib-border);
}

/* Table row hover — smooth transition + cursor pointer (set via JS for rows with view link) */
.ib-table__row {
  transition: background-color .1s ease;
}
.ib-table__row:hover .ib-table__td {
  background: var(--ib-primary-light);
  transition: background-color .1s ease;
}

/* Detailer — danger button spacing */
.ib-detailer__actions .ib-btn--danger {
  margin-left: auto;
}

/* Search input — subtle Ctrl+K hint */
.ib-search-bar__input::placeholder {
  color: var(--ib-text-muted);
}
.ib-search-hint {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .7rem;
  color: rgba(255,255,255,.5);
  margin-left: var(--ib-space-sm);
  pointer-events: none;
  white-space: nowrap;
}
.ib-search-hint kbd {
  display: inline-block;
  padding: 1px 4px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 3px;
  font-family: inherit;
  font-size: .65rem;
  line-height: 1.4;
  background: rgba(255,255,255,.08);
}

/* (Detailer header mobile consolidated in section 17) */

/* Print improvements — hide nav/sidebar/appbar on print */
@media print {
  .ib-appbar,
  .ib-sidebar,
  .ib-header,
  .ib-layout__footer,
  .ib-browser__toolbar,
  .ib-browser__pagination,
  .ib-detailer__actions,
  .ib-editor__header .ib-btn,
  .ib-form__actions,
  .ib-widgets-section {
    display: none !important;
  }
  .ib-layout__main {
    margin-left: 0 !important;
    margin-top: 0 !important;
  }
  .ib-detailer,
  .ib-editor,
  .ib-browser {
    box-shadow: none;
    border: none;
  }
  .ib-table__th,
  .ib-table__td {
    font-size: .8rem;
    padding: 6px 8px;
  }
  .ib-table__td--actions { display: none; }
}

/* Dark theme sticky header background fix */
[data-theme="dark"] .ib-browser__table-wrap .ib-table__th {
  background: var(--ib-sidebar-bg);
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
}

/* ==========================================================================
   Quality Improvements — Fase 181
   ========================================================================== */

/* Form validation — error state */
.ib-input--error,
.ib-select--error,
.ib-textarea--error {
  border-color: var(--ib-danger, #ef4444) !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, .15);
}
.ib-form__error-msg {
  color: var(--ib-danger, #ef4444);
  font-size: .78rem;
  margin-top: .25rem;
  display: flex;
  align-items: center;
  gap: .25rem;
}
.ib-form__error-msg::before {
  content: '⚠';
  font-size: .8rem;
}

/* Save shortcut — button saving state */
.ib-btn--saving {
  opacity: .7;
  cursor: wait;
}

/* Live invoice preview panel */
.ib-invoice-preview {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  background: var(--ib-primary-light, #eff6ff);
  border: 1px solid var(--ib-primary, #3b6fda);
  border-radius: var(--ib-radius-sm, 6px);
  padding: .75rem 1rem;
  margin-top: .75rem;
  font-size: .88rem;
  max-width: 320px;
  align-self: flex-end;
  margin-left: auto;
}
.ib-invoice-preview__row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ib-text, #1e293b);
}
.ib-invoice-preview__row--deduct {
  color: var(--ib-danger, #ef4444);
}
.ib-invoice-preview__row--total {
  border-top: 1px solid var(--ib-border, #e2e8f0);
  padding-top: .25rem;
  margin-top: .15rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ib-primary, #3b6fda);
}

[data-theme="dark"] .ib-invoice-preview {
  background: rgba(59, 111, 218, .12);
  border-color: rgba(59, 111, 218, .4);
}

/* Pagination improvements — show total count always */
.ib-browser__pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .75rem 1rem;
}
.ib-browser__pagination-count {
  font-size: .82rem;
  color: var(--ib-text-muted, #6b7280);
}

/* Advanced filter panel — visual improvements */
.ib-browser__filters summary {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--ib-text-muted);
  padding: .5rem .75rem;
  background: var(--ib-surface);
  user-select: none;
}
.ib-browser__filters summary:hover {
  color: var(--ib-primary);
  background: var(--ib-primary-light);
}
.ib-browser__filters[open] summary {
  background: var(--ib-primary-light);
  color: var(--ib-primary);
  border-radius: var(--ib-radius-sm, 6px) var(--ib-radius-sm, 6px) 0 0;
}

/* Textarea auto-grow hint */
.ib-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Form row focus-within highlight */
.ib-form__row:focus-within .ib-form__label {
  color: var(--ib-primary, #3b6fda);
  transition: color .15s ease;
}

/* Table — zebra stripes for better readability */
.ib-table tbody tr:nth-child(even) .ib-table__td {
  background: var(--ib-bg-alt, rgba(0,0,0,.02));
}
/* (DataDetailer mobile grid consolidated in section 17) */

/* Toast notification improvements */
.ib-toast {
  max-width: min(420px, 90vw);
}

/* Sidebar scroll when content is long */
.ib-sidebar__nav {
  overflow-y: auto;
  max-height: calc(100vh - 120px);
}

/* =========================================================================
   App Dashboard modules — KPI cards & widget grid
   ========================================================================= */

.ib-dashboard__title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ib-text);
  margin: 0 0 1.25rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* KPI row — horizontal row of metric cards */
.ib-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.ib-kpi-card {
  flex: 1 1 140px;
  background: var(--ib-surface, #fff);
  border: 1px solid var(--ib-border, #e2e8f0);
  border-radius: var(--ib-radius, 10px);
  padding: 1rem 1.25rem;
  min-width: 120px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: box-shadow .15s ease;
}
.ib-kpi-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.ib-kpi-card__value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ib-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ib-kpi-card__label {
  font-size: .78rem;
  color: var(--ib-text-muted, #6b7280);
  margin-top: .25rem;
}

/* Dashboard grid — two columns by default */
.ib-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
  align-items: start;
}

/* Dashboard widget */
.ib-dashboard-widget {
  background: var(--ib-surface, #fff);
  border: 1px solid var(--ib-border, #e2e8f0);
  border-radius: var(--ib-radius, 10px);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.ib-dashboard-widget--wide {
  grid-column: 1 / -1;
}
.ib-dashboard-widget__header {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  font-size: .9rem;
  color: var(--ib-text);
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--ib-border, #e2e8f0);
  background: var(--ib-bg-alt, #f8fafc);
}
.ib-dashboard-widget__link {
  margin-left: auto;
  font-size: .78rem;
  font-weight: 400;
  color: var(--ib-primary, #3b6fda);
  text-decoration: none;
}
.ib-dashboard-widget__link:hover { text-decoration: underline; }
.ib-dashboard-widget__empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--ib-text-muted, #6b7280);
  font-size: .88rem;
}
.ib-dashboard-widget__table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}
.ib-dashboard-widget__table thead tr {
  background: var(--ib-bg-alt, #f8fafc);
}
.ib-dashboard-widget__table th {
  padding: .4rem .75rem;
  font-weight: 600;
  color: var(--ib-text-muted, #6b7280);
  text-align: left;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--ib-border, #e2e8f0);
}
.ib-dashboard-widget__table td {
  padding: .45rem .75rem;
  border-bottom: 1px solid var(--ib-border, rgba(0,0,0,.04));
  color: var(--ib-text);
  vertical-align: middle;
}
.ib-dashboard-widget__table tbody tr:last-child td { border-bottom: 0; }
.ib-dashboard-widget__table tbody tr:hover td {
  background: var(--ib-primary-light, #eff6ff);
}

/* (Dashboard responsive consolidated in section 17) */

[data-theme="dark"] .ib-kpi-card {
  background: var(--ib-surface);
  border-color: var(--ib-border);
}
[data-theme="dark"] .ib-dashboard-widget {
  background: var(--ib-surface);
  border-color: var(--ib-border);
}
[data-theme="dark"] .ib-dashboard-widget__header {
  background: var(--ib-bg-alt);
}
[data-theme="dark"] .ib-dashboard-widget__table thead tr {
  background: var(--ib-surface-2, #2a2a2a);
}
[data-theme="dark"] .ib-dashboard-widget__table th {
  color: var(--ib-text-muted, #999);
  border-bottom-color: var(--ib-border, #444);
}
[data-theme="dark"] .ib-dashboard-widget__table td {
  border-bottom-color: var(--ib-border, rgba(255,255,255,.06));
}
[data-theme="dark"] .ib-dashboard-widget__table tbody tr:hover td {
  background: #273550;
}

/* Dashboard quick-action buttons */
.ib-btn--xs {
  padding: 4px 8px;
  font-size: .9rem;
  line-height: 1;
  border-radius: 4px;
  border: none;
  background: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color .15s, opacity .15s;
}
.ib-btn--xs:disabled { opacity: .4; cursor: not-allowed; }
.ib-dash-action { color: var(--ib-text-muted, #64748b); background: var(--ib-surface-2, #f3f4f6); border-radius: 4px; padding: 5px 8px; }
.ib-dash-action:hover:not(:disabled) { color: var(--ib-text); background: var(--ib-border, #e2e8f0); }
[data-theme="dark"] .ib-dash-action { background: #fff; color: #333; }
[data-theme="dark"] .ib-dash-action:hover:not(:disabled) { background: #e2e8f0; color: #000; }
.ib-dashboard-task__link {
  color: var(--ib-text);
  text-decoration: none;
  font-weight: 500;
}
.ib-dashboard-task__link:hover { text-decoration: underline; color: var(--ib-primary); }

/* ============================================================
   Fase 194 — UX/UI Polish Additions
   ============================================================ */

/* Button loading/saving state spinner */
.ib-btn--saving,
.ib-btn--loading {
  position: relative;
  pointer-events: none;
  opacity: .75;
  cursor: not-allowed;
}
.ib-btn--saving::after,
.ib-btn--loading::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ib-spin .65s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}
@keyframes ib-spin {
  to { transform: rotate(360deg); }
}

/* Custom scrollbar */
* { scrollbar-width: thin; scrollbar-color: rgba(100,116,139,.35) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100,116,139,.35); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,.55); }

/* Text selection */
::selection { background: var(--ib-primary); color: #fff; }

/* Focus-visible */
:focus-visible { outline: 2px solid var(--ib-primary); outline-offset: 2px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ib-primary);
  outline-offset: 2px;
}
input.ib-input:focus, select.ib-select:focus, textarea.ib-textarea:focus {
  outline: none; /* Handled by border + box-shadow */
}

/* Empty state table cell — better padding */
.ib-table__empty {
  padding: var(--ib-space-2xl) var(--ib-space-lg) !important;
}

/* Improved .ib-empty-state in table context */
td .ib-empty-state {
  padding: var(--ib-space-xl) var(--ib-space-lg);
  gap: var(--ib-space-md);
}
td .ib-empty-state i {
  font-size: 3rem;
  opacity: 1;
  color: var(--ib-text-muted);
}
td .ib-empty-state p {
  font-size: .925rem;
  color: var(--ib-text-muted);
  margin-bottom: var(--ib-space-sm);
}

/* Improved form group spacing */
.ib-form__group + .ib-form__group {
  margin-top: var(--ib-space-md);
}

/* Better placeholder color */
::placeholder { color: var(--ib-text-muted); opacity: .7; }

/* Subtle image lazy-load transition */
img { transition: opacity .2s ease; }
img[loading="lazy"] { opacity: 0; }
img[loading="lazy"].loaded { opacity: 1; }

/* Module section header */
.ib-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--ib-space-md);
  padding-bottom: var(--ib-space-sm);
  border-bottom: 1px solid var(--ib-border);
}
.ib-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ib-text);
}

/* Dark mode scrollbar */
[data-theme="dark"] * { scrollbar-color: rgba(148,163,184,.25) transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(148,163,184,.25); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.4); }
[data-theme="dark"] ::selection { background: var(--ib-primary); color: #fff; }

/* --------------------------------------------------------------------------
   17. Responsive – Mobile (max 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* --- Mobile typography --- */
  :root {
    --ib-font-size: 16px;
  }
  body {
    line-height: 1.6;
    letter-spacing: 0.01em;
  }

  /* --- Safe area insets (iPhone notch/Dynamic Island, rounded corners) --- */
  :root {
    --ib-appbar-width: 0px;
    --ib-mobile-bottombar: calc(56px + env(safe-area-inset-bottom, 0px));
    --ib-safe-top: env(safe-area-inset-top, 0px);
    --ib-safe-bottom: env(safe-area-inset-bottom, 0px);
    --ib-safe-left: env(safe-area-inset-left, 0px);
    --ib-safe-right: env(safe-area-inset-right, 0px);
    --ib-header-height: calc(46px + env(safe-area-inset-top, 0px));
  }

  .ib-appbar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--ib-mobile-bottombar);
    flex-direction: row;
    justify-content: space-around;
    padding: 0 var(--ib-safe-left) var(--ib-safe-bottom) var(--ib-safe-right);
    z-index: 1200;
    border-top: 1px solid rgba(255,255,255,.1);
  }
  .ib-appbar__nav {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 16px;
    padding: 0 12px;
    width: 100%;
    justify-content: space-around;
  }
  .ib-appbar__item {
    width: auto;
    min-width: 52px;
    height: auto;
    padding: 10px 18px;
    border-radius: 22px;
    font-size: 1.35rem;
    flex-shrink: 0;
  }
  .ib-appbar__item i { font-size: 1.4rem; }
  .ib-appbar__item--active::before { display: none; }
  .ib-appbar__item--active {
    background: rgba(255,255,255,.15);
    color: #ffffff;
  }
  .ib-appbar__item--active:hover {
    background: rgba(255,255,255,.2);
    color: #ffffff;
  }
  .ib-appbar__item--dashboard {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
  }
  .ib-appbar__item--dashboard i {
    margin-top: -4px;
    padding: 3px 0px 4px 0px;
  }
  .ib-appbar__tooltip { display: none; }
  .ib-appbar__logo { display: none; }

  /* --- Sidebar overlay from left --- */
  .ib-sidebar {
    left: 0 !important;
    top: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    width: min(280px, 85vw);
    z-index: 1300 !important;
    transform: translateX(-100%);
    border-radius: 0;
    padding-top: 0;
    padding-bottom: var(--ib-mobile-bottombar);
  }
  body.ib-sidebar-open .ib-sidebar {
    transform: translateX(0) !important;
    box-shadow: var(--ib-shadow-lg);
  }

  /* Backdrop overlay when sidebar is open */
  .ib-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1250;
    -webkit-tap-highlight-color: transparent;
  }
  body.ib-sidebar-open .ib-sidebar-backdrop {
    display: block;
  }

  /* Sidebar: larger text & spacing for touch */
  .ib-sidebar__link {
    padding: 12px 16px;
    min-height: 44px;
    font-size: 1rem;
  }
  .ib-sidebar__link--sub {
    padding: 10px 16px 10px calc(var(--ib-space-md) + 24px);
    font-size: .92rem;
    min-height: 42px;
  }
  .ib-sidebar__group-btn {
    padding: 12px 16px;
    font-size: .95rem;
    min-height: 44px;
  }
  .ib-sidebar__icon {
    width: 20px;
    font-size: 1rem;
  }
  .ib-sidebar__chevron {
    font-size: .8rem;
  }
  .ib-sidebar__subgroup-label {
    min-height: 44px;
    font-size: .92rem;
    padding: 10px 16px;
  }
  /* Freeze background scroll when sidebar is open */
  body.ib-sidebar-open {
    overflow: hidden !important;
    touch-action: none;
  }

  /* --- Main content full width --- */
  .ib-layout__main {
    margin-left: 0 !important;
    margin-top: var(--ib-header-height) !important;
    padding-bottom: var(--ib-mobile-bottombar);
    border-radius: 0;
  }
  body.ib-sidebar-closed .ib-layout__main {
    margin-left: 0 !important;
    border-radius: 0;
  }
  body.ib-layout--no-sidebar .ib-layout__main {
    border-radius: 0;
  }
  .ib-layout__content {
    padding: var(--ib-space-sm) calc(var(--ib-space-sm) + var(--ib-safe-right)) var(--ib-space-sm) calc(var(--ib-space-sm) + var(--ib-safe-left));
  }

  /* --- Header compact + safe area top --- */
  .ib-standalone .ib-header {
    padding-top: 47px;
    height: 93px !important;
  }
  .ib-header {
    padding: var(--ib-safe-top) calc(var(--ib-space-sm) + var(--ib-safe-right)) 0 calc(var(--ib-space-sm) + var(--ib-safe-left));
    gap: var(--ib-space-xs);
    height: var(--ib-header-height);
  }
  .ib-header__left { width: auto; padding: 0 0 0 var(--ib-space-xs); }
  .ib-header__logo-img { height: 22px; }
  .ib-header__main .ib-breadcrumb { display: none; }
  .ib-avatar__name { display: none; }
  .ib-avatar__chevron { display: none; }
  .ib-search-hint { display: none; }

  /* Menu open button — bigger touch target & separated from logo */
  #ib-menu-open {
    width: 44px;
    height: 44px;
    margin-left: 8px;
  }
  #ib-menu-open svg {
    width: 24px;
    height: 24px;
  }

  .ib-header__right {
    margin-right: 0;
  }

  /* Header icon buttons touch-friendly */
  .ib-header__right .ib-btn--icon,
  .ib-header__right .ib-messages-btn,
  .ib-header__right .ib-notif__btn {
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
  }

  /* Avatar image bigger on mobile */
  .ib-avatar__img {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
  }
  .ib-avatar__initial {
    width: 32px;
    height: 32px;
    font-size: .82rem;
  }
  .ib-avatar__org {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
  }

  /* --- Browser / Tables --- */
  .ib-browser { border-radius: var(--ib-radius-md); }
  .ib-browser__toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--ib-space-sm);
    padding: var(--ib-space-sm);
  }
  .ib-browser__toolbar-right {
    margin-left: 0;
    width: 100%;
  }
  .ib-browser__search {
    min-width: 0;
    max-width: none;
    width: 100%;
  }
  .ib-browser__actions { justify-content: flex-start; }
  .ib-browser__table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Table cells compact */
  .ib-table__th,
  .ib-table__td {
    padding: 8px var(--ib-space-sm);
    font-size: .82rem;
  }
  .ib-table__td--actions .ib-btn--sm {
    padding: 6px 10px;
    min-height: 36px;
  }

  /* Pagination compact */
  .ib-pagination {
    flex-direction: column;
    gap: var(--ib-space-xs);
    align-items: center;
  }
  .ib-pagination__btn {
    min-width: 36px;
    height: 36px;
  }

  /* --- Dashboard grid --- */
  .ib-dashboard__grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  /* --- Detailer --- */
  .ib-detailer { border-radius: var(--ib-radius-md); }
  .ib-detailer__grid { grid-template-columns: 1fr; }
  .ib-detailer__header {
    flex-direction: column;
    align-items: flex-start;
  }
  .ib-detailer__actions {
    width: 100%;
    justify-content: flex-end;
  }
  .ib-detailer__actions .ib-btn--danger {
    margin-left: 0;
  }
  .ib-detailer__body { padding: var(--ib-space-md); }

  /* --- Editor / Forms --- */
  .ib-editor { border-radius: var(--ib-radius-md); }
  .ib-editor__header {
    padding: var(--ib-space-sm) var(--ib-space-md);
  }
  .ib-form__fields { padding: var(--ib-space-md); }
  .ib-form__actions {
    padding: var(--ib-space-sm) var(--ib-space-md);
    flex-wrap: wrap;
    gap: var(--ib-space-xs);
  }
  .ib-form__actions .ib-btn {
    flex: 1 1 auto;
    min-height: 44px;
    justify-content: center;
  }

  /* Inputs touch-friendly */
  .ib-input,
  .ib-select,
  .ib-textarea {
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* Tabs scrollable */
  .ib-tabs__nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .ib-tabs__nav::-webkit-scrollbar { display: none; }
  .ib-tabs__btn {
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 44px;
  }

  /* Notification panel mobile */
  .ib-notif__panel {
    position: fixed;
    right: var(--ib-space-sm);
    left: var(--ib-space-sm);
    width: auto;
    max-width: none;
  }
  .ib-avatar__panel {
    right: 0;
    min-width: 220px;
  }

  /* Toast position above bottom bar */
  .ib-toast {
    left: var(--ib-space-sm);
    right: var(--ib-space-sm);
    bottom: calc(var(--ib-mobile-bottombar) + var(--ib-space-sm));
    min-width: 0;
    max-width: none;
  }

  /* Search overlay mobile */
  .ib-search-overlay__inner {
    padding: var(--ib-space-sm);
  }
  .ib-search-bar__input {
    font-size: 16px;
  }

  /* Footer compact */
  .ib-layout__footer {
    padding: var(--ib-space-sm) var(--ib-space-md);
    font-size: .75rem;
  }

  /* Widgets grid */
  .ib-widgets { grid-template-columns: 1fr; }
  .ib-widget-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .ib-widgets-section { padding: var(--ib-space-md); }
  .ib-dashboard-grid { grid-template-columns: 1fr; }

  /* Browser filters */
  .ib-browser__filters-content {
    display: flex;
    flex-direction: column;
  }

}

@media (max-width: 480px) {
  .ib-dashboard__grid {
    grid-template-columns: 1fr 1fr;
  }
  .ib-kpi-card {
    flex: 1 1 calc(50% - .75rem);
  }
  .ib-login-page {
    padding: 1rem;
  }
  .ib-login-box {
    padding: var(--ib-space-lg);
    border: none;
    box-shadow: none;
  }
  /* Even more compact table */
  .ib-table__th,
  .ib-table__td {
    padding: 6px 8px;
    font-size: .78rem;
  }
}

/* --ib-sat kept at 0px for backwards compat (mail.css references it) */
:root { --ib-sat: 0px; }

/* --------------------------------------------------------------------------
   Sidebar mobile brand
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .ib-sidebar {
    scrollbar-width: none;
  }
  .ib-sidebar::-webkit-scrollbar {
    display: none;
  }
  .ib-sidebar__header {
    margin-top: 20px;
    padding-bottom: 10px;
  }
}
@media (max-width: 768px) and (display-mode: standalone) {
  .ib-sidebar__header {
    margin-top: 50px;
  }
}

/* --------------------------------------------------------------------------
   PWA standalone safe-area utilities
   Use .ib-safe-top on any element that needs top padding in standalone mode
   (status bar: clock, signal, battery). Same for bottom, left, right.
   -------------------------------------------------------------------------- */
@media (display-mode: standalone) {
  .ib-safe-top    { padding-top:    calc(var(--ib-safe-top, 0px) + 8px) !important; }
  .ib-safe-bottom { padding-bottom: calc(var(--ib-safe-bottom, 0px) + 8px) !important; }
  .ib-safe-left   { padding-left:   calc(var(--ib-safe-left, 0px) + 8px) !important; }
  .ib-safe-right  { padding-right:  calc(var(--ib-safe-right, 0px) + 8px) !important; }
}

/* --------------------------------------------------------------------------
   PWA install banner
   -------------------------------------------------------------------------- */
.ib-pwa-banner {
  position: fixed;
  bottom: calc(var(--ib-mobile-bottombar, 56px) + 12px);
  left: 12px;
  right: 12px;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.08);
  transform: translateY(120%);
  opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
}
.ib-pwa-banner--visible {
  transform: translateY(0);
  opacity: 1;
}
.ib-pwa-banner__content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.ib-pwa-banner__icon {
  width: 36px;
  height: 36px;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}
.ib-pwa-banner__text {
  font-size: .82rem;
  line-height: 1.4;
}
.ib-pwa-banner__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ib-pwa-banner__btn {
  background: #fff;
  color: #000;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
}
.ib-pwa-banner__close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
}
[data-theme="dark"] .ib-pwa-banner {
  background: #fff;
  color: #111;
  border-color: rgba(0,0,0,.08);
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
[data-theme="dark"] .ib-pwa-banner__icon {
  filter: none;
}
[data-theme="dark"] .ib-pwa-banner__text {
  color: #222;
}
[data-theme="dark"] .ib-pwa-banner__btn {
  background: #000;
  color: #fff;
}
[data-theme="dark"] .ib-pwa-banner__close {
  color: #666;
}

/* iOS PWA help overlay */
.ib-pwa-ios-help {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 16px 32px;
}
.ib-pwa-ios-help__box {
  background: #fff;
  color: #111;
  border-radius: 16px;
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.ib-pwa-ios-help__box p {
  font-size: .9rem;
  line-height: 1.6;
  margin: 0 0 12px;
}
.ib-pwa-ios-help__box i {
  color: inherit;
  font-size: 1.1em;
}
.ib-pwa-ios-help__note {
  font-size: .78rem;
  color: #888;
  font-style: italic;
  margin: 8px 0 4px;
}
.ib-pwa-ios-help__ok {
  background: #000;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 28px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

/* Input group with prefix/suffix */
.ib-input-group{display:flex;align-items:stretch}
.ib-input-group__prefix,.ib-input-group__suffix{display:flex;align-items:center;padding:0 10px;background:var(--ib-surface-2,#f3f4f6);border:1px solid var(--ib-border,#d1d5db);font-size:.85rem;color:var(--ib-text-muted,#6b7280);font-weight:600}
.ib-input-group__prefix{border-right:none;border-radius:var(--ib-radius,6px) 0 0 var(--ib-radius,6px)}
.ib-input-group__suffix{border-left:none;border-radius:0 var(--ib-radius,6px) var(--ib-radius,6px) 0}
.ib-input-group .ib-input--has-prefix{border-radius:0 var(--ib-radius,6px) var(--ib-radius,6px) 0;flex:1;min-width:0}
.ib-input-group .ib-input--has-suffix{border-radius:var(--ib-radius,6px) 0 0 var(--ib-radius,6px);flex:1;min-width:0}
[data-theme="dark"] .ib-input-group__prefix,[data-theme="dark"] .ib-input-group__suffix{background:var(--ib-surface-2,#2a2a2a);border-color:var(--ib-border,#444);color:var(--ib-text-muted,#999)}
