:root {
  --ink: #272320;
  --muted: #7d716b;
  --line: #eadfd7;
  --panel: rgba(255, 255, 255, 0.93);
  --paper: #fffaf6;
  --brand: #8f3844;
  --brand-strong: #762c36;
  --brand-soft: #faebe5;
  --green: #2f7d5a;
  --amber: #b06b24;
  --red: #b64747;
  --blue: #3f678d;
  --shadow: 0 18px 50px rgba(72, 48, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(143, 56, 68, 0.08), transparent 30%),
    linear-gradient(135deg, #f4f1ec 0%, #f7f4ef 45%, #eef3ef 100%);
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

.login-card {
  width: min(460px, 100%);
  padding: 34px;
  border: 1px solid rgba(143, 56, 68, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 250, 246, 0.94)),
    var(--paper);
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  gap: 8px;
  margin-bottom: 28px;
}

.login-brand span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.login-card h1,
.login-card p {
  margin: 0;
}

.login-card h1 {
  font-size: 28px;
  line-height: 1.2;
}

.login-card p {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: #665a54;
  font-weight: 700;
  font-size: 14px;
}

.field input,
.field select,
.field textarea,
.search-row input,
.search-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input,
.field select,
.search-row input,
.search-row select {
  height: 44px;
  padding: 0 14px;
}

.field textarea {
  min-height: 112px;
  resize: vertical;
  padding: 12px 14px;
  line-height: 1.65;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-row input:focus,
.search-row select:focus {
  border-color: rgba(143, 56, 68, 0.65);
  box-shadow: 0 0 0 4px rgba(143, 56, 68, 0.1);
}

.login-form {
  display: grid;
  gap: 16px;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.link-btn {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
}

.primary-btn {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 24px rgba(143, 56, 68, 0.2);
}

.primary-btn:hover {
  background: var(--brand-strong);
}

.ghost-btn {
  background: #fff8f5;
  border-color: #edcfc8;
  color: var(--brand);
}

.danger-btn {
  background: #fff4f2;
  border-color: #efc8c3;
  color: var(--red);
}

.link-btn {
  background: transparent;
  color: var(--brand);
  padding: 0 6px;
}

.mini-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 14px;
}

.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.error {
  color: var(--red);
  min-height: 22px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  color: #f8eee9;
  background:
    linear-gradient(180deg, rgba(45, 38, 35, 0.98), rgba(67, 45, 43, 0.98)),
    #2f2926;
}

.side-brand {
  margin-bottom: 32px;
}

.side-brand h1,
.side-brand p {
  margin: 0;
}

.side-brand h1 {
  font-size: 28px;
  letter-spacing: 0;
}

.side-brand p {
  margin-top: 8px;
  color: rgba(248, 238, 233, 0.68);
}

.side-nav {
  display: grid;
  grid-auto-rows: 48px;
  gap: 8px;
}

.side-nav button {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 10px;
  padding: 0 16px;
  text-align: left;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  font-weight: 800;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.side-nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.side-nav button.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 3px 0 rgba(238, 177, 154, 0.92);
}

.admin-main {
  width: 100%;
  max-width: 1680px;
  min-width: 0;
  margin: 0 auto;
  padding: 30px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.title h2,
.title p {
  margin: 0;
}

.title h2 {
  font-size: 30px;
  line-height: 1.2;
}

.title p {
  margin-top: 8px;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.account-summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.session-check {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--muted);
}

.session-check-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--brand);
  font-size: 20px;
  font-weight: 900;
}

.card {
  border: 1px solid rgba(234, 223, 215, 0.9);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  padding: 18px;
}

.stat b {
  display: block;
  color: var(--brand);
  font-size: 30px;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  font-weight: 700;
}

.panel {
  padding: 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-head h3,
.panel-head p {
  margin: 0;
}

.panel-head h3 {
  font-size: 22px;
}

.panel-head p {
  margin-top: 6px;
  color: var(--muted);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  gap: 12px;
  margin-bottom: 18px;
}

.search-row.has-manager-filter {
  grid-template-columns: minmax(260px, 1fr) 160px 220px auto;
}

.customer-search-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  min-width: 0;
}

.customer-search-submit {
  min-width: 68px;
  min-height: 44px;
  border: 1px solid var(--brand);
  border-radius: 12px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.customer-search-submit:hover {
  background: var(--brand-strong);
}

.customer-search-submit:focus-visible {
  outline: 3px solid rgba(143, 56, 68, 0.18);
  outline-offset: 2px;
}

.mobile-manager-filter {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.mobile-manager-filter label {
  flex: 0 0 auto;
  margin-right: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mobile-manager-filter select {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  border: 0;
  padding: 0 10px;
  background: #fffaf6;
  color: var(--ink);
  font-weight: 800;
}

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

.customer-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-height: 52px;
  margin-top: 4px;
  padding: 18px 4px 0;
  border-top: 1px solid rgba(234, 223, 215, 0.82);
  color: var(--muted);
}

.pagination-total {
  margin-right: auto;
  font-weight: 800;
}

.pagination-control,
.pagination-pages {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-control select,
.pagination-page,
.mobile-pagination select {
  width: auto;
  min-height: 40px;
  border: 1px solid #edcfc8;
  border-radius: 10px;
  padding: 0 34px 0 12px;
  outline: none;
  background-color: #fff8f5;
  color: var(--brand);
  font-weight: 800;
  box-shadow: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.pagination-control select:hover,
.pagination-page:hover,
.mobile-pagination select:hover {
  border-color: rgba(143, 56, 68, 0.42);
  background-color: #fff4ef;
}

.pagination-control select:focus,
.pagination-page:focus,
.mobile-pagination select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(143, 56, 68, 0.12);
}

.pagination-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #edcfc8;
  border-radius: 8px;
  background: #fff8f5;
  color: var(--brand);
  font-size: 18px;
  font-weight: 900;
}

.pagination-btn:disabled {
  cursor: not-allowed;
  border-color: var(--line);
  background: #f7f3f0;
  color: #bca9a3;
  opacity: 0.42;
}

.pagination-count {
  white-space: nowrap;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 12px;
  border-bottom: 1px solid rgba(234, 223, 215, 0.82);
  text-align: left;
  vertical-align: top;
}

th {
  color: #6e635d;
  font-size: 14px;
}

td {
  line-height: 1.55;
}

.customer-name {
  font-weight: 900;
  font-size: 17px;
}

.subtext {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.status-pill,
.risk-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.consulting {
  color: #7d4c0e;
  background: #fff0d8;
}

.status-pill.preparing {
  color: #7c3843;
  background: #fae7e8;
}

.status-pill.rejected {
  color: #8c3b3b;
  background: #ffe5e2;
}

.status-pill.submitted {
  color: #2f6687;
  background: #e4f1f8;
}

.status-pill.landed {
  color: #2d7755;
  background: #e3f3ea;
}

.risk-pill.low {
  color: #2d7755;
  background: #e3f3ea;
}

.risk-pill.mid {
  color: #7d4c0e;
  background: #fff0d8;
}

.risk-pill.high {
  color: #8c3b3b;
  background: #ffe5e2;
}

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

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

.field.wide {
  grid-column: span 2;
}

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

.confirm-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf6;
  cursor: pointer;
}

.confirm-check input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.confirm-check span,
.confirm-check small {
  display: block;
}

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

.assignment-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.assignment-option:has(input:checked) {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.assignment-option input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--brand);
}

.assignment-option span,
.assignment-option b,
.assignment-option small {
  display: block;
  min-width: 0;
}

.assignment-option small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.4;
}

.sync-workspace {
  display: grid;
  gap: 22px;
}

.sync-principle,
.sync-last-run {
  display: grid;
  gap: 5px;
  padding: 15px 17px;
  border-left: 4px solid var(--brand);
  background: #fff8f5;
}

.sync-principle span,
.sync-last-run p,
.sync-enabled small,
.sync-review-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.sync-source-block {
  display: grid;
  gap: 18px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.sync-source-head {
  margin-bottom: 0;
}

.sync-title-row,
.sync-review-head,
.sync-candidate,
.sync-section-title,
.sync-last-run > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sync-title-row {
  justify-content: flex-start;
}

.sync-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: #fff;
}

.sync-metrics > div {
  display: grid;
  gap: 4px;
  padding: 17px;
  border-right: 1px solid var(--line);
}

.sync-metrics > div:last-child {
  border-right: 0;
}

.sync-metrics b {
  color: var(--brand);
  font-size: 24px;
}

.sync-metrics span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.sync-last-run > div {
  justify-content: flex-start;
}

.sync-error {
  color: var(--red) !important;
}

.sync-section-title h4,
.sync-section-title p,
.sync-review-head b,
.sync-review-head span,
.sync-candidate b,
.sync-candidate span {
  margin: 0;
}

.sync-section-title h4 {
  font-size: 18px;
}

.sync-section-title p,
.sync-review-head span,
.sync-candidate span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.sync-section-title > b {
  min-width: 34px;
  padding: 6px 10px;
  text-align: center;
  color: var(--brand);
  background: var(--brand-soft);
}

.sync-review-list {
  display: grid;
  gap: 12px;
}

.sync-review-item {
  display: grid;
  gap: 13px;
  padding: 17px;
  border: 1px solid var(--line);
  background: #fff;
}

.sync-review-facts {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 10px;
}

.sync-review-facts > span {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  background: #faf7f4;
  font-weight: 700;
}

.sync-review-facts small {
  color: var(--muted);
  font-weight: 600;
}

.sync-candidate {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.sync-review-actions {
  justify-content: flex-end;
}

.sync-source-form {
  display: grid;
  gap: 18px;
}

.sync-enabled {
  grid-column: span 2;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  background: #fffaf6;
  cursor: pointer;
}

.sync-enabled input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.sync-enabled b,
.sync-enabled small {
  display: block;
}

.sync-bulk-preview {
  max-width: 1180px;
}

.sync-bulk-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: #fff;
}

.sync-bulk-metrics > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 17px;
  border-right: 1px solid var(--line);
}

