/* FS CRM — hoster-inspired UI (no Tabler) */

:root,
[data-theme="dark"] {
  --bg: #1b2137;
  --bg-elevated: #182032;
  --bg-card: #1a2436;
  --bg-row: #232b49;
  --bg-toolbar: #36406e;
  --bg-input: #121a28;
  --bg-hover: #1e2a40;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #eef1f8;
  --text-muted: #8b93a7;
  --text-dim: #6b7388;
  --accent: #4d7cff;
  --accent-hover: #3d6ae8;
  --accent-soft: rgba(77, 124, 255, 0.16);
  --nav: rgba(238, 241, 248, 0.72);
  --nav-active: #ffffff;
  --success: #2ecc71;
  --danger: #e74c3c;
  --warning: #f39c12;
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 220px;
  --rail-w: 64px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --font: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
  --bg: #e8ecf3;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-row: #f4f6fa;
  --bg-toolbar: #e8ecf4;
  --bg-input: #f5f7fb;
  --bg-hover: #e8ecf4;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #1a2035;
  --text-muted: #5c6578;
  --text-dim: #8a93a6;
  --accent: #3d5ce0;
  --accent-hover: #2f4bc4;
  --accent-soft: rgba(61, 92, 224, 0.12);
  --nav: rgba(26, 32, 53, 0.7);
  --nav-active: #1a2035;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* Layout — page bg everywhere; content chrome merges with active tab */
.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-w);
  background: transparent;
  color: var(--nav);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 1040;
  border: none;
}

