:root {
  color-scheme: light;
  --ink: #1b1f1a;
  --muted: #66705f;
  --soft: #f5f7f1;
  --paper: #ffffff;
  --line: #dde5d5;
  --line-strong: #b8c8aa;
  --field: #fbfcf7;
  --brand: #1f4d25;
  --brand-2: #6f8e2f;
  --accent: #b8472b;
  --gold: #b8891d;
  --blue: #235c8f;
  --danger: #a53030;
  --shadow: 0 18px 48px rgba(32, 44, 24, 0.12);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--soft);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
  background:
    linear-gradient(135deg, rgba(242, 247, 232, 0.98), rgba(250, 252, 246, 0.96) 42%, rgba(229, 239, 216, 0.92)),
    linear-gradient(90deg, rgba(31, 77, 37, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(31, 77, 37, 0.04) 1px, transparent 1px);
  background-size: auto, 44px 44px, 44px 44px;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: wait;
  opacity: 0.68;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(210px, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 68px;
  padding: 10px clamp(16px, 4vw, 42px);
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid rgba(221, 229, 213, 0.95);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #1f4d25;
  box-shadow: 0 8px 18px rgba(31, 77, 37, 0.22);
  flex: 0 0 auto;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

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

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

.role-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: #edf3e6;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.nav-btn {
  min-width: 76px;
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--muted);
  background: transparent;
}

.nav-btn.active {
  color: #eef8e2;
  background: var(--brand);
  box-shadow: 0 4px 12px rgba(31, 77, 37, 0.18);
}

.session-box {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.session-pill {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.kicker {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  margin-bottom: 8px;
  font-size: clamp(31px, 4vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
  letter-spacing: 0;
}

.lede {
  max-width: 760px;
  color: #4f5a49;
  font-size: 16px;
}

.toolbar,
.panel,
.data-row,
.listing-card,
.profile-card,
.auth-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255,255,255,.7);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(190px, 1.25fr) repeat(5, minmax(110px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  margin-bottom: 18px;
}

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

.filter-actions .button,
.filter-actions .ghost-button {
  min-height: 39px;
}

.field {
  min-width: 0;
}

.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--field);
  padding: 9px 11px;
  outline: none;
}

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

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(111, 142, 47, 0.15);
}

.button,
.ghost-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 6px;
  padding: 9px 14px;
  font-weight: 750;
  text-decoration: none;
}

.button {
  border: 1px solid var(--brand);
  color: #eef8e2;
  background: var(--brand);
}

.button:hover {
  background: #2d6434;
}

.ghost-button {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: #ffffff;
}

.ghost-button:hover {
  border-color: var(--brand-2);
}

.danger-button {
  border: 1px solid #e4b4b4;
  color: var(--danger);
  background: #fff5f5;
}

.icon-button {
  width: 42px;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  font-size: 21px;
}

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

.listing-card {
  overflow: hidden;
  min-height: 100%;
}

.listing-card.premium {
  border-color: #d3b15e;
  box-shadow: 0 12px 30px rgba(138, 100, 16, 0.12);
}

.listing-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  background: #edf3e6;
}

.listing-body {
  padding: 14px;
}

.listing-title-row,
.split-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.price {
  font-size: 22px;
  font-weight: 850;
  color: var(--brand);
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

.tiny {
  color: var(--muted);
  font-size: 12px;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  color: #36502d;
  background: #eef5e9;
  font-size: 12px;
  font-weight: 750;
}

.chip.strong {
  color: #eef8e2;
  background: var(--brand);
}

.chip.gold {
  color: #4e3300;
  background: #fae8b7;
}

.chip.blue {
  color: #103a62;
  background: #dcecf8;
}

.panel {
  padding: 16px;
}

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

.metric {
  background: #f8faf3;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 23px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  padding: 11px 12px;
  font-weight: 760;
}

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

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

.data-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px;
}

.data-row > * {
  min-width: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

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

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .75fr);
  gap: 18px;
}

.detail-photo {
  width: 100%;
  max-height: 440px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.message-thread {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.message-thread.compact-thread {
  max-height: 150px;
}

.basket-panel {
  margin-bottom: 18px;
}

.basket-row {
  align-items: start;
}

.compact-fields {
  min-width: min(420px, 100%);
}

.message {
  max-width: 82%;
  border-radius: var(--radius);
  padding: 9px 11px;
  background: #f1f5ec;
}

.message.mine {
  justify-self: end;
  color: #eef8e2;
  background: var(--brand);
}

.dialog {
  width: min(560px, calc(100% - 26px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(16, 22, 14, 0.46);
}

.dialog-inner {
  position: relative;
  padding: 22px;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.dialog-head {
  padding-right: 48px;
  margin-bottom: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100% - 36px));
  transform: translateY(22px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #eef8e2;
  background: var(--brand);
  box-shadow: var(--shadow);
  transition: .18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255,255,255,.72);
  text-align: center;
  padding: 24px;
}

.auth-card {
  max-width: 560px;
  margin: 40px auto;
  padding: 22px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .role-tabs,
  .session-box {
    justify-self: stretch;
  }

  .session-box {
    justify-content: flex-start;
  }

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

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

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

  .detail-layout {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 680px) {
  body {
    background-attachment: scroll;
  }

  .app-shell {
    width: min(100% - 20px, 1240px);
    padding-top: 18px;
  }

  .role-tabs {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .nav-btn {
    min-width: max-content;
  }

  .page-head,
  .listing-title-row,
  .split-row,
  .data-row {
    display: grid;
  }

  .toolbar,
  .grid,
  .dashboard-grid,
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

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

  h1 {
    font-size: 32px;
  }
}
