/* ============================================================
   SOURCELINK — SHARED APP STYLES
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --forest:     #1B3325;
  --moss:       #2D5240;
  --terracotta: #C0623B;
  --brass:      #A07830;
  --linen:      #F7F3EE;
  --sand:       #E8E0D4;
  --sage:       #8FA897;
  --white:      #FFFFFF;
  --dark:       #111E17;
  --error:      #C0392B;
  --font-d: 'DM Serif Display', Georgia, serif;
  --font-b: 'DM Sans', system-ui, sans-serif;
  --font-m: 'DM Mono', monospace;
  --sidebar-w: 240px;
  --shadow: 0 2px 12px rgba(27,51,37,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-b); background: var(--linen); color: var(--forest); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── APP SHELL ─────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
  flex-shrink: 0;
}
.sidebar__logo {
  padding: 28px 24px 20px;
  font-family: var(--font-d);
  font-size: 20px;
  color: var(--linen);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar__logo span { color: var(--terracotta); }
.sidebar__role {
  padding: 12px 24px;
  font-family: var(--font-m);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(247,243,238,.3);
  border-bottom: 1px solid rgba(255,255,255,.04);
  margin-bottom: 8px;
}
.sidebar__nav { flex: 1; padding: 8px 12px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(247,243,238,.55);
  cursor: pointer;
  transition: all .15s;
  margin-bottom: 2px;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--linen); }
.nav-item.active { background: rgba(192,98,59,.15); color: var(--terracotta); }
.nav-item .badge {
  margin-left: auto;
  background: var(--terracotta);
  color: var(--white);
  font-size: 10px;
  font-family: var(--font-m);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}
.sidebar__bottom {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s;
}
.sidebar__user:hover { background: rgba(255,255,255,.06); }
.sidebar__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--moss);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-d);
  font-size: 12px;
  color: var(--linen);
  flex-shrink: 0;
}
.sidebar__user-info { flex: 1; overflow: hidden; }
.sidebar__user-name { font-size: 13px; font-weight: 600; color: var(--linen); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-email { font-size: 11px; color: rgba(247,243,238,.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__signout {
  font-size: 12px;
  color: rgba(247,243,238,.3);
  padding: 8px 12px;
  cursor: pointer;
  transition: color .15s;
  display: flex; align-items: center; gap: 6px;
}
.sidebar__signout:hover { color: rgba(247,243,238,.7); }

/* ── MAIN CONTENT ──────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--sand);
  padding: 0 40px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar__title { font-family: var(--font-d); font-size: 22px; letter-spacing: -.02em; }
.topbar__actions { display: flex; align-items: center; gap: 12px; }
.content { padding: 36px 40px; flex: 1; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--sand);
  border-radius: 6px;
  overflow: hidden;
}
.card__header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--sand);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card__title { font-size: 15px; font-weight: 600; }
.card__body { padding: 24px; }

/* ── STAT CARDS ────────────────────────────────────────────── */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--sand);
  border-radius: 6px;
  padding: 20px 24px;
}
.stat-card__label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--sage); margin-bottom: 8px; }
.stat-card__value { font-family: var(--font-d); font-size: 36px; letter-spacing: -.03em; color: var(--forest); }
.stat-card__sub { font-size: 12px; color: var(--sage); margin-top: 4px; }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-b); font-size: 14px; font-weight: 600;
  padding: 10px 20px; border-radius: 3px; border: none;
  cursor: pointer; transition: opacity .15s, transform .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .85; transform: translateY(-1px); }
.btn--primary { background: var(--terracotta); color: var(--white); }
.btn--brass    { background: var(--brass); color: var(--white); }
.btn--forest   { background: var(--forest); color: var(--white); }
.btn--ghost    { background: transparent; border: 1.5px solid var(--sand); color: var(--sage); }
.btn--ghost:hover { border-color: var(--sage); color: var(--forest); }
.btn--sm { font-size: 12px; padding: 7px 14px; }
.btn--full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ── FORMS ─────────────────────────────────────────────────── */
.field { margin-bottom: 20px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--forest); margin-bottom: 7px; }
label span { color: var(--terracotta); }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  font-family: var(--font-b); font-size: 14px; color: var(--forest);
  background: var(--white); border: 1.5px solid var(--sand);
  border-radius: 4px; padding: 10px 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(27,51,37,.07);
}
textarea { resize: vertical; min-height: 80px; }
.field__hint { font-size: 12px; color: var(--sage); margin-top: 5px; }
.field__row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── TRUST BADGE ───────────────────────────────────────────── */
.trust-badge {
  display: inline-flex; align-items: baseline; gap: 2px;
  background: var(--brass); color: var(--white);
  font-family: var(--font-m); font-size: 13px; font-weight: 500;
  padding: 3px 10px; border-radius: 2px;
}
.trust-badge__label { font-size: 10px; opacity: .7; }

