:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --line: #dbe4f1;
  --text: #0f172a;
  --muted: #475569;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.login-mode {
  background: linear-gradient(150deg, #dbeafe 0%, #bfdbfe 28%, #93c5fd 52%, #dbeafe 100%);
}

.admin-shell {
  width: calc(100% - 1.4rem);
  max-width: 1680px;
  margin: 0.65rem auto 1.35rem;
  display: grid;
  gap: 1.1rem;
}

body.login-mode .admin-shell {
  min-height: 100vh;
  align-content: center;
  margin: 0 auto;
}

body:not(.login-mode) .admin-shell {
  margin-top: 0;
}

#login-card { order: 1; }
#tabs-card { order: 2; }
#dashboard-card,
#budgets-card,
#erp-card,
#services-card,
#blog-card,
#chat-config-card,
#smtp-config-card,
#social-auth-card,
#profile-card,
#users-card,
#audit-card,
#newsletter-card {
  order: 3;
}

#login-card {
  max-width: 980px;
  width: min(980px, 96%);
  margin: 6vh auto 0;
  padding: 0;
  border-radius: 18px;
  box-shadow: 0 22px 46px rgba(15, 23, 42, 0.16);
  display: grid;
  grid-template-columns: minmax(300px, 1.05fr) minmax(300px, 0.95fr);
  overflow: hidden;
}

#login-card.hidden {
  display: none;
}

.login-welcome-panel {
  background: linear-gradient(145deg, #2563eb 0%, #1e40af 100%);
  color: #fff;
  padding: 2rem 1.8rem;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 0.72rem;
}

.login-kicker {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.9;
}

.login-welcome-panel h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.2;
  max-width: 18ch;
}

.login-brand-logo {
  width: min(240px, 85%);
  height: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  background: transparent;
  border-radius: 0;
  padding: 0;
  opacity: 0.98;
}

.login-form-panel {
  padding: 2rem 1.8rem;
  display: grid;
  align-content: center;
}

.login-form-panel h2 {
  margin: 0;
  font-size: 1.4rem;
}

.login-form-panel > p {
  margin: 0.35rem 0 1rem;
  color: var(--muted);
}

#login-form {
  display: grid;
  gap: 0.72rem;
}

#login-form label {
  font-size: 0.92rem;
}

#login-form input {
  padding: 0.58rem 0.62rem;
}

.login-check-row {
  margin-top: 0.1rem;
  font-size: 0.9rem;
  color: #334155;
}

.login-check-row input[type='checkbox'] {
  width: 1rem;
  height: 1rem;
}

#login-btn {
  width: 100%;
  margin-top: 0.15rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

#tabs-card {
  position: sticky;
  top: 0.45rem;
  z-index: 60;
  background: linear-gradient(120deg, #1d4ed8 0%, #4338ca 55%, #312e81 100%);
  border-color: transparent;
  box-shadow: 0 16px 34px rgba(30, 58, 138, 0.32);
}

.tabs-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
}

.tabs-nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
}

.tab-cascade {
  position: relative;
}

.tab-cascade-trigger {
  min-width: 0;
  text-align: left;
}

.tab-cascade-menu {
  position: absolute;
  top: calc(100% + 0.38rem);
  left: 0;
  min-width: 220px;
  padding: 0.42rem;
  border-radius: 12px;
  border: 0;
  background: rgba(15, 23, 42, 0.86);
  backdrop-filter: blur(8px);
  box-shadow: 0 14px 28px rgba(2, 6, 23, 0.42);
  display: grid;
  gap: 0.38rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 45;
}

.tab-cascade:hover .tab-cascade-menu,
.tab-cascade:focus-within .tab-cascade-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.tab-cascade-menu .tab-btn {
  width: 100%;
  justify-content: flex-start;
}

.tabs-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-end;
}

.tabs-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 0.5rem 0.35rem;
  border-radius: 999px;
  min-width: 0;
  border: 0;
  color: #fff;
  background: transparent;
  box-shadow: none;
}

#menu-organizer-open-btn {
  min-width: 0;
}

.tab-btn {
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.48rem 0.35rem;
  background: transparent;
  box-shadow: none;
}

.tab-cascade-trigger--active {
  font-weight: 800;
  background: transparent;
}

.tab-btn.active {
  background: transparent;
  color: #ffffff;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  box-shadow: none;
}

.tab-btn:hover,
.tabs-link:hover {
  opacity: 0.88;
}

.tab-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.menu-organizer-shell {
  display: grid;
  gap: 0.8rem;
}

.menu-organizer-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.55rem;
}

.menu-organizer-tools label {
  margin: 0;
}

.menu-organizer-main-order {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  display: grid;
  gap: 0.36rem;
}

.menu-organizer-main-order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.5rem 0.62rem;
  border-radius: 10px;
  border: 1px solid #dbeafe;
  background: #fff;
  color: #0f172a;
  cursor: grab;
}

.menu-organizer-main-order-item:active {
  cursor: grabbing;
}

.menu-organizer-main-order-item__kind {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.menu-organizer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}

.menu-organizer-group {
  display: grid;
  gap: 0.4rem;
}

.menu-organizer-group__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.menu-organizer-group__head h6 {
  margin: 0;
  color: #0f172a;
}

.menu-organizer-group__meta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.menu-organizer-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  min-height: 170px;
  display: grid;
  align-content: start;
  gap: 0.36rem;
}

.menu-organizer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.62rem;
  border-radius: 10px;
  border: 1px solid #dbeafe;
  background: #fff;
  color: #0f172a;
  cursor: grab;
}

.menu-organizer-item:active {
  cursor: grabbing;
}

