:root {
  --bg: #f5f6f4;
  --panel: #ffffff;
  --ink: #20231f;
  --muted: #687067;
  --line: #dfe3dc;
  --brand: #b3202a;
  --brand-dark: #751d24;
  --green: #2f6f55;
  --amber: #9b661a;
  --blue: #385f8c;
  --soft-red: #fff1f1;
  --soft-green: #eef7f1;
  --soft-blue: #eef4fb;
  --shadow: 0 10px 30px rgba(32, 35, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #151713;
}

.login-page .login-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 0.8fr) minmax(520px, 1.2fr);
}

.login-page .login-panel {
  padding: clamp(36px, 6vw, 88px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fbfbf8;
  border-radius: 0;
  box-shadow: none;
}

.login-intro {
  margin: 70px 0 36px;
  max-width: 480px;
}

.login-intro h1 {
  margin: 10px 0 12px;
  font-size: clamp(38px, 4vw, 58px);
  letter-spacing: -0.06em;
}

.login-intro p,
.login-help {
  color: #72766f;
  line-height: 1.7;
}

.login-form {
  max-width: 480px;
}

.login-form button {
  width: 100%;
  min-height: 56px;
  margin-top: 6px;
}

.login-help {
  margin-top: 22px;
  font-size: 14px;
}

.login-visual {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  color: white;
  background:
    radial-gradient(circle at 78% 20%, rgba(211, 35, 51, 0.75), transparent 30%),
    radial-gradient(circle at 20% 82%, rgba(139, 36, 43, 0.75), transparent 34%),
    linear-gradient(135deg, #111713 0%, #222820 44%, #681e25 100%);
}

.login-visual::before,
.login-visual::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 50%;
  width: 640px;
  height: 640px;
  right: -180px;
  top: -180px;
}

.login-visual::after {
  width: 420px;
  height: 420px;
  right: -70px;
  top: -70px;
}

.login-visual-copy {
  position: absolute;
  left: clamp(52px, 8vw, 130px);
  right: 50px;
  bottom: clamp(70px, 10vw, 140px);
  z-index: 1;
}

.login-visual-copy > span,
.eyebrow {
  color: #d32333;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .22em;
}

.login-visual-copy > span { color: #ff8d98; }

.login-visual-copy h2 {
  margin: 18px 0 42px;
  font-size: clamp(42px, 5vw, 74px);
  line-height: 1.08;
  letter-spacing: -0.06em;
}

.access-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 680px;
}

.access-legend p {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 4px 12px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 20px;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(16px);
}

.access-legend small { grid-column: 2; color: rgba(255,255,255,.66); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.legend-dot.shared { background: #62d59a; }
.legend-dot.private { background: #ff6674; }

.user-admin-panel { margin-bottom: 16px; }
.user-create {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(180px, 1.2fr);
  align-items: end;
}
.user-create .access-date-field {
  display: grid;
  gap: 6px;
}
.data-source-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff8f8;
}
.data-source-choice input { width: 18px; height: 18px; flex: 0 0 auto; }
.data-source-choice span { display: grid; gap: 2px; }
.data-source-choice small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.access-date-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.user-create > button { min-height: 48px; }
.user-list { margin-top: 18px; overflow-x: auto; }
.user-actions { display: flex; gap: 8px; }
.danger-quiet {
  border: 1px solid #f0c8cc;
  background: #fff2f3;
  color: #bb1e2d;
}
.access-note {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #fff 0%, #f0f8f3 100%);
}
.access-note h2 { margin: 8px 0; }
.access-note p { max-width: 760px; }
.user-identity {
  color: #207a58;
  background: #edf8f2;
}
.password-security { margin-bottom: 16px; }
.private-account-admin { margin-bottom: 16px; }
.password-change-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
  gap: 12px;
}
.password-change-form > * { min-height: 48px; }
.user-list .table { min-width: 1280px; }
.user-list input[type="date"] { min-width: 150px; }

@media (max-width: 900px) {
  .login-page .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-page .login-panel { min-height: 100vh; }
  .user-create { grid-template-columns: 1fr; }
  .password-change-form { grid-template-columns: 1fr; }
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  padding: 26px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.login-brand {
  margin: -8px -8px 24px;
  color: var(--ink);
  border-bottom-color: var(--line);
}

.login-brand span {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-form label {
  display: grid;
  gap: 6px;
}

.login-form label span {
  color: var(--muted);
  font-size: 13px;
}

.login-error {
  min-height: 20px;
  color: var(--brand);
  font-size: 13px;
}

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

button {
  border: 0;
  cursor: pointer;
}

.sidebar {
  width: 248px;
  min-height: 100vh;
  padding: 20px 16px;
  background: #151713;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--brand);
  font-weight: 800;
}

.brand span,
.side-card span,
.side-card small {
  display: block;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  line-height: 1.6;
}

nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  height: 40px;
  text-align: left;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  border-radius: 6px;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.side-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

main {
  flex: 1;
  min-width: 0;
}

.topbar {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  background: rgba(245, 246, 244, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
}

h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: 0;
}

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

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

select,
input,
input[type="file"] {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

textarea {
  width: 100%;
  min-height: 72px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  line-height: 1.55;
  resize: vertical;
}

.primary,
.secondary,
.ghost,
.danger {
  height: 38px;
  padding: 0 14px;
  border-radius: 6px;
}

.primary {
  color: #fff;
  background: var(--brand);
}

.secondary {
  color: var(--ink);
  background: #ecefec;
}

.ghost {
  color: var(--muted);
  background: transparent;
}

.danger {
  color: var(--brand);
  background: var(--soft-red);
}

.view {
  display: none;
  padding: 24px 28px 48px;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-2 {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

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

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

.panel,
.metric,
.account-card,
.opportunity-card,
.draft-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.metric {
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.panel-head,
.card-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2,
.section-head h2 {
  margin: 0;
  font-size: 18px;
}

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

.table th,
.table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

.table th {
  color: var(--muted);
  font-weight: 600;
  background: #fafafa;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #f0f2ef;
  font-size: 12px;
}

.tag.red {
  color: var(--brand-dark);
  background: var(--soft-red);
}

.tag.green {
  color: var(--green);
  background: var(--soft-green);
}

.tag.blue {
  color: var(--blue);
  background: var(--soft-blue);
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.owner-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 16px;
  align-items: start;
}

.owner-column {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

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

.owner-head strong {
  font-size: 18px;
}

.owner-stack {
  display: grid;
  gap: 12px;
}

.account-card.compact {
  box-shadow: none;
}

.account-card,
.account-setting-card,
.opportunity-card,
.draft-card {
  padding: 16px;
}

.account-card h3,
.account-setting-card h3,
.opportunity-card h3,
.draft-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.account-setting-list {
  display: grid;
  gap: 14px;
}

.account-setting-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

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

.field-grid label {
  display: grid;
  gap: 6px;
}

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

.field-grid .wide {
  grid-column: span 2;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.estate-search-panel p,
.empty-panel p {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.6;
}

.estate-mode-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0f2ef;
}

.estate-mode-tabs button {
  min-height: 34px;
  padding: 7px 14px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.estate-mode-tabs button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 4px rgba(20, 29, 23, 0.08);
}

.estate-filter-row {
  display: grid;
  grid-template-columns: 170px 140px 140px auto minmax(150px, 1fr);
  gap: 10px;
  align-items: end;
}

.estate-filter-row label {
  display: grid;
  gap: 5px;
}

.estate-filter-row label > span {
  color: var(--muted);
  font-size: 11px;
}

.estate-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.estate-kpis > div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.estate-kpis span,
.estate-kpis small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.estate-kpis strong {
  display: block;
  margin: 4px 0;
  font-size: 28px;
}

.estate-table-panel,
.estate-source-panel,
.estate-heat-placeholder {
  margin-top: 14px;
}

.table-scroll {
  overflow-x: auto;
}

.estate-delivery-table {
  min-width: 1120px;
}

.estate-delivery-table td:nth-child(2) {
  min-width: 210px;
}

.estate-delivery-table td strong,
.estate-delivery-table td small {
  display: block;
}

.estate-manual-panel {
  margin-top: 14px;
  padding: 0;
  overflow: hidden;
}

.estate-manual-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}

.estate-manual-panel > summary::-webkit-details-marker { display: none; }
.estate-manual-panel > summary span,
.estate-manual-panel > summary strong,
.estate-manual-panel > summary small { display: block; }
.estate-manual-panel > summary small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.estate-manual-panel > summary b { color: var(--red); font-size: 13px; }

.estate-import-strip {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(220px, 320px) auto minmax(100px, auto);
  gap: 10px;
  align-items: center;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: #fafbf9;
}

.estate-import-strip strong,
.estate-import-strip small { display: block; }
.estate-import-strip small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.5; }

.estate-manual-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 20px;
  border-top: 1px solid var(--line);
}

.estate-manual-grid label { display: grid; gap: 5px; }
.estate-manual-grid label > span { color: var(--muted); font-size: 11px; }
.handover-selects {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 8px;
}
.estate-manual-grid .handover-selects select {
  width: 100%;
  min-width: 0;
}
.estate-manual-wide { grid-column: span 2; }
.estate-manual-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }

.estate-star {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  color: #a6aaa5;
  background: #f2f3f1;
  font-size: 24px;
  line-height: 1;
}

.estate-star.active {
  color: #d49a16;
  background: #fff7d9;
  box-shadow: inset 0 0 0 1px #f0d47a;
}

.estate-showroom-select { min-width: 108px; height: 34px; padding: 5px 8px; font-size: 12px; }
.danger-text { display: block; margin-top: 5px; padding: 0; color: var(--red); background: none; font-size: 11px; }

.estate-delivery-table td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

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

.estate-source-list a {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fbfcfb;
  text-decoration: none;
}

.estate-source-list a span {
  color: var(--muted);
  font-size: 11px;
}

.estate-heat-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}

.estate-heat-flow span {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  background: #fbfcfb;
}

.estate-search-row {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto minmax(160px, 1fr);
  gap: 10px;
  align-items: center;
}

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

.estate-batch,
.estate-city-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.estate-batch span,
.estate-city-tabs button {
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: #f0f2ef;
  font-size: 12px;
}

.estate-city-tabs {
  margin-bottom: 14px;
}

.estate-city-tabs button.active {
  color: var(--green);
  background: var(--soft-green);
}

.estate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}

.estate-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.estate-card h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.estate-card p {
  font-size: 13px;
}

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

.estate-stats span {
  padding: 10px;
  border-radius: 6px;
  background: #f7f8f6;
  color: var(--muted);
  font-size: 12px;
}

.estate-stats strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 18px;
}

.estate-table th {
  width: 86px;
}

.estate-note {
  margin-top: 12px;
  padding: 10px;
  border-radius: 6px;
  background: #fbfcfb;
  font-size: 13px;
  line-height: 1.55;
}

.estate-note strong {
  display: block;
  margin-bottom: 4px;
}

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

#accounts .account-card {
  padding: 14px;
}

#accounts .account-card h3 {
  font-size: 15px;
  line-height: 1.35;
}