.sidebar-brand {
  padding: 1.25rem 1.1rem 1rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sidebar-brand a {
  color: var(--nav-active);
  text-decoration: none;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0.75rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.sidebar-nav > li.nav-item {
  position: relative;
  margin: 0.08rem 0;
}

.sidebar-nav .nav-row {
  display: flex;
  align-items: center;
  border-radius: 999px;
  color: var(--nav);
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-row:hover,
.sidebar-nav .nav-row.active {
  background: linear-gradient(
    90deg,
    rgba(77, 124, 255, 0.42) 0%,
    rgba(77, 124, 255, 0.22) 40%,
    rgba(77, 124, 255, 0.06) 75%,
    rgba(77, 124, 255, 0.01) 100%
  );
  color: var(--nav-active);
}

.sidebar-nav .nav-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.75rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
  border-radius: 999px;
}

.sidebar-nav .nav-main:hover {
  text-decoration: none;
  color: inherit;
}

.sidebar-nav .nav-main.active {
  font-weight: 600;
  color: var(--nav-active);
}

.sidebar-nav .nav-main.active .nav-icon {
  color: #7a97ff;
  opacity: 1;
}

.sidebar-nav .nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
  color: inherit;
}

.sidebar-nav .nav-newtab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 0.4rem;
  border-radius: 999px;
  color: var(--text-dim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-nav .nav-row:hover .nav-newtab {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-nav .nav-newtab:hover {
  background: rgba(255,255,255,0.1);
  color: var(--nav-active);
  text-decoration: none;
}

.sidebar-nav .nav-newtab svg {
  width: 15px;
  height: 15px;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 0.65rem 0.5rem;
  list-style: none;
  padding: 0;
}

.sidebar-nav .nav-group {
  list-style: none;
  margin: 0.08rem 0;
}

.sidebar-nav .nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-align: left;
}

.sidebar-nav .nav-group-toggle .nav-main {
  pointer-events: none;
}

.sidebar-nav .nav-group-chevron {
  width: 16px;
  height: 16px;
  margin-right: 0.65rem;
  flex-shrink: 0;
  opacity: 0.65;
  color: inherit;
  transition: transform 0.15s ease;
}

.sidebar-nav .nav-group.open .nav-group-chevron {
  transform: rotate(180deg);
}

.sidebar-nav .nav-sub {
  list-style: none;
  margin: 0.15rem 0 0.35rem;
  padding: 0 0 0 0.85rem;
  display: none;
}

.sidebar-nav .nav-group.open > .nav-sub {
  display: block;
}

.sidebar-nav .nav-sub .nav-item {
  margin: 0.06rem 0;
}

.sidebar-nav .nav-sub .nav-main {
  padding: 0.45rem 0.65rem;
}

.sidebar-nav .nav-sub .nav-icon {
  width: 16px;
  height: 16px;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* Right utility rail (hoster-style) */
.rail {
  display: none;
  width: var(--rail-w);
  flex-shrink: 0;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  padding: 1.15rem 0.5rem;
  background: transparent;
  z-index: 20;
}

.rail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}

.rail-btn svg {
  width: 18px;
  height: 18px;
}

.rail-btn:hover {
  color: var(--text);
  background: var(--accent-soft);
  border-color: transparent;
}

.dropdown-rail {
  position: relative;
}

.dropdown-rail .dropdown-menu {
  right: calc(100% + 0.55rem);
  left: auto;
  top: 0;
  min-width: 180px;
}

.dropdown-label {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.35rem 0.35rem 0.85rem 0;
}

/* Desktop tab bar — merges with workspace-chrome / toolbar */
.tab-bar {
  display: none;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.55rem 0.15rem 0;
  background: transparent;
  border: none;
  overflow-x: auto;
  min-height: 36px;
}

.tab-bar-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: 160px;
  max-width: 160px;
  flex: 0 0 160px;
  height: 36px;
  padding: 0 0.35rem 0 0.65rem;
  border-radius: 10px 10px 0 0;
  background: #121525;
  color: #fff;
  border: 1px solid transparent;
  border-bottom: none;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  font-size: 14px;
  position: relative;
  box-sizing: border-box;
}

.tab-bar-item.pinned {
  width: 40px;
  max-width: 40px;
  flex: 0 0 40px;
  padding: 0;
  justify-content: center;
  background: #121525;
  color: #fff;
}

.tab-bar-item.pinned .tab-title {
  display: none;
}

.tab-bar-item .tab-ico {
  width: 14px;
  height: 14px;
  opacity: 1;
  flex-shrink: 0;
  color: #fff;
}

.tab-bar-item.pinned .tab-ico {
  width: 16px;
  height: 16px;
  opacity: 1;
  color: #fff;
}

.tab-bar-item:hover {
  background: #16182c;
  color: #fff;
  text-decoration: none;
}

.tab-bar-item.active {
  background: var(--bg-row);
  color: #fff;
  border-color: transparent;
  z-index: 2;
  margin-bottom: 0;
}

.tab-bar-item.pinned.active {
  background: var(--bg-row);
  color: #fff;
}

.tab-bar-item.active .tab-ico {
  opacity: 1;
  color: #fff;
}

.tab-bar-item .tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.tab-bar-item .tab-close svg {
  width: 14px;
  height: 14px;
}

.tab-bar-item .tab-close:hover {
  background: var(--bg-hover);
  color: var(--danger);
}

.tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

.workspace-body {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0 0.15rem 1.25rem;
  min-height: 0;
  box-shadow: none;
}

@media (min-width: 992px) {
  .workspace-body {
    border-radius: 0;
  }
}

/* Shared panel: active tab + title + toolbar */
.workspace-chrome {
  background: var(--bg-row);
  border-radius: 14px 14px 14px 14px;
  padding: 1rem 1.15rem 1rem;
  margin-bottom: 1rem;
}

.workspace-chrome .page-title-row {
  margin-bottom: 0.85rem;
}

.workspace-chrome .toolbar {
  background: var(--bg-toolbar);
  border-color: transparent;
  margin-bottom: 0;
}

/* Mobile top header */
.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.icon-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  text-decoration: none;
}

.icon-btn-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.content {
  padding: 0;
  flex: 1;
}

.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
}