.menu-organizer-item.is-dragging {
  opacity: 0.56;
}

.menu-organizer-item__label {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 0.82rem;
}

.menu-organizer-item__rename {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.22rem 0.42rem;
  cursor: pointer;
}

.menu-organizer-item__rename:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.menu-organizer-item__handle {
  color: #64748b;
  font-size: 0.92rem;
}

.crm-table-shell {
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  max-width: 100%;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.crm-table th,
.crm-table td {
  padding: 0.42rem 0.46rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.crm-table th {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #334155;
  background: #f8fafc;
  position: sticky;
  top: 0;
}

.crm-table td.col-main {
  min-width: 210px;
  white-space: normal;
}

.crm-table td.col-budget,
.crm-table td.col-stage,
.crm-table td.col-actions {
  white-space: nowrap;
}

.crm-meta {
  margin: 0.08rem 0;
  color: #64748b;
  font-size: 0.74rem;
}

.crm-stage {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.14rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.crm-stage.stage-new { background: #e2e8f0; color: #334155; }
.crm-stage.stage-qualified { background: #dbeafe; color: #1d4ed8; }
.crm-stage.stage-proposal_sent { background: #fef9c3; color: #854d0e; }
.crm-stage.stage-won { background: #dcfce7; color: #166534; }
.crm-stage.stage-lost { background: #fee2e2; color: #991b1b; }

.crm-actions {
  display: inline-flex;
  gap: 0.28rem;
}

.budgets-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(0, 1.05fr);
  gap: 0.9rem;
  align-items: start;
}

.budgets-main-block,
.budgets-editor-block {
  min-width: 0;
}

.budgets-create-block {
  min-width: 0;
}

.budget-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.budget-editor-modal__panel {
  width: min(1100px, calc(100% - 2rem));
}

#budget-editor-modal .chat-transcript-content {
  max-height: calc(100vh - 8.5rem);
}

#budget-editor-modal .budgets-editor-block {
  border: 0;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

.budgets-editor-block h4,
.budgets-main-block h4 {
  margin-top: 0;
}

.budget-editor-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: end;
}

#budget-editor-note,
#budget-template-body,
#budget-ai-instructions,
#budget-proposal-draft,
#budget-company-address,
#budget-quote-notes,
#budget-cost-service-hours,
#budget-cost-scope-multipliers,
#budget-proposal-edit-draft {
  min-height: 90px;
}

#budget-template-body,
#budget-proposal-draft {
  min-height: 180px;
}

#budget-proposal-edit-draft {
  min-height: 260px;
}

.budget-cost-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.65rem;
}

.budget-proposals-history {
  margin-top: 0.7rem;
}

.budget-proposals-history h5 {
  margin: 0 0 0.45rem;
  font-size: 0.9rem;
  color: #334155;
}

.budget-proposals-history .table-shell {
  margin: 0;
}

.budget-proposals-history .activity-table tbody tr[data-budget-proposal-open] {
  cursor: pointer;
}

.budget-proposals-history .activity-table tbody tr[data-budget-proposal-open]:hover {
  background: #eff6ff;
}

.budget-proposal-edit-modal__panel {
  width: min(1000px, calc(100% - 2rem));
}

.budget-proposal-preview-modal__panel {
  width: min(1120px, calc(100% - 2rem));
}

.budget-proposal-preview-content {
  background: #fff;
  padding: 1rem;
  border: 1px solid #dbe4f1;
}

.budget-proposal-preview-content h2,
.budget-proposal-preview-content h3 {
  margin: 0.4rem 0;
}

.budget-proposal-preview-content .quote-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.budget-proposal-preview-content .quote-brand {
  font-size: 1.25rem;
  font-weight: 800;
}

.budget-proposal-preview-content .quote-meta {
  text-align: right;
  font-size: 0.88rem;
}

.budget-proposal-preview-content .quote-block {
  margin-top: 0.95rem;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

.budget-proposal-preview-content table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.65rem;
}

.budget-proposal-preview-content th,
.budget-proposal-preview-content td {
  border: 1px solid #cbd5e1;
  padding: 0.34rem 0.45rem;
  font-size: 0.84rem;
  vertical-align: top;
}

.budget-proposal-preview-content th {
  background: #f1f5f9;
  text-align: left;
}

.icon-action-btn {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
}

.icon-action-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.hidden { display: none; }

.form-grid {
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 500;
}

input,
select {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.66rem 0.7rem;
  font: inherit;
  font-weight: 400;
  width: 100%;
}

textarea {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.66rem 0.7rem;
  font: inherit;
  font-weight: 400;
  width: 100%;
  min-height: 110px;
  resize: vertical;
}

.editor-content {
  min-height: 280px;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.66rem 0.92rem;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
}

.btn-ghost {
  color: #1e293b;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.feedback {
  min-height: 1.35rem;
  margin: 0.65rem 0 0;
  color: #b91c1c;
}

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}

.dashboard-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-strong);
  font-weight: 700;
}

#dashboard-card h2 {
  margin: 0;
  font-size: 1.5rem;
}

#dashboard-card .dashboard-head > div > p:last-child {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  --stats-grid-cols: 4;
  grid-template-columns: repeat(var(--stats-grid-cols), minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.05rem;
}

.stat-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.78rem 0.82rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.stat-card::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 3px;
  background: var(--brand);
}

.stat-card[data-tab-target] {
  cursor: pointer;
}

.stat-card[data-tab-target]:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.11);
}

.stat-card[data-tab-target]:focus-visible {
  outline: 2px solid var(--brand-strong);
  outline-offset: 3px;
}