/* ── STATUS PILLS ──────────────────────────────────────────── */
.pill {
  display: inline-block;
  font-family: var(--font-m); font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 2px;
}
.pill--pending  { background: rgba(160,120,48,.12); color: var(--brass); }
.pill--approved { background: rgba(45,82,64,.12); color: var(--moss); }
.pill--rejected { background: rgba(192,57,43,.1); color: var(--error); }
.pill--active   { background: rgba(45,82,64,.12); color: var(--moss); }

/* ── ALERTS ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: 4px;
  font-size: 14px; margin-bottom: 20px;
  display: none;
}
.alert.show { display: block; }
.alert--error { background: rgba(192,57,43,.08); border: 1px solid rgba(192,57,43,.2); color: var(--error); }
.alert--success { background: rgba(45,82,64,.08); border: 1px solid rgba(45,82,64,.2); color: var(--moss); }
.alert--info { background: rgba(160,120,48,.08); border: 1px solid rgba(160,120,48,.2); color: var(--brass); }

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty {
  text-align: center; padding: 64px 24px;
}
.empty__icon { font-size: 40px; margin-bottom: 16px; opacity: .4; }
.empty__title { font-family: var(--font-d); font-size: 20px; margin-bottom: 8px; }
.empty__sub { font-size: 14px; color: var(--sage); margin-bottom: 24px; }

/* ── LOADING ───────────────────────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 64px; color: var(--sage); font-size: 14px; gap: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--sand);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── TABLE ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 12px 16px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--sage); background: var(--linen);
  border-bottom: 1px solid var(--sand);
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--sand);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(247,243,238,.5); }

/* ── MANUFACTURER CARD ─────────────────────────────────────── */
.mfr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.mfr-card {
  background: var(--white);
  border: 1.5px solid var(--sand);
  border-radius: 6px;
  padding: 24px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.mfr-card:hover {
  border-color: var(--sage);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.mfr-card__top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.mfr-card__avatar {
  width: 44px; height: 44px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-d); font-size: 18px; color: var(--white);
  flex-shrink: 0;
}
.mfr-card__name { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.mfr-card__location { font-size: 12px; color: var(--sage); }
.mfr-card__tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.tag {
  font-family: var(--font-m); font-size: 10px; letter-spacing: .06em;
  background: var(--linen); color: var(--sage);
  padding: 3px 8px; border-radius: 2px;
}
.mfr-card__stats { display: flex; gap: 16px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--sand); }
.mfr-stat { flex: 1; }
.mfr-stat__value { font-family: var(--font-m); font-size: 14px; color: var(--forest); font-weight: 500; }
.mfr-stat__label { font-size: 11px; color: var(--sage); margin-top: 1px; }

/* ── MESSAGES ──────────────────────────────────────────────── */
.messages-layout { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 60px); overflow: hidden; }
.convo-list { border-right: 1px solid var(--sand); overflow-y: auto; background: var(--white); }
.convo-list__header { padding: 20px 20px 16px; border-bottom: 1px solid var(--sand); }
.convo-list__title { font-family: var(--font-d); font-size: 18px; letter-spacing: -.02em; }
.convo-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px 20px; border-bottom: 1px solid var(--sand);
  cursor: pointer; transition: background .15s;
}
.convo-item:hover { background: var(--linen); }
.convo-item.active { background: rgba(27,51,37,.05); border-left: 3px solid var(--terracotta); }
.convo-item__avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-d); font-size: 14px; color: var(--white);
  flex-shrink: 0;
}
.convo-item__info { flex: 1; overflow: hidden; }
.convo-item__name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.convo-item__preview { font-size: 12px; color: var(--sage); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-item__time { font-size: 11px; color: var(--sage); white-space: nowrap; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--terracotta); flex-shrink: 0; margin-top: 4px; }

