:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-strong: #eef8f6;
  --line: #d8e3e0;
  --line-strong: #b9cac5;
  --text: #10201d;
  --muted: #60736e;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #dff4f0;
  --warning: #b7791f;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --ok: #12805c;
  --shadow: 0 18px 45px rgba(20, 35, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 18px;
}

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

.brand-logo {
  display: block;
  width: 92px;
  height: auto;
  flex: 0 0 auto;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 6px;
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 10px;
  font-size: 17px;
}

.section-head p {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(20, 35, 31, 0.06);
}

.sync-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
}

.sync-pill.offline .sync-dot {
  background: var(--warning);
}

.workspace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
}

.tab-button {
  border-radius: 0;
  background: #fbfdfc;
  color: var(--muted);
  font-weight: 700;
}

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

.tab-panel {
  display: none;
  padding: 18px;
}

.tab-panel.active {
  display: block;
}

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

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

.capture-mode {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  overflow: hidden;
}

.mode-button {
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 800;
}

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

.ai-note {
  display: none;
}

.capture-image-mode .ai-note {
  display: block;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.file-field input {
  padding: 8px;
}

.image-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.image-preview figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-strong);
}

.image-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.image-preview figcaption {
  padding: 7px;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  padding: 0 14px;
  font-weight: 800;
}

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

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.queue-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.queue-item header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.queue-item strong {
  display: block;
}

.queue-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.status-badge,
.priority-badge,
.source-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-badge {
  background: var(--surface-strong);
  color: var(--accent-strong);
}

.status-badge.failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.filters {
  display: grid;
  grid-template-columns: 1fr 180px 190px;
  gap: 10px;
  margin-bottom: 14px;
}

.customer-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.customer-list {
  border-right: 1px solid var(--line);
  background: #fbfdfc;
  overflow: auto;
}

.customer-card {
  display: grid;
  width: 100%;
  min-height: auto;
  gap: 7px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.customer-card:hover,
.customer-card.active {
  background: var(--accent-soft);
}

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

.customer-card small,
.card-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.priority-badge {
  width: max-content;
  background: #e8f6ec;
  color: var(--ok);
}

.priority-badge.priority-A {
  background: #fff4d6;
  color: #9f5d00;
}

.priority-badge.priority-B {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.priority-badge.priority-C {
  background: #eef2f6;
  color: #53616c;
}

.customer-detail {
  min-width: 0;
  padding: 18px;
  overflow: auto;
}

.empty-state {
  display: grid;
  min-height: 360px;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

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

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

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

.detail-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.source-chip {
  background: var(--surface-strong);
  color: var(--accent-strong);
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 20;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  border-radius: 8px;
  background: #10201d;
  color: #fff;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 780px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .brand-logo {
    width: 86px;
  }

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

  .tab-panel {
    padding: 14px;
  }

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

  .form-grid,
  .settings-grid,
  .filters,
  .customer-layout,
  .detail-grid,
  .edit-form {
    grid-template-columns: 1fr;
  }

  .customer-layout {
    min-height: 0;
  }

  .customer-list {
    max-height: 360px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