.stat-card h3 {
  margin: 0 0 0.42rem;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-card p {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-card--services::after { background: #2563eb; }
.stat-card--clients::after { background: #1e293b; }
.stat-card--budgets::after { background: #ca8a04; }
.stat-card--invoices::after { background: #dc2626; }
.stat-card--chat::after { background: #059669; }
.stat-card--blog::after { background: #7c3aed; }
.stat-card--leads::after { background: #ea580c; }
.stat-card--newsletter::after { background: #0891b2; }

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.quick-btn {
  min-width: 180px;
  background: #fff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}

.activity-layout {
  margin-top: 1rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.activity-block {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.activity-block h4 {
  margin: -0.85rem -0.85rem 0.8rem;
  padding: 0.68rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: #f2f7ff;
}

.compact-list {
  max-height: 390px;
  overflow: auto;
  padding-right: 0.35rem;
}

.activity-block .list {
  display: block;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
  overflow-y: auto;
  background: #fff;
  max-width: 100%;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.activity-table thead th {
  text-align: left;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #475569;
  background: #f3f6fb;
  border-bottom: 1px solid var(--line);
  padding: 0.56rem 0.62rem;
  white-space: nowrap;
}

.activity-table tbody td {
  padding: 0.54rem 0.62rem;
  border-bottom: 1px solid #e7edf7;
  color: #1e293b;
  vertical-align: top;
}

.activity-table tbody tr:nth-child(even) {
  background: #fafcff;
}

.activity-table tbody tr:hover {
  background: #eef4ff;
}

.table-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  padding: 0.35rem 0.1rem;
}

.compact-list .list-item h4 {
  font-size: 0.95rem;
}

.compact-list .list-item p {
  font-size: 0.9rem;
}

.list {
  display: grid;
  gap: 0.7rem;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.82rem 0.82rem 0.9rem;
  background: #fff;
  border-left: 4px solid var(--brand);
}

.list-item h4 {
  margin: 0 0 0.25rem;
}

.list-item p {
  margin: 0.15rem 0;
  color: var(--muted);
  white-space: pre-wrap;
  font-weight: 400;
}

.list-item .item-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

.list-item .item-actions button {
  padding: 0.42rem 0.7rem;
  font-size: 0.9rem;
}

.newsletter-item h4 {
  margin: 0 0 0.25rem;
}

.check-row {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.check-row input[type='checkbox'] {
  width: auto;
}

.users-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  margin-bottom: 1rem;
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.38fr) minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: 0.8rem;
}

#profile-card {
  max-width: 980px;
  margin-inline: auto;
}

#profile-form {
  gap: 0.65rem;
}

#profile-form input,
#profile-form input::placeholder {
  font-weight: 400;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.profile-meta {
  grid-column: 1 / -1;
  margin: 0 0 0.15rem;
}

.profile-span-2 {
  grid-column: 1 / -1;
}

.profile-save-btn {
  width: fit-content;
  min-width: 220px;
  justify-self: start;
}

.chat-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.smtp-config-panel {
  padding: 0.75rem;
}

.smtp-layout {
  display: grid;
  grid-template-columns: minmax(380px, 1.08fr) minmax(420px, 0.92fr);
  gap: 0.75rem;
  align-items: stretch;
}

.smtp-activity-panel {
  padding: 0.75rem;
  display: grid;
  align-content: start;
  gap: 0.55rem;
}

.smtp-activity-head {
  margin-bottom: 0.2rem;
}

.smtp-activity-head h4 {
  margin: 0;
  font-size: 0.96rem;
}

.smtp-activity-head p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.smtp-activity-filters {
  margin-bottom: 0.2rem;
}

#smtp-activity-list .table-shell {
  margin-top: 0;
}

#smtp-activity-list .activity-table {
  font-size: 0.78rem;
}

#smtp-activity-list .activity-table th,
#smtp-activity-list .activity-table td {
  padding: 0.36rem 0.42rem;
}

#smtp-activity-list .smtp-status-ok {
  color: #166534;
  font-weight: 700;
}

#smtp-activity-list .smtp-status-error {
  color: #b91c1c;
  font-weight: 700;
}

.smtp-send-panel {
  margin-top: 0.75rem;
}

.smtp-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.smtp-config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.social-auth-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.social-provider-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
  padding: 0.65rem;
  display: grid;
  gap: 0.5rem;
  align-content: start;
}

.social-provider-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.social-provider-card__head h4 {
  margin: 0;
  font-size: 0.95rem;
}

.social-provider-card__head a {
  color: var(--brand-strong);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}

.social-provider-card__head a:hover {
  text-decoration: underline;
}

.social-provider-meta {
  margin-top: 0.1rem;
  display: grid;
  gap: 0.22rem;
}

.social-provider-meta .form-meta {
  margin: 0;
}

.smtp-span-3 {
  grid-column: span 3;
}

.smtp-span-2 {
  grid-column: span 2;
}

.smtp-secure-row {
  margin-top: 1.6rem;
  align-items: center;
}

.smtp-actions-row {
  display: flex;
  justify-content: flex-start;
}

#smtp-send-message {
  min-height: 120px;
}

#smtp-config-card .dashboard-head h3 {
  font-size: 1.08rem;
}

#smtp-config-card .dashboard-head > div > p {
  font-size: 0.86rem;
}

#smtp-config-card label {
  font-size: 0.88rem;
}

.chat-backoffice-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 1rem;
  align-items: stretch;
  --chat-columns-height: 78vh;
}