/* Cards / panels */
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.panel + .panel { margin-top: 1rem; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

/* Quick actions carousel */
.quick-actions {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  margin-bottom: 1rem;
  scrollbar-width: thin;
}

.quick-card {
  flex: 0 0 auto;
  width: 160px;
  min-height: 88px;
  padding: 0.85rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.quick-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.quick-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}

.quick-card-icon {
  align-self: flex-end;
  opacity: 0.7;
  width: 22px;
  height: 22px;
}

/* Stat widgets */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-widget {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.stat-widget .value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-widget .label {
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.stat-widget.accent-a .value { color: #7b8cff; }
.stat-widget.accent-b .value { color: #3dd6c6; }
.stat-widget.accent-c .value { color: #f0a35a; }
.stat-widget.accent-d .value { color: #5ab0ff; }
.stat-widget.accent-e .value { color: #e87ab5; }
.stat-widget.accent-f .value { color: #ff6b6b; }

/* Toolbar / hot actions — pill capsule */
.toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.25rem;
  height: 40px;
  min-height: 40px;
  padding: 0 0.4rem;
  background: var(--bg-toolbar);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 1rem;
  box-sizing: border-box;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  height: 100%;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  align-self: center;
  min-height: 0;
  margin: 0 0.35rem;
  background: var(--border-strong);
}

.toolbar-hot {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.toolbar-hot.enabled {
  opacity: 1;
  pointer-events: auto;
}

.toolbar .btn,
.toolbar .icon-btn {
  border-radius: 999px;
  height: 32px;
  width: 32px;
  padding: 0;
  box-sizing: border-box;
}

.toolbar .btn-primary {
  width: auto;
  padding-left: 0.85rem;
  padding-right: 0.85rem;
  font-size: 13px;
}

.toolbar-tools {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.toolbar-search {
  display: none;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.25rem;
  flex: 0 1 auto;
  width: auto;
  max-width: 280px;
}

.toolbar-search.open {
  display: inline-flex;
}

.toolbar-search .form-control {
  width: 180px;
  min-width: 140px;
  height: 28px;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  border-color: transparent;
  font-size: 13px;
}

.toolbar-search .btn {
  height: 28px;
  padding: 0 0.65rem;
  border-radius: 999px;
  flex-shrink: 0;
  width: auto;
}

.toolbar-search-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--bg-hover);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; filter: brightness(1.05); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); color: #fff; }

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

.btn-danger {
  background: transparent;
  border-color: rgba(231, 76, 60, 0.45);
  color: var(--danger);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* Forms */
.form-group { margin-bottom: 0.9rem; }

.form-label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-control,
.form-select,
textarea.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-footer-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 0;
  margin-top: 1rem;
  background: linear-gradient(transparent, var(--bg) 30%);
  z-index: 5;
}

/* Accordion */
.accordion { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-card); }
.accordion + .accordion { margin-top: 0.65rem; }

.accordion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.85rem 1rem;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  text-align: left;
}

.accordion-body {
  display: none;
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
}

.accordion.open .accordion-body { display: block; }
.accordion-chevron {
  width: 18px;
  height: 18px;
  transition: transform 0.15s;
  flex-shrink: 0;
  opacity: 0.7;
}
.accordion.open .accordion-chevron { transform: rotate(180deg); }

/* Entity lists — header + rows same height/surface */
.entity-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: transparent;
  border: none;
  overflow: visible;
  font-size: 14px;
}

.entity-list-head {
  display: grid;
  grid-template-columns: 40px minmax(120px, 1.5fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 40px;
  height: 40px;
  padding: 0 1rem;
  border: none;
  border-radius: 16px;
  background: var(--bg-row);
  color: #7a97ff;
  font-size: 14px;
  font-weight: 400;
  box-sizing: border-box;
}

.entity-list-head > span,
.entity-list-head > .entity-col {
  color: #7a97ff !important;
  font-weight: 400;
  font-size: 14px !important;
}

.entity-list-head > span:nth-child(2) {
  min-width: 0;
}

.entity-list-head > .entity-col,
.entity-list-head > [data-sort] {
  cursor: pointer;
  user-select: none;
}

.entity-list-head > [data-sort]:hover {
  color: #a8bbff !important;
}

.entity-list-head > [data-sort].sort-asc::after,
.entity-list-head > [data-sort].sort-desc::after {
  content: "";
  display: inline-block;
  margin-left: 0.35rem;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  vertical-align: middle;
}

.entity-list-head > [data-sort].sort-asc::after {
  border-bottom: 5px solid #7a97ff;
}

.entity-list-head > [data-sort].sort-desc::after {
  border-top: 5px solid #7a97ff;
}

.entity-list-head > .entity-col {
  border-left: 1px solid rgba(122, 151, 255, 0.32);
  padding-left: 0.85rem;
  min-width: 0;
  display: none;
}

[data-theme="light"] .entity-list-head,
[data-theme="light"] .entity-list-head > span,
[data-theme="light"] .entity-list-head > .entity-col {
  color: #7a97ff !important;
}

[data-theme="light"] .entity-list-head > .entity-col {
  border-left-color: rgba(122, 151, 255, 0.4);
}

.entity-row,
.row-card {
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--bg-row);
  overflow: visible;
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.entity-row:hover,
.row-card:hover {
  border-color: #4d7cff;
}

.entity-row.is-selected,
.row-card.is-selected {
  background: #121525;
}

.entity-row.is-selected .entity-row-main:hover,
.row-card.is-selected .row-card-main:hover {
  background: transparent;
}

.entity-row-main,
.row-card-main {
  display: grid;
  grid-template-columns: 40px minmax(120px, 1.5fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 40px;
  height: 40px;
  padding: 0 1rem;
  border-radius: inherit;
  box-sizing: border-box;
  font-size: 14px;
  font-weight: 400;
  color: #fff;
}

.entity-row-main:hover,
.row-card-main:hover {
  background: var(--bg-hover);
}

.entity-check {
  display: flex;
  align-items: center;
  justify-content: center;
}

.entity-check input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  vertical-align: middle;
}

.entity-check input[type="checkbox"]:hover {
  border-color: rgba(122, 151, 255, 0.7);
}

.entity-check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.entity-check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

[data-theme="light"] .entity-check input[type="checkbox"] {
  border-color: rgba(15, 23, 42, 0.28);
}

.entity-primary {
  min-width: 0;
  overflow: hidden;
}

.entity-name {
  font-weight: 400;
  color: #fff;
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
  font-size: inherit;
  cursor: inherit;
}

.entity-name:hover {
  color: #fff;
  text-decoration: none;
}

.entity-meta {
  color: var(--text-muted);
  font-size: inherit;
  margin-top: 0.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-col {
  display: none;
  color: #fff;
  font-size: inherit;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  line-height: 1.3;
}

[data-theme="light"] .entity-row-main,
[data-theme="light"] .row-card-main,
[data-theme="light"] .entity-name,
[data-theme="light"] .entity-col {
  color: var(--text);
}

.entity-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  height: 100%;
}

.entity-actions-slot {
  width: 72px;
}

.entity-actions .icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border-color: transparent;
}

.entity-actions .btn-expand svg {
  transition: transform 0.15s ease;
}

.entity-row.expanded .btn-expand svg,
.row-card.expanded .btn-expand svg {
  transform: rotate(180deg);
}

.entity-row.expanded,
.row-card.expanded {
  border-radius: 16px;
}

.entity-details {
  display: none;
  padding: 0 1rem 0.85rem 3rem;
}

.entity-row.expanded .entity-details,
.row-card.expanded .entity-details { display: block; }

.entity-details-inner {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background: var(--bg-input);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-muted); }
.detail-row .v { text-align: right; }

.list-footer {
  padding: 0.35rem 0.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Desktop multi-column lists (hoster-like) */
@media (min-width: 992px) {
  .entity-list[data-cols] .entity-list-head,
  .entity-list[data-cols] .entity-row-main {
    grid-template-columns: 40px minmax(160px, 1.6fr) minmax(100px, 1fr) minmax(90px, 0.9fr) minmax(70px, 0.7fr) 72px;
  }

  .entity-list[data-cols] .entity-col {
    display: block;
  }

  .entity-list[data-cols] .entity-meta {
    display: none;
  }

  .entity-list[data-cols] .entity-row-main > .entity-col {
    padding-left: 0.85rem;
    border-left: 1px solid transparent;
  }

  .entity-list[data-cols] .entity-row:hover .entity-row-main > .entity-col {
    border-left-color: rgba(122, 151, 255, 0.32);
  }

  .entity-row,
  .row-card,
  .entity-list-head {
    border-radius: 16px;
  }
}

/* Desktop table as separated cards */
.table-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.table-cards-head {
  display: grid;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: #8fa4ff;
  font-size: 0.78rem;
  font-weight: 600;
}

[data-theme="light"] .table-cards-head {
  color: var(--accent);
}

.table-cards-row {
  display: grid;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.table-cards-row:hover {
  background: var(--bg-hover);
}

/* Desktop table variant */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-elevated);
}

.data-table tr:hover td { background: var(--bg-hover); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}

.badge-success { background: var(--success); }
.badge-danger { background: var(--danger); }
.badge-warning { background: var(--warning); color: #1a1a1a; }
.badge-muted { background: var(--text-dim); }

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.85rem;
  border: 1px solid var(--border);
}

.alert-success { background: rgba(46, 204, 113, 0.12); border-color: rgba(46, 204, 113, 0.35); }
.alert-danger { background: rgba(231, 76, 60, 0.12); border-color: rgba(231, 76, 60, 0.35); }

.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2200;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

@media (min-width: 992px) {
  .toast-stack {
    right: calc(var(--rail-w) + 0.75rem);
  }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-hiding {
  opacity: 0;
  transform: translateY(-6px);
}

.toast-message {
  flex: 1;
  min-width: 0;
}

.toast-close {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 0;
}

.toast-close:hover {
  color: var(--text);
}

.toast-success {
  border-color: rgba(46, 204, 113, 0.4);
  background: linear-gradient(180deg, rgba(46, 204, 113, 0.14), var(--bg-elevated) 70%);
}

.toast-danger {
  border-color: rgba(231, 76, 60, 0.45);
  background: linear-gradient(180deg, rgba(231, 76, 60, 0.16), var(--bg-elevated) 70%);
}

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 110%;
  min-width: 160px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 50;
  padding: 0.35rem;
}

.dropdown.open .dropdown-menu { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.dropdown-item-danger {
  color: var(--danger);
}

.dropdown-item-danger:hover {
  background: rgba(231, 76, 60, 0.12);
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal {
  width: min(640px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  border-bottom: none;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.modal-body { padding: 1rem; }

.modal-sm {
  width: min(420px, 100%);
}

.modal-confirm .modal-header {
  border-bottom: none;
  padding-bottom: 0.25rem;
}

.modal-confirm .modal-body {
  color: var(--text-muted);
  padding-top: 0.35rem;
}

.modal-confirm .modal-footer {
  border-top: none;
  padding-top: 0.25rem;
}

.modal-confirm .modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(231, 76, 60, 0.15);
  color: var(--danger);
  margin-bottom: 0.35rem;
}

.modal-confirm .modal-icon svg {
  width: 20px;
  height: 20px;
}

.mac-row { margin-bottom: 0.5rem; }

.timeline-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child { border-bottom: none; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1035;
}

body.sidebar-open .sidebar-backdrop { display: block; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.login-card {
  width: min(400px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.login-card h1 {
  margin: 0 0 0.25rem;
  text-align: center;
}

.login-card h2 {
  margin: 0 0 1.25rem;
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 500;
}

.locale-switch {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 1rem;
}

/* Tom Select override */
.ts-wrapper .ts-control {
  background: var(--bg-input) !important;
  border-color: var(--border-strong) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text) !important;
}

.ts-dropdown {
  background: var(--bg-elevated) !important;
  border-color: var(--border-strong) !important;
  color: var(--text) !important;
  z-index: 2100 !important;
}

.ts-dropdown .option.active,
.ts-dropdown .option:hover {
  background: var(--accent-soft) !important;
  color: var(--text) !important;
}

/* Responsive */
.top-actions {
  display: none;
}

@media (min-width: 992px) {
  .mobile-header { display: none; }
  .tab-bar { display: flex; }
  .rail { display: flex; }
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .mobile-only { display: none !important; }
  .desktop-only { display: block; }
}

@media (max-width: 991.98px) {
  .app { display: block; }
  .rail { display: none !important; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    max-width: 85vw;
    border-right: 1px solid var(--border);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .desktop-only { display: none !important; }
  .mobile-only { display: block; }

  .workspace {
    padding: 0 0.75rem 0.75rem;
  }

  .toolbar {
    flex-wrap: wrap;
    border-radius: 16px;
    height: auto;
    min-height: 40px;
    padding: 0.35rem 0.4rem;
  }

  .toolbar-tools {
    margin-left: 0;
    justify-content: flex-start;
  }

  .sidebar-nav .nav-newtab {
    opacity: 1;
    pointer-events: auto;
  }

  .entity-list-head {
    display: none;
  }

  .entity-row,
  .row-card {
    border-radius: var(--radius);
  }

  .entity-row-main,
  .row-card-main {
    height: auto;
    min-height: 40px;
    padding: 0.55rem 1rem;
  }

  .workspace-chrome {
    border-radius: 14px;
  }
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 992px) {
  .grid-2 { grid-template-columns: 1.6fr 1fr; }
}

.empty-state {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.user-chip {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Entity card tabs (partner form) */
.entity-tabs {
  margin-top: 0.25rem;
}

.entity-tabs-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

.entity-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  padding: 0.55rem 0.9rem;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
}

.entity-tab:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.entity-tab.active {
  color: var(--nav-active);
  background: linear-gradient(90deg, rgba(77, 124, 255, 0.28), transparent);
}

.entity-tab-panel {
  display: none;
}

.entity-tab-panel.active {
  display: block;
}

.form-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 992px) {
  .form-split {
    grid-template-columns: minmax(280px, 1fr) minmax(300px, 1.05fr);
  }
}

.form-split-main .form-group:last-child {
  margin-bottom: 0;
}

.feed-panel {
  background: var(--bg-row);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 280px;
}

.feed-title {
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.feed-compose {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.feed-compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.feed-attach {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.feed-item {
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}

.feed-item:first-child {
  border-top: none;
  padding-top: 0;
}

.feed-item-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.45rem;
}

.feed-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}

.feed-author {
  font-size: 14px;
}

.feed-body {
  font-size: 14px;
  line-height: 1.45;
}

.feed-item-system {
  padding: 0.55rem 0;
}

.feed-system-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 13px;
}

.feed-system-action {
  color: var(--text-muted);
  font-weight: 500;
}

.feed-system-time {
  margin-left: auto;
  font-size: 12px;
}

.feed-system-desc {
  margin-top: 0.2rem;
  padding-left: 0;
}

.feed-files {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.feed-file {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 13px;
  color: var(--accent);
}

.history-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  max-width: 360px;
  color: var(--text-muted);
}

.history-table-wrap {
  overflow: auto;
  border-radius: var(--radius);
  background: var(--bg-row);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.history-table th,
.history-table td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.history-table th {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

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

.history-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-date {
  white-space: nowrap;
  color: var(--text-muted);
}

.history-desc {
  color: var(--text-muted);
}

.history-row.is-hidden {
  display: none;
}