#accounts .account-card p {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

#accounts .account-card .table th,
#accounts .account-card .table td {
  padding: 8px 7px;
  font-size: 12px;
  line-height: 1.45;
}

#accounts .account-card .tag {
  min-height: 22px;
  padding: 2px 7px;
  font-size: 11px;
}

#accounts .account-card .status {
  font-size: 11px;
}

#accounts .account-card .card-actions {
  gap: 7px;
}

#accounts .account-card .card-actions button {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  font-size: 13px;
  line-height: 1.1;
  white-space: nowrap;
}

.badge-stack {
  display: grid;
  gap: 6px;
  justify-items: end;
  flex-shrink: 0;
}

.inline-create {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) auto;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px;
  border-radius: 8px;
  background: #f7f8f6;
}

.opportunity-list,
.draft-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

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

.upload-box {
  padding: 18px;
  border: 1px dashed #b8bfb6;
  border-radius: 8px;
  background: #fbfcfb;
}

.upload-box form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.file-label {
  display: grid;
  gap: 5px;
}

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

.compact-metrics {
  margin: 0;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.compact-metrics .metric {
  padding: 12px;
  box-shadow: none;
}

.compact-metrics .metric strong {
  font-size: 20px;
}

.report-dashboard {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.monthly-dashboard {
  margin-top: 16px;
}

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

.kpi-card {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.kpi-card span,
.kpi-card small,
.bar-meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.kpi-card strong {
  display: block;
  margin: 6px 0 3px;
  font-size: 26px;
  line-height: 1.1;
}

.kpi-card.blue {
  background: var(--soft-blue);
  border-color: #d8e5f3;
}

.kpi-card.green {
  background: var(--soft-green);
  border-color: #d5e9dc;
}

.kpi-card.red {
  background: var(--soft-red);
  border-color: #f2d4d7;
}

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

.chart-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chart-panel h3,
.report-title-row h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.bar-line {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.bar-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.bar-meta strong {
  font-size: 14px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0ec;
}

.progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--amber));
}

.conversion-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.conversion-metrics > div {
  border: 1px solid var(--line);
  background: #f7f9f6;
  padding: 12px;
  border-radius: 6px;
}

.conversion-metrics span,
.conversion-metrics strong {
  display: block;
}

.conversion-metrics span {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 5px;
}

.conversion-metrics strong {
  font-size: 20px;
}

.inline-rate-editor {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.inline-rate-editor label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 7px;
}

.inline-rate-editor > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-rate-editor input {
  width: 110px;
}

.progress-track.slim {
  height: 6px;
  margin-top: 7px;
}

.account-rank-panel {
  overflow-x: auto;
}

.color-table tbody tr:nth-child(odd) {
  background: #fbfcfb;
}

.color-table strong {
  display: block;
  margin-bottom: 2px;
}

.report-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 8px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f1f1ef;
  color: var(--muted);
  font-size: 12px;
}