.chat-config-side,
.chat-conversations-main {
  min-width: 0;
  height: var(--chat-columns-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat-config-form {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 0.2rem;
}

.chat-conversations-head h4 {
  margin: 0;
  font-size: 1rem;
}

.chat-conversations-head p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.chat-tools-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
  padding: 0.6rem;
  margin: 0 0 0.55rem;
}

.chat-tools-head {
  margin: 0 0 0.35rem;
}

.chat-tools-head h5 {
  margin: 0;
  font-size: 0.86rem;
  color: #0f172a;
}

.chat-tools-head p {
  margin: 0.15rem 0 0;
  font-size: 0.77rem;
  color: #475569;
}

.chat-cleanup-toolbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0.45rem 0;
}

.chat-cleanup-toolbar label {
  font-size: 0.78rem;
  gap: 0.2rem;
}

.chat-cleanup-toolbar input {
  font-size: 0.78rem;
  padding: 0.34rem 0.42rem;
}

.chat-cleanup-check {
  align-self: end;
}

.chat-cleanup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin: 0.1rem 0 0.45rem;
}

.chat-cleanup-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0;
}

.chat-cleanup-summary p {
  margin: 0;
  font-size: 0.82rem;
  color: #334155;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem 0.46rem;
  background: #f8fafc;
}

.chat-filters-toolbar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0.45rem 0 0.45rem;
}

.chat-filters-toolbar label {
  font-size: 0.78rem;
  gap: 0.2rem;
}

.chat-filters-toolbar input,
.chat-filters-toolbar select {
  font-size: 0.78rem;
  padding: 0.34rem 0.42rem;
}

.chat-filters-meta {
  margin: 0;
  color: #475569;
  font-size: 0.8rem;
}

.chat-keep-tag {
  display: inline-block;
  border-radius: 999px;
  border: 1px solid #93c5fd;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.34rem;
  margin-left: 0.2rem;
}

.chat-budget-tag {
  display: inline-block;
  border-radius: 999px;
  border: 1px solid #86efac;
  color: #166534;
  background: #dcfce7;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.34rem;
  margin-left: 0.2rem;
}

#chat-config-card .dashboard-head h3 {
  font-size: 1.08rem;
}

#chat-config-card .dashboard-head > div > p {
  font-size: 0.86rem;
}

#chat-config-card .users-block h4 {
  font-size: 0.98rem;
}

#chat-config-card label {
  font-size: 0.84rem;
  gap: 0.26rem;
}

#chat-config-card input,
#chat-config-card select,
#chat-config-card textarea {
  font-size: 0.84rem;
  padding: 0.48rem 0.55rem;
}

#chat-config-card textarea {
  min-height: 88px;
}

.chat-conversations-shell {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
  overflow-y: auto;
  background: #fff;
  height: 100%;
  max-height: none;
  max-width: 100%;
}

#chat-conversations-list {
  flex: 1;
  min-height: 0;
  display: block;
  overflow: hidden;
}

.chat-conversations-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.chat-conversations-table thead th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #475569;
  background: #f3f6fb;
  border-bottom: 1px solid var(--line);
  padding: 0.42rem 0.46rem;
  white-space: nowrap;
}

.chat-conversations-table tbody td {
  padding: 0.4rem 0.46rem;
  border-bottom: 1px solid #e7edf7;
  color: #1e293b;
  vertical-align: top;
}

.chat-conversations-table tbody tr:nth-child(even) {
  background: #fafcff;
}

.chat-conversations-table tbody tr.chat-row-unread {
  background: #eef6ff;
}

.chat-read-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  color: #334155;
  background: #f8fafc;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.12rem 0.4rem;
  letter-spacing: 0.02em;
}

.chat-read-badge.unread {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #dbeafe;
}

.chat-conversations-table .chat-preview {
  display: block;
  max-width: 34ch;
  white-space: normal;
  color: #475569;
}

.chat-conversations-table .chat-preview.unread {
  color: #0f172a;
  font-weight: 600;
}

.chat-conversations-table .btn-ghost {
  padding: 0.28rem 0.5rem;
  font-size: 0.78rem;
}

.chat-conversations-table .chat-row-select {
  width: 14px;
  height: 14px;
}

.chat-cell-open {
  cursor: pointer;
}

.chat-cell-open:hover {
  background: #eff6ff;
}

.chat-transcript-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  opacity: 1;
  transition: opacity 0.18s ease;
}

.chat-transcript-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  opacity: 1;
  transition: opacity 0.2s ease;
}

.chat-transcript-modal__panel {
  position: relative;
  width: min(980px, calc(100% - 2rem));
  max-height: calc(100vh - 3rem);
  margin: 1.5rem auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
  transform: translateY(0) scale(1);
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 1;
}

.menu-organizer-modal__panel {
  width: min(1240px, calc(100% - 1.4rem));
  max-height: calc(100vh - 1.6rem);
  margin: 0.8rem auto;
}

.chat-transcript-modal.hidden {
  display: block;
  opacity: 0;
  pointer-events: none;
}

.chat-transcript-modal.hidden .chat-transcript-modal__overlay {
  opacity: 0;
}

.chat-transcript-modal.hidden .chat-transcript-modal__panel {
  transform: translateY(8px) scale(0.985);
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .chat-transcript-modal,
  .chat-transcript-modal__overlay,
  .chat-transcript-modal__panel {
    transition: none;
  }
}

.chat-transcript-modal__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.chat-transcript-modal__head h5 {
  margin: 0;
  font-size: 0.92rem;
}

.chat-transcript-modal__actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.chat-transcript-modal__actions .btn-ghost,
.chat-transcript-modal__actions .btn-danger {
  padding: 0.34rem 0.55rem;
  font-size: 0.78rem;
}

.chat-transcript-view {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  background: #f8fbff;
}

.chat-transcript-view h5 {
  margin: 0 0 0.45rem;
  font-size: 0.84rem;
}

