:root {
  --forest: #17342d;
  --canopy: #1f8a5b;
  --leaf: #4fb06d;
  --sprout: #8fcb8a;
  --water: #2e7bb4;
  --sky: #7db9d6;
  --stone: #f7f4ee;
  --white: #ffffff;
  --amber: #b97816;
  --red: #bb3d35;
  --line: rgba(23, 52, 45, 0.14);
  --muted: rgba(23, 52, 45, 0.68);
  --shadow: 0 16px 42px rgba(23, 52, 45, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--stone);
  color: var(--forest);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
}

[hidden] {
  display: none !important;
}

button {
  border: 0;
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar,
.workspace,
.main-panel,
.side-panel,
.asset-card,
.confirm-dialog {
  border: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto 18px;
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 24px rgba(23, 52, 45, 0.06);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  color: var(--forest);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
  line-height: 1.2;
}

.brand-lockup strong {
  font-size: 17px;
  font-weight: 750;
}

.brand-lockup small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.company-chip,
.status-pill,
.asset-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.company-chip {
  background: rgba(46, 123, 180, 0.12);
  color: var(--water);
}

.status-pill {
  background: rgba(185, 120, 22, 0.14);
  color: var(--amber);
}

.status-pill.ready,
.asset-status.connected {
  background: rgba(31, 138, 91, 0.14);
  color: var(--canopy);
}

.status-pill.error,
.asset-status.error,
.asset-status.revoked,
.asset-status.disconnected {
  background: rgba(187, 61, 53, 0.12);
  color: var(--red);
}

.asset-status.permission_missing,
.asset-status.needs_assets,
.asset-status.expired {
  background: rgba(185, 120, 22, 0.14);
  color: var(--amber);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  box-shadow: var(--shadow);
}

.side-panel,
.main-panel {
  border-radius: 8px;
  background: var(--white);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
}

.main-panel {
  min-height: 620px;
  padding: 24px;
}

.logo-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 86px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(143, 203, 138, 0.18), rgba(125, 185, 214, 0.16));
}

.logo-panel img {
  display: block;
  width: min(220px, 82%);
  height: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--water);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  font-size: clamp(34px, 6vw, 46px);
  font-weight: 780;
}

h2 {
  max-width: 620px;
  font-size: 24px;
  font-weight: 760;
}

h3 {
  font-size: 17px;
  font-weight: 760;
}

.status-block p:last-child,
.empty-state p,
.config-warning p,
.confirm-dialog p,
.trust-note {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.status-block p:last-child {
  margin: 12px 0 0;
}

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

.metric-grid div {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfaf7;
}

.metric-grid strong,
.metric-grid span {
  display: block;
}

.metric-grid strong {
  font-size: 30px;
  line-height: 1;
}

.metric-grid span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.action-stack {
  display: grid;
  gap: 10px;
}

.primary-action,
.secondary-action,
.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 780;
  line-height: 1.2;
  text-align: center;
  transition:
    transform 140ms ease,
    opacity 140ms ease,
    box-shadow 140ms ease;
}

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

.primary-action:disabled,
.secondary-action:disabled,
.danger-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.primary-action {
  background: var(--canopy);
  color: var(--white);
  box-shadow: 0 12px 24px rgba(31, 138, 91, 0.2);
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--forest);
}

.danger-action {
  border: 1px solid rgba(187, 61, 53, 0.26);
  background: rgba(187, 61, 53, 0.08);
  color: var(--red);
}

.button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  font-weight: 900;
}

.compact-action {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 13px;
}

.trust-note {
  margin: auto 0 0;
  padding-top: 4px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.notice,
.config-warning {
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.45;
}

.notice {
  border: 1px solid rgba(46, 123, 180, 0.24);
  background: rgba(46, 123, 180, 0.08);
  color: var(--forest);
}

.notice.error {
  border-color: rgba(187, 61, 53, 0.24);
  background: rgba(187, 61, 53, 0.08);
}

.config-warning {
  border: 1px solid rgba(185, 120, 22, 0.28);
  background: rgba(185, 120, 22, 0.1);
}

.config-warning strong {
  display: block;
  margin-bottom: 4px;
}

.config-warning p {
  margin: 0;
}

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

.asset-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  border-radius: 8px;
  padding: 16px;
  background: #fbfaf7;
}

.asset-main {
  display: flex;
  min-width: 0;
  gap: 12px;
}

.platform-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--white);
  font-weight: 900;
}

.platform-mark.facebook {
  background: #1877f2;
}

.platform-mark.instagram {
  background: #c13584;
}

.asset-copy {
  min-width: 0;
}

.asset-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.nested-assets {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  margin-left: 52px;
}

.nested-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  border: 1px solid rgba(23, 52, 45, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--white);
}

.nested-name {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  font-size: 14px;
  font-weight: 750;
}

.nested-name span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 380px;
  border: 1px dashed rgba(23, 52, 45, 0.26);
  border-radius: 8px;
  padding: 34px;
  text-align: center;
}

.empty-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  border-radius: 18px 18px 18px 6px;
  background: var(--forest);
  color: var(--white);
  font-size: 24px;
  font-weight: 900;
}

.empty-state p {
  max-width: 430px;
  margin: 10px auto 0;
}

.confirm-dialog {
  width: min(460px, calc(100% - 32px));
  border-radius: 8px;
  padding: 0;
  color: var(--forest);
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(23, 52, 45, 0.28);
}

.confirm-dialog form {
  padding: 22px;
}

.confirm-dialog p {
  margin: 12px 0 20px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-panel {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 28px;
}

.google-action {
  width: 100%;
  margin-top: 22px;
  text-decoration: none;
}

.google-mark {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  flex: 0 0 auto;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--forest);
  font-size: 14px;
  font-weight: 750;
}

.auth-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--forest);
  font: inherit;
}

.auth-form input:focus {
  border-color: rgba(46, 123, 180, 0.56);
  outline: 3px solid rgba(46, 123, 180, 0.14);
}

.legal-shell {
  min-height: 100vh;
  padding: 32px 18px;
}

.legal-page {
  width: min(100%, 820px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.legal-page h1 {
  margin-bottom: 16px;
}

.legal-page h2 {
  margin-top: 26px;
  margin-bottom: 10px;
  font-size: 20px;
}

.legal-page p,
.legal-page li {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.62;
}

.legal-page a {
  color: var(--water);
  font-weight: 750;
}

.legal-page li + li {
  margin-top: 8px;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .workspace {
    width: 100%;
  }

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

  .topbar-meta {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .main-panel,
  .side-panel {
    padding: 18px;
  }

  .panel-head,
  .asset-card {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-head .danger-action {
    width: 100%;
  }

  .nested-assets {
    margin-left: 0;
  }

  .dialog-actions,
  .nested-row {
    align-items: stretch;
    flex-direction: column;
  }
}