.status.high {
  background: var(--soft-red);
  color: var(--brand-dark);
}

.status.ok {
  background: var(--soft-green);
  color: var(--green);
}

dialog {
  width: min(760px, calc(100vw - 40px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.32);
}

.dialog-head {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: #f1f1ef;
  font-size: 20px;
}

#dialogBody {
  padding: 18px;
}

.report-box {
  white-space: pre-wrap;
  padding: 16px;
  border-radius: 8px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  line-height: 1.7;
}

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

.compact-head {
  margin-bottom: 8px;
}

.manual-ad-form {
  margin-top: 12px;
}

.ad-workspace {
  display: grid;
  gap: 18px;
}

.ad-intake-panel {
  padding-bottom: 18px;
}

.ad-intake-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-top: 16px;
}

.ad-delete-actions {
  justify-content: flex-end;
  margin: 0;
}

.ad-manual-details {
  padding-top: 14px;
}

.ad-manual-details summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
}

.ad-manual-details summary::-webkit-details-marker { display: none; }
.ad-manual-details summary::after { content: "+"; color: var(--brand); font-size: 18px; }
.ad-manual-details[open] summary::after { content: "−"; }
.ad-manual-details summary span { color: var(--muted); font-size: 12px; font-weight: 400; }
.ad-manual-body { padding-top: 14px; }

.ad-analysis-board {
  display: grid;
  gap: 16px;
}

.ad-command-card {
  display: grid;
  grid-template-columns: minmax(300px, 1.15fr) minmax(420px, 1fr);
  gap: 34px;
  padding: 28px 30px;
  border-radius: 20px;
  color: #fff;
  background:
    radial-gradient(circle at 78% 12%, rgba(198, 30, 43, .27), transparent 34%),
    linear-gradient(135deg, #111410 0%, #1c1f1a 58%, #3a1719 100%);
  box-shadow: 0 18px 45px rgba(22, 24, 20, .12);
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--brand);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .18em;
}

.ad-command-copy h2 {
  margin: 0 0 10px;
  font-size: 30px;
  letter-spacing: -.03em;
}

.ad-command-copy p {
  max-width: 680px;
  margin: 0;
  color: rgba(255, 255, 255, .7);
  line-height: 1.7;
}

.ad-command-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 15px;
  overflow: hidden;
}

.ad-command-stats > div {
  display: grid;
  align-content: center;
  min-height: 108px;
  padding: 17px;
  border-left: 1px solid rgba(255, 255, 255, .1);
}

.ad-command-stats > div:first-child { border-left: 0; }
.ad-command-stats span, .ad-command-stats small { color: rgba(255, 255, 255, .55); font-size: 11px; }
.ad-command-stats strong { margin: 6px 0; font-size: 25px; }

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

.ad-kpi,
.ad-insight-section {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
}

.ad-kpi {
  display: grid;
  gap: 7px;
  padding: 18px 20px;
}

