:root {
  --primary: #1f5a94;
  --primary-deep: #153a5b;
  --accent: #c63c32;
  --gold: #b88935;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #17212b;
  --muted: #667085;
  --border: #e4e9f0;
  --success: #2f855a;
  --warning: #b7791f;
  --danger: #c53030;
  --shadow: 0 12px 30px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

button {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input,
select,
textarea {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 120px;
  padding: 10px 12px;
  resize: vertical;
}

.is-hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-mark {
  color: var(--primary);
  font-weight: 700;
}

.login-panel h1 {
  margin: 0;
  font-size: 26px;
}

.login-panel p {
  margin: 0;
  color: var(--muted);
}

.login-panel label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.form-message {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: var(--primary-deep);
  color: #fff;
}

.sidebar-brand {
  display: grid;
  gap: 4px;
  padding: 0 8px 18px;
}

.sidebar-brand strong {
  font-size: 22px;
}

.sidebar-brand span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.module-nav {
  display: grid;
  gap: 6px;
}

.module-nav button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  color: rgba(255, 255, 255, 0.82);
  background: transparent;
  border-radius: 12px;
}

.module-nav button.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.topbar h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.admin-session {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.metric-card,
.content-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
}

.content-panel {
  overflow: hidden;
}

.service-lead-workspace {
  display: grid;
  gap: 16px;
}

.service-lead-stats {
  display: grid;
  grid-template-columns: repeat(8, minmax(108px, 1fr));
  gap: 10px;
}

.service-lead-stat {
  min-width: 0;
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(23, 33, 43, 0.05);
  text-align: left;
}

.service-lead-stat span {
  color: var(--muted);
  font-size: 12px;
}

.service-lead-stat strong {
  font-size: 25px;
}

.service-lead-stat.is-highlight {
  border-color: rgba(31, 90, 148, 0.36);
}

.service-lead-stat.is-active {
  border-color: var(--primary);
  background: #eef5fc;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.service-lead-panel {
  min-width: 0;
}

.service-lead-filter-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.service-lead-filter-grid {
  min-width: 0;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(145px, 1fr)) minmax(260px, 1.5fr);
  gap: 10px;
}