.sync-bulk-metrics > div:last-child {
  border-right: 0;
}

.sync-bulk-metrics b {
  color: var(--brand);
  font-size: 24px;
}

.sync-bulk-metrics span,
.sync-bulk-skipped span {
  color: var(--muted);
  font-size: 14px;
}

.sync-bulk-item {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  background: #fff;
}

.sync-bulk-item.selected {
  border-color: #c7746c;
  box-shadow: inset 4px 0 0 var(--brand);
}

.sync-bulk-customer-check {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-width: 0;
  cursor: pointer;
}

.sync-bulk-customer-check input,
.sync-bulk-select-all input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--brand);
  flex: 0 0 auto;
}

.sync-bulk-customer-check > span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.sync-bulk-customer-check small {
  color: var(--muted);
  font-size: 13px;
}

.sync-bulk-select-head {
  align-items: center;
}

.sync-bulk-select-all {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #fffaf7;
  cursor: pointer;
}

.sync-bulk-select-all span {
  color: var(--brand);
  font-weight: 700;
}

.sync-bulk-select-all b {
  padding-left: 9px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.sync-bulk-fields {
  display: grid;
  gap: 10px;
}

.sync-bulk-field {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.sync-bulk-field > b {
  display: grid;
  align-content: center;
  padding: 11px 12px;
  background: #faf7f4;
}

.sync-bulk-field > div {
  min-width: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--line);
  background: #fcfbfa;
}

.sync-bulk-field > div:last-child {
  border-left-color: var(--brand);
  background: #fff8f5;
}

.sync-bulk-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sync-bulk-field p {
  margin: 5px 0 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.sync-bulk-skipped {
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.sync-bulk-skipped > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr);
  gap: 14px;
  padding: 13px 15px;
  background: #fff;
}

.sync-bulk-excluded {
  padding: 13px 15px;
  color: var(--muted);
  background: #f8f5f2;
}

.sync-bulk-confirm {
  margin-top: 2px;
}

.sync-bulk-confirm.disabled {
  cursor: not-allowed;
  opacity: 0.66;
}

.confirm-check small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.readonly-value {
  min-height: 44px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f5f2;
  font-weight: 800;
}

.readonly-value span,
.field-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.attachment-list,
.timeline-list {
  display: grid;
  gap: 10px;
}

.attachment-item,
.timeline-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf6;
}

