:root {
  --cv-red: #e31d23;
  --cv-dark: #1a1a1a;
  --toolbar-bg: linear-gradient(180deg, #fbfbfc 0%, #f0f2f5 100%);
  --toolbar-border: #d4d8df;
  --toolbar-shadow: 0 8px 18px rgba(20, 24, 31, 0.12);
}
.desktop-only { display: inline-flex; }
.mobile-only { display: none !important; }

html, body {
  height: 100%;
  overflow-x: hidden;
  touch-action: manipulation;
}

@media (max-width: 900px) {
  html, body {
    font-size: 14px;
  }
  .modern-topbar {
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 10px 12px 8px;
  }
  .modern-topbar-brand {
    flex: 1 1 auto;
    min-width: 0;
    padding-top: 2px;
  }
  .crm-nav-toggle-btn {
    display: inline-flex;
  }
  .modern-topbar-logo {
    max-height: 28px;
    max-width: min(220px, 48vw);
  }
  .modern-topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: auto;
    gap: 0;
    flex: 0 0 auto;
  }
  input,
  select,
  textarea,
  button {
    font-size: 16px;
  }
  .topbar-action-btn {
    display: none !important;
  }
  .topbar-user-menu {
    margin-left: 0;
  }
  .topbar-user-trigger {
    min-height: 34px;
    padding: 0 8px 0 6px;
    gap: 8px;
  }
  .topbar-user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.78rem;
  }
  .topbar-user-name {
    font-size: 0.84rem;
  }
  .topbar-user-caret {
    font-size: 0.74rem;
  }
  .topbar-user-dropdown {
    min-width: 180px;
    padding: 6px;
  }
  .topbar-dropdown-btn {
    min-height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 0.9rem;
  }
  .topbar-dropdown-btn:hover {
    background: #fff4f5;
    color: var(--cv-red);
  }
  .topbar-dropdown-separator {
    height: 1px;
    margin: 4px 6px;
    background: #e5e7eb;
  }
  .topbar {
    justify-content: flex-start;
    padding: 8px 10px;
  }
  .topbar-logo--desktop { display: none; }
  .topbar-logo--mobile {
    display: block;
    width: 34px;
    height: 34px;
    max-width: 34px;
    max-height: 34px;
    margin: 0;
  }
  .topbar-user {
    right: 8px;
    padding: 6px 9px;
    font-size: 0.8rem;
  }
  .tab-btn, .workspace-tab, .topbar-user, .navbar, .nav-actions { font-size: 0.97rem; }
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; width: 100%; margin: 0.5em 0; font-size: 1.1em; padding: 8px; border-radius: 8px; border: 1px solid #bcc5d2; }
  .frame-shell {
    border-radius: 0;
  }
}

/* Mobile/touch fallback so logo swap still happens when viewport width reports large */
@media (hover: none) and (pointer: coarse) {
  .topbar {
    justify-content: flex-start;
    padding: 8px 10px;
  }
  .topbar-logo--desktop { display: none !important; }
  .topbar-logo--mobile {
    display: block !important;
    width: 34px;
    height: 34px;
    max-width: 34px;
    max-height: 34px;
    margin: 0;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #ffffff;
  color: var(--cv-dark);
  font-family: "Bahnschrift", "Segoe UI", "Trebuchet MS", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

.is-hidden {
  display: none !important;
}

.modern-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid #d9e1ea;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 26px rgba(17, 24, 39, 0.05);
}

.modern-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.crm-nav-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid #d9e1ea;
  border-radius: 12px;
  background: #ffffff;
  color: #1f2937;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.crm-nav-toggle-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modern-topbar-logo {
  display: block;
  height: auto;
  max-height: 38px;
  max-width: min(360px, 42vw);
}

.modern-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid #d9e1ea;
  background: #ffffff;
  color: #1f2937;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.topbar-action-btn:hover {
  border-color: #f0b7bd;
  box-shadow: 0 10px 24px rgba(214, 24, 40, 0.09);
  transform: translateY(-1px);
}

.topbar-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--cv-red);
  font-size: 1rem;
  line-height: 1;
}

.topbar-action-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-user-menu {
  position: relative;
}

.topbar-user-menu[hidden] {
  display: none !important;
}

.topbar-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 10px 0 8px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: #ffffff;
  cursor: pointer;
  list-style: none;
}

.topbar-user-trigger:hover {
  border-color: #f0b7bd;
  box-shadow: 0 10px 24px rgba(214, 24, 40, 0.09);
}

