:root {
  --bg: #fbf7f2;
  --panel: #ffffff;
  --line: #eadfd5;
  --text: #311313;
  --muted: #7a5b52;
  --brand: #3d1616;
  --brand-2: #d08a00;
  --soft: #fff5dd;
  --ok: #e8f5e9;
  --warn: #fff0dc;
  --shadow: 0 16px 32px rgba(61, 22, 22, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #fffaf2 0%, var(--bg) 100%);
  color: var(--text);
  font: 14px/1.5 "PingFang SC", "Helvetica Neue", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

body.login-locked {
  overflow: hidden;
}

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 260px;
  height: 100vh;
  overflow-y: auto;
  padding: 24px;
  background: linear-gradient(180deg, #3d1616 0%, #5a1d1d 72%, #7d4a00 100%);
  color: #fff;
  transition: width 0.2s ease, padding 0.2s ease;
  align-self: flex-start;
}

.shell.sidebar-collapsed .sidebar {
  width: 96px;
  padding: 24px 14px;
}

.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
}

.brand-logo {
  width: 56px;
  height: auto;
  object-fit: contain;
  display: block;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.sidebar-toggle {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font: inherit;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
}

.sidebar-toggle span {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #fff;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 28px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  flex: 0 0 auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

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

.shell.sidebar-collapsed .brand-copy,
.shell.sidebar-collapsed .sidebar-footer {
  display: none;
}

.shell.sidebar-collapsed .sidebar-top {
  flex-direction: column;
  align-items: center;
}

.shell.sidebar-collapsed .brand {
  justify-content: center;
}

.shell.sidebar-collapsed .brand-mark {
  width: 52px;
  height: 52px;
}

.shell.sidebar-collapsed .sidebar-toggle {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

.shell.sidebar-collapsed .nav-item {
  padding: 12px 8px;
  text-align: center;
  font-size: 12px;
}

.shell.sidebar-collapsed .nav-label {
  width: 100%;
}

.shell.sidebar-collapsed .nav-count {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 18px;
}

.sidebar-footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.72);
}

.main {
  flex: 1;
  padding: 28px;
}

.topbar,
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.topbar-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.todo-toast {
  position: fixed;
  top: 22px;
  right: 26px;
  z-index: 1250;
  width: min(360px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 18px;
  background: #dcfce7;
  border: 1px solid #86efac;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: #166534;
}

.todo-toast-title {
  font-weight: 700;
}

.todo-toast-meta {
  margin-top: 6px;
  color: #15803d;
  font-size: 13px;
}

.admin-password-grid {
  margin-top: 18px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.ghost-btn,
.primary-btn,
.small-btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font: inherit;
  cursor: pointer;
}

.save-toast {
  position: fixed;
  top: 22px;
  right: 26px;
  z-index: 1200;
  padding: 12px 18px;
  border-radius: 14px;
  background: #dcfce7;
  color: #166534;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(208, 138, 0, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(61, 22, 22, 0.72), rgba(61, 22, 22, 0.82));
  backdrop-filter: blur(10px);
}

.login-card {
  width: min(440px, 100%);
  padding: 32px;
  border-radius: 28px;
  background: rgba(255, 250, 242, 0.98);
  box-shadow: 0 32px 80px rgba(49, 19, 19, 0.22);
}

.login-kicker {
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card h2 {
  margin: 12px 0 8px;
  font-size: 28px;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

.login-message {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff0dc;
  color: #9a3412;
}

.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-height: 36px;
  white-space: nowrap;
}

.checkbox-chip input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.permission-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.permission-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.password-modal-panel {
  width: min(520px, calc(100vw - 32px));
}

.list-toolbar-group-right {
  gap: 10px;
}

.password-copy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.password-copy-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.ghost-btn {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
}

.primary-btn,
.small-btn.primary {
  background: var(--brand);
  color: #fff;
}

.small-btn.secondary {
  background: #e2e8f0;
  color: var(--text);
}

.metrics {
  display: flex;
  flex-wrap: nowrap;
  gap: 18px;
  margin-top: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.metrics.metrics-five {
  gap: 14px;
}

.metrics.metrics-five .metric-card {
  padding: 18px;
}

.metrics.metrics-five .metric-value {
  font-size: 26px;
}

.metrics .metric-card {
  flex: 0 0 calc((100% - 54px) / 4);
  min-width: 180px;
}

.metrics.metrics-five .metric-card {
  flex: 0 0 calc((100% - 56px) / 5);
  min-width: 160px;
}

.metrics.metrics-six {
  gap: 12px;
}

.metrics.metrics-six .metric-card {
  flex: 0 0 calc((100% - 60px) / 6);
  min-width: 140px;
  padding: 16px;
}

.metrics.metrics-six .metric-value {
  font-size: 24px;
}

.metrics.metrics-seven {
  gap: 10px;
}

.metrics.metrics-seven .metric-card {
  flex: 0 0 calc((100% - 60px) / 7);
  min-width: 132px;
  padding: 16px 14px;
}

.metrics.metrics-seven .metric-value {
  font-size: 22px;
}

.dashboard-metrics-wrap {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-metric-group {
  padding: 18px;
  border: 1px solid rgba(219, 226, 234, 0.7);
  border-radius: 22px;
  background: #fffaf6;
}

.dashboard-metric-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dashboard-metric-group-head h3 {
  margin: 0;
  font-size: 18px;
}

.dashboard-metric-group .metrics {
  margin-top: 0;
  gap: 12px;
  overflow: visible;
  flex-wrap: wrap;
}

.dashboard-metric-group .metric-card {
  flex: 1 1 calc(50% - 6px);
  min-width: 140px;
  padding: 16px;
  box-shadow: none;
}

.dashboard-metric-group .metric-value {
  font-size: 24px;
}

.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.pager {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pager-select {
  min-width: 110px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font: inherit;
}

.pager-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.metric-card,
.panel,
.todo-card {
  background: var(--panel);
  border: 1px solid rgba(219, 226, 234, 0.7);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.metric-card,
.panel {
  padding: 22px;
}

.metric-card-clickable {
  cursor: pointer;
}

.metric-card-clickable:hover {
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.metric-label,
.muted,
th,
.field-label,
.field-help,
.detail-meta {
  color: var(--muted);
}

.metric-value {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 700;
}

.metric-foot {
  margin-top: 8px;
  color: #2563eb;
  font-size: 13px;
}

.section-panel {
  margin-top: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 20px;
}

.tag,
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.tag {
  background: var(--soft);
  color: var(--brand-2);
}

.tag-alert {
  background: var(--warn);
  color: #c2410c;
}

.status.pending {
  background: var(--warn);
  color: #c2410c;
}

.status.resource-ready {
  background: #dcfce7 !important;
  color: #166534 !important;
}

.status.resource-busy {
  background: #dbeafe !important;
  color: #1d4ed8 !important;
}

.status.resource-maintain {
  background: #fef3c7 !important;
  color: #b45309 !important;
}

.status.resource-invalid {
  background: #e5e7eb !important;
  color: #374151 !important;
}

.status.order-pending {
  background: #fff7ed !important;
  color: #9a3412 !important;
}

.status.order-dispatched {
  background: #fef3c7 !important;
  color: #92400e !important;
}

.status.order-picked {
  background: #e0f2fe !important;
  color: #075985 !important;
}

.status.order-transit {
  background: #dbeafe !important;
  color: #1d4ed8 !important;
}

.status.order-delivering {
  background: #ede9fe !important;
  color: #5b21b6 !important;
}

.status.order-signed {
  background: #dcfce7 !important;
  color: #166534 !important;
}

.resource-status-select {
  border-width: 1px;
  font-weight: 700;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.resource-status-select option {
  color: #111827;
  background: #ffffff;
}

.resource-status-select.resource-status-ready,
.resource-status-select option.resource-status-ready {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.resource-status-select.resource-status-busy,
.resource-status-select option.resource-status-busy {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.resource-status-select.resource-status-maintain,
.resource-status-select option.resource-status-maintain {
  background: #fef3c7;
  color: #b45309;
  border-color: #fcd34d;
}

.resource-status-select.resource-status-invalid,
.resource-status-select option.resource-status-invalid {
  background: #e5e7eb;
  color: #374151;
  border-color: #cbd5e1;
}

.status.active {
  background: var(--soft);
  color: var(--brand-2);
}

.status.done {
  background: var(--ok);
  color: #15803d;
}

.status.stage-wait {
  background: #e2e8f0 !important;
  color: #0f172a !important;
  border: 0 !important;
}

.status.stage-quoted {
  background: #dbeafe !important;
  color: #0c4a6e !important;
  border: 0 !important;
}

.status.stage-signing {
  background: #ffedd5 !important;
  color: #7c2d12 !important;
  border: 0 !important;
}

.status.stage-cooperating {
  background: #dcfce7 !important;
  color: #14532d !important;
  border: 0 !important;
}

.todo-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(280px, 1fr));
  gap: 16px;
  overflow-x: auto;
}

.todo-strip-scroll {
  max-height: 500px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 6px;
}

.todo-strip-single {
  grid-template-columns: 1fr;
  overflow-x: visible;
}

.todo-card {
  padding: 18px;
}

.todo-card > .row {
  align-items: flex-start;
  gap: 10px;
}

.todo-group .panel-head {
  margin-bottom: 16px;
}

.todo-title {
  font-size: 17px;
  font-weight: 700;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-meta {
  margin-top: 8px;
  color: var(--muted);
}

.todo-actions,
.toolbar,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.list-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.list-toolbar-split {
  justify-content: space-between;
}

.list-toolbar-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.list-toolbar-group-right {
  margin-left: auto;
}

.list-toolbar-right {
  justify-content: flex-end;
}

.fleet-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(219, 226, 234, 0.7);
  border-radius: 18px;
  background: #f8fafc;
}

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

.fleet-split-panels {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sub-panel {
  padding: 18px;
  border: 1px solid rgba(219, 226, 234, 0.7);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.resource-table-wrap {
  max-height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
}

.resource-table-wrap table {
  margin: 0;
}

.resource-table {
  table-layout: fixed;
}

.resource-table-wrap thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
  white-space: nowrap;
}

.resource-table th,
.resource-table td {
  white-space: nowrap;
}

.resource-table th:nth-child(1),
.resource-table td:nth-child(1) {
  width: 72px;
}

.resource-table th:nth-child(4),
.resource-table td:nth-child(4) {
  width: 88px;
}

.resource-table th:nth-child(5),
.resource-table td:nth-child(5) {
  width: 64px;
}

.resource-action-cell {
  text-align: center;
}

.list-toolbar input,
.list-toolbar select {
  min-width: 180px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font: inherit;
}

.inline-search-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-search-row input {
  flex: 1 1 320px;
  min-width: 240px;
}

.customer-search-input {
  width: 360px;
  min-width: 360px;
  max-width: 100%;
}

.flow-inline {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-left: 20px;
}

.flow-node {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #dbeafe;
  color: #0f172a;
  font-size: 12px;
}

.flow-node.current {
  background: #fef3c7;
  color: #dc2626;
  font-size: 16px;
  font-weight: 700;
}

.flow-node.done {
  background: #dbeafe;
  color: #0f172a;
}

.flow-node.order-pending,
.flow-node.order-pending.current,
.flow-node.order-pending.done {
  background: #fff7ed;
  color: #9a3412;
}

.flow-node.order-dispatched,
.flow-node.order-dispatched.current,
.flow-node.order-dispatched.done {
  background: #fef3c7;
  color: #92400e;
}

.flow-node.order-picked,
.flow-node.order-picked.current,
.flow-node.order-picked.done {
  background: #e0f2fe;
  color: #075985;
}

.flow-node.order-transit,
.flow-node.order-transit.current,
.flow-node.order-transit.done {
  background: #dbeafe;
  color: #1d4ed8;
}

.flow-node.order-delivering,
.flow-node.order-delivering.current,
.flow-node.order-delivering.done {
  background: #ede9fe;
  color: #5b21b6;
}

.flow-node.order-signed,
.flow-node.order-signed.current,
.flow-node.order-signed.done {
  background: #dcfce7;
  color: #166534;
}

.small-btn.disabled-fake {
  background: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
}


table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-weight: 600;
}

.link-btn {
  border: 0;
  background: none;
  color: #2563eb;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.workbench-panel {
  min-height: 420px;
}

.hidden {
  display: none;
}

.field.hidden {
  display: none;
}

.empty-state {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
}

.workbench {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  margin: 14px auto;
  padding: 24px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  contain: layout paint;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 24px 56px rgba(15, 23, 42, 0.18);
}

.detail-header {
  padding: 18px;
  border-radius: 20px;
  background: #f8fafc;
}

.detail-title {
  font-size: 24px;
  font-weight: 700;
}

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

.inquiry-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
  gap: 16px;
}

.inquiry-main {
  min-width: 0;
}

.inquiry-side {
  align-self: start;
}

.detail-card {
  padding: 18px;
  border-radius: 18px;
  background: #f8fafc;
}

.detail-card.full-span {
  grid-column: 1 / -1;
}

.detail-card h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.inquiry-history-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 16px;
  background: #eef4ff;
}

.inquiry-history-box h3 {
  margin-bottom: 12px;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.order-list-card {
  overflow-x: auto;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}

.field.full {
  grid-column: 1 / -1;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-item {
  padding-left: 16px;
  border-left: 3px solid #bfdbfe;
}

.maintenance-timeline .timeline-item {
  padding: 12px 14px 12px 16px;
  border-radius: 14px;
  background: #f8fafc;
}

.maintenance-timeline .timeline-item p {
  margin: 6px 0;
  color: var(--text);
}

.maintenance-timeline .timeline-item span {
  color: var(--muted);
  font-size: 13px;
}

.timeline-item-stage {
  padding: 10px 12px 10px 16px;
  border-left-color: #f59e0b;
  border-radius: 12px;
  background: #fff7ed;
}

.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.timeline-changes {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.timeline-changes summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.timeline-changes summary::-webkit-details-marker {
  display: none;
}

.timeline-body {
  margin-top: 10px;
  color: var(--text);
}

.timeline-change-row + .timeline-change-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.message-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
}

.message-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.message-panel-head h3 {
  margin: 0;
  font-size: 20px;
}

.message-customer-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(219, 226, 234, 0.9);
  border-radius: 14px;
  background: #f8fafc;
}

.message-customer-strip > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.message-customer-strip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-list {
  display: grid;
  gap: 10px;
  min-height: 360px;
  max-height: 520px;
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(219, 226, 234, 0.8);
  border-radius: 16px;
  background: #f8fafc;
}

.message-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.message-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.message-admin .message-meta {
  text-align: right;
}

.message-admin {
  align-items: flex-end;
}

.message-customer {
  align-items: flex-start;
}

.message-bubble {
  display: inline-block;
  width: auto;
  max-width: min(760px, 82%);
  margin: 0;
  padding: 4px 8px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 18px rgba(61, 22, 22, 0.06);
}

.message-customer .message-bubble {
  background: #fff;
  border-color: #dbe2ea;
}

.message-admin .message-bubble {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.quick-replies {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-reply {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.quick-reply:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.message-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
  align-items: end;
}

.message-composer textarea {
  min-height: 112px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: #fff;
  font: inherit;
  line-height: 1.6;
}

.message-actions {
  display: flex;
  align-items: stretch;
}

.message-actions .small-btn {
  width: 100%;
  min-height: 44px;
}

.reply-board {
  display: grid;
  gap: 12px;
}

.reply-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(219, 226, 234, 0.9);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.reply-card p {
  margin: 10px 0;
  color: var(--text);
}

.communication-page {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.communication-sidebar,
.communication-chat {
  min-width: 0;
}

.communication-sidebar {
  padding: 16px;
  border: 1px solid rgba(219, 226, 234, 0.9);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.communication-thread {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.communication-thread:hover,
.communication-thread.active {
  border-color: var(--brand);
  background: #fffaf6;
}

.communication-thread-title {
  font-weight: 700;
}

.communication-thread-customer,
.communication-thread-preview,
.communication-thread-foot {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.communication-thread-preview {
  color: var(--text);
}

.communication-empty {
  min-height: 520px;
  display: grid;
  place-content: center;
  text-align: center;
}

@media (max-width: 820px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .shell.sidebar-collapsed .sidebar {
    width: 100%;
  }

  .metrics,
  .dashboard-metrics-wrap,
  .split-panels,
  .inquiry-layout,
  .detail-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .todo-strip {
    grid-template-columns: 1fr;
  }

  .message-composer {
    grid-template-columns: 1fr;
  }

  .message-customer-strip {
    grid-template-columns: 1fr;
  }

  .communication-page {
    grid-template-columns: 1fr;
  }
}
