:root {
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --text: #182025;
  --muted: #68757f;
  --line: #d8e0e5;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #b42318;
  --warning: #b45309;
  --ok: #127c4a;
  --shadow: 0 14px 32px rgba(24, 32, 37, 0.08);
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  height: 100vh;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 18px;
}

.login-panel h1,
.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.muted,
.form-message,
.small-note {
  color: var(--muted);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 11px;
}

.keyword-filter-field {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 11px;
  overflow: hidden;
  white-space: nowrap;
}

div.keyword-filter-field:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

textarea {
  resize: vertical;
  min-height: 130px;
}

input:focus,
select:focus,
textarea:focus,
div[contenteditable="true"]:focus,
button:focus {
  outline: 2px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

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

.sidebar {
  background: #182025;
  color: #eaf0f2;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #a9b7bf;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #cbd7dc;
  text-align: left;
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-item b {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #f97316;
  color: #fff;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  font-size: 11px;
}

.nav-item b.empty {
  display: none;
}

.sidebar-status {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 14px;
  color: #a9b7bf;
  font-size: 12px;
  line-height: 1.6;
}

.sidebar-status strong {
  display: block;
  color: #fff;
  margin-bottom: 4px;
}

.sidebar-status hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  margin: 10px 0;
}

.main {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  min-height: 104px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 22px;
  gap: 16px;
}

.topbar-title {
  min-width: 220px;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  min-height: 28px;
}

.topbar-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.topbar-shop {
  min-width: 220px;
}

.status-pill {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafb;
  color: var(--muted);
  padding: 3px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.status-pill strong {
  color: var(--text);
}

.status-pill.ok {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #166534;
}

.status-pill.warning {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.status-pill.danger {
  background: #fff1f0;
  border-color: #fecaca;
  color: var(--danger);
}

.topbar-actions,
.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions button {
  min-height: 40px;
  white-space: nowrap;
}

.primary-button,
.ghost-button,
.danger-button,
.send-button {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 12px;
  font-weight: 700;
}

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

.ghost-button {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.danger-button {
  background: #fff4f2;
  color: var(--danger);
  border-color: #ffd0ca;
}

.send-button {
  background: #0f5132;
  color: #fff;
}

.primary-button:disabled,
.ghost-button:disabled,
.send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tab-view {
  min-height: 0;
  height: 100%;
  padding: 18px;
  overflow: auto;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr) minmax(320px, 1fr);
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.today-dashboard {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.dashboard-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.dashboard-hero h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid #94a3b8;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 6px;
  min-height: 146px;
}

.metric-card > span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card > strong {
  font-size: 28px;
  line-height: 1;
}

.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.metric-card.danger {
  border-left-color: var(--danger);
}

.metric-card.warning {
  border-left-color: var(--warning);
}

.metric-card.ok {
  border-left-color: var(--ok);
}

.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 14px;
  min-width: 0;
}

.dashboard-columns > *,
.metric-grid > * {
  min-width: 0;
}

.sync-summary-panel {
  grid-column: 1 / -1;
}

.task-list,
.process-list {
  display: grid;
  gap: 10px;
}

.task-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: #fff;
}

.task-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.task-row.danger {
  border-color: #fecaca;
  background: #fff7f6;
}

.task-row.warning {
  border-color: #fed7aa;
  background: #fffaf2;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.status-grid div,
.context-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
  display: grid;
  gap: 5px;
}

.status-grid span,
.context-card span {
  color: var(--muted);
  font-size: 12px;
}

.status-grid strong,
.context-card strong {
  overflow-wrap: anywhere;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.workbench > .panel:not(.recommendation-pane) {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h2 {
  font-size: 16px;
  margin: 0;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.queue-shop-switch {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  display: grid;
  gap: 8px;
}

.queue-shop-switch label {
  color: var(--text);
  font-weight: 700;
}

.queue-shop-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.conversation-list,
.message-list,
.recommendation-list,
.template-list,
.log-list {
  overflow: auto;
  min-height: 0;
}

.conversation-list {
  flex: 1;
  height: auto;
}

.conversation-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
  padding: 12px 14px;
  display: grid;
  gap: 6px;
  cursor: pointer;
}

.conversation-row:hover,
.conversation-row.active {
  background: #edf7f5;
}

.conversation-row.pinned {
  border-left: 4px solid var(--accent);
  background: #f0fdfa;
}

.conversation-row.completed {
  opacity: 0.68;
  background: #f8fafb;
}

.conversation-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row-title,
.message-meta,
.badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.row-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snippet {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thread-subline {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef2f4;
  color: #42505a;
  font-size: 12px;
  font-weight: 700;
}

.badge.high {
  background: #fff1f0;
  color: var(--danger);
}

.badge.medium {
  background: #fff7ed;
  color: var(--warning);
}

.badge.low {
  background: #ecfdf3;
  color: var(--ok);
}

.badge.pinned {
  background: #ccfbf1;
  color: #0f766e;
}

.badge.resolved {
  background: #e0f2fe;
  color: #075985;
}

.message-list {
  flex: 1;
  height: auto;
  padding: 16px;
  background: #f8fafb;
}

.conversation-context {
  padding: 12px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.context-card small {
  color: var(--muted);
  line-height: 1.35;
}

.message {
  max-width: 78%;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.message.customer {
  margin-right: auto;
  border-color: #cfe1ff;
}

.message.staff {
  margin-left: auto;
  border-color: #cbe8df;
}

.message-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.recommendation-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
}

.recommendation-list {
  padding: 12px;
}

.review-notice {
  border: 1px solid #cfe1ff;
  background: #f4f8ff;
  color: #1e3a8a;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  margin-bottom: 12px;
}

.review-notice.danger {
  border-color: #fecaca;
  background: #fff1f0;
  color: var(--danger);
}

.recommendation-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.recommendation-option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.reply-text {
  white-space: pre-wrap;
  line-height: 1.45;
}

.translation,
.basis {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.translated-box {
  margin-top: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.attachment-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.attachment-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fbff;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.attachment-item a,
.attachment-item span {
  min-width: 0;
  color: var(--accent-2);
  font-weight: 700;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-item small {
  color: var(--muted);
  font-size: 12px;
}

.pending-attachments {
  margin-top: 0;
}

.pending-attachments .attachment-item {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.send-box {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: var(--surface-2);
  display: grid;
  gap: 10px;
}

.split-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.settings-page {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.settings-page > aside.content-panel {
  grid-column: 2;
  grid-row: 1;
}

.settings-wide {
  grid-column: 1 / -1;
}

.content-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.data-table th {
  background: var(--surface-2);
  color: var(--muted);
}

.shop-roster {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.shop-roster .data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-button {
  padding: 6px 8px;
  font-size: 12px;
}

.code-block {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  background: #101820;
  color: #e8f0f2;
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
}

.logistics-page {
  display: grid;
  grid-template-columns: 320px minmax(340px, 0.9fr) minmax(420px, 1.25fr);
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.logistics-query-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.panel-header.plain {
  padding: 0 0 10px;
  border-bottom: 0;
}

.compact-textarea {
  min-height: 132px;
}

.inline-check {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}

.inline-check input {
  width: auto;
  margin-top: 3px;
}

.filter-stack {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.quality-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.logistics-list-panel,
.logistics-detail-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.shipment-list,
.shipment-detail {
  flex: 1;
  height: auto;
  min-height: 0;
  overflow: auto;
}

.shipment-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
  padding: 13px 14px;
  display: grid;
  gap: 8px;
}

.shipment-row:hover,
.shipment-row.active {
  background: #edf7f5;
}

.shipment-summary {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.shipment-detail {
  padding: 14px;
  background: #f8fafb;
}

.detail-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.detail-block h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

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

.meta-grid div {
  display: grid;
  gap: 4px;
}

.meta-grid span {
  color: var(--muted);
  font-size: 12px;
}

.meta-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.warning-text {
  color: var(--warning);
  margin: 12px 0 0;
}

.reply-text.boxed {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.events-block {
  padding-bottom: 4px;
}

.send-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 32, 37, 0.42);
}

.send-confirm-modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 12px;
  position: relative;
}

.event-row time {
  color: var(--muted);
  font-size: 12px;
}

.event-row strong,
.event-row span {
  display: block;
  line-height: 1.4;
}

.event-row span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.history-knowledge-page,
.template-library-page,
.logs-page {
  display: grid;
  gap: 14px;
}

.process-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  display: grid;
  gap: 4px;
  background: #fff;
}

.process-list span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.template-filter-grid {
  border: 0;
  padding: 0;
  margin-top: 12px;
}

@media (max-width: 1400px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .logistics-page {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .logistics-detail-panel {
    grid-column: 1 / -1;
    min-height: 520px;
  }
}

@media (max-width: 1180px) {
  .workbench {
    grid-template-columns: 300px minmax(320px, 1fr);
  }

  .recommendation-pane {
    grid-column: 1 / -1;
    min-height: 460px;
  }

  .logistics-page {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .logistics-detail-panel {
    grid-column: 1 / -1;
    min-height: 520px;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .main {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .tab-view {
    height: auto;
    overflow: visible;
  }

  .topbar-title,
  .topbar-controls,
  .topbar-shop,
  .topbar-actions,
  .tab-view,
  .content-panel,
  .settings-page,
  .filter-grid {
    min-width: 0;
    width: 100%;
  }

  .topbar-shop {
    min-width: 0;
  }

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

  .topbar-actions button {
    flex: 1 1 140px;
  }

  .filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .workbench,
  .logistics-page,
  .settings-page,
  .split-page,
  .dashboard-columns,
  .metric-grid {
    height: auto;
    grid-template-columns: 1fr;
  }

  .topbar,
  .dashboard-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-controls {
    align-items: stretch;
  }

  .conversation-context,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .conversation-list,
  .message-list,
  .shipment-list,
  .shipment-detail {
    height: auto;
    max-height: 520px;
  }

  .settings-wide {
    grid-column: auto;
  }

  .settings-page > aside.content-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .meta-grid,
  .event-row {
    grid-template-columns: 1fr;
  }
}

