:root {
  --ink: #173d32;
  --ink-2: #214c40;
  --leaf: #5b8f57;
  --leaf-soft: #dce7d7;
  --cream: #f5f2e9;
  --paper: #fffdf8;
  --sand: #e9e3d6;
  --orange: #c47742;
  --red: #ad493b;
  --muted: #738079;
  --line: #d9ded7;
  --shadow: 0 20px 55px rgba(24, 54, 43, 0.09);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--cream);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 86% 8%, rgba(123, 157, 108, 0.15), transparent 28rem),
    var(--cream);
  font-family:
    "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 46% 54% / 55% 48% 52% 45%;
  color: #f8f4e8;
  background: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 700;
  transform: rotate(-4deg);
  box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.09);
}

.auth-view {
  min-height: 100vh;
  padding: 40px 24px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  gap: 28px;
  overflow: hidden;
}

.auth-view::before {
  content: "";
  position: fixed;
  width: 520px;
  height: 520px;
  right: -170px;
  bottom: -240px;
  border-radius: 45% 55% 45% 55%;
  background: var(--ink);
  opacity: 0.06;
  pointer-events: none;
}

.auth-brand {
  width: min(100%, 1080px);
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand p,
.auth-brand strong {
  display: block;
  margin: 0;
  letter-spacing: 0.12em;
}

.auth-brand p {
  font-size: 11px;
  font-weight: 700;
}

.auth-brand strong {
  margin-top: 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  letter-spacing: 0;
}

.auth-card {
  width: min(100%, 450px);
  align-self: center;
  padding: clamp(28px, 5vw, 48px);
  border: 1px solid rgba(23, 61, 50, 0.1);
  border-radius: 30px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.auth-card h1 {
  margin: 7px 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 48px);
  font-weight: 500;
  letter-spacing: -0.035em;
}

.auth-card form {
  display: grid;
  gap: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--leaf);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.eyebrow-light {
  color: #c9e2c3;
}

.muted {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.65;
}

label {
  display: grid;
  gap: 8px;
}

label > span,
.search-field > span,
.select-field > span {
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fff;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(91, 143, 87, 0.14);
}

.button {
  min-height: 44px;
  padding: 10px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

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

.button-primary:hover {
  background: var(--ink-2);
}

.button-light {
  color: var(--ink);
  border-color: #fff;
  background: #fff;
}

.button-ghost {
  color: var(--ink);
  border-color: rgba(23, 61, 50, 0.22);
  background: transparent;
}

.button-block {
  width: 100%;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 12px;
}

.auth-footnote {
  max-width: 520px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px 20px;
  display: flex;
  flex-direction: column;
  color: #edf3e8;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.045), transparent 42%),
    var(--ink);
}

.sidebar-brand {
  padding: 0 8px 25px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.sidebar-brand .brand-mark {
  width: 42px;
  height: 42px;
  color: var(--ink);
  background: #dbe5d2;
  box-shadow: none;
  font-size: 21px;
}

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

.sidebar-brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
}

.sidebar-brand span {
  margin-top: 2px;
  color: rgba(237, 243, 232, 0.58);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.main-nav {
  padding: 24px 0;
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: rgba(237, 243, 232, 0.72);
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}

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

.nav-item.active {
  color: var(--ink);
  background: #f2f0e7;
}

.nav-icon {
  width: 22px;
  text-align: center;
  font-size: 17px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 18px 10px 0;
  display: grid;
  gap: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.sidebar-foot a,
.sidebar-foot button {
  padding: 0;
  color: rgba(237, 243, 232, 0.7);
  border: 0;
  background: transparent;
  font-size: 12px;
  text-align: left;
  text-decoration: none;
}

.workspace {
  min-width: 0;
  padding: 0 clamp(20px, 4vw, 56px) 60px;
}

.topbar {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar h1 {
  margin: 5px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
}

.topbar-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.mobile-menu {
  display: none;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.user-chip strong,
.user-chip span {
  display: block;
}

.user-chip strong {
  font-size: 13px;
}

.user-chip span:last-child {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.page {
  display: none;
  animation: page-in 260ms ease;
}

.page.active {
  display: block;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-panel {
  padding: clamp(28px, 4vw, 46px);
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  color: #f9f5e9;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 82% 20%, rgba(207, 227, 192, 0.2), transparent 28%),
    linear-gradient(130deg, #173d32 0%, #245444 65%, #306651 100%);
  box-shadow: var(--shadow);
}

.hero-panel h2 {
  max-width: 700px;
  margin: 10px 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 400;
  letter-spacing: -0.035em;
}

.hero-panel > div > p:last-child {
  max-width: 590px;
  margin: 0;
  color: rgba(249, 245, 233, 0.7);
  line-height: 1.7;
}

.metric-grid {
  margin: 22px 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 20px;
  border: 1px solid rgba(23, 61, 50, 0.1);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.88);
}

.metric-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 500;
}

.metric-card small {
  display: block;
  margin-top: 5px;
  color: var(--leaf);
  font-size: 11px;
}

.dashboard-grid,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 20px;
}

.panel {
  padding: 24px;
  border: 1px solid rgba(23, 61, 50, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.88);
}

.panel-heading,
.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.panel-heading h2,
.page-heading h2 {
  margin: 6px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.panel-heading h2 {
  font-size: 24px;
}

.page-heading {
  margin: 8px 0 24px;
}

.page-heading h2 {
  font-size: 38px;
}

.page-heading > div > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.text-button {
  padding: 0;
  color: var(--leaf);
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.compact-list {
  display: grid;
  gap: 0;
  margin-top: 16px;
}

.compact-item {
  padding: 13px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border-top: 1px solid var(--line);
}

.compact-item:first-child {
  border-top: 0;
}

.compact-item strong,
.compact-item span {
  display: block;
}

.compact-item strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-item small {
  margin-top: 4px;
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.empty-state {
  padding: 35px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.toolbar {
  margin-bottom: 14px;
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.search-field {
  min-width: min(100%, 340px);
  flex: 1;
}

.select-field {
  min-width: 170px;
}

.result-count {
  margin: 0 0 13px auto;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(23, 61, 50, 0.1);
  border-radius: 16px;
  background: var(--paper);
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 14px 15px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  background: #f7f5ee;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  font-size: 12px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfaf5;
}

.cell-title {
  display: block;
  max-width: 320px;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
}

.cell-subtitle {
  margin-top: 4px;
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.product-thumb {
  width: 76px;
  height: 54px;
  display: block;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f0e7;
}

.status {
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #eeeae0;
  font-size: 10px;
  font-weight: 800;
}

.status-sent,
.status-won,
.status-active {
  color: #315e39;
  background: #dcebd8;
}

.status-pending,
.status-new {
  color: #825626;
  background: #f5e4c9;
}

.status-replied,
.status-following,
.status-contacted,
.status-quoted {
  color: #315b72;
  background: #dbe8ef;
}

.status-failed,
.status-lost,
.status-inactive {
  color: #8c3e34;
  background: #f2ddd8;
}

.status-paused {
  color: #666;
  background: #e7e6e1;
}

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

.row-link {
  padding: 0;
  color: var(--leaf);
  border: 0;
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.row-link.danger {
  color: var(--red);
}

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

.inquiry-card {
  padding: 22px;
  border: 1px solid rgba(23, 61, 50, 0.1);
  border-radius: 17px;
  background: var(--paper);
}

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

.inquiry-card h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 500;
}

.inquiry-card p {
  color: var(--muted);
  line-height: 1.65;
}

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

.inquiry-meta span {
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4f1e9;
  font-size: 11px;
}

.settings-form {
  display: grid;
  gap: 17px;
}

.export-panel {
  align-self: start;
}

.export-panel h2 {
  margin: 8px 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
}

.export-panel > p {
  color: var(--muted);
  line-height: 1.65;
  font-size: 13px;
}

.export-panel code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #ece8dc;
}

.export-link {
  padding: 14px 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  text-decoration: none;
}

.export-link strong,
.export-link span {
  display: block;
}

.export-link span {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(15, 34, 27, 0.64);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(100%, 720px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(8, 25, 19, 0.25);
}

.modal.modal-wide {
  width: min(100%, 1040px);
}

.modal-header,
.modal-footer {
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 6px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
}

.modal-body {
  padding: 24px;
}

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

.modal-body .span-2 {
  grid-column: 1 / -1;
}

.product-editor {
  display: grid;
  gap: 24px;
}

.media-editor {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1.2fr);
  gap: 18px;
}

.primary-media-editor,
.gallery-editor {
  padding: 16px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #faf8f1;
}

.primary-media-editor {
  justify-items: start;
}

.primary-media-editor img {
  width: 100%;
  height: 220px;
  object-fit: contain;
  border-radius: 10px;
  background: #f1ede2;
}

.primary-media-editor small,
.gallery-editor small {
  color: var(--muted);
  font-size: 10px;
}

.editor-label {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
}

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

.file-button {
  min-height: 36px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  border: 1px solid rgba(23, 61, 50, 0.25);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.file-button.small {
  min-height: 30px;
  padding: 5px 9px;
}

.gallery-preview {
  min-height: 100px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #ece8dd;
}

.gallery-item img {
  width: 100%;
  height: 72px;
  display: block;
  object-fit: cover;
}

.gallery-item button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 23px;
  height: 23px;
  padding: 0;
  color: #fff;
  border: 0;
  border-radius: 50%;
  background: rgba(23, 61, 50, 0.85);
  line-height: 1;
}

.compact-empty {
  grid-column: 1 / -1;
  padding: 22px 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 11px;
}

.product-fields {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.modal > .form-error {
  padding: 0 24px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.toast-region {
  position: fixed;
  z-index: 40;
  right: 24px;
  bottom: 24px;
  display: grid;
  gap: 10px;
}

.toast {
  max-width: 360px;
  padding: 13px 16px;
  color: #fff;
  border-radius: 10px;
  background: var(--ink);
  box-shadow: 0 16px 40px rgba(11, 38, 28, 0.2);
  font-size: 13px;
}

.toast.error {
  background: var(--red);
}

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

  .dashboard-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 15;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    transform: translateX(-105%);
    transition: transform 200ms ease;
    box-shadow: 20px 0 50px rgba(8, 26, 20, 0.2);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .workspace {
    padding-inline: 18px;
  }

  .topbar {
    min-height: 90px;
  }

  .mobile-menu {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
  }

  .topbar > div:nth-child(2) {
    margin-right: auto;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .user-chip > div {
    display: none;
  }

  .hero-panel {
    align-items: start;
    flex-direction: column;
  }

  .page-heading {
    align-items: start;
    flex-direction: column;
  }

  .inquiry-grid {
    grid-template-columns: 1fr;
  }

  .media-editor {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 580px) {
  .auth-view {
    padding: 24px 16px;
  }

  .auth-card {
    padding: 26px 22px;
    border-radius: 22px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal {
    max-height: calc(100vh - 20px);
  }

  .modal-body .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-body .span-2 {
    grid-column: auto;
  }

  .gallery-preview {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .result-count {
    margin-left: 0;
  }
}
