/* =========================================================
   NEW CSS (with overlap fix included)
   ========================================================= */

/* Make widths behave (prevents input/select overflow in grids) */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* NOTE: The original file had a bare "{ display:none !important; }"
   which is invalid CSS. Removed to avoid breaking parsing. */

/* ---------- Body ---------- */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: #f5f5f5;
}

body.panel-open {
  overflow: hidden;
}

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: #f5f5f5;
}

.login-container {
  background: #fff;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 380px;
}

.login-title {
  margin: 0 0 28px;
  font-size: 24px;
  color: #2c3e50;
  text-align: center;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #555;
}

.login-field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.login-btn {
  width: 100%;
  padding: 10px;
  background-color: #2c3e50;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}

.login-btn:hover {
  background-color: #34495e;
}

.login-error {
  color: #c0392b;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- Sidebar Rail (always visible) ---------- */
#sidebar-rail {
  width: 52px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background-color: #2c3e50;
  z-index: 101;
}

#toggle-btn {
  width: 52px;
  height: 52px;
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#toggle-btn:hover {
  background-color: #34495e;
}

/* ---------- Sidebar Panel (slides in/out behind the rail) ---------- */
#sidebar {
  width: 200px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 52px;
  background-color: #2c3e50;
  color: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.25s ease;
  z-index: 100;
}

#sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar__header {
  padding: 15px 16px;
  border-bottom: 1px solid #34495e;
  flex-shrink: 0;
}

.sidebar__title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  color: #fff;
}

.sidebar__nav {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}

.sidebar__footer {
  padding: 12px 16px;
  border-top: 1px solid #34495e;
  flex-shrink: 0;
}

.logout-btn {
  width: 100%;
  background: none;
  border: 1px solid #566f8a;
  color: #ccc;
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}

.logout-btn:hover {
  background-color: #34495e;
  color: #fff;
}

#sidebar a {
  display: block;
  color: #fff;
  padding: 12px 20px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s;
}

#sidebar a:hover {
  background-color: #34495e;
}

.nav-group {
  margin-top: 16px;
}

.nav-group span {
  display: block;
  font-weight: bold;
  padding: 8px 20px;
  background-color: #34495e;
  white-space: nowrap;
}

/* ---------- Main Content ---------- */
#content {
  padding: 24px;
  margin-left: 252px; /* rail (52) + sidebar (200) */
  transition: margin-left 0.25s ease;
}

#content.full-width {
  margin-left: 52px; /* rail only */
}

/* ---------- Quick Add Button ---------- */
.quick-add-wrapper {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 101;
}

#quick-add-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background-color: #e74c3c;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: background 0.2s;
}

#quick-add-btn:hover {
  background-color: #c0392b;
}

.quick-add-menu {
  display: none;
  flex-direction: column;
  margin-bottom: 10px;
  background: #2c3e50;
  border-radius: 8px;
  overflow: hidden;
}

.quick-add-menu a {
  color: #ecf0f1;
  text-decoration: none;
  padding: 10px 15px;
  display: block;
  transition: background 0.2s;
}

.quick-add-menu a:hover {
  background-color: #34495e;
}

.quick-add-wrapper.active .quick-add-menu {
  display: flex;
}

/* ===============================
   Right Slide Panel (CRM)
================================= */

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9998;
}

.right-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 92vw);
  height: 100vh;
  background: #ffffff;
  box-shadow: -10px 0 30px rgba(0,0,0,0.18);
  transform: translateX(100%);
  transition: transform 180ms ease;
  z-index: 9999;
  display: flex;
  flex-direction: column;
}

/* Wide mode for heavy layouts (quote matrix) */
.right-panel.is-wide {
  width: min(1100px, 95vw);
}

.right-panel.is-open {
  transform: translateX(0);
}

.right-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #ddd;
}

.right-panel__body {
  padding: 14px;
  overflow: auto;
}

/* ===== CRM Companies List UI ===== */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.page-title {
  margin: 0;
}

.page-subtitle {
  margin: 6px 0 0;
  color: #666;
}

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

.card {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 14px;
  padding: 12px;
}

.filters {
  margin: 10px 0 14px;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 14px;
  padding: 12px;
  overflow: hidden;
}

/* =========================================================
   FIX: Search bar overlapping Group dropdown
   - Allow grid tracks/items to shrink properly.
   - Prevent min-content sizing overflow in CSS grid.
   ========================================================= */
.filters__row{
  display:grid;
  grid-template-columns:
    minmax(260px, 2fr)
    minmax(180px, 1fr)
    minmax(180px, 1fr)
    minmax(160px, 1fr)
    auto;
  gap:16px;
  align-items:end;
}

/* critical: let grid children shrink instead of overflowing/overlapping */
.filters__row > * {
  min-width: 0;
}

@media (max-width: 1200px){
  .filters__row{
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px){
  .filters__row{
    grid-template-columns: 1fr;
  }
}

.field__label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
}

.input,
.select {
  width: 100%;
  min-width: 0; /* also helps inside grid cells */
  padding: 10px 10px;
  border: 1px solid #dcdcdc;
  border-radius: 10px;
  outline: none;
}

.input:focus,
.select:focus {
  border-color: #bdbdbd;
}

.filters__buttons{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  align-self:end;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table thead th {
  text-align: left;
  font-size: 12px;
  color: #666;
  padding: 10px 10px;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}

.table tbody tr:hover td {
  background: #fafafa;
}

.company-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.company-name {
  font-weight: 600;
  text-decoration: none;
  color: #111;
}

.company-name:hover {
  text-decoration: underline;
}

.muted {
  color: #777;
  font-size: 12px;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f3f3;
  border: 1px solid #e6e6e6;
  font-size: 12px;
  color: #555;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #dcdcdc;
  background: #fff;
  cursor: pointer;
  text-decoration: none;
  color: #111;
}

.btn:hover {
  background: #f7f7f7;
}

.btn-small {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.btn-primary {
  border-color: #111;
  background: #111;
  color: #fff;
}

.btn-primary:hover {
  background: #222;
}

.btn-ghost {
  background: transparent;
}

.btn-ghost:hover {
  background: #f7f7f7;
}

.btn.is-disabled {
  pointer-events: none;
  opacity: 0.45;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 6px 4px;
}

.pagination__controls {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  font-size: 14px;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}