:root {
  --bg: #f5f2ea;
  --panel: #fffdf8;
  --line: #d7d0c3;
  --line-soft: #ece6da;
  --ink: #1e2430;
  --muted: #67707e;
  --accent: #1f6f5f;
  --accent-strong: #164e46;
  --accent-soft: #dceee8;
  --warm: #b46a2a;
  --warm-soft: #f7eadb;
  --alert: #8a2f2b;
  --alert-soft: #f8dfdc;
  --sky: #dbe9f7;
  --sky-strong: #3e6a93;
  --client-soft: #eef5ea;
  --client-strong: #3f6f2d;
  --shadow: 0 18px 45px rgba(51, 43, 29, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(31, 111, 95, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(180, 106, 42, 0.10), transparent 26%),
    linear-gradient(180deg, #f9f6ef 0%, var(--bg) 100%);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

.page {
  max-width: 1380px;
  margin: 0 auto;
  padding: 22px;
}

.card {
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.hero-card {
  max-width: 480px;
  margin: 52px auto;
  display: grid;
  gap: 10px;
}

.hero-kicker,
.section-kicker,
.zone-kicker {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 700;
  color: var(--warm);
}

.topbar-alt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.topbar-main {
  display: flex;
  gap: 14px;
  align-items: center;
}

.client-header-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #faf8f1;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.client-header-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.nav-card {
  padding: 12px 14px;
}

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

.tab-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfaf6;
  color: var(--ink);
  padding: 10px 16px;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.tab-btn:hover {
  transform: translateY(-1px);
  border-color: #b9ac97;
}

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

.client-tab-panel {
  display: none;
}

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

#panel-my-data:not(.active),
#panel-new-supplier:not(.active),
#panel-consents:not(.active),
#panel-my-suppliers:not(.active) {
  display: none !important;
}

#panel-my-data.active,
#panel-consents.active,
#panel-new-supplier.active {
  display: block !important;
}

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

.section-head h3,
.zone-head h4,
.history-box h4,
.request-card h4 {
  margin: 2px 0 0;
}

.section-head-copy {
  max-width: 520px;
  text-align: right;
}

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

.client-tab-panel.layout-clarified {
  display: none;
}

.client-tab-panel.layout-clarified.active {
  display: grid !important;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: stretch;
}

.supplier-rail {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.rail-hint {
  margin: 0;
}

.editor-stack {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.intro-panel {
  min-height: auto;
}

.intro-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.intro-box,
.request-card,
.editor-zone,
.history-box {
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 16px;
}

.intro-box p,
.request-card p,
.zone-copy {
  margin-bottom: 0;
}

.intro-box-global {
  background: linear-gradient(180deg, #f7fbff 0%, #fefefe 100%);
  border-color: #cbdced;
}

.intro-box-client {
  background: linear-gradient(180deg, #f3f9ef 0%, #ffffff 100%);
  border-color: #d7e6ce;
}

.intro-box-request {
  background: linear-gradient(180deg, #fff6f2 0%, #ffffff 100%);
  border-color: #ebd1c7;
}

.intro-tag,
.request-badge,
.zone-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}

.request-badge,
.zone-pill-readonly {
  background: var(--sky);
  color: var(--sky-strong);
}

.zone-pill-edit {
  background: var(--client-soft);
  color: var(--client-strong);
}

.zone-pill-admin {
  background: var(--warm-soft);
  color: var(--warm);
}

.supplier-focus-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

.supplier-focus-head {
  align-items: center;
}

.editor-dual-zone {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(340px, 1.05fr);
  gap: 16px;
}

.editor-zone-global {
  background: linear-gradient(180deg, #f7fbff 0%, #fff 100%);
  border-color: #c8d9ec;
}

.editor-zone-client {
  background: linear-gradient(180deg, #f4fbf2 0%, #fff 100%);
  border-color: #d5e8cb;
}

.change-request-shell {
  border: 1px solid #ecd8c7;
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(180deg, #fff8f3 0%, #fffdfb 100%);
}

.change-request-form {
  display: grid;
  gap: 10px;
}

.history-box {
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.history-box-wide {
  margin-top: 18px;
}

.history-head {
  justify-content: space-between;
  align-items: end;
  margin-bottom: 8px;
}

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

.request-card-create {
  background: linear-gradient(180deg, #fef9f2 0%, #fff 100%);
}

.request-card-link {
  background: linear-gradient(180deg, #f5fafc 0%, #fff 100%);
}

.panel {
  min-height: 420px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 13px;
}

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

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  background: #fffefb;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31, 111, 95, 0.18);
  border-color: #8fbaae;
}

textarea {
  min-height: 92px;
}

button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 13px;
  background: #f8f5ee;
  cursor: pointer;
}

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

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row-actions {
  margin-top: 6px;
}

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

.editor-toolbar button {
  padding: 7px 10px;
  font-size: 12px;
}

.rich-editor {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  line-height: 1.45;
}

.client-map {
  height: 280px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #eef2f7;
}

.list {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  overflow: auto;
  min-height: 240px;
  max-height: 58vh;
  background: rgba(255, 255, 255, 0.8);
}

.supplier-rail .list {
  min-height: 0;
  height: 100%;
  max-height: none;
}

.list-item {
  padding: 12px;
  border-bottom: 1px solid #ede8dc;
  cursor: pointer;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: #f9f6ef;
}

.list-item.active {
  background: #edf6f2;
  outline: 1px solid #b9ddd1;
}

.list-main {
  font-weight: 700;
}

.list-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.global-box {
  border: 1px dashed #b4cde2;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  padding: 14px;
  min-height: 220px;
}

.multi-picker {
  display: grid;
  gap: 6px;
}

.multi-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.multi-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  font-size: 12px;
  color: #334155;
}

.multi-chip-remove {
  color: #64748b;
  cursor: pointer;
  padding: 0 1px;
  line-height: 1;
  font-size: 12px;
  user-select: none;
}

.multi-chip-remove:hover {
  color: #ef4444;
}

.multi-chip-locked {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #94a3b8;
  cursor: default;
}

.msg {
  color: var(--muted);
  font-size: 13px;
}

.msg.error {
  color: var(--alert);
}

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

.hidden {
  display: none !important;
}

.pending-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 999px;
  background: #fff3df;
  border: 1px solid #f0c17d;
  color: #975d17;
  vertical-align: middle;
}

.consent-stack {
  display: grid;
  gap: 14px;
}

.consent-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(250, 248, 242, 0.96) 100%);
}

.consent-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.consent-card-head h4 {
  margin: 0 0 4px;
}

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

.consent-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #f6f1e7;
  color: var(--ink);
  white-space: nowrap;
}

.status-approved {
  background: #e7f6ee;
  border-color: #87c79f;
  color: #21603b;
}

.status-pending {
  background: #fff2df;
  border-color: #e7bb78;
  color: #8a5a16;
}

.status-rejected {
  background: #fae6e4;
  border-color: #d59894;
  color: #8a2f2b;
}

.consent-note {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8f5ee;
  border: 1px solid var(--line-soft);
  font-size: 13px;
}

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

.consent-supplier-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.7);
}

.consent-supplier-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.consent-badge-global {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid #a4c6e4;
  background: #e9f4ff;
  color: #315a7d;
}

@media (max-width: 760px) {
  .consent-card-head,
  .consent-supplier-top {
    flex-direction: column;
  }
}

@media (max-width: 1100px) {
  .layout-clarified,
  .editor-dual-zone,
  .request-split,
  .intro-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .history-head,
  .topbar-alt {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-head-copy {
    text-align: left;
  }
}

@media (max-width: 760px) {
  .page {
    padding: 14px;
  }

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

  .topbar-main {
    width: 100%;
  }
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  max-width: 700px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1001;
}

.supplier-map-modal {
  padding: 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  color: var(--ink);
}

.modal-body {
  padding: 18px;
}

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

/* Consent Badge Styles */
.consent-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
}

.consent-badge.approved {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.consent-badge.pending {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

.consent-badge.sent {
  background-color: #cfe2ff;
  color: #084298;
  border: 1px solid #b6d4fe;
}

.consent-badge.none {
  background-color: #e2e3e5;
  color: #383d41;
  border: 1px solid #d3d6d8;
}

.consent-badge-info {
  padding: 12px;
  border-radius: 6px;
  background-color: #e9f4ff;
  border: 1px solid #b6d4fe;
  color: #084298;
  font-size: 14px;
}

.consent-badge-info strong {
  display: block;
  margin-bottom: 6px;
}

.supplier-list-item-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

.supplier-list-item-badge.approved {
  color: #155724;
}

.supplier-list-item-badge.pending {
  color: #856404;
}

.supplier-list-item-badge.sent {
  color: #084298;
}

.view-map-btn {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

@media (max-width: 760px) {
  .modal-content {
    max-width: 95vw;
    max-height: 95vh;
  }

  #supplierMapContainer {
    height: 350px !important;
  }
}
