:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
  background: #f8fafc;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f8fafc; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: #64748b; }
.danger { color: #b91c1c; }
.success { color: #047857; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top right, #fff7ed, #f8fafc 44%);
}
.login-card {
  width: min(430px, 100%);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .10);
}
.brand { display: flex; gap: 12px; align-items: center; font-weight: 850; letter-spacing: -.02em; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: #f97316; color: #fff; font-weight: 900;
}
.login-card h1 { margin: 22px 0 6px; font-size: 25px; }
.field { display: grid; gap: 6px; margin-top: 16px; }
.field label { font-size: 13px; font-weight: 750; color: #334155; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 10px; padding: 11px 12px;
  background: #fff; color: #0f172a;
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 3px solid #ffedd5; border-color: #fb923c;
}
.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 760;
  background: #f97316; color: #fff;
}
.btn.secondary { background: #e2e8f0; color: #0f172a; }
.btn.ghost { background: transparent; color: #475569; border: 1px solid #cbd5e1; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.form-error { margin-top: 14px; color: #b91c1c; font-size: 13px; font-weight: 650; min-height: 20px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  background: #0f172a; color: #e2e8f0; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.sidebar .brand { padding: 0 8px 20px; color: #fff; }
.nav-section { margin: 18px 8px 7px; font-size: 10px; font-weight: 850; color: #64748b; letter-spacing: .11em; }
.nav-link {
  display: flex; gap: 10px; align-items: center; width: 100%; margin: 3px 0; padding: 10px 12px;
  border: 0; border-radius: 9px; background: transparent; color: #cbd5e1; text-align: left;
}
.nav-link:hover { background: #1e293b; color: #fff; }
.nav-link.active { background: #fff7ed; color: #9a3412; font-weight: 800; }
.content-shell { min-width: 0; }
.topbar {
  height: 68px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-weight: 850; }
.staff-chip {
  display: flex; gap: 9px; align-items: center; padding: 7px 10px; border: 1px solid #e2e8f0;
  border-radius: 999px; background: #fff;
}
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #ffedd5; color: #9a3412; display: grid; place-items: center; font-weight: 850; }
.page { padding: 28px; max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; gap: 18px; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 6px; font-size: 27px; letter-spacing: -.025em; }
.page-head p { margin: 0; color: #64748b; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 18px;
  box-shadow: 0 5px 20px rgba(15, 23, 42, .035);
}
.metric-label { color: #64748b; font-size: 12px; font-weight: 750; }
.metric-value { margin-top: 7px; font-size: 28px; font-weight: 880; letter-spacing: -.03em; }
.metric-sub { margin-top: 5px; color: #64748b; font-size: 12px; }
.panel { margin-top: 16px; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.state { padding: 26px; border: 1px dashed #cbd5e1; border-radius: 12px; color: #64748b; background: #fff; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-wrap { overflow: auto; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 14px; border-bottom: 1px solid #eef2f7; text-align: left; font-size: 13px; vertical-align: top; }
th { color: #475569; background: #f8fafc; font-size: 11px; letter-spacing: .02em; position: sticky; top: 0; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; background: #f1f5f9; color: #334155; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.suspended { background: #fee2e2; color: #991b1b; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.small { font-size: 12px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

@media (max-width: 1050px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar .brand { padding-bottom: 8px; }
  .nav-section { display: none; }
  #adminNav { display: flex; overflow: auto; gap: 4px; }
  .nav-link { min-width: max-content; }
  .topbar { padding: 0 16px; }
  .page { padding: 20px 14px; }
  .cards { grid-template-columns: 1fr; }
  .staff-chip .identity-copy { display: none; }
}

.tabs {
  display: flex; gap: 8px; align-items: center; margin: 0 0 16px;
  border-bottom: 1px solid #e2e8f0; padding-bottom: 10px;
}
.tab {
  border: 0; background: transparent; color: #64748b; padding: 9px 12px;
  border-radius: 9px; font-weight: 750;
}
.tab:hover { background: #f8fafc; color: #0f172a; }
.tab.active { background: #fff7ed; color: #9a3412; }
.templates-table { min-width: 1180px; }
.danger-button { color: #b91c1c !important; border-color: #fecaca !important; }

.modal {
  width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 40px);
  padding: 0; border: 0; border-radius: 16px; box-shadow: 0 28px 90px rgba(15,23,42,.28);
}
.modal::backdrop { background: rgba(15, 23, 42, .48); }
.modal-card { padding: 22px; max-height: calc(100vh - 40px); overflow: auto; background: #fff; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-head h2 { margin: 0 0 5px; font-size: 21px; }
.modal-head p { margin: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.template-source-list { display: grid; gap: 10px; }
.source-card {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 18px; align-items: center; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px;
}
.source-card-main, .source-card-actions { display: grid; gap: 6px; }
.field.compact { margin-top: 0; }
.form-grid { display: grid; gap: 12px; }
.check-row { display: flex; gap: 9px; align-items: center; color: #334155; font-size: 13px; }
.check-row input { width: 16px; height: 16px; }
.audience-options { margin-top: 12px; }
.field select[multiple] { min-height: 170px; }


.template-preview-thumb {
  width: 168px; height: 116px; padding: 8px; border: 1px solid #dbe3ee; border-radius: 12px;
  background: #f8fafc; display: grid; place-items: center; overflow: hidden; color: #64748b; font-size: 11px;
}
.template-preview-thumb:hover { border-color: #fb923c; background: #fff7ed; }
.template-preview-thumb .lc-preview-stage,
.template-preview-large .lc-preview-stage {
  box-shadow: 0 2px 8px rgba(15,23,42,.12); border: 1px solid #e2e8f0; overflow: hidden;
}
.template-preview-large {
  min-height: 360px; border: 1px solid #e2e8f0; border-radius: 14px; background: #f8fafc;
  padding: 18px; display: grid; place-items: center; overflow: auto;
}
.template-preview-large.standalone { min-height: 540px; }
.metadata-layout { display: grid; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); gap: 22px; align-items: start; }
.metadata-form { display: grid; gap: 2px; }
.preview-caption { margin-bottom: 8px; }
.template-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.template-tag {
  display: inline-flex; padding: 3px 7px; border-radius: 999px; border: 1px solid #bfdbfe;
  background: #eff6ff; color: #1d4ed8; font-size: 10px; font-weight: 750;
}
.template-description { margin-top: 5px; max-width: 330px; }
.template-badge-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.draft-badge { background: #fef3c7; color: #92400e; }
.templates-table { min-width: 1480px; }
@media (max-width: 900px) {
  .metadata-layout { grid-template-columns: 1fr; }
  .template-preview-large { min-height: 280px; }
}


.template-filterbar {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) auto repeat(4, minmax(150px, .65fr)) auto;
  gap: 8px; align-items: center; margin: 0 0 8px;
}
.template-filter-search,
.template-filter-select {
  min-height: 40px; width: 100%; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 9px 11px; background: #fff; color: #0f172a;
}
.template-filter-search:focus,
.template-filter-select:focus { outline: 3px solid #ffedd5; border-color: #fb923c; }
.template-filter-count { margin: 0 0 10px 2px; }
.marketplace-badge { background: #eef2ff; color: #3730a3; }
.order-badge { background: #f8fafc; color: #475569; border: 1px solid #e2e8f0; }
@media (max-width: 1250px) {
  .template-filterbar { grid-template-columns: minmax(260px, 1fr) auto repeat(2, minmax(160px, .7fr)); }
}
@media (max-width: 760px) {
  .template-filterbar { display: flex; flex-direction: column; align-items: stretch; }
}

/* ADMIN-005 communications/support */
.link-button {
  border: 0; background: transparent; padding: 0; color: #0f172a;
  font-weight: 800; text-align: left; cursor: pointer;
}
.link-button:hover { color: #ea580c; text-decoration: underline; }
.support-toolbar { margin-bottom: 14px; }
.support-toolbar input, .support-toolbar select {
  min-height: 40px; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 9px 11px; background: #fff;
}
.support-toolbar input { min-width: 320px; flex: 1; }
.support-table { min-width: 1180px; }
.support-modal { width: min(1020px, calc(100vw - 32px)); }
.support-ticket-meta {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.support-ticket-meta > div {
  display: grid; gap: 4px; padding: 11px; border: 1px solid #e2e8f0;
  border-radius: 10px; background: #f8fafc;
}
.support-ticket-controls {
  display: grid; grid-template-columns: 180px 180px minmax(0, 1fr);
  gap: 10px; align-items: end; margin-bottom: 18px;
}
.support-control-actions { padding-bottom: 1px; }
.support-thread {
  display: grid; gap: 10px; padding: 14px; border: 1px solid #e2e8f0;
  border-radius: 12px; background: #f8fafc; max-height: 430px; overflow: auto;
}
.support-message {
  max-width: 78%; padding: 11px 13px; border-radius: 12px;
  border: 1px solid #e2e8f0; background: #fff;
}
.support-message.staff { margin-left: auto; background: #fff7ed; border-color: #fed7aa; }
.support-message.internal { margin-left: auto; background: #fefce8; border-style: dashed; }
.support-message-head { display: flex; gap: 10px; justify-content: space-between; margin-bottom: 5px; }
.support-message-body { white-space: pre-wrap; line-height: 1.45; }
.support-reply-box { margin-top: 16px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.news-table { min-width: 1120px; }
.news-editor-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px;
}
.news-span-2 { grid-column: 1 / -1; }
.news-editor-grid textarea { min-height: 92px; }
.news-editor-grid .news-span-2 textarea { min-height: 130px; }
.news-pin-row { margin-top: 35px; }
.news-preview-card {
  max-width: 760px; margin: 0 auto; padding: 4px 2px 12px;
}
.news-preview-image {
  width: 100%; max-height: 340px; object-fit: cover; border-radius: 14px;
  border: 1px solid #e2e8f0; margin-bottom: 18px;
}
.news-preview-kicker {
  color: #ea580c; font-size: 12px; font-weight: 850; text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 6px;
}
.news-preview-card h2 { font-size: 30px; margin: 0 0 10px; }
.news-preview-excerpt { color: #475569; font-size: 16px; margin: 0 0 16px; }
.news-preview-body { white-space: pre-wrap; line-height: 1.65; color: #1e293b; }
.news-preview-cta { margin-top: 20px; }
@media (max-width: 900px) {
  .support-ticket-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .support-ticket-controls { grid-template-columns: 1fr 1fr; }
  .news-editor-grid { grid-template-columns: 1fr; }
  .news-span-2 { grid-column: auto; }
}
@media (max-width: 620px) {
  .support-toolbar { align-items: stretch; }
  .support-toolbar input { min-width: 0; width: 100%; }
  .support-ticket-meta { grid-template-columns: 1fr; }
  .support-ticket-controls { grid-template-columns: 1fr; }
  .support-message { max-width: 94%; }
}

.news-rich-wrap { border: 1px solid #cbd5e1; border-radius: 10px; overflow: hidden; background: #fff; }
.news-rich-toolbar { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
.rich-tool { border: 1px solid #cbd5e1; border-radius: 7px; background: #fff; color: #334155; padding: 5px 8px; font-size: 12px; font-weight: 750; }
.rich-tool:hover { border-color: #fb923c; background: #fff7ed; }
.news-rich-editor { min-height: 180px; padding: 12px; outline: none; line-height: 1.6; overflow: auto; }
.news-rich-editor:empty::before { content: attr(data-placeholder); color: #94a3b8; pointer-events: none; }
.news-rich-editor h2, .news-rich-editor h3 { margin: 14px 0 8px; }
.news-rich-editor p, .news-rich-editor div { margin: 0 0 8px; }
.news-rich-editor ul, .news-rich-editor ol { padding-left: 24px; }
.news-rich-editor a, .news-preview-body a { color: #2563eb; text-decoration: underline; }
.news-preview-body h2, .news-preview-body h3 { margin: 16px 0 8px; }
.news-preview-body p, .news-preview-body div { margin: 0 0 9px; }
.news-preview-body ul, .news-preview-body ol { padding-left: 24px; }


/* ADMIN-006 Customer 360 */
.badge.partial { background: #fef3c7; color: #92400e; }
.data-source-list { display: grid; gap: 0; }
.data-source-row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 11px 0; border-top: 1px solid #eef2f7;
}
.data-source-row:first-child { border-top: 0; padding-top: 0; }
.customer-toolbar { margin-bottom: 14px; }
.customer-toolbar input, .customer-toolbar select {
  min-height: 40px; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 9px 11px; background: #fff; color: #0f172a;
}
.customer-toolbar input { flex: 1; min-width: 300px; }
.customers-table { min-width: 1420px; }
.customer-users-table { min-width: 980px; }
.customer-primary { font-weight: 800; color: #0f172a; }
.customer-marketplaces, .customer-capabilities { display: flex; gap: 5px; flex-wrap: wrap; }
.customer-list-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 10px; }
.customer-modal { width: min(1180px, calc(100vw - 32px)); }
.customer-detail-section { margin-top: 22px; }
.customer-detail-section h3 { margin: 0 0 10px; font-size: 16px; }
.customer-kv-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
}
.customer-kv {
  min-width: 0; display: grid; gap: 4px; padding: 11px;
  border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc;
  overflow-wrap: anywhere;
}
.customer-integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.customer-integration-block {
  display: grid; gap: 8px; border: 1px solid #e2e8f0; border-radius: 12px; padding: 13px; background: #f8fafc;
}
.customer-integration-block h4 { margin: 0 0 2px; font-size: 13px; }
.customer-integration-row { padding-top: 8px; border-top: 1px solid #e2e8f0; }
.customer-integration-row:first-of-type { border-top: 0; padding-top: 0; }
.customer-integration-title { font-weight: 750; }
@media (max-width: 900px) {
  .customer-kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .customer-integration-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .customer-toolbar { align-items: stretch; }
  .customer-toolbar input { min-width: 0; width: 100%; }
  .customer-kv-grid { grid-template-columns: 1fr; }
  .customer-list-meta { align-items: flex-start; flex-direction: column; }
}


/* ADMIN-007 period analytics */
.analytics-panel { display: grid; gap: 18px; }
.analytics-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
}
.analytics-head h2 { margin: 0 0 4px; }
.analytics-year-control { display: grid; gap: 5px; color: #475569; font-size: 12px; font-weight: 750; }
.analytics-year-select {
  min-width: 110px; min-height: 40px; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 8px 10px; background: #fff; color: #0f172a;
}
.analytics-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.analytics-summary .card { box-shadow: none; background: #f8fafc; }
.analytics-section { display: grid; gap: 10px; }
.analytics-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.analytics-section-head h3 { margin: 0; font-size: 15px; }
.analytics-table { min-width: 900px; }
.analytics-note {
  padding: 12px 14px; border: 1px solid #fde68a; border-radius: 10px;
  background: #fffbeb; color: #78350f; font-size: 12px; line-height: 1.5;
}
@media (max-width: 1050px) {
  .analytics-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .analytics-head, .analytics-section-head { align-items: stretch; flex-direction: column; }
  .analytics-year-select { width: 100%; }
  .analytics-summary { grid-template-columns: 1fr; }
}


/* ADMIN-008 — platform reference data */
.reference-settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 2fr) minmax(220px, 1fr) 160px 190px;
  gap: 14px;
  align-items: end;
  margin-top: 18px;
}
.reference-enabled {
  min-height: 42px;
  padding-bottom: 2px;
}
.reference-actions { margin-top: 16px; }
.reference-error { margin-top: 12px; font-size: 12px; }
@media (max-width: 1180px) {
  .reference-settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .reference-settings-grid { grid-template-columns: 1fr; }
}