.attachment-item div,
.timeline-item {
  min-width: 0;
}

.attachment-item b,
.attachment-item span,
.timeline-item b,
.timeline-item span,
.timeline-item p {
  display: block;
}

.attachment-item b {
  overflow-wrap: anywhere;
}

.attachment-item span,
.timeline-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.attachment-item-actions,
.mobile-attachment-actions,
.attachment-preview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.attachment-pending {
  color: #a15d28 !important;
}

.attachment-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(32, 27, 25, 0.72);
  backdrop-filter: blur(4px);
}

.attachment-preview-dialog {
  width: min(1120px, 96vw);
  height: min(820px, 92vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #eadfd7;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(22, 17, 15, 0.28);
}

.attachment-preview-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fffaf6;
}

.attachment-preview-head > div:first-child {
  min-width: 0;
}

.attachment-preview-head b,
.attachment-preview-head span {
  display: block;
  overflow-wrap: anywhere;
}

.attachment-preview-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.attachment-preview-canvas {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 20px;
  background: #2a2725;
}

.attachment-preview-canvas img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center;
  transition: transform 160ms ease;
}

.attachment-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #f5f1ee;
}

.attachment-preview-text {
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: auto;
  padding: 22px;
  background: #fbf8f5;
  color: #302b28;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 14px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.timeline-item {
  display: block;
}

