* { box-sizing: border-box; }
html { margin: 0; min-height: 100%; }
body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { width: 18px; height: 18px; flex: 0 0 auto; }

.confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  box-shadow: 0 18px 50px rgba(18, 31, 28, 0.22);
}
.confirm-dialog::backdrop { background: rgba(18, 25, 23, 0.54); }
.confirm-dialog__surface { overflow: hidden; border-radius: 8px; background: var(--surface); }
.confirm-dialog__heading {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: start;
  gap: 12px;
  padding: 20px;
}
.confirm-dialog__heading strong { display: block; margin: 1px 0 7px; font-size: 16px; }
.confirm-dialog__heading p { margin: 0; color: var(--muted); line-height: 1.5; }
.confirm-dialog__icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--primary);
}
.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

@media (max-width: 480px) {
  .confirm-dialog__heading { grid-template-columns: 38px minmax(0, 1fr); }
  .confirm-dialog__heading > .icon-button { position: absolute; top: 12px; right: 12px; }
  .confirm-dialog__actions .button { flex: 1; }
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: white;
  padding: 18px 12px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: #35a28f;
  color: white;
  font-size: 17px;
  font-weight: 800;
}
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: 15px; letter-spacing: 0; }
.brand small { color: var(--sidebar-muted); font-size: 11px; }
.nav-list { display: grid; gap: 3px; }
.nav-list a, .sidebar-footer a, .nav-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 6px;
  padding: 0 11px;
  background: transparent;
  color: #d7dfdd;
  text-align: left;
  cursor: pointer;
}
.nav-list a:hover, .sidebar-footer a:hover, .nav-button:hover { background: #2a3532; color: white; }
.nav-list a.active { background: #e7f4f0; color: #135e54; font-weight: 700; }
.nav-list a.disabled { color: #75817e; cursor: default; }
.nav-list a small { margin-left: auto; font-size: 10px; text-transform: uppercase; }
.sidebar-footer { margin-top: auto; display: grid; gap: 3px; border-top: 1px solid #38423f; padding-top: 10px; }
.sidebar-footer .trailing { margin-left: auto; width: 14px; }
.sidebar-footer form { margin: 0; }

.main { min-width: 0; }
.topbar {
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 26px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
}
.topbar > div:first-of-type { display: flex; align-items: center; gap: 10px; }
.topbar strong { font-size: 15px; }
.environment {
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
}
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--muted); }
.mobile-menu { display: inline-grid; }
.content { max-width: 1500px; margin: 0 auto; padding: 24px 28px 40px; }

body.sidebar-collapsed .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
.sidebar.collapsed { padding-inline: 10px; }
.sidebar.collapsed .brand { justify-content: center; padding-inline: 0; }
.sidebar.collapsed .brand-subtitle,
.sidebar.collapsed .nav-list span,
.sidebar.collapsed .sidebar-footer span,
.sidebar.collapsed .sidebar-footer .trailing { display: none; }
.sidebar.collapsed .brand-logo { width: 38px; overflow: hidden; }
.sidebar.collapsed .brand-logo img { max-width: none; width: 116px; }
.sidebar.collapsed .nav-list a,
.sidebar.collapsed .sidebar-footer a,
.sidebar.collapsed .nav-button { justify-content: center; padding-inline: 0; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.page-heading h1 { margin: 0 0 5px; font-size: 23px; line-height: 1.25; letter-spacing: 0; }
.page-heading p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; }
.actions form { margin: 0; }
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { background: white; border-color: var(--border); color: var(--text); }
.button.secondary:hover { border-color: #aebbb7; }
.button.secondary.danger { color: var(--red); border-color: #f0c7c2; }
.button.secondary.danger:hover { background: #fff5f3; border-color: #e4aaa3; }
.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  cursor: pointer;
}

.safe-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #b8ddd4;
  border-radius: 6px;
  background: var(--green-soft);
  color: #145e53;
}
.safe-banner > svg { width: 22px; height: 22px; }
.safe-banner div { display: grid; gap: 2px; }
.safe-banner span { font-size: 12px; color: #42746c; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 18px;
}
.metric {
  min-height: 104px;
  position: relative;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 16px;
  border-right: 1px solid var(--border);
}
.metric:last-child { border-right: 0; }
.metric:hover { background: var(--surface-muted); }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { font-size: 26px; line-height: 1; }
.metric > svg { position: absolute; right: 14px; top: 14px; color: #84a59e; }
.metric.danger > svg, .metric.danger strong { color: var(--red); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr); gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.panel-heading { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.panel-heading h2 { margin: 0; font-size: 14px; }
.panel-heading a { display: inline-flex; align-items: center; gap: 5px; color: var(--primary); font-size: 12px; font-weight: 700; }
.panel-heading a svg { width: 14px; }
.compact-list > a, .operation-list > div {
  min-height: 66px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px 16px;
  border-bottom: 1px solid #edf0ef;
}
.compact-list > a:last-child, .operation-list > div:last-child { border-bottom: 0; }
.compact-list > a:hover { background: var(--surface-muted); }
.compact-list div, .operation-list div { min-width: 0; display: grid; gap: 3px; }
.compact-list strong, .operation-list strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.compact-list small, .operation-list small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #8a9693; }
.status-dot.done { background: #2c9b78; }
.status-dot.waiting { background: #d39520; }
.status-dot.blocked { background: #c64a4a; }

.kind {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.kind-feedback { background: #f2edff; color: #66509d; }
.kind-question { background: #e8f2fb; color: var(--blue); }
.kind-chat { background: var(--green-soft); color: #19705f; }
.metric small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}
.chat-state-tabs {
  width: max-content;
}
.status.chat-unread {
  background: #e8f2fb;
  color: var(--blue);
}
tr.chat-seen,
.mobile-card.chat-seen {
  opacity: .72;
}
.rating { margin-top: 7px; display: flex; align-items: center; gap: 3px; color: #9a6500; font-size: 12px; font-weight: 700; }
.rating svg { width: 13px; fill: #e8b449; stroke: #c78c16; }

.filters {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) 180px 38px;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.segmented { display: flex; height: 38px; border: 1px solid var(--border); border-radius: 6px; background: white; overflow: hidden; }
.segmented a { display: grid; place-items: center; padding: 0 12px; border-right: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 700; }
.segmented a:last-child { border-right: 0; }
.segmented a.active { background: var(--primary); color: white; }
.search { height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--border); border-radius: 6px; background: white; color: var(--muted); }
.search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; }
.filters select { height: 38px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; background: white; color: var(--text); }
.data-table-wrap { max-width: 100%; overflow-x: auto; contain: paint; border: 1px solid var(--border); border-radius: 6px; background: white; box-shadow: var(--shadow); }
.data-table { width: 100%; min-width: 1160px; border-collapse: collapse; table-layout: fixed; }
.data-table th { height: 42px; padding: 0 12px; background: #f7f9f8; border-bottom: 1px solid var(--border); color: var(--muted); text-align: left; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.data-table td { height: 94px; padding: 11px 12px; border-bottom: 1px solid #edf0ef; vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcfc; }
.data-table th:nth-child(1) { width: 100px; }
.data-table th:nth-child(2) { width: 210px; }
.data-table th:nth-child(3) { width: 27%; }
.data-table th:nth-child(4) { width: 29%; }
.data-table th:nth-child(5) { width: 125px; }
.data-table th:nth-child(6) { width: 58px; }
.identity { display: grid; gap: 3px; }
.identity strong, .identity span, .identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity span, .identity small { color: var(--muted); font-size: 11px; }
.cell-text { max-height: 67px; overflow: hidden; line-height: 1.45; color: #394541; }
.cell-text.draft { color: #315d55; }
.row-action { text-align: right; }
.row-action .icon-button { margin-left: auto; }
.button:disabled { opacity: 0.48; cursor: not-allowed; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.interaction-dialog {
  width: min(820px, calc(100% - 28px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 55px rgba(21, 35, 31, 0.22);
}
.interaction-dialog::backdrop { background: rgba(24, 36, 33, 0.48); }
.interaction-dialog form { display: grid; max-height: calc(100vh - 34px); }
.interaction-dialog header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
.interaction-dialog header > div { min-width: 0; display: flex; align-items: center; gap: 10px; }
.interaction-dialog header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.interaction-body { min-height: 0; overflow-y: auto; display: grid; gap: 16px; padding: 18px; }
.interaction-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; color: var(--muted); font-size: 12px; }
.interaction-meta span { display: inline-flex; align-items: center; gap: 4px; }
.interaction-meta svg { width: 14px; height: 14px; }
.customer-message { display: grid; gap: 6px; }
.customer-message label, .draft-editor > span { font-size: 12px; font-weight: 800; }
.chat-history { display: grid; gap: 8px; }
.chat-history > label { font-size: 12px; font-weight: 800; }
.chat-thread {
  max-height: 320px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8faf9;
}
.chat-message {
  max-width: 78%;
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border: 1px solid #dbe4e1;
  border-radius: 7px;
  background: white;
}
.chat-message.client { justify-self: start; border-left: 3px solid var(--primary); }
.chat-message.seller { justify-self: end; border-right: 3px solid var(--blue); background: #f4f8ff; }
.chat-message.system { justify-self: center; max-width: 92%; background: #edf1f4; color: #52615d; }
.chat-message.unread { box-shadow: 0 0 0 2px rgba(70, 139, 211, .18); }
.chat-message header { min-height: 0; padding: 0; border: 0; display: flex; gap: 8px; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 800; }
.chat-message p { margin: 0; white-space: pre-wrap; line-height: 1.45; }
.chat-attachments { display: flex; flex-wrap: wrap; gap: 5px; }
.chat-attachments span { padding: 3px 6px; border-radius: 4px; background: #e8f2fb; color: var(--blue); font-size: 11px; font-weight: 700; }
.chat-empty { padding: 12px; color: var(--muted); text-align: center; }.customer-message > div {
  max-height: 180px;
  overflow-y: auto;
  padding: 12px;
  border-left: 3px solid #b8ddd4;
  background: var(--surface-muted);
  white-space: pre-wrap;
  line-height: 1.48;
}
.draft-editor { display: grid; gap: 6px; }
.draft-editor textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid #cdd5d3;
  border-radius: 6px;
  padding: 11px 12px;
  outline: 0;
  color: var(--text);
  line-height: 1.48;
}
.draft-editor textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20, 125, 111, 0.12); }
.character-count { justify-self: end; color: var(--muted); font-size: 11px; }
.inline-error { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border: 1px solid #efc1c1; border-radius: 6px; background: var(--red-soft); color: var(--red); }
.inline-error svg { margin-top: 1px; }
.approval-toggle { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.approval-toggle input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--primary); }
.approval-toggle > span { display: grid; gap: 2px; }
.approval-toggle small { color: var(--muted); font-size: 11px; }
.interaction-dialog footer { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }
.dialog-spacer { flex: 1; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status svg { width: 14px; height: 14px; }
.status.success { background: var(--green-soft); color: #18705f; }
.status.error { background: var(--red-soft); color: var(--red); }
.status.waiting { background: var(--amber-soft); color: var(--amber); }
.status.neutral { background: #edf1f4; color: #51616b; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.pagination a { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 6px; background: white; }
.pagination span { color: var(--muted); font-size: 12px; }

.settings-list { display: grid; gap: 8px; }
.settings-list section, .settings-list .setting-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
}
.settings-list section > svg, .settings-list .setting-row > svg:first-child { width: 22px; height: 22px; color: var(--primary); }
.settings-list section div, .settings-list .setting-row div { display: grid; gap: 3px; }
.settings-list section span:not(.status), .settings-list .setting-row span:not(.status) { color: var(--muted); font-size: 12px; }
.setting-row {
  width: 100%;
  grid-template-columns: 38px minmax(0, 1fr) auto 18px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.setting-row:hover { border-color: #aebbb7; background: var(--surface-muted); }
.setting-row .setting-chevron { width: 17px; height: 17px; color: #8a9693; }

.secret-dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 55px rgba(21, 35, 31, 0.22);
}
.secret-dialog::backdrop { background: rgba(24, 36, 33, 0.48); }
.secret-dialog form { display: grid; }
.secret-dialog header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
.secret-dialog header > div { display: flex; align-items: center; gap: 9px; }
.secret-dialog header > div svg { color: var(--primary); }
.dialog-body { display: grid; gap: 8px; padding: 20px 18px; }
.dialog-body label { font-size: 12px; font-weight: 700; }
.dialog-body p { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.secret-input {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid #cdd5d3;
  border-radius: 6px;
  background: white;
  color: var(--muted);
}
.secret-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20, 125, 111, 0.12); }
.secret-input input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.secret-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }
.notice { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; padding: 11px 13px; border: 1px solid #c8d9e7; border-radius: 6px; background: #eef6fb; color: #315c7d; }
.notice.error { border-color: #efc1c1; background: var(--red-soft); color: var(--red); }
.toast-region {
  position: fixed;
  right: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 80;
  width: min(420px, calc(100vw - 28px));
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.portal-toast {
  min-height: 48px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 10px;
  padding: 9px 8px 9px 12px;
  border: 1px solid #c8d9e7;
  border-radius: 8px;
  background: #f5faff;
  color: #315c7d;
  box-shadow: 0 12px 32px rgba(24, 36, 33, .16);
  line-height: 1.4;
  pointer-events: auto;
  animation: portal-toast-in 160ms ease-out both;
}
.portal-toast > svg { width: 19px; height: 19px; }
.portal-toast .icon-button { width: 32px; height: 32px; color: currentColor; }
.portal-toast.success { border-color: #b9ddd3; background: #f0faf7; color: #176d5c; }
.portal-toast.warning { border-color: #ead49f; background: #fff9e9; color: #855b06; }
.portal-toast.error { border-color: #e8b7b7; background: #fff5f5; color: #a83232; }
.portal-toast.is-leaving { animation: portal-toast-out 180ms ease-in both; }
@keyframes portal-toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes portal-toast-out { to { opacity: 0; transform: translateY(6px); } }

form[aria-busy="true"] { cursor: progress; }
.button.is-loading,
.icon-button.is-loading { cursor: wait; opacity: .72; }
.button.is-loading svg,
.icon-button.is-loading svg { animation: portal-spin .8s linear infinite; }
@keyframes portal-spin { to { transform: rotate(360deg); } }

.page-state-highlight {
  outline: 3px solid rgba(20, 125, 111, .24);
  outline-offset: 3px;
  transition: outline-color 180ms ease;
}
.errorlist { margin: 5px 0 0; padding: 0; list-style: none; color: var(--red); font-size: 11px; }
.employee-filters { grid-template-columns: minmax(240px, 1fr) 180px auto; }
.operation-filters { grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(140px, 180px)) auto; }
.empty-state { padding: 28px 16px; color: var(--muted); text-align: center; }
.operation-list.full > div { min-height: 72px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #eef1f0; }
.login-panel { width: min(380px, 100%); padding: 28px; border: 1px solid var(--border); border-radius: 8px; background: white; box-shadow: 0 12px 35px rgba(25, 39, 35, 0.10); }
.login-brand { padding: 0 0 26px; color: var(--text); }
.login-brand small { color: var(--muted); }
.login-panel h1 { margin: 0 0 6px; font-size: 24px; }
.login-panel > p { margin: 0 0 22px; color: var(--muted); }
.login-form { display: grid; gap: 8px; }
.login-form label { margin-top: 5px; color: #46534f; font-size: 12px; font-weight: 700; }
.login-form input { height: 42px; border: 1px solid #cdd5d3; border-radius: 6px; padding: 0 11px; outline: 0; }
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20, 125, 111, 0.12); }
.login-form .button { margin-top: 10px; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr 180px 38px; }
  .segmented { grid-column: 1 / -1; width: max-content; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  body.sidebar-collapsed .app-shell { display: block; }
  .sidebar { position: fixed; left: -260px; width: 240px; transition: left 160ms ease; box-shadow: 12px 0 30px rgba(0,0,0,.18); }
  .sidebar.open { left: 0; }
  .mobile-menu { display: inline-grid; }
  .topbar { padding: 0 14px; }
  .topbar > div:first-of-type { min-width: 0; display: grid; gap: 2px; }
  .topbar > div:first-of-type strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .environment { width: max-content; }
  .user-chip span { display: none; }
  .content { padding: 18px 14px 30px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 14px; }
  .page-heading h1 { font-size: 21px; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .actions .button { width: 100%; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric { border-bottom: 1px solid var(--border); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .filters { grid-template-columns: minmax(0, 1fr) 38px; }
  .segmented { width: 100%; overflow-x: auto; }
  .segmented a { flex: 1 0 auto; }
  .filters select { grid-column: 1 / -1; grid-row: 3; }
  .settings-list section, .settings-list .setting-row { grid-template-columns: 34px minmax(0, 1fr); }
  .settings-list section .status, .settings-list .setting-row .status { grid-column: 2; width: max-content; }
  .setting-row .setting-chevron { display: none; }
  .secret-dialog footer { display: grid; grid-template-columns: 1fr 1fr; }
  .secret-dialog footer .button { width: 100%; white-space: normal; }
  .interaction-dialog footer { display: grid; grid-template-columns: 1fr 1fr; }
  .interaction-dialog footer .dialog-spacer { display: none; }
  .interaction-dialog footer .button { width: 100%; white-space: normal; }
  .interaction-dialog footer .send-button { grid-column: 1 / -1; }
  .customer-message > div { max-height: 145px; }
  .draft-editor textarea { min-height: 155px; }
  .safe-banner { align-items: flex-start; }
  .toast-region {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    width: calc(100vw - 28px);
  }
  body:has(.mobile-sticky-actions:not([hidden])) .toast-region {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }
  .employee-filters,
  .operation-filters { grid-template-columns: minmax(0, 1fr); }
  .employee-filters .search,
  .employee-filters select,
  .employee-filters .button,
  .operation-filters .search,
  .operation-filters select,
  .operation-filters .button {
    width: 100%;
    grid-column: 1;
    grid-row: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-toast,
  .portal-toast.is-leaving { animation: none; }
  .page-state-highlight { transition: none; }
}


.automation-state {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid #b8ddd4;
  border-radius: 6px;
  background: var(--green-soft);
  color: #145e53;
  font-size: 12px;
  font-weight: 700;
}
.auto-reply-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  box-shadow: var(--shadow);
}
.auto-reply-title { min-width: 0; display: flex; align-items: center; gap: 10px; }
.auto-reply-title > svg { width: 21px; height: 21px; color: var(--primary); }
.auto-reply-title > div { display: grid; gap: 2px; }
.auto-reply-title span { color: var(--muted); font-size: 11px; }
.rating-switches { display: flex; align-items: center; gap: 8px; }
.rating-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.rating-label { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 800; }
.rating-label svg { width: 13px; height: 13px; fill: #e8b449; stroke: #c78c16; }
.rating-switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 32px;
  height: 18px;
  position: relative;
  border-radius: 9px;
  background: #cbd3d1;
  transition: background 140ms ease;
}
.switch-track::after {
  content: "";
  width: 14px;
  height: 14px;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 2px rgba(24, 36, 33, .22);
  transition: transform 140ms ease;
}
.rating-switch input:checked + .switch-track { background: var(--primary); }
.rating-switch input:checked + .switch-track::after { transform: translateX(14px); }
.rating-switch input:focus-visible + .switch-track { outline: 3px solid rgba(20, 125, 111, .18); }

.bulk-toolbar {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: white;
}
.select-all-label { display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.select-all-label input, .selection-column input { width: 17px; height: 17px; accent-color: var(--primary); }
.selection-count { color: var(--muted); font-size: 12px; }
.bulk-send { margin-left: auto; }
.bulk-toolbar + .data-table-wrap { border-radius: 0 0 6px 6px; }

.queue-table { min-width: 1380px; }
.queue-table th:nth-child(1) { width: 44px; }
.queue-table th:nth-child(2) { width: 90px; }
.queue-table th:nth-child(3) { width: 210px; }
.queue-table th:nth-child(4) { width: 30%; }
.queue-table th:nth-child(5) { width: 31%; }
.queue-table th:nth-child(6) { width: 125px; }
.queue-table th:nth-child(7) { width: 104px; }
.queue-table td { height: auto; min-height: 94px; }
.selection-column { text-align: center; vertical-align: middle !important; }
.cell-text {
  max-height: none;
  overflow: visible;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.42;
}
.cell-text.fit-medium { font-size: 12px; line-height: 1.38; }
.cell-text.fit-small { font-size: 11px; line-height: 1.34; }
.cell-text.fit-xsmall { font-size: 10px; line-height: 1.3; }
.identity strong, .identity span, .identity small {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-actions form { margin: 0; }
.row-actions .icon-button { margin: 0; }
.row-actions .quick-send { color: var(--primary); }
.row-actions .quick-send:disabled { color: var(--muted); cursor: not-allowed; }
.status.auto { margin-top: 6px; background: #e9f6ff; color: #35699a; }

@media (max-width: 760px) {
  .auto-reply-panel { align-items: stretch; flex-direction: column; }
  .rating-switches { justify-content: space-between; overflow-x: auto; }
  .rating-switch { flex: 0 0 auto; }
  .bulk-toolbar { flex-wrap: wrap; padding: 8px 10px; }
  .bulk-send { width: 100%; margin-left: 0; }
  .automation-state { width: 100%; justify-content: center; }
}

.brand {
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
  padding: 2px 8px 20px;
}
.brand-logo {
  width: 132px;
  height: 53px;
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: #000;
}
.brand-logo img {
  width: 106%;
  height: 106%;
  display: block;
  object-fit: cover;
  transform: translate(-3%, -3%);
}
.brand-subtitle {
  color: var(--sidebar-muted);
  font-size: 10.5px;
  line-height: 1.4;
}
.login-brand {
  width: 100%;
  align-items: center;
  padding: 0 0 24px;
}
.login-brand .brand-logo {
  width: 164px;
  height: 66px;
}
.login-brand .brand-subtitle {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
/* Mobile foundation and queue cards */
.sidebar-close,
.sidebar-backdrop,
.mobile-filter-toggle,
.mobile-card-list,
.mobile-sticky-actions {
  display: none;
}

.mobile-filter-panel {
  display: contents;
}

.filter-submit span,
.mobile-filter-field > span {
  display: none;
}

.filters.queue-filters.appeal-aware {
  grid-template-columns: auto minmax(180px, 1fr) 150px minmax(190px, 230px) 150px 150px 38px;
}

@media (min-width: 769px) and (max-width: 1180px) {
  .filters.queue-filters.appeal-aware {
    grid-template-columns: repeat(4, minmax(0, 1fr)) 38px;
  }
  .queue-kind-tabs,
  .queue-filters .search { grid-column: span 2; }
}

.active-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 12px;
}

.filter-chip {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.filter-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-chip svg {
  width: 12px;
  height: 12px;
}

.text-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-expanded {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.text-toggle {
  width: max-content;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.inline-error.compact {
  padding: 8px 10px;
  font-size: 12px;
}

@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .app-shell,
  .main,
  .content {
    max-width: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    left: 0;
    width: min(288px, 84vw);
    height: 100dvh;
    padding: calc(16px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-104%);
    transition: transform 180ms ease;
    box-shadow: 12px 0 30px rgba(0, 0, 0, .18);
  }

  .sidebar.open {
    left: 0;
    transform: translateX(0);
  }

  .sidebar-close {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    display: inline-grid;
    border-color: #38423f;
    background: #2a3532;
    color: white;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: block;
    border: 0;
    background: rgba(20, 28, 26, .38);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .topbar {
    min-height: calc(56px + env(safe-area-inset-top));
    height: auto;
    align-items: end;
    padding: env(safe-area-inset-top) 12px 8px;
    gap: 8px;
  }

  .topbar strong {
    font-size: 14px;
  }

  .environment {
    width: max-content;
    max-width: 100%;
    padding: 3px 6px;
    font-size: 10px;
  }

  .icon-button {
    min-width: 42px;
    width: 42px;
    height: 42px;
  }

  .button {
    min-height: 42px;
    white-space: normal;
  }

  .content {
    padding: 14px 12px calc(80px + env(safe-area-inset-bottom));
  }

  .page-heading {
    gap: 10px;
    margin-bottom: 14px;
  }

  .page-heading h1 {
    font-size: 20px;
  }

  .page-heading p {
    font-size: 12px;
    line-height: 1.35;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .automation-state {
    min-height: 36px;
    width: 100%;
    justify-content: center;
    text-align: center;
    white-space: normal;
  }

  .auto-reply-panel {
    gap: 10px;
    padding: 10px;
  }

  .auto-reply-title {
    align-items: flex-start;
  }

  .rating-switches {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    overflow-x: visible;
  }

  .rating-switch {
    min-width: 0;
    justify-content: center;
    gap: 4px;
  }

  .switch-track {
    flex: 0 0 auto;
  }

  .filters.queue-filters.appeal-aware {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .queue-kind-tabs {
    grid-column: 1 / -1;
    width: 100%;
    height: auto;
    flex-wrap: wrap;
    overflow: hidden;
  }

  .queue-kind-tabs a {
    min-height: 36px;
    flex: 1 1 50%;
    min-width: 0;
    padding: 0 8px;
    border-bottom: 1px solid var(--border);
    text-align: center;
  }

  .queue-kind-tabs a:nth-last-child(-n+2) {
    border-bottom: 0;
  }

  .queue-filters .search {
    grid-column: 1;
    min-width: 0;
  }

  .mobile-filter-toggle {
    grid-column: 2;
    display: inline-flex;
    padding: 0 11px;
  }

  .mobile-filter-panel {
    grid-column: 1 / -1;
    display: none;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
  }

  .mobile-filter-panel.is-open {
    display: grid;
  }

  .mobile-filter-field {
    display: grid;
    gap: 5px;
    min-width: 0;
  }

  .mobile-filter-field > span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
  }

  .mobile-filter-field select,
  .queue-filters select {
    width: 100%;
    min-width: 0;
  }

  .filter-submit {
    width: 100%;
    display: inline-flex;
    gap: 7px;
  }

  .filter-submit span {
    display: inline;
  }

  .active-filter-chips {
    margin-top: -2px;
    overflow: hidden;
  }

  .filter-chip {
    flex: 1 1 auto;
    min-width: 0;
  }

  .bulk-toolbar,
  .queue-table-wrap {
    display: none;
  }

  .mobile-card-list {
    display: grid;
    gap: 10px;
  }

  .mobile-card {
    min-width: 0;
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    box-shadow: var(--shadow);
  }

  .mobile-card-header {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 9px;
    align-items: start;
  }

  .mobile-card-check {
    min-height: 28px;
    display: grid;
    place-items: center;
  }

  .mobile-card-check input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
  }

  .mobile-card-title {
    min-width: 0;
    display: grid;
    gap: 6px;
  }

  .mobile-card-title > strong {
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.25;
  }

  .mobile-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 0;
  }

  .mobile-card .kind,
  .mobile-card .status,
  .mobile-card .rating {
    width: auto;
    max-width: 100%;
    margin: 0;
    white-space: normal;
  }

  .mobile-card-body {
    display: grid;
    gap: 10px;
    min-width: 0;
  }

  .mobile-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.3;
  }

  .mobile-card-meta span,
  .mobile-card-meta time {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .mobile-card-meta svg {
    width: 14px;
    height: 14px;
  }

  .mobile-card-text {
    display: grid;
    gap: 4px;
    min-width: 0;
  }

  .mobile-card-text > span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .mobile-card-text p {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: #394541;
    font-size: 13px;
    line-height: 1.38;
    white-space: pre-wrap;
  }

  .draft-text p {
    color: #315d55;
  }

  .mobile-card-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 42px;
    gap: 7px;
  }

  .mobile-card-actions form,
  .mobile-card-actions .button {
    min-width: 0;
    width: 100%;
  }

  .mobile-card-more {
    min-width: 0;
    border-top: 1px solid #edf0ef;
    padding-top: 8px;
  }

  .mobile-card-more summary {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
  }

  .mobile-card-more dl {
    display: grid;
    gap: 6px;
    margin: 4px 0 0;
  }

  .mobile-card-more dl div {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 8px;
  }

  .mobile-card-more dt {
    color: var(--muted);
    font-size: 11px;
  }

  .mobile-card-more dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
  }

  .mobile-empty-state {
    color: var(--muted);
    text-align: center;
  }

  .mobile-sticky-actions {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 12px 34px rgba(21, 35, 31, .22);
  }

  .mobile-sticky-actions[hidden] {
    display: none;
  }

  .mobile-sticky-actions span {
    min-width: max-content;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .mobile-sticky-actions .button {
    flex: 1 1 auto;
    min-width: 0;
    padding-inline: 10px;
  }

  .interaction-dialog,
  .secret-dialog,
  .confirm-dialog {
    width: min(100vw - 16px, 560px);
  }

  .interaction-dialog {
    max-height: calc(100dvh - 18px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .interaction-dialog form {
    max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}
@media (max-width: 768px) {
  .mobile-select {
    min-width: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
  }

  .queue-card input[data-row-select] {
    width: 22px;
    height: 22px;
    accent-color: var(--primary);
  }

  .text-toggle {
    min-height: 36px;
    padding: 6px 0;
  }
}

.employee-create-panel,
.employees-panel {
  margin-bottom: 18px;
}
.employee-form,
.employee-edit-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}
.employee-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}
.employee-form label,
.employee-edit-form label,
.access-matrix label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.employee-form input[type="text"],
.employee-form input[type="password"],
.employee-form select,
.employee-edit-form input[type="text"],
.employee-edit-form input[type="password"],
.employee-edit-form select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid #cdd5d3;
  border-radius: 6px;
  padding: 0 10px;
  background: white;
  color: var(--text);
  outline: 0;
}
.employee-form input:focus,
.employee-form select:focus,
.employee-edit-form input:focus,
.employee-edit-form select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 125, 111, 0.12);
}
.employee-active {
  min-height: 38px;
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
  cursor: pointer;
}
.employee-active input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
.access-matrix {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.access-matrix.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.employee-actions {
  display: flex;
  justify-content: flex-end;
}
.employee-grid {
  display: grid;
  grid-template-columns: minmax(180px, .9fr) minmax(130px, .45fr) minmax(360px, 1.6fr) minmax(170px, .7fr) 130px;
  gap: 12px;
  align-items: start;
}
.employee-grid-head {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: #f7f9f8;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.employee-list {
  display: grid;
}
.employee-edit-form {
  border-bottom: 1px solid #edf0ef;
}
.employee-edit-form:last-child {
  border-bottom: 0;
}
.employee-person-cell,
.employee-status-cell,
.employee-password-cell,
.employee-actions-cell {
  min-width: 0;
  display: grid;
  gap: 8px;
}
.employee-actions-cell {
  justify-content: end;
}
.readonly-switches .rating-label {
  padding: 4px 6px;
  border-radius: 4px;
  background: #edf1f4;
  color: var(--muted);
}
.readonly-switches .rating-label.active {
  background: var(--green-soft);
  color: var(--primary);
}

@media (max-width: 768px) {
  .employee-fields,
  .access-matrix,
  .access-matrix.compact,
  .employee-grid {
    grid-template-columns: 1fr;
  }
  .employee-grid-head {
    display: none;
  }
  .employee-edit-form {
    margin: 0 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
  }
  .employee-actions,
  .employee-actions-cell {
    justify-content: stretch;
  }
  .employee-actions .button,
  .employee-actions-cell .button {
    width: 100%;
  }
  .access-matrix {
    gap: 7px;
  }
}



/* RNP dashboard */
.rnp-heading { align-items: flex-start; }
.rnp-import-form {
  display: flex;
  align-items: end;
  gap: 8px;
  max-width: 520px;
}
.rnp-import-form label,
.rnp-field {
  min-width: 0;
  display: grid;
  gap: 5px;
}
.rnp-import-form label { flex: 1 1 260px; }
.rnp-import-form span,
.rnp-field span,
.rnp-chip-block > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.rnp-file-input,
.rnp-field input,
.rnp-field select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
}
.rnp-file-input { padding: 7px 9px; }
.rnp-field input,
.rnp-field select { padding: 0 10px; }
.rnp-banner { margin-bottom: 14px; }
.rnp-filters {
  display: grid;
  grid-template-columns: 170px 180px 180px minmax(220px, 1fr) 38px;
  align-items: end;
  gap: 8px;
  margin-bottom: 14px;
}
.rnp-search { margin-top: auto; }
.rnp-kpi-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.rnp-kpi:nth-child(4n) { border-right: 0; }
.rnp-status-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 18px;
  margin-bottom: 18px;
}
.rnp-panel-body { display: grid; gap: 14px; padding: 16px; }
.rnp-state-list,
.rnp-source-list,
.rnp-sync-list { display: grid; }
.rnp-state-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(132px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid #edf0ef;
}
.rnp-state-row:last-child,
.rnp-source-list > div:last-child,
.rnp-sync-list > div:last-child { border-bottom: 0; }
.rnp-state-row p { min-width: 0; margin: 0; color: var(--muted); line-height: 1.42; overflow-wrap: anywhere; }
.rnp-import-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
}
.rnp-import-summary strong { min-width: 0; overflow-wrap: anywhere; }
.rnp-import-summary span:not(.status) { color: var(--muted); font-size: 12px; }
.rnp-import-summary .status { grid-row: 1 / span 2; grid-column: 2; }
.rnp-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.rnp-stat {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
}
.rnp-stat span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.rnp-stat strong { font-size: 18px; overflow-wrap: anywhere; }
.rnp-chip-block { display: grid; gap: 7px; }
.rnp-chip-list { display: flex; flex-wrap: wrap; gap: 5px; }
.rnp-chip {
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.rnp-source-list > div,
.rnp-sync-list > div {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid #edf0ef;
}
.rnp-source-list strong,
.rnp-sync-list strong { overflow-wrap: anywhere; }
.rnp-source-list span,
.rnp-sync-list small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.rnp-sync-list > div { grid-template-columns: auto minmax(0, 1fr) auto; }
.rnp-table-section { margin-top: 18px; overflow: hidden; }
.rnp-products-table { min-width: 980px; }
.rnp-cost-table { min-width: 1080px; }
.rnp-products-table th:nth-child(1),
.rnp-cost-table th:nth-child(1) { width: 120px; }
.rnp-products-table th:nth-child(2),
.rnp-cost-table th:nth-child(2) { width: 180px; }
.rnp-products-table th:nth-child(6) { width: 140px; }
.rnp-cost-table th:nth-child(5) { width: 140px; }
.rnp-empty-state { display: grid; gap: 6px; place-items: center; }
.rnp-empty-state svg { width: 24px; height: 24px; color: #84a59e; }
.rnp-card-title { min-width: 0; display: grid; gap: 4px; }
.rnp-card-title strong,
.rnp-card-title span { overflow-wrap: anywhere; }
.rnp-card-title span { color: var(--muted); font-size: 12px; }
.rnp-card-cost {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  background: var(--surface-muted);
}
.rnp-card-cost span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.rnp-card-cost strong { font-size: 18px; }

@media (max-width: 1040px) {
  .rnp-filters { grid-template-columns: repeat(2, minmax(0, 1fr)) 42px; }
  .rnp-search { grid-column: 1 / 3; }
  .rnp-status-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .rnp-import-form,
  .rnp-filters { grid-template-columns: 1fr; display: grid; }
  .rnp-import-form .button,
  .rnp-filters .icon-button { width: 100%; }
  .rnp-search { grid-column: auto; }
  .rnp-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rnp-kpi { min-height: 92px; }
  .rnp-kpi:nth-child(2n) { border-right: 0; }
  .rnp-state-row,
  .rnp-source-list > div,
  .rnp-sync-list > div { grid-template-columns: 1fr; align-items: start; }
  .rnp-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rnp-import-summary { grid-template-columns: 1fr; }
  .rnp-import-summary .status { grid-row: auto; grid-column: auto; width: max-content; max-width: 100%; }
  .rnp-products-table-wrap,
  .rnp-cost-table-wrap { display: none; }
  .rnp-mobile-list { margin: 0; padding: 12px; background: var(--surface-muted); }
  .rnp-card .mobile-card-meta { display: flex; }
}

@media (max-width: 430px) {
  .rnp-stat-grid { grid-template-columns: 1fr; }
  .rnp-kpi-grid .metric strong { font-size: 22px; }
}


@media (max-width: 768px) {
  .chat-state-tabs {
    grid-column: 1 / -1;
    width: 100%;
    height: auto;
    flex-wrap: wrap;
  }

  .chat-state-tabs a {
    min-height: 36px;
    flex: 1 1 50%;
    min-width: 0;
    padding: 0 8px;
    text-align: center;
  }
}


/* RNP Dashboard v1: Google Sheet DASHBOARD analogue */
.rnp-actions {
  min-width: min(760px, 100%);
  display: grid;
  gap: 8px;
}
.rnp-import-form.compact {
  max-width: none;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px) auto;
  align-items: end;
}
.rnp-import-form.compact + .rnp-import-form.compact {
  grid-template-columns: minmax(180px, 1fr) auto auto;
}
.rnp-month-input { padding: 0 10px; }
.rnp-filters.dashboard-like {
  grid-template-columns: minmax(150px, 1fr) minmax(140px, .8fr) minmax(180px, 1.1fr) 130px 100px 42px;
}
.rnp-field.small { min-width: 0; }
.dashboard-status { align-items: start; }
.rnp-source-list.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rnp-source-list.compact > div { grid-template-columns: 1fr; align-items: start; gap: 3px; }
.rnp-warning-list { display: grid; gap: 8px; padding: 12px; }
.rnp-warning {
  min-width: 0;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid #f2ddb1;
  border-radius: 6px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  line-height: 1.35;
}
.rnp-warning.danger { border-color: #efc1c1; background: var(--red-soft); color: var(--red); }
.rnp-warning svg { width: 16px; height: 16px; margin-top: 1px; }
.rnp-warning span { min-width: 0; overflow-wrap: anywhere; }
.rnp-dashboard-panel { margin-top: 18px; overflow: hidden; }
.rnp-period-note { color: var(--muted); font-size: 12px; }
.rnp-dashboard-table { min-width: 1260px; table-layout: fixed; }
.rnp-dashboard-table th,
.rnp-dashboard-table td { height: 42px; padding: 8px 9px; vertical-align: middle; text-align: right; }
.rnp-dashboard-table th:first-child,
.rnp-dashboard-table td:first-child { width: 112px; text-align: left; }
.rnp-dashboard-table th { white-space: normal; line-height: 1.2; }
.rnp-dashboard-table td { font-variant-numeric: tabular-nums; }
.rnp-summary-table td { height: 48px; }
.rnp-total-row td { border-top: 2px solid #aebbb7; background: #f2f6f5; font-weight: 800; }
.muted-row td,
.rnp-day-card.muted-row { opacity: .66; }
.metric-cell {
  min-width: 0;
  border-radius: 4px;
  font-weight: 750;
  overflow-wrap: anywhere;
}
.metric-cell.good { background: #dff2e8; color: #176846; }
.metric-cell.warn { background: #fff2c2; color: #805700; }
.metric-cell.bad { background: #fde2df; color: #9d2d2d; }
.metric-cell.neutral { background: transparent; color: inherit; }
.metric-cell.total { color: #102c28; }
.rnp-day-cards,
.rnp-summary-cards { display: none; }
.rnp-card-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.rnp-card-metrics .metric-cell {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--border);
  background-clip: padding-box;
}
.rnp-card-metrics .metric-cell span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
}
.rnp-card-metrics .metric-cell strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

@media (max-width: 1180px) {
  .rnp-filters.dashboard-like { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rnp-filters.dashboard-like .icon-button { width: 100%; }
}

@media (max-width: 768px) {
  .rnp-actions,
  .rnp-import-form.compact,
  .rnp-import-form.compact + .rnp-import-form.compact,
  .rnp-filters.dashboard-like,
  .rnp-source-list.compact { grid-template-columns: 1fr; }
  .rnp-import-form.compact .button { width: 100%; }
  .rnp-dashboard-table-wrap,
  .rnp-summary-table-wrap { display: none; }
  .rnp-day-cards,
  .rnp-summary-cards { display: grid; gap: 10px; padding: 12px; background: var(--surface-muted); }
  .rnp-card-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 430px) {
  .rnp-card-metrics { grid-template-columns: 1fr; }
}