.topbar-user-trigger::-webkit-details-marker {
  display: none;
}

.topbar-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: #eef2f7;
  color: #374151;
  font-weight: 800;
}

.topbar-user-name {
  font-weight: 700;
  color: #1f2937;
}

.topbar-user-caret {
  color: #4b5563;
  font-size: 0.92rem;
}

.topbar-user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 160px;
  padding: 8px;
  border: 1px solid #d9e1ea;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.12);
}

.topbar-dropdown-btn {
  width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #111827;
  font: inherit;
  font-weight: 700;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.topbar-dropdown-btn:hover {
  background: #fff4f5;
  color: var(--cv-red);
}

.topbar-dropdown-separator {
  height: 1px;
  margin: 4px 6px;
  background: #e5e7eb;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 0 10px 16px;
  background: #ffffff;
  border-bottom: 3px solid var(--cv-red);
  position: relative;
}

.topbar-logo {
  display: block;
  height: auto;
  max-height: 38px;
  max-width: min(420px, 65vw);
}

.topbar-logo--mobile {
  display: none;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  position: absolute;
  right: 12px;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--toolbar-border);
  box-shadow: var(--toolbar-shadow);
}

.workspace-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 280px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid #c9d1dc;
  background: #f8fafc;
  color: #314052;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.workspace-tab:hover {
  background: #ffffff;
  border-color: #b5c0cf;
}

.workspace-tab.active {
  background: #ffffff;
  border-color: var(--cv-red);
  box-shadow: 0 4px 12px rgba(227, 29, 35, 0.15);
}

.workspace-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-tab-close {
  border: none;
  background: transparent;
  color: #6b7788;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
}

.workspace-tab-close:hover {
  color: var(--cv-red);
}

.workspace-tab-dirty {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--cv-red);
  box-shadow: 0 0 0 3px rgba(227, 29, 35, 0.12);
  flex: 0 0 auto;
}

.tab-btn {
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid #bcc5d2;
  background: #ffffff;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.tab-btn.active {
  background: var(--cv-red);
  color: #fff;
  border-color: var(--cv-red);
  box-shadow: 0 5px 14px rgba(227, 29, 35, 0.35);
}

.frame-wrapper {
  padding: 0;
  width: 100%;
  min-height: 0;
}

.frame-wrapper-topbar {
  padding: 0;
}

.frame-shell-topbar {
  height: 100%;
}

.sync-toast {
  position: fixed;
  top: 86px;
  right: 16px;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  color: #f8fafc;
  font-size: 0.95rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
}

.sync-toast[hidden] {
  display: none !important;
}

.sync-toast::before {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: #f8fafc;
  animation: sync-toast-pulse 1.2s ease-in-out infinite;
}

@keyframes sync-toast-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.6; }
}

.frame-shell {
  background: #ffffff;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  height: 100%;
  position: relative;
  transition: height 150ms ease;
}

.frame-shell-loading {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(247, 249, 252, 0.94) 100%);
  color: #314052;
  font-weight: 800;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.frame-shell.is-loading .frame-shell-loading {
  opacity: 1;
}

.frame-shell-loading[hidden] {
  display: grid !important;
}

.frame-shell-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  margin-right: 10px;
  border-radius: 999px;
  border: 2px solid rgba(227, 29, 35, 0.18);
  border-top-color: var(--cv-red);
  animation: frame-shell-spin 0.9s linear infinite;
}

@keyframes frame-shell-spin {
  to { transform: rotate(360deg); }
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 1rem;
}

.modal-card {
  width: min(760px, 100%);
  border-radius: 16px;
  background: #fff;
  border: 1px solid #d8dce4;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
  padding: 1.25rem 1.4rem;
  display: grid;
  gap: 1rem;
}

.modal-row {
  display: grid;
  gap: 0.45rem;
}

.modal-row label {
  font-weight: 700;
  color: #24324a;
}

.modal-row input[type="search"],
.modal-row input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 0.8rem 0.95rem;
  border: 1px solid #d2dae3;
  border-radius: 10px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.modal-row input[type="search"]:focus,
.modal-row input[type="text"]:focus {
  border-color: var(--cv-red);
  box-shadow: 0 0 0 3px rgba(227, 29, 35, 0.12);
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid #d2dae3;
  border-radius: 10px;
  background: #f9fbff;
}