.timeline-item p {
  margin: 8px 0 0;
  line-height: 1.55;
}

.account-editor {
  margin: 16px 0;
  padding: 18px;
  border: 1px solid #edcfc8;
  border-radius: 12px;
  background: #fff9f6;
}

.backup-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.backup-summary > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7fbf8;
}

.backup-summary.warning > div:last-child {
  border-color: #ebcca8;
  background: #fff8ed;
}

.backup-summary b,
.backup-summary span {
  display: block;
}

.backup-summary span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.form-section-title {
  grid-column: 1 / -1;
  margin: 10px 0 -2px;
  padding-top: 8px;
  border-top: 1px solid rgba(234, 223, 215, 0.8);
  color: var(--brand);
  font-weight: 900;
}

.customer-attachment-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
}

.customer-attachment-editor-head,
.attachment-upload-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.customer-attachment-editor-head b,
.customer-attachment-editor-head span,
.attachment-upload-progress b,
.attachment-upload-progress span,
.attachment-upload-progress small {
  display: block;
}

.customer-attachment-editor-head span,
.attachment-upload-progress span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.attachment-upload-progress small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.visually-hidden-file {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.attachment-upload-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 38%) minmax(150px, auto);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf6;
}

.attachment-upload-track {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #eadfd7;
}

.attachment-upload-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width 160ms ease;
}

.attachment-upload-progress strong {
  color: var(--brand);
  text-align: right;
}

.attachment-upload-summary {
  min-width: 150px;
  text-align: right;
}

.attachment-upload-progress.failed {
  border-color: rgba(182, 71, 71, 0.32);
  background: #fff5f3;
}

.attachment-upload-progress.failed strong {
  color: var(--red);
}

.active-operation-progress {
  position: sticky;
  top: 12px;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(180px, 32%) minmax(160px, auto);
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(143, 56, 68, 0.22);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: rgba(255, 250, 246, 0.98);
  box-shadow: 0 10px 28px rgba(72, 48, 38, 0.12);
  backdrop-filter: blur(12px);
}

.active-operation-copy b,
.active-operation-copy span,
.active-operation-status strong,
.active-operation-status span {
  display: block;
}

.active-operation-copy b,
.active-operation-status strong {
  color: var(--brand);
}

.active-operation-copy span,
.active-operation-status span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.active-operation-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-operation-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #eadfd7;
}

.active-operation-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #c66d4f);
  transition: width 180ms ease;
}

.active-operation-status {
  min-width: 160px;
  text-align: right;
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.detail-layout {
  display: grid;
  gap: 16px;
}

.detail-hero {
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(143, 56, 68, 0.94), rgba(191, 109, 79, 0.9)),
    var(--brand);
  color: #fff;
}

.detail-hero h3,
.detail-hero p {
  margin: 0;
}

.detail-hero h3 {
  font-size: 28px;
}