.chat-area { display: flex; flex-direction: column; background: var(--linen); }
.chat-header {
  padding: 16px 24px; background: var(--white);
  border-bottom: 1px solid var(--sand);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header__name { font-size: 16px; font-weight: 600; }
.chat-header__sub { font-size: 12px; color: var(--sage); }
.chat-notice {
  background: rgba(160,120,48,.08);
  border-bottom: 1px solid rgba(160,120,48,.15);
  padding: 8px 24px;
  font-size: 12px; color: var(--brass);
  display: flex; align-items: center; gap: 8px;
}
.chat-messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 10px; max-width: 70%; }
.msg--mine { align-self: flex-end; flex-direction: row-reverse; }
.msg__avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-d); font-size: 11px; color: var(--white);
}
.msg__body {}
.msg__bubble {
  padding: 10px 14px; border-radius: 12px 12px 12px 4px;
  font-size: 14px; line-height: 1.55; background: var(--white);
  border: 1px solid var(--sand); color: var(--forest);
}
.msg--mine .msg__bubble { background: var(--forest); color: var(--linen); border-color: var(--forest); border-radius: 12px 12px 4px 12px; }
.msg__time { font-size: 10px; color: var(--sage); margin-top: 4px; padding: 0 4px; }
.msg--mine .msg__time { text-align: right; }
.chat-input {
  padding: 16px 24px; background: var(--white);
  border-top: 1px solid var(--sand);
  display: flex; gap: 12px; align-items: flex-end;
}
.chat-input textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 120px;
  font-size: 14px; border-radius: 6px;
  padding: 10px 14px;
}
.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--sage); text-align: center; padding: 48px;
}
.chat-empty__icon { font-size: 48px; opacity: .3; margin-bottom: 16px; }
.chat-empty__title { font-family: var(--font-d); font-size: 22px; color: var(--forest); margin-bottom: 8px; }
.chat-empty__sub { font-size: 14px; max-width: 280px; }

/* ── PENDING BANNER ────────────────────────────────────────── */
.pending-banner {
  background: var(--moss);
  color: var(--linen);
  padding: 16px 40px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px;
}
.pending-banner strong { font-weight: 600; }

/* ── PROFILE PAGE ──────────────────────────────────────────── */
.profile-hero {
  background: var(--forest);
  padding: 40px 40px 32px;
  display: flex; align-items: flex-start; gap: 24px;
}
.profile-hero__avatar {
  width: 72px; height: 72px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-d); font-size: 28px; color: var(--white);
  flex-shrink: 0;
}
.profile-hero__name { font-family: var(--font-d); font-size: 32px; color: var(--linen); letter-spacing: -.02em; margin-bottom: 6px; }
.profile-hero__meta { font-size: 14px; color: rgba(247,243,238,.6); display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-hero__actions { margin-left: auto; display: flex; gap: 12px; align-items: flex-start; }
.profile-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; padding: 32px 40px; }
.profile-section__title { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--sage); margin-bottom: 16px; }
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.spec { background: var(--linen); border-radius: 4px; padding: 14px 16px; }
.spec__value { font-family: var(--font-m); font-size: 18px; color: var(--forest); font-weight: 500; }
.spec__label { font-size: 12px; color: var(--sage); margin-top: 3px; }

/* ── FILTER SIDEBAR ────────────────────────────────────────── */
.dir-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
.filters { background: var(--white); border: 1px solid var(--sand); border-radius: 6px; padding: 20px; position: sticky; top: 80px; }
.filter-group { margin-bottom: 20px; }
.filter-label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--sage); margin-bottom: 10px; display: block; }
.filter-check { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; cursor: pointer; }
.filter-check input { width: 14px; height: 14px; cursor: pointer; accent-color: var(--forest); }
.filter-range { display: flex; gap: 8px; }
.filter-range input { padding: 7px 10px; font-size: 13px; }

/* ── SEARCH BAR ────────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--white); border: 1.5px solid var(--sand);
  border-radius: 4px; padding: 0 14px;
  margin-bottom: 20px;
}
.search-bar:focus-within { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(27,51,37,.07); }
.search-bar svg { color: var(--sage); flex-shrink: 0; }
.search-bar input { flex: 1; border: none; background: transparent; padding: 11px 0; font-size: 14px; outline: none; font-family: var(--font-b); }

/* ── ADMIN ─────────────────────────────────────────────────── */
.admin-actions { display: flex; gap: 8px; }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .messages-layout { grid-template-columns: 1fr; }
  .convo-list { display: none; }
  .dir-layout { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-hero { flex-direction: column; }
  .profile-hero__actions { margin-left: 0; }
  .content { padding: 24px 20px; }
}