.ad-kpi span, .ad-kpi small { color: var(--muted); font-size: 11px; }
.ad-kpi strong { font-size: 22px; letter-spacing: -.02em; }
.ad-kpi i { color: #c5c6c2; font-style: normal; }

.ad-insight-section { padding: 22px; }

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

.ad-section-head h3 { margin: 0; font-size: 20px; }
.ad-section-head p { margin: 0; color: var(--muted); font-size: 12px; }

.ad-funnel-row {
  display: grid;
  grid-template-columns: repeat(7, auto);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-radius: 13px;
  background: #f7f7f4;
}

.ad-funnel-row > div { min-width: 140px; }
.ad-funnel-row span, .ad-funnel-row small { display: block; color: var(--muted); font-size: 11px; }
.ad-funnel-row strong { display: block; margin: 5px 0; font-size: 22px; }
.ad-funnel-row > b { color: #bbbdb7; }

.ad-plan-table-wrap { overflow-x: auto; }
.ad-plan-table { min-width: 1060px; }
.ad-plan-table th { white-space: nowrap; }
.ad-plan-table td { min-width: 95px; vertical-align: top; line-height: 1.5; }
.ad-plan-table td:first-child { max-width: 250px; }
.ad-plan-table td:first-child strong { display: block; max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-plan-table td span, .ad-plan-table td small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }

.ad-decision {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
}

.ad-decision.scale { color: #11623f; background: #e9f6ef; }
.ad-decision.keep { color: #285d50; background: #edf4f1; }
.ad-decision.optimize { color: #8a5b16; background: #fbf2df; }
.ad-decision.watch { color: #5c625d; background: #eff0ed; }
.ad-decision.stop { color: #b31927; background: #fae9eb; }

.ad-month-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.ad-month-grid > div {
  min-height: 110px;
  padding: 15px;
  border-radius: 12px;
  background: #f7f7f4;
}

.ad-month-grid span, .ad-month-grid small { display: block; color: var(--muted); font-size: 10px; line-height: 1.6; }
.ad-month-grid strong { display: block; margin: 8px 0; font-size: 19px; }
.ad-empty-state { padding: 28px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.ad-method-note { margin: 0; padding: 0 4px; color: var(--muted); font-size: 10px; line-height: 1.7; }

.report-editor {
  width: 100%;
  min-height: 720px;
  resize: vertical;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  color: var(--text);
  line-height: 1.7;
  font: inherit;
  outline: none;
}

.report-editor:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(180, 24, 36, 0.12);
}

.ai-result-shell {
  display: grid;
  gap: 12px;
}

.ai-result-editor {
  width: 100%;
  min-height: 520px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  line-height: 1.75;
}

.ai-instruction-field {
  display: grid;
  gap: 6px;
}

.ai-instruction-field span {
  color: var(--muted);
  font-size: 11px;
}

.inline-status {
  min-height: 24px;
  margin-top: 8px;
  color: var(--muted);
}

.xhs-login-box {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.xhs-login-box img {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.debug-shot {
  width: 100%;
  max-height: 460px;
  object-fit: contain;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 980px) {
  body {
    display: block;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    position: static;
  }

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

  .topbar,
  .grid.cols-2,
  .grid.cols-3,
  .metric-row,
  .kpi-grid,
  .insight-board,
  .split,
  .field-grid,
  .estate-filter-row,
  .estate-kpis,
  .estate-source-list,
  .estate-heat-flow,
  .estate-import-strip,
  .estate-manual-grid {
    grid-template-columns: 1fr;
  }

  .estate-manual-wide,
  .estate-manual-actions {
    grid-column: auto;
  }

  .estate-heat-flow b {
    text-align: center;
    transform: rotate(90deg);
  }

  .field-grid .wide {
    grid-column: auto;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
  }
}

/* 2026 executive cockpit visual system */
:root {
  --bg: #f3f3ef;
  --panel: #ffffff;
  --ink: #181a17;
  --muted: #71766e;
  --line: #e5e6df;
  --brand: #bf202d;
  --brand-dark: #891720;
  --green: #237a58;
  --amber: #b7791f;
  --blue: #315f92;
  --soft-red: #fff2f2;
  --soft-green: #edf8f2;
  --soft-blue: #edf4fb;
  --shadow: 0 18px 45px rgba(28, 32, 25, 0.055);
  --shadow-hover: 0 22px 60px rgba(28, 32, 25, 0.1);
}

body {
  background:
    radial-gradient(circle at 75% -10%, rgba(191, 32, 45, 0.055), transparent 34%),
    var(--bg);
  letter-spacing: -0.01em;
}

.sidebar {
  width: 264px;
  padding: 24px 18px;
  gap: 24px;
  background: linear-gradient(178deg, #151713 0%, #10110f 72%, #1c1615 100%);
  box-shadow: 16px 0 50px rgba(14, 16, 13, 0.08);
  z-index: 10;
}

.brand {
  gap: 13px;
  padding: 4px 8px 22px;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(145deg, #d92b38, #a91420);
  box-shadow: 0 9px 22px rgba(191, 32, 45, 0.28);
  font-size: 20px;
}

.brand strong {
  font-size: 18px;
  letter-spacing: 0.02em;
}

.brand span {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.48);
  font-size: 11px;
  letter-spacing: 0.03em;
}

nav {
  gap: 7px;
}

.nav-item {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 14px;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.nav-item:hover {
  transform: translateX(2px);
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.065));
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--brand);
}

.nav-glyph {
  width: 22px;
  color: rgba(255, 255, 255, 0.48);
  font-size: 17px;
  text-align: center;
}

.nav-item.active .nav-glyph {
  color: #ff6370;
}

.side-card {
  padding: 16px;
  border-color: rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.side-card strong {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 4px;
  font-size: 13px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #56d69a;
  box-shadow: 0 0 0 5px rgba(86, 214, 154, 0.11);
}

.topbar {
  height: 96px;
  padding: 20px 34px;
  border-bottom-color: rgba(218, 220, 212, 0.78);
  background: rgba(247, 247, 243, 0.86);
  backdrop-filter: blur(20px) saturate(1.3);
}

h1 {
  font-size: 28px;
  font-weight: 760;
  letter-spacing: -0.04em;
}

.topbar p {
  font-size: 13px;
}

.top-actions {
  gap: 9px;
}

select,
input,
input[type="file"],
textarea {
  border-color: #dedfd8;
  border-radius: 11px;
  transition: border 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(191, 32, 45, 0.55);
  outline: 0;
  box-shadow: 0 0 0 4px rgba(191, 32, 45, 0.08);
}

.primary,
.secondary,
.ghost,
.danger {
  height: 42px;
  padding: 0 17px;
  border-radius: 11px;
  font-weight: 650;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary {
  background: linear-gradient(145deg, #cc2734, #ad1824);
  box-shadow: 0 8px 18px rgba(191, 32, 45, 0.18);
}

.primary:hover,
.secondary:hover {
  transform: translateY(-1px);
}

.primary:hover {
  box-shadow: 0 12px 24px rgba(191, 32, 45, 0.25);
}

.secondary {
  background: #eeefeb;
}

.view {
  width: min(100%, 1640px);
  margin: 0 auto;
  padding: 30px 34px 64px;
}

.panel,
.metric,
.account-card,
.opportunity-card,
.draft-card {
  border-color: rgba(221, 223, 214, 0.88);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.panel-head {
  margin-bottom: 20px;
}

.panel-head h2,
.section-head h2 {
  margin-top: 2px;
  font-size: 19px;
  letter-spacing: -0.025em;
}

.section-kicker,
.eyebrow,
.chart-title > div > span {
  color: var(--brand);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.status {
  min-height: 27px;
  padding: 4px 10px;
  border-radius: 999px;
}

.metric-row {
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  position: relative;
  min-height: 128px;
  padding: 20px;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  right: -25px;
  bottom: -48px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(62, 72, 57, 0.035);
}

.metric strong {
  margin-top: 13px;
  font-size: 32px;
  letter-spacing: -0.045em;
}

.metric small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.metric.accent {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #1e211d, #32382f);
}

.metric.accent span,
.metric.accent small {
  color: rgba(255, 255, 255, 0.6);
}

.dashboard-hero {
  min-height: 154px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 18px;
  padding: 28px 30px;
  overflow: hidden;
  position: relative;
  color: #fff;
  border-radius: 22px;
  background:
    radial-gradient(circle at 86% 20%, rgba(217, 43, 56, 0.55), transparent 28%),
    linear-gradient(120deg, #151814, #2c312a 65%, #4b2022);
  box-shadow: 0 24px 50px rgba(24, 27, 22, 0.16);
}

.dashboard-hero::after {
  content: "";
  position: absolute;
  right: 8%;
  top: -80px;
  width: 250px;
  height: 250px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  box-shadow: 0 0 0 42px rgba(255, 255, 255, 0.025), 0 0 0 84px rgba(255, 255, 255, 0.018);
}

.dashboard-hero > * {
  position: relative;
  z-index: 1;
}

.dashboard-hero .eyebrow {
  color: #ff8a94;
}

.dashboard-hero h2 {
  margin: 8px 0 7px;
  font-size: clamp(22px, 2vw, 32px);
  letter-spacing: -0.045em;
}

.dashboard-hero p {
  color: rgba(255, 255, 255, 0.58);
  font-size: 13px;
}

.hero-signal {
  min-width: 145px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(8px);
}

.hero-signal i {
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border-radius: 50%;
  background: #65e4a7;
}

.hero-signal span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
}

.hero-signal strong {
  grid-column: 2;
  font-size: 14px;
}

.account-snapshot-list {
  display: grid;
}

.account-snapshot {
  min-height: 70px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.account-snapshot:last-child {
  border-bottom: 0;
}

.account-index {
  color: #a7aaa2;
  font-size: 11px;
  font-weight: 750;
}

.account-snapshot > div > strong,
.account-snapshot > div > small {
  display: block;
}

.account-snapshot > div > small {
  max-width: 470px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snapshot-target {
  text-align: right;
}

.snapshot-target span,
.snapshot-target small {
  color: var(--muted);
  font-size: 10px;
}

.snapshot-target strong {
  margin-top: 2px;
  font-size: 22px;
}

.funnel-chart {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 8px 0 16px;
}

.funnel-step {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  color: #fff;
  clip-path: polygon(4% 0, 96% 0, 100% 100%, 0 100%);
  background: linear-gradient(90deg, #30352f, #454c43);
}

.funnel-step.wide { width: 100%; }
.funnel-step.medium { width: 78%; background: linear-gradient(90deg, #6d383a, #8f3037); }
.funnel-step.narrow { width: 56%; background: linear-gradient(90deg, #a61c27, #cf2936); }

.funnel-step span {
  color: rgba(255, 255, 255, 0.64);
  font-size: 11px;
}

.funnel-step strong {
  font-size: 17px;
}

.conversion-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
}

.conversion-summary > div {
  padding: 16px 10px 0;
  text-align: center;
}

.conversion-summary span,
.conversion-summary strong {
  display: block;
}

.conversion-summary span {
  color: var(--muted);
  font-size: 10px;
}

.conversion-summary strong {
  margin-top: 5px;
  font-size: 17px;
}

.upload-box {
  padding: 20px;
  border: 1px solid #e1e2da;
  border-radius: 17px;
  background: linear-gradient(150deg, #fafbf8, #f5f6f1);
}

.upload-box-intro {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 17px;
}

.upload-box-number {
  min-width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  color: var(--brand);
  border-radius: 9px;
  background: rgba(191, 32, 45, 0.09);
  font-size: 10px;
  font-weight: 800;
}

.upload-box-intro strong {
  font-size: 14px;
}

.upload-box-intro p {
  margin-top: 4px;
  font-size: 12px;
}

.upload-box form.modern-upload-form {
  display: grid;
  gap: 14px;
  margin-top: 0;
}

.upload-select-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.weekly-select-row {
  grid-template-columns: minmax(220px, 1.5fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) auto;
}

.upload-select-row label {
  display: grid;
  gap: 6px;
}

.upload-select-row label > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.upload-select-row select,
.upload-select-row input {
  width: 100%;
  height: 44px;
}

.upload-submit {
  min-width: 138px;
  height: 44px;
}

.upload-submit span {
  margin-left: 8px;
  font-size: 17px;
}

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

.monthly-intake-card {
  display: grid;
  gap: 18px;
  margin: 10px 0 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #f8f9f6;
}

.monthly-intake-head,
.monthly-intake-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.monthly-intake-head h3 {
  margin: 5px 0 4px;
  font-size: 20px;
}

.monthly-intake-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.monthly-intake-summary {
  min-width: 132px;
  display: grid;
  justify-items: end;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.monthly-intake-summary strong {
  font-size: 28px;
  line-height: 1;
}

.monthly-intake-summary strong small {
  margin-left: 2px;
  color: var(--muted);
  font-size: 14px;
}

.monthly-intake-summary > span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

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

.monthly-source-grid .upload-tile {
  min-height: 96px;
  padding: 16px;
  background: #fff;
}

.monthly-source-grid .upload-tile-copy strong {
  font-size: 14px;
  white-space: nowrap;
}

.monthly-source-grid .upload-tile-copy small {
  max-width: 220px;
  font-size: 11px;
}

.monthly-source-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.monthly-source-status > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  color: var(--muted);
  border-radius: 999px;
  background: #eceee9;
  font-size: 10px;
  white-space: nowrap;
}

.monthly-source-status > span i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b2b5ad;
}

.monthly-source-status > span.ready {
  color: var(--green);
  background: var(--soft-green);
}

.monthly-source-status > span.ready i {
  background: var(--green);
}

.monthly-source-status .history-status {
  color: #8b6b29;
  background: #f5efe0;
}

.monthly-intake-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.monthly-intake-actions button {
  min-height: 46px;
  padding-inline: 22px;
  white-space: nowrap;
}

.monthly-intake-actions .inline-status {
  color: var(--muted);
  font-size: 11px;
}

.top-content-item small.content-analysis {
  display: block;
  margin-top: 3px;
  color: #9a444a;
  font-weight: 650;
}

.single-upload-form .upload-tile {
  min-height: 92px;
}

.upload-tile {
  min-width: 0;
  min-height: 108px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  padding: 16px;
  overflow: hidden;
  cursor: pointer;
  border: 1px dashed #cfd2c8;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  transition: border 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.upload-tile:hover,
.upload-tile.is-dragging {
  border-color: rgba(191, 32, 45, 0.5);
  background: #fff;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(37, 42, 34, 0.07);
}

.upload-tile.has-file {
  border-style: solid;
  border-color: rgba(35, 122, 88, 0.35);
  background: var(--soft-green);
}

.upload-tile input {
  width: 1px;
  height: 1px;
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-tile-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--brand);
  border-radius: 12px;
  background: var(--soft-red);
  font-size: 20px;
}

.has-file .upload-tile-icon {
  color: var(--green);
  background: #dff1e7;
}

.upload-tile-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.upload-tile-copy strong {
  font-size: 13px;
}

.upload-tile-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-tile-action {
  margin-left: auto;
  padding: 5px 8px;
  color: var(--brand);
  border-radius: 7px;
  background: var(--soft-red);
  font-size: 9px;
  white-space: nowrap;
}

.has-file .upload-tile-action {
  color: var(--green);
  background: #dff1e7;
}

.kpi-grid {
  gap: 11px;
}

.kpi-card {
  min-height: 116px;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(145deg, #fff, #f8f9f6);
}

.kpi-card strong {
  margin: 10px 0 7px;
  font-size: 30px;
  letter-spacing: -0.045em;
}

.kpi-card.blue,
.kpi-card.green,
.kpi-card.red {
  border-color: var(--line);
}

.kpi-card.blue { background: linear-gradient(145deg, #f5f9fe, #eaf2fb); }
.kpi-card.green { background: linear-gradient(145deg, #f5fbf7, #e8f5ed); }
.kpi-card.red { background: linear-gradient(145deg, #fff8f7, #ffeded); }

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

.chart-panel {
  padding: 19px;
  border-radius: 16px;
  background: linear-gradient(145deg, #fff, #fbfcfa);
}

.chart-title {
  min-height: 42px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.chart-title h3 {
  margin: 3px 0 0;
  font-size: 15px;
}

.chart-title > small {
  color: var(--muted);
  font-size: 10px;
}

.mini-ring {
  --ring: 0;
  width: 62px;
  height: 62px;
  display: grid;
  place-content: center;
  flex: 0 0 auto;
  position: relative;
  border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--ring) * 1%), #eceee9 0);
  text-align: center;
}

.mini-ring::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #fff;
}

.mini-ring strong,
.mini-ring small {
  position: relative;
  z-index: 1;
}

.mini-ring strong {
  font-size: 11px;
}

.mini-ring small {
  color: var(--muted);
  font-size: 8px;
}

.progress-track {
  height: 8px;
  background: #eceee9;
}

.progress-track i {
  background: linear-gradient(90deg, #b81e2a, #e15964);
}

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

.trend-pill {
  min-height: 65px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f9f6;
}

.trend-pill span {
  color: var(--muted);
  font-size: 10px;
}

.trend-pill strong {
  font-size: 13px;
}

.trend-pill.up strong { color: var(--green); }
.trend-pill.down strong { color: var(--brand); }

.top-content-list {
  display: grid;
  gap: 12px;
}

.top-content-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.top-content-item > span {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  color: var(--brand);
  border-radius: 8px;
  background: var(--soft-red);
  font-size: 10px;
  font-weight: 800;
}

.top-content-item strong,
.top-content-item small {
  display: block;
}

.top-content-item strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-content-item small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  font-size: 12px;
}

.empty-state.compact {
  padding: 36px 18px;
}

.report-raw-details {
  margin-top: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fafbf8;
}

.report-raw-details summary {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
}

.report-raw-details summary::-webkit-details-marker { display: none; }

.report-raw-details summary span,
.report-raw-details summary strong,
.report-raw-details summary small {
  display: block;
}

.report-raw-details summary strong {
  font-size: 13px;
}

.report-raw-details summary small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.report-raw-details summary b {
  color: var(--brand);
  font-size: 11px;
}

.report-raw-details[open] summary {
  border-bottom: 1px solid var(--line);
}

.report-editor {
  min-height: 520px;
  margin: 14px;
  width: calc(100% - 28px);
  border-radius: 12px;
  background: #fff;
  font-size: 13px;
}

.report-raw-details .inline-status {
  margin: 0 14px 12px;
}

.report-box {
  border-radius: 14px;
  background: #fafbf8;
  font-size: 13px;
}

dialog {
  border-radius: 20px;
  box-shadow: 0 30px 100px rgba(16, 18, 15, 0.32);
}

@media (max-width: 1180px) {
  .ad-command-card { grid-template-columns: 1fr; }
  .ad-month-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ad-funnel-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ad-funnel-row > b { display: none; }
  .ad-funnel-row > div { min-width: 0; }

  .monthly-source-grid { grid-template-columns: 1fr; }

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

  .file-upload-grid {
    grid-template-columns: 1fr;
  }

  .upload-tile {
    min-height: 86px;
  }
}

@media (max-width: 980px) {
  .ad-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ad-intake-bottom { grid-template-columns: 1fr; }
  .ad-delete-actions { justify-content: flex-start; }

  .monthly-intake-head,
  .monthly-intake-footer { align-items: stretch; flex-direction: column; }
  .monthly-intake-summary { justify-items: start; padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .monthly-intake-actions { justify-content: space-between; }

  .sidebar {
    width: 100%;
    padding: 16px;
  }

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

  .nav-item {
    justify-content: center;
    padding: 0 8px;
    font-size: 12px;
  }

  .nav-glyph {
    display: none;
  }

  .view {
    padding: 22px 18px 48px;
  }

  .weekly-insight-board,
  .weekly-select-row,
  .upload-select-row {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .ad-command-card { padding: 22px; }
  .ad-command-stats, .ad-kpi-grid, .ad-month-grid, .ad-funnel-row { grid-template-columns: 1fr; }
  .ad-command-stats > div { min-height: 82px; border-left: 0; border-top: 1px solid rgba(255, 255, 255, .1); }
  .ad-command-stats > div:first-child { border-top: 0; }
  .ad-section-head { align-items: flex-start; flex-direction: column; gap: 6px; }

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

  .topbar {
    padding: 18px;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .top-actions select {
    width: 100%;
  }

  .conversion-summary,
  .trend-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px;
    border-radius: 15px;
  }
}

/* Fixed PSD cover maker */
@font-face {
  font-family: "BoloniCover";
  src: url("/cover-maker/fonts/NotoSansCJKsc-Bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}

.cover-maker-shell {
  padding: 28px;
}

.cover-maker-heading {
  align-items: flex-end;
  margin-bottom: 24px;
}

.cover-maker-heading h2 {
  margin: 4px 0 7px;
  font-size: 28px;
}

.cover-maker-heading p,
.cover-preview-card > p {
  margin: 0;
  color: var(--muted);
}

.cover-template-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cover-template-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #f1f2ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.cover-template-meta .success-badge {
  background: var(--soft-green);
  color: var(--green);
}

.cover-template-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.cover-template-option {
  position: relative;
  min-width: 0;
  padding: 10px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.cover-template-option:hover {
  transform: translateY(-2px);
  border-color: #d1aaa9;
  box-shadow: 0 10px 24px rgba(38, 34, 29, .08);
}

.cover-template-option.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(179, 32, 42, .09);
}

.cover-template-thumb {
  display: block;
  height: 156px;
  margin-bottom: 10px;
  overflow: hidden;
  border-radius: 12px;
  background: #ecece8;
}

.cover-template-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-template-option strong,
.cover-template-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cover-template-option strong {
  font-size: 14px;
}

.cover-template-option small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.cover-template-option i {
  display: inline-flex;
  margin-top: 8px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #f1f2ef;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
}

.cover-template-option.active i {
  background: #fff0f1;
  color: var(--brand);
}

.cover-maker-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(330px, .72fr);
  gap: 22px;
  align-items: start;
}

.cover-editor-card,
.cover-preview-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
  padding: 24px;
}

.cover-step {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cover-step-spaced {
  margin-top: 28px;
}

.cover-step-number {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 14px;
  background: #fff0f1;
  color: var(--brand);
  font-weight: 800;
}

.cover-step strong,
.cover-step small {
  display: block;
}

.cover-step small {
  margin-top: 4px;
  color: var(--muted);
}

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

.cover-secondary-remove-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 9px;
}

.cover-secondary-remove-row button {
  min-height: 34px;
  padding: 7px 12px;
  color: var(--brand);
  font-size: 12px;
}

.cover-upload-tile {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  min-height: 112px;
  padding: 17px;
  border: 1.5px dashed #d9d9d3;
  border-radius: 18px;
  background: #fafaf8;
  cursor: pointer;
  transition: .2s ease;
}

.cover-upload-tile:hover,
.cover-upload-tile.has-file {
  border-color: #d74a53;
  background: #fff7f7;
}

.cover-upload-tile input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.cover-upload-icon {
  display: grid;
  grid-row: 1 / span 2;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: #ffecee;
  color: var(--brand);
  font-size: 22px;
  font-style: normal;
}

.cover-upload-tile strong,
.cover-upload-tile small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cover-upload-tile small {
  color: var(--muted);
}

.cover-upload-tile em {
  grid-row: 1 / span 2;
  color: var(--brand);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.cover-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(180px, .75fr);
  gap: 12px;
  margin-top: 16px;
}

.cover-fields label > span,
.cover-crop-controls label > span {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.cover-fields i {
  color: #aaa;
  font-style: normal;
  font-weight: 500;
}

.cover-fields input {
  width: 100%;
  min-height: 48px;
}

.cover-fields label.wide {
  grid-column: 1 / -1;
}

.cover-crop-controls {
  margin-top: 18px;
  padding: 15px 17px;
  border-radius: 16px;
  background: #f7f7f4;
}

.cover-crop-controls summary {
  cursor: pointer;
  font-weight: 700;
}

.cover-crop-controls label {
  display: block;
  margin-top: 14px;
}

.cover-crop-controls input {
  width: 100%;
  accent-color: var(--brand);
}

.cover-editor-actions {
  display: grid;
  grid-template-columns: .7fr 1.3fr;
  gap: 10px;
  margin-top: 22px;
}

.cover-editor-actions button {
  min-height: 48px;
}

.cover-privacy-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.cover-preview-card {
  position: sticky;
  top: 24px;
  background: #f4f3ef;
}

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

.cover-preview-head strong,
.cover-preview-head small {
  display: block;
}

.cover-preview-head small,
.cover-preview-head span {
  color: var(--muted);
  font-size: 12px;
}

.cover-canvas-frame {
  width: min(100%, 470px);
  margin: 0 auto 14px;
  overflow: hidden;
  border-radius: 18px;
  background: #1c1e1a;
  box-shadow: 0 18px 48px rgba(26, 28, 24, .18);
  line-height: 0;
}

#coverCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1772 / 2362;
}

@media (max-width: 1100px) {
  .cover-template-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cover-maker-grid {
    grid-template-columns: 1fr;
  }

  .cover-preview-card {
    position: static;
  }
}

@media (max-width: 720px) {
  .cover-maker-shell,
  .cover-editor-card,
  .cover-preview-card {
    padding: 18px;
  }

  .cover-maker-heading,
  .cover-upload-grid,
  .cover-fields,
  .cover-editor-actions {
    grid-template-columns: 1fr;
  }

  .cover-template-picker {
    display: flex;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
  }

  .cover-template-option {
    min-width: 156px;
    scroll-snap-align: start;
  }

  .cover-template-thumb {
    height: 174px;
  }

  .cover-maker-heading {
    align-items: flex-start;
  }

  .cover-template-meta {
    justify-content: flex-start;
  }
}

/* Account portfolio segmentation and compact account dashboards */
.portfolio-panel {
  overflow: hidden;
}

.portfolio-head-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.portfolio-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.portfolio-group {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fafbf8;
}

.portfolio-group.self {
  box-shadow: inset 0 3px 0 #287957;
}

.portfolio-group.agency {
  box-shadow: inset 0 3px 0 var(--brand);
}

.portfolio-group-head {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.portfolio-group-head > div {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 2px 9px;
}

.portfolio-group-head strong,
.portfolio-group-head small {
  display: block;
}

.portfolio-group-head strong {
  font-size: 15px;
}

.portfolio-group-head small {
  grid-column: 2;
  color: var(--muted);
  font-size: 10px;
}

.portfolio-type-dot {
  width: 9px;
  height: 9px;
  grid-row: span 2;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(35, 122, 88, 0.1);
}

.agency .portfolio-type-dot {
  background: var(--brand);
  box-shadow: 0 0 0 5px rgba(191, 32, 45, 0.09);
}

.portfolio-account-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.portfolio-account-list > .empty-state {
  margin: 14px;
  background: #fff;
}

.portfolio-account-card {
  min-height: 124px;
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(210px, 0.9fr) 112px;
  align-items: center;
  gap: 15px;
  padding: 15px 16px;
  background: #fff;
  transition: background 150ms ease, transform 150ms ease;
}

.portfolio-account-card:hover {
  position: relative;
  z-index: 1;
  background: #fffefa;
  transform: translateY(-1px);
}

.portfolio-account-meta {
  min-width: 0;
}

.portfolio-account-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.portfolio-account-title strong {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portfolio-account-title span {
  flex: 0 0 auto;
  padding: 3px 6px;
  color: var(--green);
  border-radius: 6px;
  background: var(--soft-green);
  font-size: 9px;
  font-weight: 700;
}

.agency .portfolio-account-title span {
  color: var(--brand);
  background: var(--soft-red);
}

.portfolio-account-meta > small {
  display: -webkit-box;
  margin-top: 7px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

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

.account-core-numbers > div {
  min-width: 0;
  padding: 7px 9px;
  border-radius: 9px;
  background: #f5f6f2;
}

.account-core-numbers span,
.account-core-numbers strong {
  display: block;
}

.account-core-numbers span {
  color: var(--muted);
  font-size: 8px;
}

.account-core-numbers strong {
  margin-top: 3px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-mini-chart {
  height: 76px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 7px;
  padding: 6px 7px 2px;
  border-left: 1px solid var(--line);
}

.mini-chart-column {
  min-width: 14px;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.mini-chart-column i {
  width: 100%;
  max-width: 17px;
  min-height: 4px;
  display: block;
  border-radius: 5px 5px 2px 2px;
  background: #4c78a8;
  transition: height 220ms ease;
}

.mini-chart-column.green i { background: #3e956f; }
.mini-chart-column.amber i { background: #c68a36; }
.mini-chart-column.red i { background: #c82c38; }

.mini-chart-column span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
}

.dashboard-conversion-wide {
  padding-bottom: 20px;
}

.dashboard-conversion-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.3fr) minmax(320px, 0.7fr);
  align-items: center;
  gap: 28px;
}

.dashboard-conversion-layout .funnel-chart {
  padding: 0;
}

.dashboard-conversion-layout .conversion-summary {
  min-height: 130px;
  align-items: center;
  border-top: 0;
  border-left: 1px solid var(--line);
}

.dashboard-conversion-layout .conversion-summary > div {
  padding: 12px;
}

@media (max-width: 1380px) {
  .portfolio-account-card {
    grid-template-columns: minmax(160px, 1fr) 190px 92px;
    gap: 10px;
    padding: 14px 12px;
  }
}

@media (max-width: 1180px) {
  .portfolio-groups {
    grid-template-columns: 1fr;
  }

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

  .dashboard-conversion-layout .conversion-summary {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .portfolio-account-card {
    grid-template-columns: 1fr 82px;
  }

  .account-core-numbers {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .account-mini-chart {
    grid-column: 2;
    grid-row: 1;
  }

  .dashboard-conversion-layout {
    display: block;
  }
}

/* Layout QA: full-width portfolio groups and overflow-safe report dashboard */
.portfolio-groups {
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.portfolio-account-card {
  grid-template-columns: minmax(250px, 1.15fr) minmax(360px, 0.85fr) 150px;
  gap: 22px;
  padding: 18px 22px;
}

.account-mini-chart {
  height: 82px;
  padding-inline: 14px;
}

.mini-chart-column i {
  max-width: 22px;
}

.reports-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.reports-main-grid > .panel,
.report-workbench-panel,
.report-plan-panel {
  min-width: 0;
}

.report-plan-panel {
  align-self: start;
}

.report-account-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.report-account-title {
  min-width: 0;
}

.report-account-title h2 {
  margin-top: 4px;
  max-width: 100%;
  font-size: clamp(19px, 1.8vw, 27px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.report-head-actions {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  gap: 9px;
  margin: 0;
}

.report-head-actions button {
  width: auto;
  min-width: 116px;
  min-height: 42px;
  padding: 9px 14px;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.report-workbench-panel .kpi-grid,
.monthly-dashboard .kpi-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.kpi-card {
  min-width: 0;
  overflow: hidden;
}

.kpi-card strong {
  max-width: 100%;
  font-size: clamp(24px, 2.25vw, 34px);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-card.red strong {
  font-size: clamp(22px, 2.05vw, 32px);
}

.report-plan-panel .report-box {
  min-height: 0;
}

@media (max-width: 1320px) {
  .portfolio-account-card {
    grid-template-columns: minmax(210px, 1fr) minmax(300px, 0.9fr) 120px;
    gap: 16px;
    padding-inline: 18px;
  }

  .report-account-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .report-head-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .report-head-actions button {
    width: 100%;
  }
}

@media (max-width: 980px) {
  .portfolio-account-card {
    grid-template-columns: minmax(0, 1fr) 120px;
  }

  .account-core-numbers {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .account-mini-chart {
    grid-column: 2;
    grid-row: 1;
  }

  .report-workbench-panel .kpi-grid,
  .monthly-dashboard .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .portfolio-panel .panel-head,
  .portfolio-group-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .portfolio-head-summary {
    justify-content: flex-start;
  }

  .portfolio-account-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 13px;
    padding: 16px;
  }

  .account-core-numbers {
    grid-column: 1;
    grid-row: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .account-mini-chart {
    grid-column: 1;
    grid-row: auto;
    height: 96px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .report-head-actions {
    grid-template-columns: 1fr;
  }

  .report-head-actions button {
    min-width: 0;
  }

  .report-workbench-panel .kpi-grid,
  .monthly-dashboard .kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .kpi-card strong,
  .kpi-card.red strong {
    font-size: 28px;
  }
}