.detail-hero p {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.82);
}

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

.info-box {
  padding: 16px;
  border: 1px solid rgba(234, 223, 215, 0.9);
  border-radius: 14px;
  background: rgba(255, 250, 246, 0.9);
}

.info-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.info-box b {
  display: block;
  margin-top: 8px;
  line-height: 1.5;
}

.info-box.full {
  grid-column: 1 / -1;
}

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

.followup-item {
  padding: 14px;
  border: 1px solid rgba(234, 223, 215, 0.9);
  border-radius: 12px;
  background: #fffaf6;
}

.followup-item b {
  display: block;
  margin-bottom: 6px;
}

.followup-item p {
  margin: 0;
  color: #5d524d;
  line-height: 1.6;
}

.import-workspace,
.account-form-page {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.import-page-head {
  align-items: center;
  margin-bottom: 22px;
}

.analyzer-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #d6e9de;
  border-radius: 999px;
  background: #edf8f2;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.analyzer-status.warning {
  border-color: #ecd9bd;
  background: #fff7e9;
  color: #8a5a1e;
}

.import-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 22px;
}

.import-steps > div {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #faf8f6;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.import-steps b {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e9e3de;
  color: #6e635d;
  font-size: 12px;
}

.import-steps > div.active {
  border-color: rgba(143, 56, 68, 0.28);
  background: #fff5f2;
  color: var(--brand);
}

.import-steps > div.active b {
  background: var(--brand);
  color: #fff;
}

.import-source-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  width: min(520px, 100%);
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid rgba(234, 223, 215, 0.9);
  border-radius: 12px;
  background: #f4efeb;
}

.import-source-tab {
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #756963;
  font-weight: 800;
}

.import-source-tab:hover {
  color: var(--brand);
}

.import-source-tab.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 3px 12px rgba(72, 48, 38, 0.1);
}

.import-source-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  grid-template-areas:
    "copy selection"
    "copy actions";
  gap: 16px 28px;
  align-items: center;
  min-height: 210px;
  padding: 26px;
  border: 1px solid rgba(143, 56, 68, 0.2);
  border-radius: 14px;
  background: #fffaf7;
}

.server-source-panel {
  grid-template-areas:
    "copy field"
    "copy actions";
}

.import-picker-copy {
  grid-area: copy;
}

.section-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 900;
}

.import-picker-copy h4,
.import-picker-copy p {
  margin: 0;
}

.import-picker-copy h4 {
  font-size: 22px;
  line-height: 1.35;
}

.import-picker-copy p {
  max-width: 620px;
  margin-top: 9px;
  color: var(--muted);
  line-height: 1.65;
}

.import-selection {
  grid-area: selection;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.selection-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #b9ada6;
}

.import-selection.ready .selection-dot {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(47, 125, 90, 0.1);
}

.import-selection b,
.import-selection small {
  display: block;
}

.import-selection small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

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

.server-path-field {
  grid-area: field;
}

.server-actions {
  grid-template-columns: 1fr;
}

.import-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: #6a5d56;
  font-size: 13px;
  line-height: 1.6;
}

.import-note b {
  color: var(--brand);
  white-space: nowrap;
}