.chat-transcript-content {
  display: grid;
  gap: 0.42rem;
  max-height: calc(100vh - 10rem);
  overflow: auto;
  padding: 0.8rem;
}

.chat-transcript-line {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.38rem 0.45rem;
  background: #fff;
  font-size: 0.82rem;
}

.chat-transcript-line strong {
  display: inline-block;
  margin-right: 0.35rem;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.workspace-side,
.workspace-main {
  min-width: 0;
}

.ai-placeholder {
  border: 1px dashed #93c5fd;
  border-radius: 12px;
  background: linear-gradient(180deg, #eff6ff 0%, #f8fbff 100%);
  padding: 0.85rem;
  display: grid;
  gap: 0.5rem;
}

.ai-placeholder p {
  margin: 0;
  color: #334155;
}

.table-controls {
  display: grid;
  grid-template-columns: 1.5fr minmax(180px, 0.5fr);
  gap: 0.65rem;
  margin-bottom: 0.7rem;
}

.table-controls--users {
  grid-template-columns: 1.5fr minmax(160px, 0.45fr) minmax(160px, 0.45fr);
}

#erp-card .table-controls--users {
  grid-template-columns: minmax(280px, 1.5fr) minmax(170px, 0.55fr) minmax(170px, 0.55fr) auto;
  align-items: end;
}

@media (max-width: 1480px) {
  #erp-card .table-controls--users {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
}

#erp-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100dvh - 6.4rem);
  overflow: hidden;
}

#erp-card.hidden {
  display: none;
}

#erp-card .erp-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.62rem;
  align-items: stretch;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

#erp-card .erp-main-column {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.62rem;
  min-width: 0;
  height: 100%;
  min-height: 0;
}

#erp-card .erp-customers-panel,
#erp-card .erp-quick-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  height: 100%;
  border-color: var(--line);
  padding: 0.7rem;
}

#erp-card .erp-panel--customers {
  border-top: 3px solid var(--brand);
}

#erp-card .erp-panel--budgets {
  border-top: 3px solid var(--brand-strong);
}

#erp-card .erp-panel--invoices {
  border-top: 3px solid var(--brand);
}

#erp-card .erp-panel--contracts {
  border-top: 3px solid var(--brand-strong);
}

#erp-card .erp-customers-panel h4,
#erp-card .erp-quick-panel h4 {
  margin: -0.7rem -0.7rem 0.45rem;
  padding: 0.48rem 0.68rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  font-size: 1rem;
}

#erp-card .erp-quick-column {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.62rem;
  min-width: 0;
  height: 100%;
  min-height: 0;
}

#erp-card .erp-layout .list {
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

#erp-card .erp-layout .table-shell {
  max-height: 100%;
  height: 100%;
  border-radius: 12px;
}

#erp-card .erp-layout .table-controls {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  padding: 0.34rem 0.4rem;
  margin-bottom: 0.48rem;
  gap: 0.45rem;
}

#erp-card .erp-layout .table-controls label {
  gap: 0.22rem;
  font-size: 0.9rem;
}

#erp-card .erp-layout .table-controls input,
#erp-card .erp-layout .table-controls select,
#erp-card .erp-layout .table-controls button {
  padding: 0.48rem 0.55rem;
  font-size: 0.92rem;
}

#erp-card .erp-layout .activity-table {
  font-size: 0.83rem;
}

#erp-card .erp-layout .activity-table thead th {
  padding: 0.42rem 0.48rem;
}

#erp-card .erp-layout .activity-table tbody td {
  padding: 0.4rem 0.48rem;
  line-height: 1.28;
}

#erp-card .activity-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
}

#erp-card .activity-table tbody tr {
  transition: background-color 0.16s ease;
}

#erp-card .activity-table tbody tr[data-erp-open-customer]:hover,
#erp-card .activity-table tbody tr[data-erp-edit-contract]:hover,
#erp-card .activity-table tbody tr[data-erp-open-budget]:hover,
#erp-card .activity-table tbody tr[data-erp-edit-invoice]:hover,
#erp-card .activity-table tbody tr[data-erp-modal-edit-invoice]:hover {
  background: #eaf2ff;
}

#erp-card .activity-table tbody tr[data-erp-open-customer],
#erp-card .activity-table tbody tr[data-erp-edit-contract],
#erp-card .activity-table tbody tr[data-erp-open-budget],
#erp-card .activity-table tbody tr[data-erp-edit-invoice],
#erp-card .activity-table tbody tr[data-erp-modal-edit-invoice] {
  cursor: pointer;
}

#erp-card .table-controls--users .users-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
}

@media (max-width: 1480px) {
  #erp-card .table-controls--users .users-actions {
    grid-column: 1 / -1;
    margin-left: 0;
    justify-content: flex-start;
  }
}

/*
  Tablet landscape / low-height screens: keep content readable.
  If there is not enough vertical room for at least a few table rows,
  collapse ERP dashboard to a single column and allow natural page flow.
*/
#erp-card.erp-force-single-column {
  height: auto;
  overflow: visible;
}

#erp-card.erp-force-single-column .erp-layout {
  grid-template-columns: 1fr;
  height: auto;
  overflow: visible;
}

#erp-card.erp-force-single-column .erp-main-column,
#erp-card.erp-force-single-column .erp-quick-column {
  grid-template-rows: auto;
  height: auto;
}

#erp-card.erp-force-single-column .erp-customers-panel,
#erp-card.erp-force-single-column .erp-quick-panel,
#erp-card.erp-force-single-column .erp-layout .list,
#erp-card.erp-force-single-column .erp-layout .table-shell {
  height: auto;
  min-height: 0;
  max-height: none;
}