.search-results li {
  padding: 0.8rem 0.95rem;
  border-bottom: 1px solid #e9edf2;
  cursor: pointer;
  color: #162a45;
}

.search-results li:last-child {
  border-bottom: none;
}

.search-results li:hover {
  background: rgba(227, 29, 35, 0.05);
}

.search-results li.error,
.search-results li.empty {
  cursor: default;
  color: #475569;
  background: transparent;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-message {
  padding: 0.95rem 1rem;
  border-radius: 12px;
  background: #fff2f2;
  color: #a32f2f;
  border: 1px solid #f2d6d6;
  font-weight: 600;
}

#morawareSelectedCustomer {
  min-height: 36px;
  padding: 0.75rem 0.95rem;
  color: #202a3c;
  border: 1px solid #d2dae3;
  border-radius: 10px;
  background: #f7f9fb;
}
iframe.tool-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  max-width: 100vw;
  max-height: 100vh;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease;
  background: #ffffff;
}
iframe.tool-frame.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Collapsible table styles */
.collapsible-table { width: 100%; border-collapse: collapse; }
.collapsible-table th, .collapsible-table td { padding: 8px 6px; border-bottom: 1px solid #e0e4ea; }
.collapsible-table .collapsible-row { cursor: pointer; background: #f7f9fb; }
.collapsible-table .collapsible-content { display: none; background: #f9fafb; }
.collapsible-table .collapsible-row.open + .collapsible-content { display: table-row; }

.helper-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 6px;
  color: #4b5666;
  font-size: 0.9rem;
}

.helper-row a {
  color: var(--cv-red);
  font-weight: 700;
  text-decoration: none;
}

.hub-status-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background: rgba(16, 24, 40, 0.28);
  backdrop-filter: blur(2px);
}

.hub-status-overlay[hidden] {
  display: none !important;
}

.hub-status-card {
  min-width: 320px;
  max-width: min(92vw, 440px);
  padding: 20px 22px;
  border-radius: 16px;
  border: 1px solid #d8dee8;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
}

.hub-status-spinner {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 3px solid #d7dce6;
  border-top-color: var(--cv-red);
  animation: hub-spin 0.9s linear infinite;
}

.hub-status-title {
  font-weight: 700;
  color: #16202d;
  margin-bottom: 3px;
}

.hub-status-message {
  color: #556274;
  font-size: 0.95rem;
  line-height: 1.4;
}

.idle-warning-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.45);
}

.idle-warning-overlay[hidden] {
  display: none !important;
}

.idle-warning-card {
  width: min(480px, 100%);
  border-radius: 16px;
  border: 1px solid rgba(201, 31, 37, 0.35);
  background: #ffffff;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.26);
  padding: 18px 18px 16px;
}

.idle-warning-card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.idle-warning-card p {
  margin: 0;
  color: #334155;
}

.idle-warning-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

#idleLogoutNowBtn {
  background: #eef2f7;
  color: #1e293b;
}

@keyframes hub-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .frame-shell { height: 100%; }
  .navbar { flex-wrap: wrap; }
  .workspace-tabs {
    order: 3;
    width: 100%;
  }
  .nav-actions {
    margin-left: auto;
    width: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }
  .nav-actions .tab-btn {
    margin-left: 0;
  }
  .hub-shell {
    grid-template-columns: 1fr;
  }
  .hub-sidebar {
    position: relative;
    height: auto;
  }
}

.hub-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.hub-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px 12px;
  border-right: 1px solid var(--toolbar-border);
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
  box-shadow: 10px 0 26px rgba(17, 24, 39, 0.04);
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--toolbar-border);
}

.hub-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 38px;
  border-radius: 12px;
  background: #fff1f2;
  color: var(--cv-red);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.hub-brand-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--cv-dark);
}

.hub-brand-subtitle {
  color: #6b7280;
  font-size: 0.86rem;
}

.sidebar-workspace-tabs {
  display: grid;
  gap: 8px;
}

.sidebar-workspace-tabs .workspace-tab {
  width: 100%;
  max-width: none;
  justify-content: space-between;
}

.hub-sidebar-section {
  display: grid;
  gap: 8px;
}

.hub-sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--toolbar-border);
  display: grid;
  gap: 8px;
}

.hub-sidebar-footer .topbar-user {
  position: static;
  right: auto;
  width: 100%;
  justify-content: flex-start;
}

.hub-sidebar .tab-btn {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: space-between;
}

.hub-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hub-main .frame-wrapper {
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
}