.file-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.import-progress,
.operation-progress {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(143, 56, 68, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
}

.operation-progress {
  margin-top: 0;
  border-radius: 8px;
  background: #fffaf6;
}

.operation-progress.failed {
  border-color: rgba(182, 71, 71, 0.34);
  background: #fff5f3;
}

.operation-progress.failed .progress-head b,
.operation-progress.failed .progress-head strong {
  color: var(--red);
}

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

.progress-head b,
.progress-head span {
  display: block;
}

.progress-head b,
.progress-head strong {
  color: var(--brand);
  font-weight: 900;
}

.progress-head span {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.5;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #f2ded8;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #c66d4f);
  transition: width 0.22s ease;
}

.progress-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.progress-meta span {
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff7f3;
}

.import-job-grid,
.import-item-list {
  display: grid;
  gap: 12px;
}

.import-summary-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.import-job-card,
.import-item {
  display: block;
  width: 100%;
  padding: 16px;
  border: 1px solid rgba(234, 223, 215, 0.9);
  border-radius: 14px;
  background: #fffaf6;
  text-align: left;
}

.import-item.duplicate-warning {
  border-color: #e4bd82;
  background: #fffaf0;
}

.duplicate-alert {
  display: grid;
  gap: 5px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #e7ca9d;
  border-radius: 10px;
  background: #fff5df;
  color: #75501e;
}

.duplicate-alert span {
  line-height: 1.55;
}

.import-job-card p,
.import-job-card small,
.import-message {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.import-summary-row span {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff7f3;
  color: var(--muted);
  font-weight: 800;
}

.empty-actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.import-summary-row b {
  color: var(--brand);
}

.import-core {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.file-details {
  margin-top: 12px;
  color: var(--muted);
}

.file-details summary {
  cursor: pointer;
  font-weight: 800;
}

.file-details p {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid rgba(234, 223, 215, 0.7);
}

.message {
  margin-bottom: 16px;
  padding: 13px 16px;
  border-radius: 12px;
  background: #e8f5ee;
  color: #286b4c;
  font-weight: 800;
}

.message.error {
  background: #fff0ee;
  color: var(--red);
  border: 1px solid #efc8c3;
}

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

.mobile-page {
  background: #f8f1ec;
}

.mobile-shell {
  width: min(430px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  background: #fffaf6;
  box-shadow: 0 0 40px rgba(72, 48, 38, 0.12);
}

.mobile-header {
  padding: 28px 20px 18px;
  color: #fff;
  background: linear-gradient(135deg, #8f3844, #c66d4f);
  border-radius: 0 0 24px 24px;
}

.mobile-detail-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 56px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(234, 223, 215, 0.92);
  background: rgba(255, 250, 246, 0.96);
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(72, 48, 38, 0.08);
  backdrop-filter: blur(12px);
}

.mobile-detail-nav strong {
  font-size: 15px;
}

.mobile-detail-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  border: 1px solid #edcfc8;
  border-radius: 10px;
  padding: 0 12px;
  background: #fff8f5;
  color: var(--brand);
  font-weight: 800;
}

.mobile-detail-back:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(143, 56, 68, 0.12);
}

.mobile-header h1,
.mobile-header p {
  margin: 0;
}

.mobile-header h1 {
  font-size: 28px;
}

.mobile-header p {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.84);
  line-height: 1.5;
}

.mobile-content {
  padding: 16px;
}

.mobile-card {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid rgba(234, 223, 215, 0.9);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(72, 48, 38, 0.08);
}

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

.mobile-key h3 {
  margin: 0;
  font-size: 20px;
}

.mobile-line {
  margin: 10px 0 0;
  color: #5f544f;
  line-height: 1.55;
}

.mobile-inquiry-date {
  color: var(--muted);
  font-size: 13px;
}

.mobile-pagination {
  margin: 4px 0 12px;
  padding: 16px;
  border: 1px solid rgba(234, 223, 215, 0.9);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(72, 48, 38, 0.08);
}

.mobile-pagination-summary {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.mobile-pagination-controls {
  display: grid;
  grid-template-columns: minmax(112px, 1fr) 40px minmax(92px, 1fr) 40px;
  gap: 8px;
  align-items: center;
}

.mobile-pagination-size,
.mobile-pagination-page {
  width: 100% !important;
  min-width: 0;
}

.mobile-pagination-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #edcfc8;
  border-radius: 8px;
  background: #fff8f5;
  color: var(--brand);
  font-size: 18px;
  font-weight: 900;
}

.mobile-pagination-btn:disabled {
  border-color: var(--line);
  background: #f7f3f0;
  color: #bca9a3;
  opacity: 0.4;
}

.mobile-terminal {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7f4f1;
  color: var(--muted);
  line-height: 1.5;
}

.mobile-attachment {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.mobile-attachment-actions .mini-btn {
  min-width: 54px;
}

@media (max-width: 640px) {
  .attachment-preview-modal {
    padding: 0;
  }

  .attachment-preview-dialog {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .attachment-preview-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .attachment-preview-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .mobile-attachment {
    align-items: flex-start;
    flex-direction: column;
  }

  .mobile-attachment-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

.mobile-attachment:last-child {
  border-bottom: 0;
}

.mobile-attachment span {
  min-width: 0;
}

.mobile-attachment b,
.mobile-attachment small {
  display: block;
  overflow-wrap: anywhere;
}

.mobile-attachment small,
.mobile-history span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-attachment strong {
  flex: 0 0 auto;
  color: var(--brand);
  font-size: 14px;
}

.mobile-history {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.mobile-history:last-child {
  border-bottom: 0;
}

.mobile-history b,
.mobile-history span {
  display: block;
}

.mobile-history p {
  margin: 7px 0 0;
  color: #5f544f;
  line-height: 1.5;
}

.chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  width: 100%;
  min-height: 34px;
  border: 1px solid #edcfc8;
  border-radius: 999px;
  padding: 0 8px;
  background: #fff8f5;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.chip.active {
  background: var(--brand);
  color: #fff;
}

@media (max-width: 1100px) {
  .active-operation-progress {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 32%);
  }

  .active-operation-status {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    min-width: 0;
    text-align: left;
  }

  .active-operation-status span {
    margin-top: 0;
  }

  .admin-shell {
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    width: 100%;
    min-width: 0;
    height: auto;
    padding: 16px;
  }

  .side-brand {
    margin-bottom: 14px;
  }

  .side-nav {
    display: flex;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
  }

  .side-nav button {
    flex: 1 0 128px;
    justify-content: center;
    text-align: center;
  }

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

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

@media (max-width: 720px) {
  .admin-main {
    padding: 18px;
  }

  .topbar,
  .panel-head {
    display: grid;
  }

  .top-actions,
  .form-footer {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .customer-attachment-editor-head,
  .attachment-item {
    align-items: stretch;
    flex-direction: column;
  }

  .customer-attachment-editor-head .primary-btn,
  .attachment-item-actions button {
    flex: 1 1 auto;
  }

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

  .attachment-upload-track {
    grid-column: 1;
    grid-row: auto;
  }

  .attachment-upload-summary {
    min-width: 0;
    text-align: left;
  }

  .top-actions button,
  .form-footer button {
    flex: 1 1 140px;
  }

  .stats-grid,
  .search-row,
  .search-row.has-manager-filter,
  .form-grid,
  .detail-grid,
  .assignment-picker,
  .import-core,
  .import-source-panel {
    grid-template-columns: 1fr;
  }

  .customer-pagination {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .pagination-total {
    flex: 1 0 100%;
    margin: 0;
  }

  .pagination-control,
  .pagination-pages {
    flex: 1 1 auto;
  }

  .pagination-pages {
    justify-content: flex-end;
  }

  .import-source-panel {
    grid-template-areas:
      "copy"
      "selection"
      "actions";
    min-height: 0;
    padding: 20px;
  }

  .server-source-panel {
    grid-template-areas:
      "copy"
      "field"
      "actions";
  }

  .import-note {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .import-summary-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .sync-metrics,
  .sync-bulk-metrics,
  .sync-review-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sync-bulk-metrics > div:nth-child(2) {
    border-right: 0;
  }

  .sync-bulk-metrics > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .sync-metrics > div:nth-child(2),
  .sync-metrics > div:nth-child(4) {
    border-right: 0;
  }

  .sync-metrics > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .sync-metrics > div:nth-child(3),
  .sync-metrics > div:nth-child(4) {
    border-bottom: 1px solid var(--line);
  }

  .sync-metrics > div:nth-child(5) {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .sync-enabled {
    grid-column: 1 / -1;
  }

  .sync-source-head,
  .sync-review-head,
  .sync-candidate,
  .sync-section-title {
    display: grid;
  }

  .sync-bulk-select-all {
    width: 100%;
    justify-content: space-between;
  }

  .sync-review-facts {
    grid-template-columns: 1fr;
  }

  .sync-bulk-field {
    grid-template-columns: 1fr;
  }

  .sync-bulk-field > div {
    border-left-width: 3px;
  }

  .sync-bulk-skipped > div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .sync-review-item,
  .sync-source-block {
    min-width: 0;
  }

  .sync-review-head > div,
  .sync-candidate > div {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .account-summary {
    width: 100%;
  }

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