@media (min-width: 1201px) and (max-height: 980px) {
  #erp-card {
    height: auto;
    overflow: visible;
  }

  #erp-card .erp-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  #erp-card .erp-main-column,
  #erp-card .erp-quick-column {
    grid-template-rows: auto;
    height: auto;
  }

  #erp-card .erp-customers-panel,
  #erp-card .erp-quick-panel,
  #erp-card .erp-layout .list,
  #erp-card .erp-layout .table-shell {
    height: auto;
    min-height: 0;
    max-height: none;
  }
}

#erp-customer-modal .chat-transcript-modal__panel,
#erp-contract-modal .chat-transcript-modal__panel,
#erp-invoice-modal .chat-transcript-modal__panel {
  width: min(1020px, calc(100% - 2rem));
}

#erp-customer-modal .chat-transcript-modal__head,
#erp-contract-modal .chat-transcript-modal__head,
#erp-invoice-modal .chat-transcript-modal__head,
#budget-editor-modal .chat-transcript-modal__head,
#budget-proposal-edit-modal .chat-transcript-modal__head {
  background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
}

.erp-modal-shell {
  border-top: 3px solid var(--brand);
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

#erp-customer-modal .chat-transcript-content,
#erp-contract-modal .chat-transcript-content,
#erp-invoice-modal .chat-transcript-content,
#budget-editor-modal .chat-transcript-content,
#budget-proposal-edit-modal .chat-transcript-content {
  padding: 0.7rem;
  gap: 0.35rem;
}

#erp-customer-modal .erp-modal-shell h5 {
  margin: 0.5rem 0 0.4rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #334155;
}

.erp-customer-quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0.25rem 0 0.65rem;
}

.erp-customer-quick-actions .btn-ghost {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
}

#erp-customer-modal #erp-customer-modal-contracts .table-shell,
#erp-customer-modal #erp-customer-modal-invoices .table-shell,
#erp-customer-modal #erp-customer-modal-budgets .table-shell {
  max-height: 220px;
}

#erp-customer-form,
#erp-contract-form,
#erp-invoice-form {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.68rem;
  align-items: end;
}

#erp-customer-form .erp-col-12,
#erp-contract-form .erp-col-12,
#erp-invoice-form .erp-col-12 {
  grid-column: span 12;
}

#erp-customer-form .erp-col-8,
#erp-contract-form .erp-col-8,
#erp-invoice-form .erp-col-8 {
  grid-column: span 8;
}

#erp-customer-form .erp-col-6,
#erp-contract-form .erp-col-6,
#erp-invoice-form .erp-col-6 {
  grid-column: span 6;
}

#erp-customer-form .erp-col-4,
#erp-contract-form .erp-col-4,
#erp-invoice-form .erp-col-4 {
  grid-column: span 4;
}

#erp-customer-form .check-row,
#erp-contract-form .check-row,
#erp-invoice-form .check-row {
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.45rem 0.62rem;
}

#erp-customer-form textarea,
#erp-contract-form textarea,
#erp-invoice-form textarea {
  min-height: 86px;
}

#erp-customer-form .budget-editor-inline,
#erp-contract-form .budget-editor-inline,
#erp-invoice-form .budget-editor-inline {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#erp-customer-form .btn-danger,
#erp-contract-form .btn-danger,
#erp-invoice-form .btn-danger {
  justify-self: start;
}

#budgets-card .table-controls--users {
  grid-template-columns: 1.5fr repeat(3, minmax(150px, 0.42fr));
}

.budgets-bulk-actions {
  margin: 0.1rem 0 0.4rem;
}

#budgets-selected-count {
  font-weight: 700;
}

.audit-filters {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.7rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
}

.audit-filter-wide {
  grid-column: span 2;
}

#blog-card .users-layout {
  grid-template-columns: minmax(320px, 460px) minmax(520px, 1fr);
}

#services-card .users-layout {
  grid-template-columns: minmax(320px, 430px) minmax(520px, 1fr);
}