.service-lead-filter-grid label {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.service-lead-filter-grid label > span {
  color: var(--muted);
  font-size: 12px;
}

.service-lead-filter-grid input,
.service-lead-filter-grid select {
  width: 100%;
}

.service-lead-filter-actions {
  display: flex;
  gap: 8px;
}

.service-lead-table-wrap {
  max-height: calc(100vh - 390px);
}

.service-lead-table {
  min-width: 1160px;
}

.service-lead-id {
  max-width: 170px;
  display: block;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.service-lead-applicant,
.service-lead-contact-summary,
.service-lead-source {
  display: grid;
  gap: 4px;
}

.service-lead-applicant span,
.service-lead-contact-summary span,
.service-lead-source span {
  color: var(--muted);
  font-size: 12px;
}

.service-lead-source span {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-table-cell,
.workspace-loading,
.workspace-error {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.workspace-error {
  color: var(--danger);
}

.panel-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.filter-row,
.primary-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.extra-filters {
  display: contents;
}

.table-wrap {
  max-height: calc(100vh - 260px);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfcff;
  color: var(--muted);
}

.cell-title {
  display: grid;
  gap: 4px;
}

.cell-title strong {
  font-size: 14px;
}

.cell-title span {
  color: var(--muted);
}

.cell-content {
  max-width: 320px;
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--primary);
  background: #e8f1fb;
  white-space: nowrap;
}

.status-pill.pending,
.status-pill.pending_review,
.status-pill.requested,
.status-pill.unpaid,
.status-pill.submitted,
.status-pill.voucher_submitted {
  color: var(--warning);
  background: #fff5dd;
}

.status-pill.approved,
.status-pill.active,
.status-pill.confirmed,
.status-pill.published,
.status-pill.completed,
.status-pill.resolved {
  color: var(--success);
  background: #e8f7ee;
}

.status-pill.rejected,
.status-pill.hidden,
.status-pill.deleted,
.status-pill.expired,
.status-pill.cancelled {
  color: var(--danger);
  background: #ffecec;
}

.status-pill.disabled {
  color: var(--muted);
  background: #eef2f7;
}

.status-pill.service-new,
.status-pill.service-contacted,
.status-pill.service-materials_collecting,
.status-pill.service-quoted {
  color: var(--warning);
  background: #fff5dd;
}

.status-pill.service-converted,
.status-pill.service-completed {
  color: var(--success);
  background: #e8f7ee;
}

.status-pill.service-invalid {
  color: var(--danger);
  background: #ffecec;
}

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

.button-muted {
  color: var(--text);
  background: #eef2f7;
}

.button-danger {
  background: var(--danger);
}

.button-gold {
  background: var(--gold);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 16px;
  color: var(--muted);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 50px rgba(23, 33, 43, 0.14);
  transform: translateX(104%);
  transition: transform 180ms ease;
  z-index: 20;
}

.detail-drawer.is-open {
  transform: translateX(0);
}

.detail-drawer.service-lead-drawer {
  width: min(760px, 100vw);
}

.detail-drawer.news-editor-drawer {
  width: min(720px, 100vw);
}

.drawer-header,
.drawer-actions {
  padding: 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.drawer-actions {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  flex-wrap: wrap;
}

.drawer-header h2 {
  margin: 0 0 6px;
}

.drawer-header p {
  margin: 0;
  color: var(--muted);
}

.drawer-body {
  overflow: auto;
  padding: 18px;
}

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

.form-grid {
  gap: 14px;
}

.form-field {
  display: grid;
  gap: 7px;
}

.form-field span {
  color: var(--muted);
  font-size: 12px;
}

.form-field input[readonly] {
  color: var(--muted);
  background: #f7f9fc;
}

.news-editor-form > .form-field textarea[id$="Content"] {
  min-height: 260px;
  line-height: 1.65;
}

.news-cta-editor {
  display: grid;
  gap: 14px;
  margin-top: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
}

.news-cta-editor h3 {
  margin: 0;
  font-size: 16px;
}

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

.admin-subsection {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.admin-subsection h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.action-hint {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

.service-lead-drawer-section {
  padding: 0 0 20px;
  margin: 0 0 20px;
  border-bottom: 1px solid var(--border);
}

.service-lead-drawer-section:last-child {
  margin-bottom: 0;
}

.service-lead-drawer-section h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

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

.service-lead-contact-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.button-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0 14px;
  color: #fff;
  background: var(--primary);
  text-decoration: none;
}

.service-lead-dynamic-fields {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.service-lead-files {
  display: grid;
  gap: 9px;
}

.service-lead-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcff;
}

.service-lead-file > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.service-lead-file strong {
  overflow-wrap: anywhere;
}

.service-lead-file span {
  color: var(--muted);
  font-size: 12px;
}

.compact-button {
  width: fit-content;
}

.service-lead-processing-hint {
  padding: 14px;
  border: 1px solid #d8e6f5;
  border-radius: 12px;
  background: #f4f8fc;
}

.service-lead-processing-hint h3 {
  margin-bottom: 8px;
}

.service-lead-processing-hint p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

.detail-field {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.detail-field.wide {
  grid-column: 1 / -1;
}

.detail-field span {
  color: var(--muted);
  font-size: 12px;
}

.detail-field pre {
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: #f7f9fc;
  white-space: pre-wrap;
}

.detail-field > div {
  overflow-wrap: anywhere;
}

.detail-field.wide > div {
  white-space: pre-wrap;
}

.file-link-list {
  display: grid;
  gap: 8px;
}

.file-link-list a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.file-link-list a:hover {
  text-decoration: underline;
}

.admin-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.admin-thumb-grid a {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.admin-thumb-grid span {
  overflow-wrap: anywhere;
}

.admin-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: 8px;
  object-fit: cover;
  background: #f7f9fc;
}

.compare-grid {
  display: grid;
  grid-template-columns: minmax(100px, 0.7fr) minmax(0, 1.4fr) minmax(0, 1.4fr);
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.compare-head,
.compare-cell {
  min-width: 0;
  padding: 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
  font-size: 13px;
}

.compare-head {
  color: var(--muted);
  background: #fbfcff;
  font-weight: 700;
}

.compare-label {
  color: var(--muted);
  background: #fbfcff;
}

.compare-cell.is-changed {
  background: #fff8e8;
}

.inline-table {
  max-height: 460px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 11px 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(23, 33, 43, 0.92);
  z-index: 30;
}

@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .module-nav {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .topbar,
  .panel-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .service-lead-stats {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .service-lead-filter-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .service-lead-filter-grid {
    grid-template-columns: repeat(2, minmax(145px, 1fr));
  }
}

@media (max-width: 560px) {
  .promotion-order-detail {
    grid-template-columns: 1fr;
  }

  .service-lead-stats,
  .service-lead-filter-grid,
  .service-lead-contact-grid {
    grid-template-columns: 1fr;
  }

  .service-lead-file,
  .service-lead-contact-actions,
  .service-lead-filter-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