@media (max-width: 1200px) {
  #login-card {
    grid-template-columns: 1fr;
    margin-top: 4.5vh;
  }

  .chat-config-grid {
    grid-template-columns: 1fr;
  }

  .smtp-config-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .smtp-layout {
    grid-template-columns: 1fr;
  }

  .social-auth-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .smtp-span-2 {
    grid-column: span 2;
  }

  .smtp-span-3 {
    grid-column: span 2;
  }

  .activity-layout {
    grid-template-columns: 1fr;
  }

  .tabs-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .tabs-actions {
    justify-content: flex-start;
  }

  .menu-organizer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-organizer-tools {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .workspace-layout {
    grid-template-columns: 1fr;
  }

  #erp-card .erp-layout {
    grid-template-columns: 1fr;
  }

  #erp-card .erp-main-column {
    grid-template-rows: auto;
    height: auto;
  }

  #erp-card {
    height: auto;
    overflow: visible;
  }

  #erp-card .erp-quick-column {
    grid-template-rows: auto;
    height: auto;
  }

  #erp-card .erp-customers-panel,
  #erp-card .erp-quick-panel,
  #erp-card .erp-layout .list {
    height: auto;
    min-height: 0;
  }

  .budgets-layout {
    grid-template-columns: 1fr;
  }

  .budget-create-grid {
    grid-template-columns: 1fr;
  }

  .budget-editor-inline {
    grid-template-columns: 1fr;
  }

  .chat-backoffice-layout {
    grid-template-columns: 1fr;
  }

  .chat-config-side,
  .chat-conversations-main {
    height: auto;
    overflow: visible;
  }

  #chat-config-form {
    overflow: visible;
    padding-right: 0;
  }

  #chat-conversations-list {
    overflow: visible;
  }

  .chat-cleanup-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #budgets-card .table-controls--users {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-cleanup-summary {
    grid-template-columns: 1fr;
  }

  .chat-filters-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #blog-card .users-layout,
  #services-card .users-layout,
  .users-layout {
    grid-template-columns: 1fr;
  }

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

  .profile-save-btn {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 860px) {
  .admin-shell {
    width: calc(100% - 0.6rem);
  }

  body:not(.login-mode) .admin-shell {
    margin-top: 0;
  }

  .tabs-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .tabs-nav {
    display: grid;
    grid-template-columns: 1fr;
    flex-wrap: nowrap;
    overflow: visible;
    padding-bottom: 0;
  }

  .tab-cascade,
  .tab-cascade-trigger {
    width: 100%;
  }

  .tab-cascade-menu {
    position: static;
    min-width: 0;
    width: 100%;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    background: rgba(15, 23, 42, 0.48);
    border: 0;
    box-shadow: none;
    display: none;
    margin-top: 0.28rem;
  }

  .tab-cascade--open .tab-cascade-menu {
    display: grid;
  }

  .tab-cascade-trigger {
    display: inline-flex;
    justify-content: space-between;
    align-items: center;
  }

  .tabs-nav .tab-btn {
    white-space: normal;
    width: 100%;
    justify-content: flex-start;
    flex: 1 1 auto;
  }

  .tabs-actions {
    justify-content: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .menu-organizer-list {
    min-height: 130px;
  }

  .menu-organizer-grid {
    grid-template-columns: 1fr;
  }

  .menu-organizer-main-order-item {
    flex-wrap: wrap;
  }

  .smtp-head-actions {
    justify-content: stretch;
    width: 100%;
  }

  .smtp-head-actions .btn-ghost {
    width: 100%;
  }

  .tabs-link {
    width: 100%;
  }

  .table-controls,
  .table-controls--users {
    grid-template-columns: 1fr;
  }

  #erp-card .table-controls--users {
    grid-template-columns: 1fr;
  }

  #erp-customer-form,
  #erp-contract-form,
  #erp-invoice-form {
    grid-template-columns: 1fr;
  }

  .erp-customer-quick-actions {
    grid-template-columns: 1fr;
  }

  #erp-customer-form .erp-col-12,
  #erp-customer-form .erp-col-8,
  #erp-customer-form .erp-col-6,
  #erp-customer-form .erp-col-4,
  #erp-contract-form .erp-col-12,
  #erp-contract-form .erp-col-8,
  #erp-contract-form .erp-col-6,
  #erp-contract-form .erp-col-4,
  #erp-invoice-form .erp-col-12,
  #erp-invoice-form .erp-col-8,
  #erp-invoice-form .erp-col-6,
  #erp-invoice-form .erp-col-4 {
    grid-column: auto;
  }

  .smtp-config-grid {
    grid-template-columns: 1fr;
  }

  .smtp-layout {
    grid-template-columns: 1fr;
  }

  .social-auth-grid {
    grid-template-columns: 1fr;
  }

  .smtp-span-2 {
    grid-column: auto;
  }

  .smtp-span-3 {
    grid-column: auto;
  }

  .smtp-secure-row {
    margin-top: 0;
  }

  .chat-filters-toolbar {
    grid-template-columns: 1fr;
  }

  .audit-filters,
  .audit-filter-wide {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .quick-links {
    display: grid;
    grid-template-columns: 1fr;
  }

  .quick-btn {
    width: 100%;
  }

  .activity-table {
    font-size: 0.86rem;
    min-width: 720px;
  }

  .crm-table {
    min-width: 780px;
  }

  .chat-conversations-table {
    min-width: 760px;
  }

  #smtp-activity-list .activity-table {
    min-width: 920px;
  }

  .activity-table thead th,
  .activity-table tbody td {
    padding: 0.45rem 0.48rem;
  }
}

@media (max-width: 560px) {
  .card {
    padding: 0.75rem;
    border-radius: 12px;
  }

  #login-card {
    width: 100%;
    border-radius: 14px;
    margin-top: 2.8vh;
  }

  body.login-mode #login-card {
    margin-top: 0;
  }

  .login-welcome-panel,
  .login-form-panel {
    padding: 1.15rem 1rem;
  }

  .login-welcome-panel h1 {
    font-size: 1.5rem;
  }

  .dashboard-head {
    flex-direction: column;
  }
}

.users-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.95rem;
  background: #fff;
}

.users-block h4 {
  margin: 0 0 0.75rem;
}

.users-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn-danger {
  background: #b91c1c;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

/* Refinamiento visual conservador (sin cambios funcionales) */
body:not(.login-mode) {
  background:
    radial-gradient(900px 320px at 8% -12%, rgba(37, 99, 235, 0.08), transparent 62%),
    radial-gradient(700px 300px at 96% -10%, rgba(14, 165, 233, 0.08), transparent 60%),
    var(--bg);
}

body:not(.login-mode) .admin-shell {
  gap: 0.95rem;
  margin-top: 0.35rem;
}

body:not(.login-mode) .card {
  border-color: #d7e2f0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

body:not(.login-mode) #tabs-card {
  top: 0.35rem;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(30, 58, 138, 0.26);
}

body:not(.login-mode) .tabs-toolbar {
  gap: 0.55rem;
}

body:not(.login-mode) .tabs-nav {
  gap: 0.45rem;
}

body:not(.login-mode) .tab-btn,
body:not(.login-mode) .tabs-link {
  padding: 0.46rem 0.74rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
}

body:not(.login-mode) #tabs-card .tabs-link {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

body:not(.login-mode) #tabs-card .tab-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
}

body:not(.login-mode) .tab-btn:hover,
body:not(.login-mode) .tabs-link:hover {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}

body:not(.login-mode) .tab-btn.active,
body:not(.login-mode) .tab-cascade-trigger--active,
body:not(.login-mode) .tabs-link[data-tab='mi-usuario'] {
  text-decoration: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

#dashboard-card .dashboard-head {
  margin-bottom: 0.95rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #e2e8f0;
}

#dashboard-card .dashboard-kicker {
  color: #1d4ed8;
  letter-spacing: 0.09em;
}

#dashboard-card h2 {
  font-size: 1.45rem;
}

.stat-card {
  border-color: #d7e3f1;
  background: linear-gradient(180deg, #ffffff 0%, #f6faff 100%);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.stat-card p {
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.quick-btn {
  border: 1px solid #cfe0ff;
  background: #f8fbff;
  color: #1e3a8a;
}

.quick-btn:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.users-block {
  border-color: #dbe5f3;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.activity-block h4,
.users-block h4 {
  font-size: 0.98rem;
  color: #0f172a;
}

.list-item {
  border-color: #dbe5f3;
  background: #ffffff;
}

.activity-table thead th {
  background: #eff5ff;
  color: #334155;
}

.activity-table tbody tr:hover {
  background: #eaf2ff;
}

.table-shell,
.crm-table-shell {
  border-color: #dbe5f3;
}

button,
.btn-ghost {
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #c9d8ee;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #b8cae6;
}

/* Modo compacto global del backoffice (excepto login) */
body:not(.login-mode) {
  font-size: 14px;
}

body:not(.login-mode) .admin-shell {
  gap: 0.78rem;
}

body:not(.login-mode) .card,
body:not(.login-mode) .users-block,
body:not(.login-mode) .workspace-main,
body:not(.login-mode) .workspace-side {
  padding: 0.72rem;
  border-radius: 12px;
}

body:not(.login-mode) .dashboard-head {
  gap: 0.58rem;
  margin-bottom: 0.62rem;
}

body:not(.login-mode) .dashboard-head h3,
body:not(.login-mode) .dashboard-head h4,
body:not(.login-mode) #dashboard-card h2,
body:not(.login-mode) .users-block h4,
body:not(.login-mode) .activity-block h4 {
  margin: 0;
  line-height: 1.2;
}

body:not(.login-mode) .dashboard-head p,
body:not(.login-mode) .section-intro,
body:not(.login-mode) .table-empty {
  margin: 0.18rem 0 0;
}

body:not(.login-mode) .stats-grid,
body:not(.login-mode) .activity-layout,
body:not(.login-mode) .workspace-layout,
body:not(.login-mode) .users-layout,
body:not(.login-mode) .list,
body:not(.login-mode) .form-grid {
  gap: 0.58rem;
}

body:not(.login-mode) .table-controls,
body:not(.login-mode) .audit-filters,
body:not(.login-mode) .chat-cleanup-toolbar,
body:not(.login-mode) .chat-filters-toolbar {
  gap: 0.48rem;
  margin-bottom: 0.5rem;
  padding: 0.48rem;
}

body:not(.login-mode) label {
  gap: 0.2rem;
  font-size: 0.86rem;
}

body:not(.login-mode) input,
body:not(.login-mode) select,
body:not(.login-mode) textarea,
body:not(.login-mode) button,
body:not(.login-mode) .btn-ghost,
body:not(.login-mode) .btn-danger,
body:not(.login-mode) .tab-btn,
body:not(.login-mode) .tabs-link {
  font-size: 0.84rem;
}

body:not(.login-mode) input,
body:not(.login-mode) select,
body:not(.login-mode) textarea {
  padding: 0.44rem 0.54rem;
  border-radius: 8px;
}

body:not(.login-mode) textarea {
  min-height: 84px;
}

body:not(.login-mode) button,
body:not(.login-mode) .btn-ghost,
body:not(.login-mode) .btn-danger {
  padding: 0.44rem 0.66rem;
  border-radius: 8px;
}

body:not(.login-mode) .activity-table {
  font-size: 0.82rem;
}

body:not(.login-mode) .activity-table thead th {
  padding: 0.38rem 0.44rem;
}

body:not(.login-mode) .activity-table tbody td {
  padding: 0.36rem 0.44rem;
  line-height: 1.24;
}

body:not(.login-mode) .list-item {
  padding: 0.58rem 0.62rem 0.6rem 0.68rem;
  border-radius: 10px;
}

body:not(.login-mode) .list-item .item-actions {
  margin-top: 0.38rem;
  gap: 0.38rem;
}

body:not(.login-mode) .chat-transcript-modal__panel {
  border-radius: 12px;
}

body:not(.login-mode) .chat-transcript-modal__head {
  padding: 0.58rem 0.66rem;
}

body:not(.login-mode) .chat-transcript-modal__head h5 {
  font-size: 0.86rem;
}

body:not(.login-mode) .chat-transcript-modal__actions {
  gap: 0.36rem;
}

body:not(.login-mode) .chat-transcript-content {
  gap: 0.34rem;
  padding: 0.58rem;
}

body:not(.login-mode) .chat-transcript-line {
  padding: 0.3rem 0.38rem;
  font-size: 0.78rem;
}

@media (max-width: 980px) {
  body:not(.login-mode) .tab-btn,
  body:not(.login-mode) .tabs-link {
    padding: 0.42rem 0.62rem;
    font-size: 0.83rem;
  }

  #dashboard-card h2 {
    font-size: 1.3rem;
  }
}
